| 
									
										
										
										
											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 AspNet = System.Web.UI.WebControls; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | namespace FineUIPro.Web.HSSE.Environmental | 
					
						
							|  |  |  |  | { | 
					
						
							|  |  |  |  |     public partial class EnvironmentalMonitoring : PageBase | 
					
						
							|  |  |  |  |     { | 
					
						
							|  |  |  |  |         /// <summary> | 
					
						
							| 
									
										
										
										
											2024-12-24 19:04:32 +08:00
										 |  |  |  |         /// 项目id | 
					
						
							| 
									
										
										
										
											2021-04-30 10:28:37 +08:00
										 |  |  |  |         /// </summary> | 
					
						
							| 
									
										
										
										
											2024-12-24 19:04:32 +08:00
										 |  |  |  |         public string ProjectId | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             get | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 return (string)ViewState["ProjectId"]; | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             set | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 ViewState["ProjectId"] = value; | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |         } | 
					
						
							| 
									
										
										
										
											2021-04-30 10:28:37 +08:00
										 |  |  |  |         protected void Page_Load(object sender, EventArgs e) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             if (!IsPostBack) | 
					
						
							|  |  |  |  |             { | 
					
						
							| 
									
										
										
										
											2024-12-24 19:04:32 +08:00
										 |  |  |  |                 this.ProjectId = this.CurrUser.LoginProjectId; | 
					
						
							|  |  |  |  |                 if (!string.IsNullOrEmpty(Request.Params["projectId"]) && Request.Params["projectId"] != this.CurrUser.LoginProjectId) | 
					
						
							| 
									
										
										
										
											2021-04-30 10:28:37 +08:00
										 |  |  |  |                 { | 
					
						
							| 
									
										
										
										
											2024-12-24 19:04:32 +08:00
										 |  |  |  |                     this.ProjectId = Request.Params["projectId"]; | 
					
						
							| 
									
										
										
										
											2021-04-30 10:28:37 +08:00
										 |  |  |  |                 } | 
					
						
							| 
									
										
										
										
											2024-12-24 19:04:32 +08:00
										 |  |  |  |                 this.ucTree.UnitId = this.CurrUser.UnitId; | 
					
						
							|  |  |  |  |                 this.ucTree.ProjectId = this.ProjectId; | 
					
						
							|  |  |  |  |                 this.ddlPageSize.SelectedValue = this.Grid1.PageSize.ToString(); | 
					
						
							|  |  |  |  |                 txtStartTime.SelectedDate = DateTime.Now; | 
					
						
							|  |  |  |  |                 txtLogTime.SelectedDate = DateTime.Now; | 
					
						
							| 
									
										
										
										
											2021-04-30 10:28:37 +08:00
										 |  |  |  |                 // 绑定表格 | 
					
						
							| 
									
										
										
										
											2024-12-24 19:04:32 +08:00
										 |  |  |  |                 this.BindGrid(); | 
					
						
							|  |  |  |  |                 if (!string.IsNullOrEmpty(this.CurrUser.LoginProjectId)) | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     this.panelLeftRegion.Hidden = true; | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-04-30 10:28:37 +08:00
										 |  |  |  |             } | 
					
						
							|  |  |  |  |         } | 
					
						
							| 
									
										
										
										
											2024-12-24 19:04:32 +08:00
										 |  |  |  |         protected void changeTree(object sender, EventArgs e) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             this.ProjectId = this.ucTree.ProjectId; | 
					
						
							|  |  |  |  |             this.BindGrid(); | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |         #region 绑定数据 | 
					
						
							| 
									
										
										
										
											2021-04-30 10:28:37 +08:00
										 |  |  |  |         /// <summary> | 
					
						
							|  |  |  |  |         /// 绑定数据 | 
					
						
							|  |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         private void BindGrid() | 
					
						
							|  |  |  |  |         { | 
					
						
							| 
									
										
										
										
											2024-12-24 19:04:32 +08:00
										 |  |  |  |             if (!string.IsNullOrEmpty(ProjectId)) | 
					
						
							| 
									
										
										
										
											2021-04-30 10:28:37 +08:00
										 |  |  |  |             { | 
					
						
							| 
									
										
										
										
											2024-12-24 19:04:32 +08:00
										 |  |  |  |                 Model.EnvironmentalCheck table = new Model.EnvironmentalCheck(); | 
					
						
							|  |  |  |  |                 var q = (from x in Funs.DB.EnvironmentalCheck | 
					
						
							|  |  |  |  |                          where x.Time.Value.Date >= txtStartTime.SelectedDate.Value && x.Time.Value.Date <= txtLogTime.SelectedDate.Value && x.ProjectId == this.ProjectId | 
					
						
							|  |  |  |  |                          select | 
					
						
							|  |  |  |  |                          x).ToList(); | 
					
						
							|  |  |  |  |                 Grid1.RecordCount = q.Count; | 
					
						
							|  |  |  |  |                 q = q.OrderByDescending(x => x.Time).Skip(Grid1.PageSize * (Grid1.PageIndex)).Take(Grid1.PageSize).ToList(); | 
					
						
							|  |  |  |  |                 Grid1.DataSource = q; | 
					
						
							|  |  |  |  |                 Grid1.DataBind(); | 
					
						
							| 
									
										
										
										
											2021-04-30 10:28:37 +08:00
										 |  |  |  |             } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         } | 
					
						
							| 
									
										
										
										
											2024-12-24 19:04:32 +08:00
										 |  |  |  |         #endregion | 
					
						
							| 
									
										
										
										
											2021-04-30 10:28:37 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-12-24 19:04:32 +08:00
										 |  |  |  |         #region GV 数据操作 | 
					
						
							| 
									
										
										
										
											2021-04-30 10:28:37 +08:00
										 |  |  |  |         /// <summary> | 
					
						
							| 
									
										
										
										
											2024-12-24 19:04:32 +08:00
										 |  |  |  |         /// 分页 | 
					
						
							| 
									
										
										
										
											2021-04-30 10:28:37 +08:00
										 |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         /// <param name="sender"></param> | 
					
						
							|  |  |  |  |         /// <param name="e"></param> | 
					
						
							|  |  |  |  |         protected void Grid1_PageIndexChange(object sender, GridPageEventArgs e) | 
					
						
							|  |  |  |  |         { | 
					
						
							| 
									
										
										
										
											2024-12-24 19:04:32 +08:00
										 |  |  |  |             this.Grid1.PageIndex = e.NewPageIndex; | 
					
						
							|  |  |  |  |             this.BindGrid(); | 
					
						
							| 
									
										
										
										
											2021-04-30 10:28:37 +08:00
										 |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         /// <summary> | 
					
						
							|  |  |  |  |         /// 排序 | 
					
						
							|  |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         /// <param name="sender"></param> | 
					
						
							|  |  |  |  |         /// <param name="e"></param> | 
					
						
							| 
									
										
										
										
											2024-12-24 19:04:32 +08:00
										 |  |  |  |         protected void Grid1_Sort(object sender, GridSortEventArgs e) | 
					
						
							| 
									
										
										
										
											2021-04-30 10:28:37 +08:00
										 |  |  |  |         { | 
					
						
							| 
									
										
										
										
											2024-12-24 19:04:32 +08:00
										 |  |  |  |             this.Grid1.SortDirection = e.SortDirection; | 
					
						
							|  |  |  |  |             this.Grid1.SortField = e.SortField; | 
					
						
							| 
									
										
										
										
											2021-04-30 10:28:37 +08:00
										 |  |  |  |             this.BindGrid(); | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         /// <summary> | 
					
						
							| 
									
										
										
										
											2024-12-24 19:04:32 +08:00
										 |  |  |  |         /// 分页显示条数下拉框 | 
					
						
							| 
									
										
										
										
											2021-04-30 10:28:37 +08:00
										 |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         /// <param name="sender"></param> | 
					
						
							|  |  |  |  |         /// <param name="e"></param> | 
					
						
							| 
									
										
										
										
											2024-12-24 19:04:32 +08:00
										 |  |  |  |         protected void ddlPageSize_SelectedIndexChanged(object sender, EventArgs e) | 
					
						
							| 
									
										
										
										
											2021-04-30 10:28:37 +08:00
										 |  |  |  |         { | 
					
						
							| 
									
										
										
										
											2024-12-24 19:04:32 +08:00
										 |  |  |  |             this.Grid1.PageSize = Convert.ToInt32(this.ddlPageSize.SelectedValue); | 
					
						
							| 
									
										
										
										
											2021-04-30 10:28:37 +08:00
										 |  |  |  |             this.BindGrid(); | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-12-24 19:04:32 +08:00
										 |  |  |  |         protected void txtLogTime_TextChanged(object sender, EventArgs e) | 
					
						
							| 
									
										
										
										
											2021-04-30 10:28:37 +08:00
										 |  |  |  |         { | 
					
						
							| 
									
										
										
										
											2024-12-24 19:04:32 +08:00
										 |  |  |  |             BindGrid(); | 
					
						
							| 
									
										
										
										
											2021-04-30 10:28:37 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |         #endregion | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-12-24 19:04:32 +08:00
										 |  |  |  |         #region 数据编辑事件 | 
					
						
							| 
									
										
										
										
											2021-04-30 10:28:37 +08:00
										 |  |  |  |         /// <summary> | 
					
						
							| 
									
										
										
										
											2024-12-24 19:04:32 +08:00
										 |  |  |  |         /// 批量删除 | 
					
						
							| 
									
										
										
										
											2021-04-30 10:28:37 +08:00
										 |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         /// <param name="sender"></param> | 
					
						
							|  |  |  |  |         /// <param name="e"></param> | 
					
						
							| 
									
										
										
										
											2024-12-24 19:04:32 +08:00
										 |  |  |  |         protected void btnDelete_Click(object sender, EventArgs e) | 
					
						
							| 
									
										
										
										
											2021-04-30 10:28:37 +08:00
										 |  |  |  |         { | 
					
						
							|  |  |  |  |             if (Grid1.SelectedRowIndexArray.Length > 0) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 foreach (int rowIndex in Grid1.SelectedRowIndexArray) | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     string rowID = Grid1.DataKeys[rowIndex][0].ToString(); | 
					
						
							| 
									
										
										
										
											2024-12-24 19:04:32 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  |                     Model.EnvironmentalCheck table = Funs.DB.EnvironmentalCheck.FirstOrDefault(x => x.Id == rowID); | 
					
						
							|  |  |  |  |                     if (table != null) | 
					
						
							| 
									
										
										
										
											2021-04-30 10:28:37 +08:00
										 |  |  |  |                     { | 
					
						
							| 
									
										
										
										
											2024-12-24 19:04:32 +08:00
										 |  |  |  |                         Funs.DB.EnvironmentalCheck.DeleteOnSubmit(table); | 
					
						
							|  |  |  |  |                         Funs.DB.SubmitChanges(); | 
					
						
							| 
									
										
										
										
											2021-04-30 10:28:37 +08:00
										 |  |  |  |                     } | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |             } | 
					
						
							| 
									
										
										
										
											2024-12-24 19:04:32 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  |             BindGrid(); | 
					
						
							|  |  |  |  |             ShowNotify("删除数据成功!", MessageBoxIcon.Success); | 
					
						
							| 
									
										
										
										
											2021-04-30 10:28:37 +08:00
										 |  |  |  |         } | 
					
						
							|  |  |  |  |         #endregion | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         #region 导出按钮 | 
					
						
							|  |  |  |  |         /// 导出按钮 | 
					
						
							|  |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         /// <param name="sender"></param> | 
					
						
							|  |  |  |  |         /// <param name="e"></param> | 
					
						
							|  |  |  |  |         protected void btnOut_Click(object sender, EventArgs e) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             Response.ClearContent(); | 
					
						
							|  |  |  |  |             string filename = Funs.GetNewFileName(); | 
					
						
							| 
									
										
										
										
											2024-12-24 19:04:32 +08:00
										 |  |  |  |             Response.AddHeader("content-disposition", "attachment; filename=" + System.Web.HttpUtility.UrlEncode("环境监测" + filename, System.Text.Encoding.UTF8) + ".xls"); | 
					
						
							| 
									
										
										
										
											2021-04-30 10:28:37 +08:00
										 |  |  |  |             Response.ContentType = "application/excel"; | 
					
						
							|  |  |  |  |             Response.ContentEncoding = System.Text.Encoding.UTF8; | 
					
						
							| 
									
										
										
										
											2024-12-24 19:04:32 +08:00
										 |  |  |  |             this.Grid1.PageSize = this.Grid1.RecordCount; | 
					
						
							| 
									
										
										
										
											2021-04-30 10:28:37 +08:00
										 |  |  |  |             this.BindGrid(); | 
					
						
							|  |  |  |  |             Response.Write(GetGridTableHtml(Grid1)); | 
					
						
							|  |  |  |  |             Response.End(); | 
					
						
							|  |  |  |  |         } | 
					
						
							| 
									
										
										
										
											2024-12-24 19:04:32 +08:00
										 |  |  |  |         #endregion | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         protected void btnApiView_Click(object sender, EventArgs e) | 
					
						
							|  |  |  |  |         {  | 
					
						
							|  |  |  |  |             PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("EnvironmentalMonitoringApiView.aspx?Projectid={0}", this.ProjectId, "查看 - "))); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         } | 
					
						
							| 
									
										
										
										
											2021-04-30 10:28:37 +08:00
										 |  |  |  |     } | 
					
						
							|  |  |  |  | } |