using BLL; using System; using System.Collections.Generic; using System.Data.SqlClient; using System.Data; using System.Linq; namespace FineUIPro.Web.SYHSE { public partial class Data_EnvironmentProtectionShow : PageBase { /// /// 加载页面 /// /// /// protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { Funs.DropDownPageSize(this.ddlPageSize); // 绑定表格 this.BindGrid(); } } #region 绑定数据 /// /// 绑定数据 /// private void BindGrid() { string strSql = @" SELECT newId() Id, [DetectionTimeA],[DetectionAddress] ,[DetectionProject] ,max([DetectionValue])[DetectionValue] ,max([StandValue])[StandValue] ,max([AvgFlow])[AvgFlow] ,max([SumFlow])[SumFlow] FROM [dbo].[SYHSEData_EnvironmentProtection] WHERE ProjectId = @ProjectId "; List listStr = new List { new SqlParameter("@projectId", this.CurrUser.LoginProjectId), }; if (!string.IsNullOrEmpty(this.txtStartTime.Text.Trim())) { strSql += " AND DetectionTimeA >= @DetectionTimeA "; listStr.Add(new SqlParameter("@DetectionTimeA", "%" + this.txtStartTime.Text.Trim() + "%")); } if (!string.IsNullOrEmpty(this.txtStartTime.Text.Trim())) { strSql += " AND DetectionTimeZ <= @DetectionTimeZ "; listStr.Add(new SqlParameter("@DetectionTimeZ", "%" + this.txtStartTime.Text.Trim() + "%")); } strSql += @" group by [DetectionTimeA],[DetectionAddress] ,[DetectionProject],ShowIndex order by [DetectionTimeA] desc,ShowIndex asc"; SqlParameter[] parameter = listStr.ToArray(); DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter); // 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 btSearch_Click(object sender, EventArgs e) { this.BindGrid(); } #endregion #region 导入 /// /// 导入焊接日报 /// /// /// protected void btnImport_Click(object sender, EventArgs e) { if (BLL.CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, BLL.Const.SYHSE_EnvironmentProtectionMenuId, BLL.Const.BtnSave)) { PageContext.RegisterStartupScript(WindowImport.GetShowReference(String.Format("Data_EnvironmentProtectionDataIn.aspx", "导入 - "))); } else { ShowNotify("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning); } } #endregion #region 删除数据 /// /// 右键删除事件 /// /// /// protected void btnMenuDelete_Click(object sender, EventArgs e) { this.DeleteData(); } /// /// 删除方法 /// private void DeleteData() { if (CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.SYHSE_EnvironmentProtectionMenuId, Const.BtnDelete)) { if (Grid1.SelectedRowIDArray.Length > 0) { foreach (var item in Grid1.SelectedRowIDArray) { SYHSEData_EnvironmentProtectionService.DeleteProjectById(item); } BindGrid(); ShowNotify("删除数据成功!", MessageBoxIcon.Success); } } else { ShowNotify("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning); } } #endregion #region 分页 /// /// 分页 /// /// /// protected void Grid1_PageIndexChange(object sender, GridPageEventArgs e) { BindGrid(); } /// /// 分页显示条数下拉框 /// /// /// protected void ddlPageSize_SelectedIndexChanged(object sender, EventArgs e) { Grid1.PageSize = Convert.ToInt32(ddlPageSize.SelectedValue); BindGrid(); } /// /// 排序 /// /// /// protected void Grid1_Sort(object sender, FineUIPro.GridSortEventArgs e) { BindGrid(); } #endregion protected void btAdd_Click(object sender, EventArgs e) { if (CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.SYHSE_EnvironmentProtectionMenuId, Const.BtnAdd)) { PageContext.RegisterStartupScript(WindowAdd.GetShowReference(String.Format("Data_EnvironmentProtectionEdit.aspx?Id={0}", string.Empty, "新增 - "))); } else { ShowNotify("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning); } } protected void WindowAdd_Close(object sender, WindowCloseEventArgs e) { this.BindGrid(); } public string ConvertMan(Object userId) { Model.Sys_User user = Funs.DB.Sys_User.FirstOrDefault(e => e.UserId == userId.ToString()); if (user != null) { return user.UserName; } else { return userId.ToString(); } } protected void Grid1_RowDoubleClick(object sender, GridRowClickEventArgs e) { if (Grid1.SelectedRowIndexArray.Length == 0) { Alert.ShowInTop("请至少选择一条记录", MessageBoxIcon.Warning); return; } PageContext.RegisterStartupScript(WindowAdd.GetShowReference(String.Format("Data_EnvironmentProtectionEdit.aspx?Id={0}", Grid1.SelectedRowID, "编辑 - "))); } protected void drpUnit_SelectedIndexChanged(object sender, EventArgs e) { BindGrid(); } } }