using System; using System.Collections.Generic; using System.Data; using System.Data.SqlClient; using System.Linq; using System.Text; using System.Threading.Tasks; using BLL; namespace FineUIPro.Web.ZHGL.ManagementReport { public partial class CQMSCheckSpecial : PageBase { protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { ////权限按钮方法 this.GetButtonPower(); UnitService.InitUnitByProjectIdUnitTypeDropDownList(drpSponsorUnit, this.CurrUser.LoginProjectId, BLL.Const.ProjectUnitType_2, true); UnitWorkService.InitUnitWorkDownList(drpUnitWork, this.CurrUser.LoginProjectId, true); CNProfessionalService.InitCNProfessionalDownList(drpCNProfessional, true); // 绑定表格 //BindGrid(); InitTreeMenu(); } } protected void btnQuery_Click(object sender, EventArgs e) { BindGrid(); } private void InitTreeMenu() { this.tvControlItem.Nodes.Clear(); TreeNode rootNode = new TreeNode(); rootNode.Text = "项目"; rootNode.NodeID = "0"; rootNode.Expanded = true; this.tvControlItem.Nodes.Add(rootNode); var project = (from x in Funs.DB.Base_Project select new { x.ProjectId, x.ProjectName }).Distinct(); if (project.Count() > 0) { foreach (var pro in project) { TreeNode tnProject = new TreeNode();//年节点 tnProject.Text = SubStr(pro.ProjectName); tnProject.NodeID = pro.ProjectId; tnProject.ToolTip = pro.ProjectName; tnProject.EnableClickEvent = true; rootNode.Nodes.Add(tnProject); } } } protected void tvControlItem_NodeCommand(object sender, TreeCommandEventArgs e) { BindGrid(); } #region /// /// 整改状态 /// /// protected IDictionary Handelstatus() { Dictionary dic = new Dictionary(); dic.Add(1, "未确认"); dic.Add(2, "已闭环"); dic.Add(3, "超期未整改"); dic.Add(4, "未整改"); return dic; } public Task data() { Task task = new Task(() => { return ChecklistData(); }); task.Start(); return task; } protected DataTable ChecklistData() { string strSql = @"SELECT * from Check_CheckSpecialDataIn chec where 1=1 "; List listStr = new List(); if (!string.IsNullOrEmpty(tvControlItem.SelectedNodeID)) { strSql += " AND chec.ProjectId = @ProjectId"; listStr.Add(new SqlParameter("@ProjectId", tvControlItem.SelectedNodeID)); } strSql += " AND (chec.CheckTime>=@startTime or @startTime='') and (chec.CheckTime<=@endTime or @endTime='') "; listStr.Add(new SqlParameter("@startTime", !string.IsNullOrEmpty(txtStartTime.Text.Trim()) ? txtStartTime.Text.Trim() + " 00:00:00" : "")); listStr.Add(new SqlParameter("@endTime", !string.IsNullOrEmpty(txtEndTime.Text.Trim()) ? txtEndTime.Text.Trim() + " 23:59:59" : "")); if (drpSponsorUnit.SelectedValue != BLL.Const._Null) { strSql += " AND chec.UnitId=@unitId"; listStr.Add(new SqlParameter("@unitId", drpSponsorUnit.SelectedValue)); } if (drpUnitWork.SelectedValue != Const._Null) { strSql += " AND chec.WorkAreaId=@unitworkId"; listStr.Add(new SqlParameter("@unitworkId", drpUnitWork.SelectedValue)); } if (drpCNProfessional.SelectedValue != Const._Null) { strSql += " AND chec.CNProfessionalCode=@CNProfessionalCode"; listStr.Add(new SqlParameter("@CNProfessionalCode", drpCNProfessional.SelectedValue)); } SqlParameter[] parameter = listStr.ToArray(); DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter); return tb; } protected string ConvertUnit(object unitId) { if (unitId != null) { var unit = UnitService.GetUnitByUnitId(unitId.ToString()); if (unit != null) { return unit.UnitName; } } return ""; } protected string ConvertUser(object userId) { if (userId != null) { var type = UserService.GetUserNameByUserId(userId.ToString()); return type; } return ""; } protected string ConvertWorkArea(object WorkAreaId) { if (WorkAreaId != null) { var type = UnitWorkService.getUnitWorkByUnitWorkId(WorkAreaId.ToString()); if (type != null) { return type.UnitWorkName; } } return ""; } protected string ConvertCNProfessional(object WorkAreaId) { if (WorkAreaId != null) { var type = CNProfessionalService.GetCNProfessional(WorkAreaId.ToString()); if (type != null) { return type.ProfessionalName; } } return ""; } protected string ConvertImageUrlByImage(object registrationId) { string url = string.Empty; if (registrationId != null) { IList sourlist = AttachFileService.GetBeforeFileList(registrationId.ToString(), BLL.Const.CheckListMenuId); if (sourlist != null && sourlist.Count > 0) { string AttachUrl = ""; foreach (var item in sourlist) { if (!string.IsNullOrEmpty(item.AttachUrl) && item.AttachUrl.ToLower().EndsWith(".jpg") || item.AttachUrl.ToLower().EndsWith(".jpeg") || item.AttachUrl.ToLower().EndsWith(".png")) AttachUrl += item.AttachUrl.TrimEnd(',') + ","; } url = BLL.UploadAttachmentService.ShowImage("../../", AttachUrl.TrimEnd(',')); } } return url; } protected string ConvertImgUrlByImage(object registrationId) { string url = string.Empty; if (registrationId != null) { IList sourlist = AttachFileService.Getfilelist(registrationId.ToString() + "r", BLL.Const.CheckListMenuId); if (sourlist != null && sourlist.Count > 0) { string AttachUrl = ""; foreach (var item in sourlist) { if (!string.IsNullOrEmpty(item.AttachUrl) && item.AttachUrl.ToLower().EndsWith(".jpg") || item.AttachUrl.ToLower().EndsWith(".jpeg") || item.AttachUrl.ToLower().EndsWith(".png")) AttachUrl += item.AttachUrl.TrimEnd(',') + ","; } url = BLL.UploadAttachmentService.ShowImage("../../", AttachUrl.TrimEnd(',')); } } return url; } public string Convertstatus(Object code) { Model.Check_CheckControl checkControl = BLL.CheckControlService.GetCheckControl(code.ToString()); if (checkControl.State.Equals("5") || checkControl.State.Equals("6")) { return "未确认"; } else if (checkControl.State == Const.CheckControl_Complete) { //闭环 return "已闭环"; } //else if( checkControl.LimitDate> ) else if (Convert.ToDateTime(checkControl.LimitDate).AddDays(1) < DateTime.Now) //延期未整改 { return "超期未整改"; } else //期内未整改 { return "未整改"; } } /// /// 绑定数据 /// public void BindGrid() { DataTable tb = ChecklistData(); // 2.获取当前分页数据 //var table = this.GetPagedDataTable(Grid1, tb1); Grid1.RecordCount = tb.Rows.Count; tb = GetFilteredTable(Grid1.FilteredData, tb); var table = this.GetPagedDataTable(Grid1, tb); Grid1.DataSource = table; Grid1.DataBind(); } #endregion #region 查询 protected void TextBox_TextChanged(object sender, EventArgs e) { this.BindGrid(); } protected void rbStates_SelectedIndexChanged(object sender, EventArgs e) { this.BindGrid(); } protected void drpSupCheckItemSet_SelectedIndexChanged(object sender, EventArgs e) { this.BindGrid(); } #endregion #region 表排序、分页、关闭窗口 /// /// 分页 /// /// /// protected void Grid1_PageIndexChange(object sender, GridPageEventArgs e) { Grid1.PageIndex = e.NewPageIndex; BindGrid(); } /// /// 排序 /// /// /// protected void Grid1_Sort(object sender, GridSortEventArgs e) { BindGrid(); } /// /// 分页显示条数下拉框 /// /// /// protected void ddlPageSize_SelectedIndexChanged(object sender, EventArgs e) { Grid1.PageSize = Convert.ToInt32(ddlPageSize.SelectedValue); BindGrid(); } /// /// 关闭弹出窗 /// /// /// protected void Window1_Close(object sender, WindowCloseEventArgs e) { BindGrid(); } #endregion #region 获取按钮权限 /// /// 获取按钮权限 /// /// /// private void GetButtonPower() { if (Request.Params["value"] == "0") { return; } } #endregion private string SubStr(string str) { string reStr = str; if (!string.IsNullOrEmpty(str) && str.Length > 16) { reStr = str.Substring(0, 16) + ".."; } return reStr; } } }