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; using AspNet = System.Web.UI.WebControls; using System.Drawing; 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, isnull((convert(float,PMIBySNum)/NULLIF(convert(float,PMINum),0)*100),0) as RateBys, PMIBySNum, isnull( (convert(float,PMIByFNum)/NULLIF(convert(float,PMINum),0)*100),0) 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 "; 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=@workAreaId"; 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_RowDataBound(object sender, GridRowEventArgs e) { DataRowView row = e.DataItem as DataRowView; decimal rates =Math.Round(Convert.ToDecimal(row["RateBys"]),2); decimal ratef = Math.Round(Convert.ToDecimal(row["RateByf"]), 2); AspNet.Label itemLable = e.Row.FindControl("labRateBys") as AspNet.Label; if (itemLable !=null && !string.IsNullOrEmpty(itemLable.Text)) { itemLable.Text = rates.ToString() + "%"; if (rates>0 && rates <= 2) { itemLable.ForeColor = Color.Red; } } AspNet.Label labRateByf = e.Row.FindControl("labRateByf") as AspNet.Label; if(labRateByf!=null && !string.IsNullOrEmpty(labRateByf.Text)) { labRateByf.Text= ratef.ToString() + "%"; if (ratef>0 && ratef <= 2) { labRateByf.ForeColor = Color.Red; } } } /// /// 排序 /// /// /// 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 } }