using BLL; using System; using System.Collections.Generic; using System.Data; using System.Data.SqlClient; using System.Linq; namespace FineUIPro.Web { public partial class mainMenu_HJGL : PageBase { #region 项目焊接工程量统计 public decimal Dy1 { get { return (decimal)ViewState["Dy1"]; } set { ViewState["Dy1"] = value; } } public decimal Dy2 { get { return (decimal)ViewState["Dy2"]; } set { ViewState["Dy2"] = value; } } public int HK1 { get { return (int)ViewState["HK1"]; } set { ViewState["HK1"] = value; } } public int HK2 { get { return (int)ViewState["HK2"]; } set { ViewState["HK2"] = value; } } #endregion /// /// /// /// /// protected void Page_Load(object sender, EventArgs e) { string projectId = this.CurrUser.LoginProjectId; string unitId = this.CurrUser.UnitId; this.getWeld(projectId, unitId); this.SetWorkNum(projectId, unitId); } #region 焊工现场统计 /// /// 焊工现场统计 /// private void getWeld(string projectId, string unitId) { var getWelders = from x in Funs.DB.SitePerson_Person where x.ProjectId == projectId && x.WorkPostId == Const.WorkPost_Welder select x; if (!string.IsNullOrEmpty(this.CurrUser.UnitId) && unitId != Const.UnitId_SEDIN) { getWelders = getWelders.Where(x => x.UnitId == unitId); } this.divWelderNum.InnerText = getWelders.Count().ToString(); string strSql = @"SELECT SUM(TotalFilm) AS TotalFilm, SUM(PassFilm) AS PassFilm from HJGL_Batch_NDEItem item left join HJGL_Batch_NDE nde on nde.NDEID = item.NDEID where ProjectId = @ProjectId"; List listStr = new List { new SqlParameter("@ProjectId", this.CurrUser.LoginProjectId) }; if (!string.IsNullOrEmpty(this.CurrUser.UnitId) && unitId != Const.UnitId_SEDIN) { strSql += " AND UnitId=@unitId"; listStr.Add(new SqlParameter("@unitId", unitId)); } SqlParameter[] parameter = listStr.ToArray(); DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter); if (tb != null && tb.Rows.Count > 0) { try { var rate = 100 * double.Parse(tb.Rows[0]["PassFilm"].ToString()) / double.Parse(tb.Rows[0]["TotalFilm"].ToString()); this.divPassRate.InnerText = "" + ((int)rate) + "%"; } catch (Exception ex) { this.divPassRate.InnerText = "0%"; } } } #endregion #region 项目焊接工程量统计 private void SetWorkNum(string projectId, string unitId) { this.Dy1 = 0; this.Dy2 = 0; this.HK1 = 0; this.HK2 = 0; var getWelds = Funs.DB.HJGL_WeldJoint.Where(x => x.ProjectId == projectId); if (!string.IsNullOrEmpty(this.CurrUser.UnitId) && unitId != Const.UnitId_SEDIN) { getWelds = from x in getWelds join y in Funs.DB.HJGL_Pipeline on x.PipelineId equals y.PipelineId where y.UnitId == unitId select x; } if (getWelds.Count() > 0) { decimal allDy = getWelds.Sum(x => x.Size ?? 0); int allHk = getWelds.Count(); var getWeldsOk = getWelds.Where(x => x.WeldingDailyId != null); HK1 = getWeldsOk.Count(); HK2 = allHk - HK1; if (HK1 > 0) { Dy1 = getWeldsOk.Sum(x => x.Size ?? 0); } Dy2 = allDy - Dy1; } } #endregion } }