| 
									
										
										
										
											2021-04-30 10:28:37 +08:00
										 |  |  |  | using BLL; | 
					
						
							|  |  |  |  | using System; | 
					
						
							|  |  |  |  | using System.Collections.Generic; | 
					
						
							|  |  |  |  | using System.Data; | 
					
						
							|  |  |  |  | using System.Data.SqlClient; | 
					
						
							|  |  |  |  | using System.Linq; | 
					
						
							|  |  |  |  | using System.Text; | 
					
						
							|  |  |  |  | using System.Web; | 
					
						
							|  |  |  |  | using System.Web.UI; | 
					
						
							|  |  |  |  | using System.Web.UI.WebControls; | 
					
						
							|  |  |  |  | using AspNet = System.Web.UI.WebControls; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | namespace FineUIPro.Web.CQMS.Foreign | 
					
						
							|  |  |  |  | { | 
					
						
							|  |  |  |  |     public partial class ControlPointCheck : PageBase | 
					
						
							|  |  |  |  |     { | 
					
						
							|  |  |  |  |         #region 加载 | 
					
						
							|  |  |  |  |         /// <summary> | 
					
						
							|  |  |  |  |         /// 加载 | 
					
						
							|  |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         /// <param name="sender"></param> | 
					
						
							|  |  |  |  |         /// <param name="e"></param> | 
					
						
							|  |  |  |  |         protected void Page_Load(object sender, EventArgs e) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             if (!IsPostBack) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 GetButtonPower(); | 
					
						
							|  |  |  |  |                 BLL.UnitWorkService.InitUnitWorkDropDownList(this.drpUnitWorkId, this.CurrUser.LoginProjectId, true); | 
					
						
							|  |  |  |  |                 BLL.ForeignCNProfessionalService.InitForeignCNProfessionalDropDownList(this.drpCNProfessionalId, true); | 
					
						
							|  |  |  |  |                 BindGrid(); | 
					
						
							|  |  |  |  |                 btnNew.OnClientClick = Window1.GetShowReference("ControlPointCheckEdit.aspx") + "return false;"; | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |         #endregion | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         #region 绑定数据 | 
					
						
							|  |  |  |  |         /// <summary> | 
					
						
							|  |  |  |  |         /// 绑定数据 | 
					
						
							|  |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         private void BindGrid() | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             string strSql = @"SELECT checks.ControlPointCheckId, 
 | 
					
						
							|  |  |  |  |                                     checks.ProjectId, | 
					
						
							|  |  |  |  |                                     checks.UnitId,  | 
					
						
							|  |  |  |  |                                     checks.CNProfessionalId,  | 
					
						
							|  |  |  |  |                                     checks.InspectionCode,  | 
					
						
							|  |  |  |  |                                     checks.UnitWorkId,  | 
					
						
							|  |  |  |  |                                     checks.Branch,  | 
					
						
							|  |  |  |  |                                     breakdown.BreakdownName as ControlPointType,  | 
					
						
							|  |  |  |  |                                     checks.AcceptanceSite,  | 
					
						
							| 
									
										
										
										
											2025-10-24 18:27:46 +08:00
										 |  |  |  |                                     (CASE WHEN checks.IsOnceQualified='True' THEN '是' ELSE '否' END) AS IsOnceQualified,  | 
					
						
							| 
									
										
										
										
											2021-04-30 10:28:37 +08:00
										 |  |  |  |                                     checks.InspectionDate, | 
					
						
							|  |  |  |  |                                     checks.AttachUrl,  | 
					
						
							|  |  |  |  |                                     checks.CheckDate,  | 
					
						
							|  |  |  |  |                                     checks.CheckMan,  | 
					
						
							|  |  |  |  |                                     checks.UnqualifiedReason,  | 
					
						
							|  |  |  |  |                                     checks.NoticeCode,  | 
					
						
							|  |  |  |  |                                     checks.AcceptanceCheckMan,  | 
					
						
							|  |  |  |  |                                     checks.ParentDivisionProjectId,  | 
					
						
							|  |  |  |  |                                     checks.CompileMan,  | 
					
						
							|  |  |  |  |                                     checks.CompileDate, | 
					
						
							|  |  |  |  |                                     unit.UnitName, | 
					
						
							|  |  |  |  |                                     cn.ProfessionalName, | 
					
						
							|  |  |  |  |                                     unitWork.UnitWorkName"
 | 
					
						
							|  |  |  |  |                             + @" FROM CQMS_Foreign_ControlPointCheck checks" | 
					
						
							|  |  |  |  |                             + @" LEFT JOIN Base_Unit AS unit ON unit.UnitId = checks.UnitId" | 
					
						
							|  |  |  |  |                             + @" LEFT JOIN WBS_ForeignCNProfessional AS cn ON cn.CNProfessionalId = checks.CNProfessionalId" | 
					
						
							|  |  |  |  |                             + @" LEFT JOIN WBS_UnitWork AS unitWork ON unitWork.UnitWorkId = checks.UnitWorkId" | 
					
						
							|  |  |  |  |                             + @" LEFT JOIN WBS_ForeignBreakdownProject AS breakdown ON breakdown.BreakdownProjectId = checks.ControlPointType" | 
					
						
							|  |  |  |  |                             + @" WHERE checks.ProjectId=@projectId"; | 
					
						
							|  |  |  |  |             List<SqlParameter> listStr = new List<SqlParameter>(); | 
					
						
							|  |  |  |  |             listStr.Add(new SqlParameter("@projectId", this.CurrUser.LoginProjectId)); | 
					
						
							|  |  |  |  |             if (this.drpCNProfessionalId.SelectedValue != BLL.Const._Null && !string.IsNullOrEmpty(this.drpCNProfessionalId.SelectedValue) && this.drpCNProfessionalId.SelectedValue != "null") | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 strSql += " AND checks.CNProfessionalId=@CNProfessionalId"; | 
					
						
							|  |  |  |  |                 listStr.Add(new SqlParameter("@CNProfessionalId", this.drpCNProfessionalId.SelectedValue)); | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             if (this.drpUnitWorkId.SelectedValue != BLL.Const._Null && !string.IsNullOrEmpty(this.drpUnitWorkId.SelectedValue) && this.drpUnitWorkId.SelectedValue != "null") | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 strSql += " AND checks.UnitWorkId=@UnitWorkId"; | 
					
						
							|  |  |  |  |                 listStr.Add(new SqlParameter("@UnitWorkId", this.drpUnitWorkId.SelectedValue)); | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             if (!string.IsNullOrEmpty(this.txtInspectionDateStart.Text.Trim())) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 strSql += " AND checks.InspectionDate>=@InspectionDateStart"; | 
					
						
							|  |  |  |  |                 listStr.Add(new SqlParameter("@InspectionDateStart", this.txtInspectionDateStart.Text.Trim())); | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             if (!string.IsNullOrEmpty(this.txtInspectionDateEnd.Text.Trim())) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 strSql += " AND checks.InspectionDate<=@InspectionDateEnd"; | 
					
						
							|  |  |  |  |                 listStr.Add(new SqlParameter("@InspectionDateEnd", this.txtInspectionDateEnd.Text.Trim())); | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             SqlParameter[] parameter = listStr.ToArray(); | 
					
						
							|  |  |  |  |             DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter); | 
					
						
							|  |  |  |  |             Grid1.RecordCount = tb.Rows.Count; | 
					
						
							|  |  |  |  |             var table = this.GetPagedDataTable(Grid1, tb); | 
					
						
							|  |  |  |  |             Grid1.DataSource = table; | 
					
						
							|  |  |  |  |             Grid1.DataBind(); | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |         #endregion | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         #region 分页 | 
					
						
							|  |  |  |  |         /// <summary> | 
					
						
							|  |  |  |  |         /// 分页索引事件 | 
					
						
							|  |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         /// <param name="sender"></param> | 
					
						
							|  |  |  |  |         /// <param name="e"></param> | 
					
						
							|  |  |  |  |         protected void Grid1_PageIndexChange(object sender, GridPageEventArgs e) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             BindGrid(); | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         /// <summary> | 
					
						
							|  |  |  |  |         /// 分页下拉框事件 | 
					
						
							|  |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         /// <param name="sender"></param> | 
					
						
							|  |  |  |  |         /// <param name="e"></param> | 
					
						
							|  |  |  |  |         protected void ddlPageSize_SelectedIndexChanged(object sender, EventArgs e) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             Grid1.PageSize = Convert.ToInt32(ddlPageSize.SelectedValue); | 
					
						
							|  |  |  |  |             BindGrid(); | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         /// <summary> | 
					
						
							|  |  |  |  |         /// 排序 | 
					
						
							|  |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         /// <param name="sender"></param> | 
					
						
							|  |  |  |  |         /// <param name="e"></param> | 
					
						
							|  |  |  |  |         protected void Grid1_Sort(object sender, FineUIPro.GridSortEventArgs e) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             Grid1.SortDirection = e.SortDirection; | 
					
						
							|  |  |  |  |             Grid1.SortField = e.SortField; | 
					
						
							|  |  |  |  |             BindGrid(); | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |         #endregion | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         #region 关闭窗体 | 
					
						
							|  |  |  |  |         /// <summary> | 
					
						
							|  |  |  |  |         /// 关闭窗体 | 
					
						
							|  |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         /// <param name="sender"></param> | 
					
						
							|  |  |  |  |         /// <param name="e"></param> | 
					
						
							|  |  |  |  |         protected void Window1_Close(object sender, WindowCloseEventArgs e) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             BindGrid(); | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |         #endregion | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         #region 编辑 | 
					
						
							|  |  |  |  |         /// <summary> | 
					
						
							|  |  |  |  |         /// 右键编辑 | 
					
						
							|  |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         /// <param name="sender"></param> | 
					
						
							|  |  |  |  |         /// <param name="e"></param> | 
					
						
							|  |  |  |  |         protected void btnMenuModify_Click(object sender, EventArgs e) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             EditData(); | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         /// <summary> | 
					
						
							|  |  |  |  |         /// Grid行双击事件 | 
					
						
							|  |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         /// <param name="sender"></param> | 
					
						
							|  |  |  |  |         /// <param name="e"></param> | 
					
						
							|  |  |  |  |         protected void Grid1_RowDoubleClick(object sender, GridRowClickEventArgs e) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             EditData(); | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         /// <summary> | 
					
						
							|  |  |  |  |         /// 编辑 | 
					
						
							|  |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         private void EditData() | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             if (Grid1.SelectedRowIndexArray.Length == 0) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 Alert.ShowInTop("请至少选择一条记录", MessageBoxIcon.Warning); | 
					
						
							|  |  |  |  |                 return; | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("ControlPointCheckEdit.aspx?ControlPointCheckId={0}", Grid1.SelectedRowID, "编辑 - "))); | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |         #endregion | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         #region 删除 | 
					
						
							|  |  |  |  |         /// <summary> | 
					
						
							|  |  |  |  |         /// 右键删除 | 
					
						
							|  |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         /// <param name="sender"></param> | 
					
						
							|  |  |  |  |         /// <param name="e"></param> | 
					
						
							|  |  |  |  |         protected void btnMenuDel_Click(object sender, EventArgs e) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             if (Grid1.SelectedRowIndexArray.Length > 0) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 foreach (int rowIndex in Grid1.SelectedRowIndexArray) | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     string rowID = Grid1.DataKeys[rowIndex][0].ToString(); | 
					
						
							|  |  |  |  |                     var controlPointCheck = BLL.ControlPointCheckService.GetControlPointCheckById(rowID); | 
					
						
							|  |  |  |  |                     if (controlPointCheck != null) | 
					
						
							|  |  |  |  |                     { | 
					
						
							|  |  |  |  |                         BLL.ControlPointCheckService.DeleteControlPointCheck(rowID); | 
					
						
							|  |  |  |  |                     } | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |                 BindGrid(); | 
					
						
							|  |  |  |  |                 ShowNotify("删除数据成功!", MessageBoxIcon.Success); | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |         #endregion | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         #region 权限设置 | 
					
						
							|  |  |  |  |         /// <summary> | 
					
						
							|  |  |  |  |         /// 权限设置 | 
					
						
							|  |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         private void GetButtonPower() | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             var buttonList = BLL.CommonService.GetAllButtonList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, BLL.Const.ControlPointCheckMenuId); | 
					
						
							|  |  |  |  |             if (buttonList.Count() > 0) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 if (buttonList.Contains(BLL.Const.BtnAdd)) | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     this.btnNew.Hidden = false; | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |                 if (buttonList.Contains(BLL.Const.BtnModify)) | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     this.btnMenuModify.Hidden = false; | 
					
						
							|  |  |  |  |                     this.Grid1.EnableRowDoubleClickEvent = true; | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |                 if (buttonList.Contains(BLL.Const.BtnDelete)) | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     this.btnMenuDel.Hidden = false; | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |         #endregion | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         #region Grid行点击事件 | 
					
						
							|  |  |  |  |         protected void Grid1_RowCommand(object sender, GridCommandEventArgs e) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             string id = Grid1.DataKeys[e.RowIndex][0].ToString(); | 
					
						
							|  |  |  |  |             if (e.CommandName == "AttachUrl") | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("../../AttachFile/webuploader.aspx?type=-1&toKeyId={0}&path=FileUpload/Foreign/ControlPointCheck&menuId={1}", id, BLL.Const.ControlPointCheckMenuId))); | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |         #endregion | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         #region 导出 | 
					
						
							|  |  |  |  |         /// <summary> | 
					
						
							|  |  |  |  |         /// 导出按钮 | 
					
						
							|  |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         /// <param name="sender"></param> | 
					
						
							|  |  |  |  |         /// <param name="e"></param> | 
					
						
							|  |  |  |  |         protected void btnOut_Click(object sender, EventArgs e) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             Response.ClearContent(); | 
					
						
							|  |  |  |  |             string filename = Funs.GetNewFileName(); | 
					
						
							|  |  |  |  |             Response.AddHeader("content-disposition", "attachment; filename=" + System.Web.HttpUtility.UrlEncode("控制点检查检测" + filename, System.Text.Encoding.UTF8) + ".xls"); | 
					
						
							|  |  |  |  |             Response.ContentType = "application/excel"; | 
					
						
							|  |  |  |  |             Response.ContentEncoding = System.Text.Encoding.UTF8; | 
					
						
							|  |  |  |  |             //this.Grid1.PageSize = this.; | 
					
						
							|  |  |  |  |             this.Grid1.PageSize = 10000; | 
					
						
							|  |  |  |  |             BindGrid(); | 
					
						
							|  |  |  |  |             Response.Write(GetGridTableHtml(Grid1)); | 
					
						
							|  |  |  |  |             Response.End(); | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         /// <summary> | 
					
						
							|  |  |  |  |         /// 导出方法 | 
					
						
							|  |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         /// <param name="grid"></param> | 
					
						
							|  |  |  |  |         /// <returns></returns> | 
					
						
							|  |  |  |  |         private string GetGridTableHtml(Grid grid) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             StringBuilder sb = new StringBuilder(); | 
					
						
							|  |  |  |  |             sb.Append("<meta http-equiv=\"content-type\" content=\"application/excel; charset=UTF-8\"/>"); | 
					
						
							|  |  |  |  |             sb.Append("<table cellspacing=\"0\" rules=\"all\" border=\"1\" style=\"border-collapse:collapse;\">"); | 
					
						
							|  |  |  |  |             sb.Append("<tr>"); | 
					
						
							|  |  |  |  |             foreach (GridColumn column in grid.Columns) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 if (column.ColumnID != "AttachUrl" && column.ColumnID != "ControlPointCheckId") | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     sb.AppendFormat("<td>{0}</td>", column.HeaderText); | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             sb.Append("</tr>"); | 
					
						
							|  |  |  |  |             foreach (GridRow row in grid.Rows) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 sb.Append("<tr>"); | 
					
						
							|  |  |  |  |                 foreach (GridColumn column in grid.Columns) | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     if (column.ColumnID != "AttachUrl" && column.ColumnID != "ControlPointCheckId") | 
					
						
							|  |  |  |  |                     { | 
					
						
							|  |  |  |  |                         string html = row.Values[column.ColumnIndex].ToString(); | 
					
						
							|  |  |  |  |                         if (column.ColumnID == "tfPageIndex") | 
					
						
							|  |  |  |  |                         { | 
					
						
							|  |  |  |  |                             html = (row.FindControl("lblPageIndex") as AspNet.Label).Text; | 
					
						
							|  |  |  |  |                         } | 
					
						
							|  |  |  |  |                         sb.AppendFormat("<td style='vnd.ms-excel.numberformat:@;width:140px;'>{0}</td>", html); | 
					
						
							|  |  |  |  |                     } | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |                 sb.Append("</tr>"); | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             sb.Append("</table>"); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             return sb.ToString(); | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |         #endregion | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         #region 查询 | 
					
						
							|  |  |  |  |         /// <summary> | 
					
						
							|  |  |  |  |         /// 查询 | 
					
						
							|  |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         /// <param name="sender"></param> | 
					
						
							|  |  |  |  |         /// <param name="e"></param> | 
					
						
							|  |  |  |  |         protected void btnSearch_Click(object sender, EventArgs e) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             BindGrid(); | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |         #endregion | 
					
						
							|  |  |  |  |     } | 
					
						
							|  |  |  |  | } |