| 
									
										
										
										
											2023-11-02 15:34:51 +08:00
										 |  |  |  | using BLL; | 
					
						
							|  |  |  |  | using System; | 
					
						
							|  |  |  |  | using System.Collections.Generic; | 
					
						
							|  |  |  |  | using System.Data.SqlClient; | 
					
						
							|  |  |  |  | using System.Data; | 
					
						
							|  |  |  |  | using System.Linq; | 
					
						
							|  |  |  |  | using System.Web; | 
					
						
							|  |  |  |  | using System.Web.UI; | 
					
						
							|  |  |  |  | using System.Web.UI.WebControls; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | namespace FineUIPro.Web.DataShowLocal | 
					
						
							|  |  |  |  | { | 
					
						
							|  |  |  |  |     public partial class InspectionManagementStatisc : PageBase | 
					
						
							|  |  |  |  |     { | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         #region 加载页面 | 
					
						
							|  |  |  |  |         /// <summary> | 
					
						
							|  |  |  |  |         /// 加载页面 | 
					
						
							|  |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         /// <param name="sender"></param> | 
					
						
							|  |  |  |  |         /// <param name="e"></param> | 
					
						
							|  |  |  |  |         protected void Page_Load(object sender, EventArgs e) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             if (!IsPostBack) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 Funs.DropDownPageSize(this.ddlPageSize); | 
					
						
							|  |  |  |  |                 ddlPageSize.SelectedValue = Grid1.PageSize.ToString(); | 
					
						
							|  |  |  |  |                 BLL.ProjectService.InitProjectDropDownList(this.drpProject, true); | 
					
						
							|  |  |  |  |                 // 绑定表格t | 
					
						
							|  |  |  |  |                 BindGrid(); | 
					
						
							|  |  |  |  |                 this.Panel1.Title = "质量验收数据(" + BLL.UnitService.GetUnitNameByUnitId(BLL.Const.UnitId_CWCEC) + ")"; | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         /// <summary> | 
					
						
							|  |  |  |  |         /// 绑定数据 | 
					
						
							|  |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         private void BindGrid() | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             string strSql = @"select ProjectId,ProjectCode, ProjectName from Base_Project where ProjectState =1"; | 
					
						
							|  |  |  |  |             List<SqlParameter> listStr = new List<SqlParameter>(); | 
					
						
							|  |  |  |  |             string cpara = string.Empty; | 
					
						
							|  |  |  |  |             if (this.drpProject.SelectedValue != Const._Null) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 strSql += " AND projectId = @projectId";  ///状态为已完成 | 
					
						
							|  |  |  |  |                 listStr.Add(new SqlParameter("@projectId", this.drpProject.SelectedValue)); | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             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 TextBox_TextChanged(object sender, EventArgs e) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             this.BindGrid(); | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |         #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 Grid1_Sort(object sender, GridSortEventArgs 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 Window1_Close(object sender, WindowCloseEventArgs e) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             BindGrid(); | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |         #endregion | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         #region Grid双击事件 编辑 | 
					
						
							|  |  |  |  |         /// <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("InspectionManagementStatiscItem.aspx?projectId={0}", Grid1.SelectedRowID, "查看 - "))); | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |         #endregion | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         protected void btnView_Click(object sender, EventArgs e) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             EditData(); | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         /// <summary> | 
					
						
							|  |  |  |  |         /// 共检总数 | 
					
						
							|  |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         /// <param name="state"></param> | 
					
						
							|  |  |  |  |         /// <returns></returns> | 
					
						
							|  |  |  |  |         protected int Count1(object projectId) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             int cout1 = 0; | 
					
						
							|  |  |  |  |             if (projectId != null) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 var datetime1 = Funs.GetNewDateTime(this.txtStartTime.Text); | 
					
						
							|  |  |  |  |                 var datetime2 = Funs.GetNewDateTime(this.txtStartTime.Text); | 
					
						
							|  |  |  |  |                 var getD1 = from x in Funs.DB.View_CQMS_InspectionManagementDetail where x.ProjectId == projectId.ToString() select x; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |                 if (datetime1.HasValue) | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     getD1 = getD1.Where(x => x.InspectionDate >= datetime1); | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |                 if (datetime2.HasValue) | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     getD1 = getD1.Where(x => x.InspectionDate <= datetime2); | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |                 cout1 = getD1.Count(); | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             return cout1; | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         /// <summary> | 
					
						
							|  |  |  |  |         /// 一次合格数 | 
					
						
							|  |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         /// <param name="state"></param> | 
					
						
							|  |  |  |  |         /// <returns></returns> | 
					
						
							|  |  |  |  |         protected int Count2(object projectId) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             int cout1 = 0; | 
					
						
							|  |  |  |  |             if (projectId != null) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 var datetime1 = Funs.GetNewDateTime(this.txtStartTime.Text); | 
					
						
							|  |  |  |  |                 var datetime2 = Funs.GetNewDateTime(this.txtStartTime.Text); | 
					
						
							|  |  |  |  |                 var getD1 = from x in Funs.DB.View_CQMS_InspectionManagementDetail | 
					
						
							| 
									
										
										
										
											2025-10-24 18:27:46 +08:00
										 |  |  |  |                             where x.ProjectId == projectId.ToString() && x.IsOnceQualified == true | 
					
						
							| 
									
										
										
										
											2023-11-02 15:34:51 +08:00
										 |  |  |  |                             select x; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |                 if (datetime1.HasValue) | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     getD1 = getD1.Where(x => x.InspectionDate >= datetime1); | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |                 if (datetime2.HasValue) | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     getD1 = getD1.Where(x => x.InspectionDate <= datetime2); | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |                 cout1 = getD1.Count(); | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             return cout1; | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |           | 
					
						
							|  |  |  |  |         protected string Count3(object projectId) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             string result = ""; | 
					
						
							|  |  |  |  |             if (projectId != null) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 if (Count1(projectId) != 0)//被除数不能为零 | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     result = Math.Round((double)Count2(projectId) / (double)Count1(projectId) * 100, 2) + "%";//保留两位小数、后四舍五入 | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |                 else | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     result = "0%"; | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             return result; | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |     } | 
					
						
							|  |  |  |  | } |