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.WeldingProcess.PMI { public partial class PMIDelegationReport : PageBase { #region 加载 /// /// 加载页面 /// /// /// protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { this.ddlPageSize.SelectedValue = this.Grid1.PageSize.ToString(); BLL.Base_UnitService.InitProjectUnitDropDownList(this.drpUnitId, true, this.CurrUser.LoginProjectId, BLL.Const.UnitType_5, Resources.Lan.PleaseSelect);//单位 BLL.Project_WorkAreaService.InitWorkAreaDropDownList(this.drpWorkAreaId, true, this.CurrUser.LoginProjectId, string.Empty, this.drpUnitId.SelectedValue, string.Empty, Resources.Lan.PleaseSelect);//区域 } } /// /// 绑定数据 /// private void BindGrid() { string sql = @"select *from ( select projectId, InstallationId, WorkAreaId, UnitId, PipelineId, InstallationCode, WorkAreaCode, PipelineCode, PMINum, (convert(float,PMIBySNum)/NULLIF(convert(float,PMINum),0)*100) as RateBys, PMIBySNum, (convert(float,PMIByFNum)/NULLIF(convert(float,PMINum),0)*100) as RateByf, PMIByFNum from ( select a.projectId, a.InstallationId, a.WorkAreaId, a.UnitId, a.PipelineId, b.InstallationCode, c.WorkAreaCode, a.PipelineCode, (select count(1) from Pipeline_WeldJoint as d where isPMI=1 and d.PipelineId=a.PipelineId) as PMINum, ( select count(1) from PMI_Delegation as pd inner join PMI_DelegationDetails as pdd on pd.Id=pdd.PMIId inner join Pipeline_WeldJoint as pwj on pdd.JointId=pwj.WeldJointId where pd.InstallationId=a.InstallationId and pd.UnitId=a.UnitId and pdd.WorkAreaId=a.WorkAreaId and pwj.PipelineId=a.PipelineId and pwj.JointAttribute='活动S' and pwj.isPMI=1 ) as PMIBySNum, ( select count(1) from PMI_Delegation as pd inner join PMI_DelegationDetails as pdd on pd.Id=pdd.PMIId inner join Pipeline_WeldJoint as pwj on pdd.JointId=pwj.WeldJointId where pd.InstallationId=a.InstallationId and pd.UnitId=a.UnitId and pdd.WorkAreaId=a.WorkAreaId and pwj.PipelineId=a.PipelineId and pwj.JointAttribute='固定F' and pwj.isPMI=1 ) as PMIByFNum from Pipeline_Pipeline as a left join Project_Installation as b on a.InstallationId=b.InstallationId left join Project_WorkArea as c on a.WorkAreaId=c.WorkAreaId ) as t ) as H where projectId=@projectId and RateBys>0 "; List listStr = new List(); listStr.Add(new SqlParameter("@projectId", this.CurrUser.LoginProjectId)); if (this.drpUnitId.SelectedValue != BLL.Const._Null) { sql += " and UnitId=@unitId"; listStr.Add(new SqlParameter("@unitId", this.drpUnitId.SelectedValue)); } if (this.drpWorkAreaId.SelectedValue != BLL.Const._Null) { sql += " and WorkAreaId=@unitId"; listStr.Add(new SqlParameter("@workAreaId", this.drpWorkAreaId.SelectedValue)); } if (this.drpIsALl.SelectedValue!="全部") { sql += " and RateBys<=2"; } if (!string.IsNullOrEmpty(this.txtPipelineCode.Text)) { sql += " and PipelineCode like '%@PipelineCode%'"; listStr.Add(new SqlParameter("@PipelineCode", this.txtPipelineCode.Text.Trim())); } SqlParameter[] parameter = listStr.ToArray(); DataTable tb = SQLHelper.GetDataTableRunText(sql, parameter); this.Grid1.RecordCount = tb.Rows.Count; var table = this.GetPagedDataTable(Grid1, tb); Grid1.DataSource = table; Grid1.DataBind(); } /// /// 改变索引事件 /// /// /// 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) { this.BindGrid(); } #endregion #region 统计按钮事件 /// /// 统计 /// /// /// protected void BtnAnalyse_Click(object sender, EventArgs e) { BindGrid(); } #endregion #region 下拉选择事件 /// /// 单位下拉选择事件 /// /// /// protected void drpUnitId_SelectedIndexChanged(object sender, EventArgs e) { this.drpWorkAreaId.Items.Clear(); if (this.drpUnitId.SelectedValue != BLL.Const._Null) { BLL.Project_WorkAreaService.InitWorkAreaDropDownList(this.drpWorkAreaId, true, this.CurrUser.LoginProjectId, string.Empty, this.drpUnitId.SelectedValue, string.Empty, Resources.Lan.PleaseSelect); } else { Funs.FineUIPleaseSelect(this.drpWorkAreaId, Resources.Lan.PleaseSelect); } this.drpWorkAreaId.SelectedValue = BLL.Const._Null; } protected void drpIsALl_SelectedIndexChanged(object obj, EventArgs e) { this.BindGrid(); } #endregion } }