SGGL_SHJ/SGGL/FineUIPro.Web/HJGL/PreDesign/PackagingManageSelect.aspx.cs

281 lines
10 KiB
C#

using BLL;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
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;
}
}
/// <summary>
/// 0是散件 1 是其他
/// </summary>
public string TypeInt
{
get
{
return (string)ViewState["TypeInt"];
}
set
{
ViewState["TypeInt"] = 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.Params["PackagingManageId"];
TypeInt = Request.Params["TypeInt"];
this.InitTreeMenu();//加载树
InitDropList();
}
}
#endregion
#region
/// <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();
//获取当前项目出库单
Model.Tw_InOutMasterOutput querytable = new Model.Tw_InOutMasterOutput();
querytable.ProjectId = this.CurrUser.LoginProjectId;
querytable.InOutType = (int?)TwConst.InOutType.;
querytable.TypeInt = TypeInt == ((int)HJGLPackagingmanageService.TypeInt.).ToString() ? (int)TwConst.TypeInt. : (int)TwConst.TypeInt.;
var outMasterOutputs = BLL.TwOutputmasterService.GetListData(querytable);
List<Model.WBS_UnitWork> unitWork1 = null;
List<Model.WBS_UnitWork> unitWork2 = null;
unitWork2 = (from x in unitWorkList where x.ProjectType == "2" select x).ToList();
if (unitWork2.Count() > 0)
{
foreach (var q in unitWork2)
{
var unitworkOutMasterOutputs = outMasterOutputs.Where(x => x.UnitWorkId == q.UnitWorkId);
var unitNamesUnitIds = BLL.UnitService.getUnitNamesUnitIds(q.UnitId);
TreeNode tn2 = new TreeNode();
tn2.NodeID = q.UnitWorkId;
tn2.Text = q.UnitWorkName;
tn2.ToolTip = "施工单位:" + unitNamesUnitIds;
//tn2.CommandName = 1 + "|" + Funs.GetEndPageNumber(a, pageSize);
tn2.EnableExpandEvent = true;
tn2.EnableClickEvent = true;
rootNode2.Nodes.Add(tn2);
foreach (var item in unitworkOutMasterOutputs)
{
FineUIPro.TreeNode newNode = new FineUIPro.TreeNode();
newNode.Text = item.CusBillCode;
newNode.NodeID = item.Id;
newNode.CommandName = "出库单";
newNode.EnableClickEvent = true;
tn2.Nodes.Add(newNode);
}
}
}
}
#endregion
#region Methods
protected void btnTreeFind_Click(object sender, EventArgs e)
{
this.InitTreeMenu();
}
#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);
}
else
{
if (!string.IsNullOrEmpty(this.tvControlItem.SelectedNodeID))
{
this.BindGrid(this.tvControlItem.SelectedNodeID);
}
}
}
#endregion TreeView
#region
/// <summary>
/// 行绑定事件(没有焊接方法无法选择)
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Grid1_RowDataBound(object sender, GridRowEventArgs e)
{
DataRowView row = e.DataItem as DataRowView;
string id = e.RowID;
if (Funs.DB.HJGL_PackagingManageDetail.Any(x => x.TwOutputDetailId == id))
{
e.RowSelectable = false;
}
;
}
private void BindGrid(string outputMasterId)
{
////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();
Model.Tw_InOutDetailOutput table = new Model.Tw_InOutDetailOutput();
table.OutputMasterId = outputMasterId;
var tb = BLL.TwOutputdetailService.GetByModle(table).ToList();
Grid1.DataSource = tb;
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);
}
private void Save()
{
var SelectIDArry = Grid1.SelectedRowIDArray;
if (SelectIDArry != null)
{
foreach (var id in SelectIDArry)
{
var twoutputdetailModel = BLL.TwOutputdetailService.GetById(id);
if (twoutputdetailModel != null)
{
var model = new Model.HJGL_PackagingManageDetail()
{
Id = SQLHelper.GetNewID(),
PackagingManageId = this.PackagingManageId,
//PipelineId = hJGL_PipeLineMat.PipelineId,
MaterialCode = twoutputdetailModel.MaterialCode,
Number = twoutputdetailModel.ActNum,
TwOutputDetailId = twoutputdetailModel.Id,
CreateTime = DateTime.Now,
CreateUser = this.CurrUser.PersonId,
};
HJGLPackagingmanagedetailService.Add(model);
}
}
}
}
#endregion
}
}