372 lines
15 KiB
C#
372 lines
15 KiB
C#
using BLL;
|
|
using FastReport.DevComponents.DotNetBar;
|
|
using FineUIPro.Web.HJGL.WeldingManage;
|
|
using Model;
|
|
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Data.SqlClient;
|
|
using System.Linq;
|
|
using System.Web;
|
|
using System.Web.UI;
|
|
using System.Web.UI.WebControls;
|
|
|
|
namespace FineUIPro.Web.HJGL.PreDesign
|
|
{
|
|
public partial class PackagingManageSelect : PageBase
|
|
{
|
|
#region 定义项
|
|
|
|
// public List<HJGL_Pipeline> Tree_hJGL_Pipelines;
|
|
public int pageSize = PipelineService.pageSize;
|
|
|
|
public string PackagingManageId
|
|
{
|
|
get
|
|
{
|
|
return (string)ViewState["PackagingManageId"];
|
|
}
|
|
set
|
|
{
|
|
ViewState["PackagingManageId"] = value;
|
|
}
|
|
}
|
|
|
|
#endregion 定义项
|
|
|
|
#region 加载页面
|
|
|
|
/// <summary>
|
|
/// 加载页面
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if (!IsPostBack)
|
|
{
|
|
PackagingManageId = Request.QueryString["PackagingManageId"];
|
|
this.InitTreeMenu();//加载树
|
|
InitDropList();
|
|
}
|
|
}
|
|
|
|
#endregion 加载页面
|
|
|
|
#region 加载树
|
|
|
|
private void BindNodes(TreeNode node)
|
|
{
|
|
BLL.PipelineService.BindTreeNodes(node, this.tvPipeCode.Text.Trim(), txtMaterialCode.Text.Trim(), this.CurrUser.LoginProjectId, pageSize);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 加载树
|
|
/// </summary>
|
|
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<Model.WBS_UnitWork> unitWork1 = null;
|
|
List<Model.WBS_UnitWork> 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();
|
|
//}
|
|
//var dbpipeLineMat = from x in Funs.DB.HJGL_PipeLineMat select x;
|
|
//var DBpipeline = from x in Funs.DB.HJGL_Pipeline where x.ProjectId == this.CurrUser.LoginProjectId select x;
|
|
if (unitWork1.Count() > 0)
|
|
{
|
|
foreach (var q in unitWork1)
|
|
{
|
|
string strSql = " SELECT DISTINCT [t0].[PipelineId] FROM [dbo].[HJGL_Pipeline] AS [t0]\r\nleft JOIN [dbo].[HJGL_PipeLineMat] AS [t1] ON [t0].[PipelineId] = [t1].[PipelineId]";
|
|
strSql += "where [t0].[UnitWorkId] =@UnitWorkId ";
|
|
List<SqlParameter> listStr = new List<SqlParameter>();
|
|
listStr.Add(new SqlParameter("@UnitWorkId", q.UnitWorkId));
|
|
|
|
if (!string.IsNullOrEmpty(txtMaterialCode.Text.Trim()))
|
|
{
|
|
strSql += " and [t1].[MaterialCode] like @MaterialCode";
|
|
listStr.Add(new SqlParameter("@MaterialCode", "%" + txtMaterialCode.Text.Trim() + "%"));
|
|
|
|
}
|
|
if (!string.IsNullOrEmpty(tvPipeCode.Text.Trim()))
|
|
{
|
|
strSql += " and [t0].[PipelineCode] like @PipelineCode";
|
|
listStr.Add(new SqlParameter("@PipelineCode", "%" + tvPipeCode.Text.Trim() + "%"));
|
|
|
|
}
|
|
SqlParameter[] parameter = listStr.ToArray();
|
|
DataTable dt = SQLHelper.GetDataTableRunText(strSql, parameter);
|
|
var a = dt.Rows.Count;
|
|
|
|
//int a = (from x in DBpipeline
|
|
// join y in dbpipeLineMat on x.PipelineId equals y.PipelineId
|
|
// where x.PipelineCode.Contains(tvPipeCode.Text.Trim()) && x.UnitWorkId == q.UnitWorkId
|
|
// && y.MaterialCode.Contains(txtMaterialCode.Text.Trim())
|
|
// select x.PipelineId).Distinct().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.CommandName = 1 + "|" + Funs.GetEndPageNumber(a, pageSize);
|
|
tn1.EnableExpandEvent = true;
|
|
rootNode1.Nodes.Add(tn1);
|
|
if (a > 0)
|
|
{
|
|
// BindNodes(tn1);
|
|
TreeNode newNode = new TreeNode();
|
|
newNode.Text = "加载管线...";
|
|
newNode.NodeID = "加载管线...";
|
|
tn1.Nodes.Add(newNode);
|
|
}
|
|
}
|
|
}
|
|
if (unitWork2.Count() > 0)
|
|
{
|
|
|
|
foreach (var q in unitWork2)
|
|
{
|
|
string strSql = " SELECT DISTINCT [t0].[PipelineId] FROM [dbo].[HJGL_Pipeline] AS [t0]\r\nleft JOIN [dbo].[HJGL_PipeLineMat] AS [t1] ON [t0].[PipelineId] = [t1].[PipelineId]";
|
|
strSql += "where [t0].[UnitWorkId] =@UnitWorkId ";
|
|
List<SqlParameter> listStr = new List<SqlParameter>();
|
|
listStr.Add(new SqlParameter("@UnitWorkId", q.UnitWorkId));
|
|
|
|
if (!string.IsNullOrEmpty(txtMaterialCode.Text.Trim()))
|
|
{
|
|
strSql += " and [t1].[MaterialCode] like @MaterialCode";
|
|
listStr.Add(new SqlParameter("@MaterialCode", "%" + txtMaterialCode.Text.Trim() + "%"));
|
|
|
|
}
|
|
if (!string.IsNullOrEmpty(tvPipeCode.Text.Trim()))
|
|
{
|
|
strSql += " and [t0].[PipelineCode] like @PipelineCode";
|
|
listStr.Add(new SqlParameter("@PipelineCode", "%" + tvPipeCode.Text.Trim() + "%"));
|
|
|
|
}
|
|
SqlParameter[] parameter = listStr.ToArray();
|
|
DataTable dt = SQLHelper.GetDataTableRunText(strSql, parameter);
|
|
|
|
var a = dt.Rows.Count;
|
|
|
|
//var b = (from x in Funs.DB.HJGL_Pipeline
|
|
// join y in Funs.DB.HJGL_PipeLineMat on x.PipelineId equals y.PipelineId
|
|
// where x.ProjectId == this.CurrUser.LoginProjectId && x.UnitWorkId == q.UnitWorkId && y.MaterialCode.Contains(txtMaterialCode.Text.Trim())
|
|
// select x).Distinct();
|
|
//var b = (from x in DBpipeline
|
|
// join y in dbpipeLineMat on x.PipelineId equals y.PipelineId
|
|
// where x.PipelineCode.Contains(tvPipeCode.Text.Trim()) && x.UnitWorkId == q.UnitWorkId
|
|
// && y.MaterialCode.Contains(txtMaterialCode.Text.Trim())
|
|
// select x.PipelineId).Distinct();
|
|
//int a = (from x in DBpipeline
|
|
// join y in dbpipeLineMat on x.PipelineId equals y.PipelineId
|
|
// where x.PipelineCode.Contains(tvPipeCode.Text.Trim()) && x.UnitWorkId == q.UnitWorkId
|
|
// && y.MaterialCode.Contains(txtMaterialCode.Text.Trim())
|
|
// select x.PipelineId).Distinct().Count();
|
|
var unitNamesUnitIds = BLL.UnitService.getUnitNamesUnitIds(q.UnitId);
|
|
TreeNode tn2 = new TreeNode();
|
|
tn2.NodeID = q.UnitWorkId;
|
|
tn2.Text = q.UnitWorkName + "【" + a.ToString() + "】" + "管线";
|
|
//if (q.UnitWorkId == this.hdUnitWorkId.Text)
|
|
//{
|
|
// tn2.Expanded = true;
|
|
//}
|
|
tn2.ToolTip = "施工单位:" + unitNamesUnitIds;
|
|
tn2.CommandName = 1 + "|" + Funs.GetEndPageNumber(a, pageSize);
|
|
tn2.EnableExpandEvent = true;
|
|
tn2.EnableClickEvent = true;
|
|
|
|
rootNode2.Nodes.Add(tn2);
|
|
if (a > 0)
|
|
{
|
|
// BindNodes(tn2);
|
|
TreeNode newNode = new TreeNode();
|
|
newNode.Text = "加载管线...";
|
|
newNode.NodeID = "加载管线...";
|
|
tn2.Nodes.Add(newNode);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
#endregion 加载树
|
|
|
|
#region Methods
|
|
|
|
protected void btnTreeFind_Click(object sender, EventArgs e)
|
|
{
|
|
this.InitTreeMenu();
|
|
//this.BindGrid3(this.tvControlItem.SelectedNodeID);
|
|
}
|
|
|
|
#endregion Methods
|
|
|
|
#region Methods
|
|
|
|
protected void tvControlItem_TreeNodeExpanded(object sender, TreeNodeEventArgs e)
|
|
{
|
|
if (e.Node.Nodes[0].NodeID == "加载管线...")
|
|
{
|
|
e.Node.Nodes.Clear();
|
|
BindNodes(e.Node);
|
|
}
|
|
}
|
|
|
|
#endregion Methods
|
|
|
|
#region 点击TreeView
|
|
|
|
/// <summary>
|
|
/// 点击TreeView
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void tvControlItem_NodeCommand(object sender, TreeCommandEventArgs e)
|
|
{
|
|
if (e.CommandName == "加载")
|
|
{
|
|
string CommandName = e.Node.ParentNode.CommandName;
|
|
e.Node.ParentNode.CommandName = (int.Parse(CommandName.Split('|')[0]) + 1) + "|" + int.Parse(CommandName.Split('|')[1]);
|
|
TreeNode treeNode = e.Node.ParentNode;
|
|
treeNode.Nodes.Remove(e.Node);
|
|
BindNodes(e.Node.ParentNode);
|
|
}
|
|
else
|
|
{
|
|
if (!string.IsNullOrEmpty(this.tvControlItem.SelectedNodeID))
|
|
{
|
|
Model.HJGL_Pipeline pipeline = BLL.PipelineService.GetPipelineByPipelineId(this.tvControlItem.SelectedNodeID);
|
|
this.hdUnitWorkId.Text = string.Empty;
|
|
if (pipeline != null)
|
|
{
|
|
this.hdUnitWorkId.Text = this.tvControlItem.SelectedNode.ParentNode.NodeID;
|
|
|
|
this.BindGrid(this.tvControlItem.SelectedNodeID, this.hdUnitWorkId.Text);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
#endregion 点击TreeView
|
|
|
|
#region 数据绑定
|
|
|
|
private void BindGrid(string pipelineId, string unitworkid)
|
|
{
|
|
var Prelist = HJGL_PipelineComponentService.GetPipelinePrefabricatedComponent(unitworkid, pipelineId);
|
|
|
|
var inoutplandetail = (from x in Funs.DB.HJGL_PackagingManageDetail
|
|
where x.PipelineId == pipelineId
|
|
&& (x.PipelineComponentId == null || x.PipelineComponentId == "")
|
|
select x).ToList();
|
|
var queryList = Prelist;
|
|
// 优化 Linq 过滤条件,过滤已经进入包装的预制散件
|
|
var result = (from x in queryList
|
|
join y in inoutplandetail on x.MaterialCode equals y.MaterialCode into yy
|
|
from y in yy.DefaultIfEmpty()
|
|
where y == null
|
|
select x).ToList();
|
|
Grid1.DataSource = result;
|
|
Grid1.DataBind();
|
|
}
|
|
|
|
private void InitDropList()
|
|
{
|
|
/* var pipeline = (from x in Funs.DB.HJGL_Pipeline
|
|
where x.ProjectId == this.CurrUser.LoginProjectId
|
|
&& x.UnitWorkId == this.UnitWorkId
|
|
select x.FlowingSection).Distinct().ToList();
|
|
this.drpFlowingSection.DataTextField = "Value";
|
|
this.drpFlowingSection.DataValueField = "Value";
|
|
this.drpFlowingSection.DataSource = pipeline;
|
|
this.drpFlowingSection.DataBind();
|
|
Funs.FineUIPleaseSelect(drpFlowingSection);*/
|
|
}
|
|
|
|
#endregion 数据绑定
|
|
|
|
#region 提交按钮
|
|
|
|
/// <summary>
|
|
/// 提交按钮
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnAccept_Click(object sender, EventArgs e)
|
|
{
|
|
PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
|
|
}
|
|
|
|
protected void btnSave_Click(object sender, EventArgs e)
|
|
{
|
|
Save();
|
|
this.BindGrid(this.tvControlItem.SelectedNodeID, this.hdUnitWorkId.Text);
|
|
}
|
|
|
|
private void Save()
|
|
{
|
|
var List_Id = Grid1.SelectedRowIDArray;
|
|
if (List_Id != null)
|
|
{
|
|
foreach (var id in List_Id)
|
|
{
|
|
var hJGL_PipeLineMat = BLL.PipelineMatService.GetPipeLineMat(id);
|
|
if (hJGL_PipeLineMat != null)
|
|
{
|
|
var model = new Model.HJGL_PackagingManageDetail()
|
|
{
|
|
Id = SQLHelper.GetNewID(),
|
|
PackagingManageId = this.PackagingManageId,
|
|
PipelineId = hJGL_PipeLineMat.PipelineId,
|
|
MaterialCode = hJGL_PipeLineMat.MaterialCode,
|
|
Number = hJGL_PipeLineMat.Number,
|
|
CreateTime = DateTime.Now,
|
|
CreateUser = this.CurrUser.PersonId,
|
|
};
|
|
HJGLPackagingmanagedetailService.Add(model);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
#endregion 提交按钮
|
|
}
|
|
} |