using BLL;
using MiniExcelLibs;
using Model;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.IO;
using System.Linq;
namespace FineUIPro.Web.common
{
public partial class mainMenu_HJGL3 : PageBase
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
this.InitTreeMenu();//加载树
this.txtWeldingDate.Text = string.Format("{0:yyyy-MM-dd}", DateTime.Now);
BindGrid1();
BindGrid3();
}
}
protected void WeldingDateText_OnTextChanged(object sender, EventArgs e)
{
BindGrid1();
BindGrid2(this.tvControlItem.SelectedNodeID);
BindGrid3();
}
#region 加载树装置-单位-工作区
///
/// 加载树
///
private void InitTreeMenu()
{
this.tvControlItem.Nodes.Clear();
TreeNode rootNode1 = new TreeNode();
rootNode1.NodeID = "1";
rootNode1.Text = "建筑工程";
rootNode1.CommandName = "建筑工程";
rootNode1.Selectable = false;
this.tvControlItem.Nodes.Add(rootNode1);
TreeNode rootNode2 = new TreeNode();
rootNode2.NodeID = "2";
rootNode2.Text = "安装工程";
rootNode2.CommandName = "安装工程";
rootNode2.Expanded = true;
this.tvControlItem.Nodes.Add(rootNode2);
var pUnits = (from x in Funs.DB.Project_ProjectUnit where x.ProjectId == this.CurrUser.LoginProjectId select x).ToList();
// 获取当前用户所在单位
var currUnit = pUnits.FirstOrDefault(x => x.UnitId == this.CurrUser.UnitId);
var unitWorkList = (from x in Funs.DB.WBS_UnitWork
where x.ProjectId == this.CurrUser.LoginProjectId
&& x.SuperUnitWork == null && x.UnitId != null && x.ProjectType != null
select x).ToList();
List unitWork1 = null;
List unitWork2 = null;
//// 当前为施工单位,只能操作本单位的数据
//if (currUnit != null && currUnit.UnitType == Const.ProjectUnitType_2)
//{
// unitWork1 = (from x in unitWorkList
// where x.UnitId == this.CurrUser.UnitId && x.ProjectType == "1"
// select x).ToList();
// unitWork2 = (from x in unitWorkList
// where x.UnitId == this.CurrUser.UnitId && x.ProjectType == "2"
// select x).ToList();
//}
//else
//{
unitWork1 = (from x in unitWorkList where x.ProjectType == "1" select x).ToList();
unitWork2 = (from x in unitWorkList where x.ProjectType == "2" select x).ToList();
//}
if (unitWork1.Count() > 0)
{
foreach (var q in unitWork1)
{
int a = (from x in Funs.DB.HJGL_Pipeline where x.ProjectId == this.CurrUser.LoginProjectId && x.UnitWorkId == q.UnitWorkId select x).Count();
var unitNamesUnitIds = BLL.UnitService.getUnitNamesUnitIds(q.UnitId);
TreeNode tn1 = new TreeNode();
tn1.NodeID = q.UnitWorkId;
tn1.Text = q.UnitWorkName + "【" + a.ToString() + "】" + "管线";
tn1.ToolTip = "施工单位:" + unitNamesUnitIds;
tn1.EnableClickEvent = true;
rootNode1.Nodes.Add(tn1);
}
}
if (unitWork2.Count() > 0)
{
foreach (var q in unitWork2)
{
int a = (from x in Funs.DB.HJGL_Pipeline where x.ProjectId == this.CurrUser.LoginProjectId && x.UnitWorkId == q.UnitWorkId select x).Count();
var unitNamesUnitIds = BLL.UnitService.getUnitNamesUnitIds(q.UnitId);
TreeNode tn2 = new TreeNode();
tn2.NodeID = q.UnitWorkId;
tn2.Text = q.UnitWorkName + "【" + a.ToString() + "】" + "管线";
tn2.ToolTip = "施工单位:" + unitNamesUnitIds;
tn2.EnableClickEvent = true;
rootNode2.Nodes.Add(tn2);
}
}
}
#endregion
#region 点击TreeView
///
/// 点击TreeView
///
///
///
protected void tvControlItem_NodeCommand(object sender, TreeCommandEventArgs e)
{
if (this.tvControlItem.SelectedNodeID.Length > 1)
{
this.BindGrid2(this.tvControlItem.SelectedNodeID);
}
}
#endregion
#region 数据绑定
///
/// 数据绑定
///
private void BindGrid1()
{
string strSql = string.Empty;
List listStr = new List();
if (this.rbType.SelectedValue == "1")
{
strSql = @"select ProjectId,TotalDin,TodayFinishSize,FinishSize,CONVERT(NVARCHAR(10),(CAST((CASE ISNULL(TotalDin,0) WHEN 0 THEN 0
ELSE 100.0 * ISNULL(FinishSize,0)/(1.0 * TotalDin) END) AS DECIMAL(8,2))))+'%'
AS Rate from
(select b.ProjectId,CAST((SELECT ISNULL(SUM(ISNULL(Size,0)),0) FROM dbo.HJGL_WeldJoint WHERE ProjectId=b.ProjectId) AS DECIMAL(12,3)) AS TotalDin,
CAST((SELECT ISNULL(SUM(ISNULL(jot.Size,0)),0) FROM dbo.HJGL_WeldJoint jot left join dbo.HJGL_WeldingDaily d on d.WeldingDailyId=jot.WeldingDailyId WHERE jot.ProjectId=b.ProjectId AND jot.WeldingDailyId IS NOT NULL and d.WeldingDate=@WeldingDate) AS DECIMAL(12,3)) AS TodayFinishSize,
CAST((SELECT ISNULL(SUM(ISNULL(jot.Size,0)),0) FROM dbo.HJGL_WeldJoint jot left join dbo.HJGL_WeldingDaily d on d.WeldingDailyId=jot.WeldingDailyId WHERE jot.ProjectId=b.ProjectId AND jot.WeldingDailyId IS NOT NULL and d.WeldingDate<=@WeldingDate) AS DECIMAL(12,3)) AS FinishSize
from Base_Project b) v where ProjectId=@ProjectId ";
listStr.Add(new SqlParameter("@ProjectId", (CurrUser != null) ? CurrUser.LoginProjectId : ""));
listStr.Add(new SqlParameter("@WeldingDate", this.txtWeldingDate.Text.Trim()));
}
else
{
strSql = @"select ProjectId,TotalDin,TodayFinishSize,FinishSize,CONVERT(NVARCHAR(10),(CAST((CASE ISNULL(TotalDin,0) WHEN 0 THEN 0
ELSE 100.0 * ISNULL(FinishSize,0)/(1.0 * TotalDin) END) AS DECIMAL(8,2))))+'%'
AS Rate from
(select b.ProjectId,CAST((SELECT ISNULL(SUM(ISNULL(Size,0)),0) FROM dbo.HJGL_WeldJoint WHERE ProjectId=b.ProjectId) AS DECIMAL(12,3)) AS TotalDin,
CAST((SELECT ISNULL(SUM(ISNULL(jot.Size,0)),0) FROM dbo.HJGL_WeldJoint jot left join dbo.HJGL_WeldingDaily d on d.WeldingDailyId=jot.WeldingDailyId WHERE jot.ProjectId=b.ProjectId AND jot.WeldingDailyId IS NOT NULL and d.WeldingDate>=@WeldingStartDate and d.WeldingDate<=@WeldingEndDate) AS DECIMAL(12,3)) AS TodayFinishSize,
CAST((SELECT ISNULL(SUM(ISNULL(jot.Size,0)),0) FROM dbo.HJGL_WeldJoint jot left join dbo.HJGL_WeldingDaily d on d.WeldingDailyId=jot.WeldingDailyId WHERE jot.ProjectId=b.ProjectId AND jot.WeldingDailyId IS NOT NULL and d.WeldingDate<=@WeldingEndDate) AS DECIMAL(12,3)) AS FinishSize
from Base_Project b) v where ProjectId=@ProjectId ";
listStr.Add(new SqlParameter("@ProjectId", (CurrUser != null) ? CurrUser.LoginProjectId : ""));
listStr.Add(new SqlParameter("@WeldingStartDate", this.txtWeldingStartDate.Text.Trim()));
listStr.Add(new SqlParameter("@WeldingEndDate", this.txtWeldingEndDate.Text.Trim()));
}
SqlParameter[] parameter = listStr.ToArray();
DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter);
Grid1.RecordCount = tb.Rows.Count;
tb = GetFilteredTable(Grid1.FilteredData, tb);
var table = GetPagedDataTable(Grid1, tb);
Grid1.DataSource = table;
Grid1.DataBind();
decimal totalDin = Funs.GetNewDecimalOrZero(this.Grid1.Rows[0].Values[0].ToString());
decimal finishSize = Funs.GetNewDecimalOrZero(this.Grid1.Rows[0].Values[2].ToString());
decimal notCompleteDin = totalDin - finishSize;
this.lbNotCompleteDinTotal.Text = notCompleteDin.ToString();
}
///
/// 数据绑定
///
private void BindGrid2(string unitWorkId)
{
string strSql = string.Empty;
List listStr = new List();
if (this.rbType.SelectedValue == "1")
{
strSql = @"select '工厂预制焊口' as PipeArea,UnitWorkId,TotalDin,TodayFinishSize,FinishSize,CONVERT(NVARCHAR(10),(CAST((CASE ISNULL(TotalDin,0) WHEN 0 THEN 0
ELSE 100.0 * ISNULL(FinishSize,0)/(1.0 * TotalDin) END) AS DECIMAL(8,2))))+'%'
AS Rate from
(select b.UnitWorkId,CAST((SELECT ISNULL(SUM(ISNULL(Size,0)),0) FROM dbo.HJGL_WeldJoint jot left join dbo.HJGL_Pipeline pipeline on jot.PipelineId=pipeline.PipelineId WHERE pipeline.UnitWorkId=b.UnitWorkId and PipeArea='1' and jot.JointAttribute='预制口') AS DECIMAL(12,3)) AS TotalDin,
CAST((SELECT ISNULL(SUM(ISNULL(jot.Size,0)),0) FROM dbo.HJGL_WeldJoint jot left join dbo.HJGL_Pipeline pipeline on jot.PipelineId=pipeline.PipelineId left join dbo.HJGL_WeldingDaily d on d.WeldingDailyId=jot.WeldingDailyId WHERE pipeline.UnitWorkId=b.UnitWorkId and PipeArea='1' and jot.JointAttribute='预制口' AND jot.WeldingDailyId IS NOT NULL and d.WeldingDate=@WeldingDate) AS DECIMAL(12,3)) AS TodayFinishSize,
CAST((SELECT ISNULL(SUM(ISNULL(jot.Size,0)),0) FROM dbo.HJGL_WeldJoint jot left join dbo.HJGL_Pipeline pipeline on jot.PipelineId=pipeline.PipelineId left join dbo.HJGL_WeldingDaily d on d.WeldingDailyId=jot.WeldingDailyId WHERE pipeline.UnitWorkId=b.UnitWorkId and PipeArea='1' and jot.JointAttribute='预制口' AND jot.WeldingDailyId IS NOT NULL and d.WeldingDate<=@WeldingDate) AS DECIMAL(12,3)) AS FinishSize
from WBS_UnitWork b) v where UnitWorkId=@UnitWorkId
union
select '现场施工焊口' as PipeArea,UnitWorkId,TotalDin,TodayFinishSize,FinishSize,CONVERT(NVARCHAR(10),(CAST((CASE ISNULL(TotalDin,0) WHEN 0 THEN 0
ELSE 100.0 * ISNULL(FinishSize,0)/(1.0 * TotalDin) END) AS DECIMAL(8,2))))+'%'
AS Rate from
(select b.UnitWorkId,CAST((SELECT ISNULL(SUM(ISNULL(Size,0)),0) FROM dbo.HJGL_WeldJoint jot left join dbo.HJGL_Pipeline pipeline on jot.PipelineId=pipeline.PipelineId WHERE pipeline.UnitWorkId=b.UnitWorkId and PipeArea='2')+(SELECT ISNULL(SUM(ISNULL(Size,0)),0) FROM dbo.HJGL_WeldJoint jot left join dbo.HJGL_Pipeline pipeline on jot.PipelineId=pipeline.PipelineId WHERE pipeline.UnitWorkId=b.UnitWorkId and PipeArea='1' and jot.JointAttribute='安装口') AS DECIMAL(12,3)) AS TotalDin,
CAST((SELECT ISNULL(SUM(ISNULL(jot.Size,0)),0) FROM dbo.HJGL_WeldJoint jot left join dbo.HJGL_Pipeline pipeline on jot.PipelineId=pipeline.PipelineId left join dbo.HJGL_WeldingDaily d on d.WeldingDailyId=jot.WeldingDailyId WHERE pipeline.UnitWorkId=b.UnitWorkId and PipeArea='2' AND jot.WeldingDailyId IS NOT NULL and d.WeldingDate=@WeldingDate)+(SELECT ISNULL(SUM(ISNULL(jot.Size,0)),0) FROM dbo.HJGL_WeldJoint jot left join dbo.HJGL_Pipeline pipeline on jot.PipelineId=pipeline.PipelineId left join dbo.HJGL_WeldingDaily d on d.WeldingDailyId=jot.WeldingDailyId WHERE pipeline.UnitWorkId=b.UnitWorkId and PipeArea='1' and jot.JointAttribute='安装口' AND jot.WeldingDailyId IS NOT NULL and d.WeldingDate=@WeldingDate) AS DECIMAL(12,3)) AS TodayFinishSize,
CAST((SELECT ISNULL(SUM(ISNULL(jot.Size,0)),0) FROM dbo.HJGL_WeldJoint jot left join dbo.HJGL_Pipeline pipeline on jot.PipelineId=pipeline.PipelineId left join dbo.HJGL_WeldingDaily d on d.WeldingDailyId=jot.WeldingDailyId WHERE pipeline.UnitWorkId=b.UnitWorkId and PipeArea='2' AND jot.WeldingDailyId IS NOT NULL and d.WeldingDate<=@WeldingDate)+(SELECT ISNULL(SUM(ISNULL(jot.Size,0)),0) FROM dbo.HJGL_WeldJoint jot left join dbo.HJGL_Pipeline pipeline on jot.PipelineId=pipeline.PipelineId left join dbo.HJGL_WeldingDaily d on d.WeldingDailyId=jot.WeldingDailyId WHERE pipeline.UnitWorkId=b.UnitWorkId and PipeArea='1' and jot.JointAttribute='安装口' AND jot.WeldingDailyId IS NOT NULL and d.WeldingDate<=@WeldingDate) AS DECIMAL(12,3)) AS FinishSize
from WBS_UnitWork b) v where UnitWorkId=@UnitWorkId";
listStr.Add(new SqlParameter("@UnitWorkId", unitWorkId));
listStr.Add(new SqlParameter("@WeldingDate", this.txtWeldingDate.Text.Trim()));
}
else
{
strSql = @"select '工厂预制焊口' as PipeArea,UnitWorkId,TotalDin,TodayFinishSize,FinishSize,CONVERT(NVARCHAR(10),(CAST((CASE ISNULL(TotalDin,0) WHEN 0 THEN 0
ELSE 100.0 * ISNULL(FinishSize,0)/(1.0 * TotalDin) END) AS DECIMAL(8,2))))+'%'
AS Rate from
(select b.UnitWorkId,CAST((SELECT ISNULL(SUM(ISNULL(Size,0)),0) FROM dbo.HJGL_WeldJoint jot left join dbo.HJGL_Pipeline pipeline on jot.PipelineId=pipeline.PipelineId WHERE pipeline.UnitWorkId=b.UnitWorkId and PipeArea='1' and jot.JointAttribute='预制口') AS DECIMAL(12,3)) AS TotalDin,
CAST((SELECT ISNULL(SUM(ISNULL(jot.Size,0)),0) FROM dbo.HJGL_WeldJoint jot left join dbo.HJGL_Pipeline pipeline on jot.PipelineId=pipeline.PipelineId left join dbo.HJGL_WeldingDaily d on d.WeldingDailyId=jot.WeldingDailyId WHERE pipeline.UnitWorkId=b.UnitWorkId and PipeArea='1' and jot.JointAttribute='预制口' AND jot.WeldingDailyId IS NOT NULL and d.WeldingDate>=@WeldingStartDate and d.WeldingDate<=@WeldingEndDate) AS DECIMAL(12,3)) AS TodayFinishSize,
CAST((SELECT ISNULL(SUM(ISNULL(jot.Size,0)),0) FROM dbo.HJGL_WeldJoint jot left join dbo.HJGL_Pipeline pipeline on jot.PipelineId=pipeline.PipelineId left join dbo.HJGL_WeldingDaily d on d.WeldingDailyId=jot.WeldingDailyId WHERE pipeline.UnitWorkId=b.UnitWorkId and PipeArea='1' and jot.JointAttribute='预制口' AND jot.WeldingDailyId IS NOT NULL and d.WeldingDate<=@WeldingEndDate) AS DECIMAL(12,3)) AS FinishSize
from WBS_UnitWork b) v where UnitWorkId=@UnitWorkId
union
select '现场施工焊口' as PipeArea,UnitWorkId,TotalDin,TodayFinishSize,FinishSize,CONVERT(NVARCHAR(10),(CAST((CASE ISNULL(TotalDin,0) WHEN 0 THEN 0
ELSE 100.0 * ISNULL(FinishSize,0)/(1.0 * TotalDin) END) AS DECIMAL(8,2))))+'%'
AS Rate from
(select b.UnitWorkId,CAST((SELECT ISNULL(SUM(ISNULL(Size,0)),0) FROM dbo.HJGL_WeldJoint jot left join dbo.HJGL_Pipeline pipeline on jot.PipelineId=pipeline.PipelineId WHERE pipeline.UnitWorkId=b.UnitWorkId and PipeArea='2')+(SELECT ISNULL(SUM(ISNULL(Size,0)),0) FROM dbo.HJGL_WeldJoint jot left join dbo.HJGL_Pipeline pipeline on jot.PipelineId=pipeline.PipelineId WHERE pipeline.UnitWorkId=b.UnitWorkId and PipeArea='1' and jot.JointAttribute='安装口') AS DECIMAL(12,3)) AS TotalDin,
CAST((SELECT ISNULL(SUM(ISNULL(jot.Size,0)),0) FROM dbo.HJGL_WeldJoint jot left join dbo.HJGL_Pipeline pipeline on jot.PipelineId=pipeline.PipelineId left join dbo.HJGL_WeldingDaily d on d.WeldingDailyId=jot.WeldingDailyId WHERE pipeline.UnitWorkId=b.UnitWorkId and PipeArea='2' AND jot.WeldingDailyId IS NOT NULL and d.WeldingDate>=@WeldingStartDate and d.WeldingDate<=@WeldingEndDate)+(SELECT ISNULL(SUM(ISNULL(jot.Size,0)),0) FROM dbo.HJGL_WeldJoint jot left join dbo.HJGL_Pipeline pipeline on jot.PipelineId=pipeline.PipelineId left join dbo.HJGL_WeldingDaily d on d.WeldingDailyId=jot.WeldingDailyId WHERE pipeline.UnitWorkId=b.UnitWorkId and PipeArea='1' and jot.JointAttribute='安装口' AND jot.WeldingDailyId IS NOT NULL and d.WeldingDate>=@WeldingStartDate and d.WeldingDate<=@WeldingEndDate) AS DECIMAL(12,3)) AS TodayFinishSize,
CAST((SELECT ISNULL(SUM(ISNULL(jot.Size,0)),0) FROM dbo.HJGL_WeldJoint jot left join dbo.HJGL_Pipeline pipeline on jot.PipelineId=pipeline.PipelineId left join dbo.HJGL_WeldingDaily d on d.WeldingDailyId=jot.WeldingDailyId WHERE pipeline.UnitWorkId=b.UnitWorkId and PipeArea='2' AND jot.WeldingDailyId IS NOT NULL and d.WeldingDate<=@WeldingEndDate)+(SELECT ISNULL(SUM(ISNULL(jot.Size,0)),0) FROM dbo.HJGL_WeldJoint jot left join dbo.HJGL_Pipeline pipeline on jot.PipelineId=pipeline.PipelineId left join dbo.HJGL_WeldingDaily d on d.WeldingDailyId=jot.WeldingDailyId WHERE pipeline.UnitWorkId=b.UnitWorkId and PipeArea='1' and jot.JointAttribute='安装口' AND jot.WeldingDailyId IS NOT NULL and d.WeldingDate<=@WeldingEndDate) AS DECIMAL(12,3)) AS FinishSize
from WBS_UnitWork b) v where UnitWorkId=@UnitWorkId";
listStr.Add(new SqlParameter("@UnitWorkId", unitWorkId));
listStr.Add(new SqlParameter("@WeldingStartDate", this.txtWeldingStartDate.Text.Trim()));
listStr.Add(new SqlParameter("@WeldingEndDate", this.txtWeldingEndDate.Text.Trim()));
}
SqlParameter[] parameter = listStr.ToArray();
DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter);
Grid2.RecordCount = tb.Rows.Count;
tb = GetFilteredTable(Grid2.FilteredData, tb);
var table = GetPagedDataTable(Grid2, tb);
Grid2.DataSource = table;
Grid2.DataBind();
if (Grid2.RecordCount > 0)
{
decimal totalDin1 = Funs.GetNewDecimalOrZero(this.Grid2.Rows[0].Values[1].ToString());
decimal finishSize1 = Funs.GetNewDecimalOrZero(this.Grid2.Rows[0].Values[3].ToString());
decimal notCompleteDin1 = totalDin1 - finishSize1;
this.lbNotCompleteDin1.Text = notCompleteDin1.ToString();
decimal totalDin2 = Funs.GetNewDecimalOrZero(this.Grid2.Rows[1].Values[1].ToString());
decimal finishSize2 = Funs.GetNewDecimalOrZero(this.Grid2.Rows[1].Values[3].ToString());
decimal notCompleteDin2 = totalDin2 - finishSize2;
this.lbNotCompleteDin2.Text = notCompleteDin2.ToString();
}
}
///
/// 数据绑定
///
private void BindGrid3()
{
string strSql = string.Empty;
List listStr = new List();
if (this.rbType.SelectedValue == "1")
{
strSql = @"select distinct UnitName,
CAST((SELECT ISNULL(SUM(ISNULL(jot.Size,0)),0) FROM dbo.HJGL_WeldJoint jot left join dbo.HJGL_WeldingDaily d on d.WeldingDailyId=jot.WeldingDailyId WHERE d.ProjectId=@ProjectId and d.UnitId=b.UnitId and jot.WeldingDailyId IS NOT NULL and d.WeldingDate=@WeldingDate) AS DECIMAL(12,3)) AS TodayFinishSize,
CAST((SELECT ISNULL(SUM(ISNULL(jot.Size,0)),0) FROM dbo.HJGL_WeldJoint jot left join dbo.HJGL_WeldingDaily d on d.WeldingDailyId=jot.WeldingDailyId WHERE d.ProjectId=@ProjectId and d.UnitId=b.UnitId and jot.WeldingDailyId IS NOT NULL and d.WeldingDate<=@WeldingDate) AS DECIMAL(12,3)) AS FinishSize
from HJGL_WeldingDaily b
left join Base_Unit u on b.UnitId=u.UnitId
where b.ProjectId=@ProjectId ";
listStr.Add(new SqlParameter("@ProjectId", (CurrUser != null) ? CurrUser.LoginProjectId : ""));
listStr.Add(new SqlParameter("@WeldingDate", this.txtWeldingDate.Text.Trim()));
}
else
{
strSql = @"select distinct UnitName,
CAST((SELECT ISNULL(SUM(ISNULL(jot.Size,0)),0) FROM dbo.HJGL_WeldJoint jot left join dbo.HJGL_WeldingDaily d on d.WeldingDailyId=jot.WeldingDailyId WHERE d.ProjectId=@ProjectId and d.UnitId=b.UnitId and jot.WeldingDailyId IS NOT NULL and d.WeldingDate>=@WeldingStartDate and d.WeldingDate<=@WeldingEndDate) AS DECIMAL(12,3)) AS TodayFinishSize,
CAST((SELECT ISNULL(SUM(ISNULL(jot.Size,0)),0) FROM dbo.HJGL_WeldJoint jot left join dbo.HJGL_WeldingDaily d on d.WeldingDailyId=jot.WeldingDailyId WHERE d.ProjectId=@ProjectId and d.UnitId=b.UnitId and jot.WeldingDailyId IS NOT NULL and d.WeldingDate<=@WeldingEndDate) AS DECIMAL(12,3)) AS FinishSize
from HJGL_WeldingDaily b
left join Base_Unit u on b.UnitId=u.UnitId
where b.ProjectId=@ProjectId ";
listStr.Add(new SqlParameter("@ProjectId", (CurrUser != null) ? CurrUser.LoginProjectId : ""));
listStr.Add(new SqlParameter("@WeldingStartDate", this.txtWeldingStartDate.Text.Trim()));
listStr.Add(new SqlParameter("@WeldingEndDate", this.txtWeldingEndDate.Text.Trim()));
}
SqlParameter[] parameter = listStr.ToArray();
DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter);
Grid3.RecordCount = tb.Rows.Count;
tb = GetFilteredTable(Grid3.FilteredData, tb);
var table = GetPagedDataTable(Grid3, tb);
Grid3.DataSource = table;
Grid3.DataBind();
}
#endregion
///
/// 查询
///
///
///
protected void btnQuery1_Click(object sender, EventArgs e)
{
if (this.tvControlItem.SelectedNodeID.Length > 1)
{
if (string.IsNullOrEmpty(this.txtPlanEndDate1.Text.Trim()))
{
ShowNotify("请输入计划完成日期!", MessageBoxIcon.Warning);
return;
}
if (string.IsNullOrEmpty(this.txtWorkEfficiency1.Text.Trim()))
{
ShowNotify("请输入日工效!", MessageBoxIcon.Warning);
return;
}
decimal totalDin = Funs.GetNewDecimalOrZero(this.Grid2.Rows[0].Values[1].ToString());
decimal finishSize = Funs.GetNewDecimalOrZero(this.Grid2.Rows[0].Values[3].ToString());
decimal notCompleteDin = totalDin - finishSize;
this.lbNotCompleteDin1.Text = notCompleteDin.ToString();
TimeSpan ts = (TimeSpan)(Funs.GetNewDateTime(this.txtPlanEndDate1.Text.Trim()) - Funs.GetNewDateTime(this.txtWeldingDate.Text.Trim()));
decimal leaveDay = Convert.ToDecimal(ts.Days);
decimal workEfficiency = Funs.GetNewDecimalOrZero(this.txtWorkEfficiency1.Text.Trim());
if (notCompleteDin > 0)
{
if (leaveDay == 0)
{
ShowNotify("剩余工期(天)为0!", MessageBoxIcon.Warning);
return;
}
if (workEfficiency == 0)
{
ShowNotify("日工效为0!", MessageBoxIcon.Warning);
return;
}
this.lbDayNeedSize1.Text = Convert.ToInt32(Math.Ceiling(notCompleteDin / leaveDay)).ToString();
this.lbNeedWelderNum1.Text = Convert.ToInt32(Math.Ceiling(notCompleteDin / leaveDay / workEfficiency)).ToString();
}
else
{
ShowNotify("工厂预制未完成达因为0!", MessageBoxIcon.Warning);
return;
}
}
else
{
ShowNotify("请选择单位工程", MessageBoxIcon.Warning);
return;
}
}
///
/// 查询
///
///
///
protected void btnQuery2_Click(object sender, EventArgs e)
{
if (this.tvControlItem.SelectedNodeID.Length > 1)
{
if (string.IsNullOrEmpty(this.txtPlanEndDate2.Text.Trim()))
{
ShowNotify("请输入计划完成日期!", MessageBoxIcon.Warning);
return;
}
if (string.IsNullOrEmpty(this.txtWorkEfficiency2.Text.Trim()))
{
ShowNotify("请输入日工效!", MessageBoxIcon.Warning);
return;
}
decimal totalDin = Funs.GetNewDecimalOrZero(this.Grid2.Rows[1].Values[1].ToString());
decimal finishSize = Funs.GetNewDecimalOrZero(this.Grid2.Rows[1].Values[3].ToString());
decimal notCompleteDin = totalDin - finishSize;
this.lbNotCompleteDin2.Text = notCompleteDin.ToString();
TimeSpan ts = (TimeSpan)(Funs.GetNewDateTime(this.txtPlanEndDate2.Text.Trim()) - Funs.GetNewDateTime(this.txtWeldingDate.Text.Trim()));
decimal leaveDay = Convert.ToDecimal(ts.Days);
decimal workEfficiency = Funs.GetNewDecimalOrZero(this.txtWorkEfficiency2.Text.Trim());
if (notCompleteDin > 0)
{
if (leaveDay == 0)
{
ShowNotify("剩余工期(天)为0!", MessageBoxIcon.Warning);
return;
}
if (workEfficiency == 0)
{
ShowNotify("日工效为0!", MessageBoxIcon.Warning);
return;
}
this.lbDayNeedSize2.Text = Convert.ToInt32(Math.Ceiling(notCompleteDin / leaveDay)).ToString();
this.lbNeedWelderNum2.Text = Convert.ToInt32(Math.Ceiling(notCompleteDin / leaveDay / workEfficiency)).ToString();
}
else
{
ShowNotify("现场施工未完成达因为0!", MessageBoxIcon.Warning);
return;
}
}
else
{
ShowNotify("请选择单位工程", MessageBoxIcon.Warning);
return;
}
}
///
/// 查询
///
///
///
protected void btnQueryTotal_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(this.txtPlanEndDate.Text.Trim()))
{
ShowNotify("请输入计划完成日期!", MessageBoxIcon.Warning);
return;
}
if (string.IsNullOrEmpty(this.txtWorkEfficiencyTotal.Text.Trim()))
{
ShowNotify("请输入日工效!", MessageBoxIcon.Warning);
return;
}
decimal totalDin = Funs.GetNewDecimalOrZero(this.Grid1.Rows[0].Values[0].ToString());
decimal finishSize = Funs.GetNewDecimalOrZero(this.Grid1.Rows[0].Values[2].ToString());
decimal notCompleteDin = totalDin - finishSize;
TimeSpan ts = (TimeSpan)(Funs.GetNewDateTime(this.txtPlanEndDate.Text.Trim()) - Funs.GetNewDateTime(this.txtWeldingDate.Text.Trim()));
decimal leaveDay = Convert.ToDecimal(ts.Days);
decimal workEfficiency = Funs.GetNewDecimalOrZero(this.txtWorkEfficiencyTotal.Text.Trim());
if (notCompleteDin > 0)
{
if (leaveDay == 0)
{
ShowNotify("剩余工期(天)为0!", MessageBoxIcon.Warning);
return;
}
if (workEfficiency == 0)
{
ShowNotify("日工效为0!", MessageBoxIcon.Warning);
return;
}
this.lbDayNeedSize.Text = Convert.ToInt32(Math.Ceiling(notCompleteDin / leaveDay)).ToString();
this.lbNeedWelderNumTotal.Text = Convert.ToInt32(Math.Ceiling(notCompleteDin / leaveDay / workEfficiency)).ToString();
}
else
{
ShowNotify("未完成达因为0!", MessageBoxIcon.Warning);
return;
}
}
protected void rbType_SelectedIndexChanged(object sender, EventArgs e)
{
if (this.rbType.SelectedValue == "1")
{
this.txtWeldingDate.Hidden = false;
this.txtWeldingStartDate.Hidden = true;
this.txtWeldingEndDate.Hidden = true;
this.Grid1.Columns[1].HeaderText = "当日完成达因数";
this.Grid2.Columns[2].HeaderText = "当日完成达因数";
this.Grid3.Columns[1].HeaderText = "当日完成达因数";
this.BtnAnalyse.Hidden = true;
BindGrid1();
BindGrid2(this.tvControlItem.SelectedNodeID);
BindGrid3();
}
else
{
this.txtWeldingDate.Hidden = true;
this.txtWeldingStartDate.Hidden = false;
this.txtWeldingEndDate.Hidden = false;
this.Grid1.Columns[1].HeaderText = "当期完成达因数";
this.Grid2.Columns[2].HeaderText = "当期完成达因数";
this.Grid3.Columns[1].HeaderText = "当期完成达因数";
this.BtnAnalyse.Hidden = false;
}
}
///
/// 统计
///
///
///
protected void BtnAnalyse_Click(object sender, EventArgs e)
{
if (!string.IsNullOrEmpty(this.txtWeldingStartDate.Text.Trim()) && !string.IsNullOrEmpty(this.txtWeldingEndDate.Text.Trim()))
{
BindGrid1();
BindGrid2(this.tvControlItem.SelectedNodeID);
BindGrid3();
}
else
{
ShowNotify("请选择开始日期和结束日期!", MessageBoxIcon.Warning);
}
}
}
}