xinjiang/SGGL/FineUIPro.Web/HJGL/HotProcessHard/HotProessTrustItemEdit.aspx.cs

333 lines
11 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using BLL;
using System.Data;
using AspNet = System.Web.UI.WebControls;
namespace FineUIPro.Web.HJGL.HotProcessHard
{
public partial class HotProessTrustItemEdit : PageBase
{
#region
/// <summary>
/// 单位主键
/// </summary>
public string UnitId
{
get
{
return (string)ViewState["UnitId"];
}
set
{
ViewState["UnitId"] = value;
}
}
/// <summary>
/// 区域主键
/// </summary>
public string WorkAreaId
{
get
{
return (string)ViewState["WorkAreaId"];
}
set
{
ViewState["WorkAreaId"] = value;
}
}
/// <summary>
/// 热处理委托主键
/// </summary>
public string HotProessTrustId
{
get
{
return (string)ViewState["HotProessTrustId"];
}
set
{
ViewState["HotProessTrustId"] = value;
}
}
/// <summary>
/// 选择内容字符串
/// </summary>
public string ItemsString
{
get
{
return (string)ViewState["ItemsString"];
}
set
{
ViewState["ItemsString"] = value;
}
}
/// <summary>
/// 被选择项列表
/// </summary>
public List<string> SelectedList
{
get
{
return (List<string>)ViewState["SelectedList"];
}
set
{
ViewState["SelectedList"] = value;
}
}
/// <summary>
/// 未被选择项列表
/// </summary>
public List<string> NoSelectedList
{
get
{
return (List<string>)ViewState["NoSelectedList"];
}
set
{
ViewState["NoSelectedList"] = value;
}
}
#endregion
#region
/// <summary>
/// 加载页面
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
this.SelectedList = new List<string>();
this.NoSelectedList = new List<string>();
string strList = Request.Params["strList"];
List<string> list = Funs.GetStrListByStr(strList, '|');
if (list.Count() == 3)
{
this.UnitId = list[0];
this.WorkAreaId = list[1];
this.HotProessTrustId = list[2];
this.InitTreeMenu();//加载树
}
}
}
#endregion
#region 线
/// <summary>
/// 加载树
/// </summary>
private void InitTreeMenu()
{
this.tvControlItem.Nodes.Clear();
TreeNode rootNode = new TreeNode();
rootNode.Text = "管线号";
rootNode.NodeID = "0";
rootNode.ToolTip = "绿色表示管线下有已焊接的焊口未委托热处理";
rootNode.Expanded = true;
this.tvControlItem.Nodes.Add(rootNode);
var hotProessItems = from x in Funs.DB.HJGL_HotProess_TrustItem select x; //热处理委托明细集合
var iso = from x in Funs.DB.PW_IsoInfo where x.ProjectId == this.CurrUser.LoginProjectId && x.UnitId == this.UnitId && x.WorkAreaId == this.WorkAreaId select x;
if (!string.IsNullOrEmpty(this.txtIsono.Text))
{
iso = iso.Where(e => e.ISO_IsoNo.Contains(this.txtIsono.Text.Trim()));
}
iso = iso.OrderBy(x => x.ISO_IsoNo);
if (iso.Count() > 0)
{
foreach (var q in iso)
{
var jots = from x in Funs.DB.PW_JointInfo
where x.ISO_ID == q.ISO_ID && x.IS_Proess == "1"
select x;
var hotItem = from x in Funs.DB.HJGL_HotProess_TrustItem
join y in Funs.DB.PW_JointInfo on x.WeldJointId equals y.JOT_ID
where y.ISO_ID == q.ISO_ID
select x;
if (jots.Count() > hotItem.Count())
{
TreeNode newNode = new TreeNode();
newNode.NodeID = q.ISO_ID;
newNode.Text = q.ISO_IsoNo;
newNode.EnableClickEvent = true;
rootNode.Nodes.Add(newNode);
}
}
}
}
#endregion
#region 线
/// <summary>
/// 查询
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Tree_TextChanged(object sender, EventArgs e)
{
this.InitTreeMenu();
this.BindGrid();
}
#endregion
#region TreeView
/// <summary>
/// 点击TreeView
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void tvControlItem_NodeCommand(object sender, TreeCommandEventArgs e)
{
string[] selectRowId = Grid1.SelectedRowIDArray;
foreach (var id in selectRowId)
{
SelectedList.Add(id);
}
this.BindGrid();
}
#endregion
#region
/// <summary>
/// 数据绑定
/// </summary>
private void BindGrid()
{
//List<Model.View_HotProessTrustItemSearch> toDoMatterList = BLL.HotProess_TrustService.GetHotProessTrustFind(this.ProjectId, this.HotProessTrustId, this.tvControlItem.SelectedNodeID);
List<Model.View_HJGL_HotProessTrustItemSearch> toDoMatterList = (from x in Funs.DB.View_HJGL_HotProessTrustItemSearch
where x.ProjectId == this.CurrUser.LoginProjectId && x.HotProessTrustItemId == null
&& x.IS_Proess == "1"
orderby x.JOT_JointNo
select x).ToList();
if (rblIsWeld.SelectedValue == "0")
{
toDoMatterList = toDoMatterList.Where(x => x.DReportID == null).ToList();
}
if (rblIsWeld.SelectedValue == "1")
{
toDoMatterList = toDoMatterList.Where(x => x.DReportID != null).ToList();
}
if (this.tvControlItem.SelectedNodeID != null)
{
toDoMatterList = toDoMatterList.Where(x => x.ISO_ID == this.tvControlItem.SelectedNodeID).ToList();
}
if (!string.IsNullOrEmpty(this.txtJointNo.Text.Trim()))
{
toDoMatterList = toDoMatterList.Where(x => x.JOT_JointNo.Contains(this.txtJointNo.Text.Trim())).ToList();
}
//string weldJointIds = Request.Params["weldJointIds"];
//if (!string.IsNullOrEmpty(weldJointIds))
//{
// string[] jots = weldJointIds.Split('|');
// foreach (string jotId in jots)
// {
// Model.View_HotProessTrustItemSearch item = toDoMatterList.FirstOrDefault(e => e.WeldJointId == jotId);
// if (item != null)
// {
// toDoMatterList.Remove(item);
// }
// }
//}
//DataTable tb = this.LINQToDataTable(toDoMatterList);
//Grid1.RecordCount = tb.Rows.Count;
//tb = GetFilteredTable(Grid1.FilteredData, tb);
//var table = this.GetPagedDataTable(Grid1, tb);
Grid1.DataSource = toDoMatterList;
Grid1.DataBind();
}
#endregion
#region
/// <summary>
/// 排序
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Grid1_Sort(object sender, GridSortEventArgs e)
{
this.BindGrid();
}
#endregion
#region
/// <summary>
/// 筛选焊口信息
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void rblIsWeld_SelectedIndexChanged(object sender, EventArgs e)
{
this.BindGrid();
}
#endregion
#region
/// <summary>
/// 提交按钮
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnAccept_Click(object sender, EventArgs e)
{
string itemsString = "";
string[] selectRowId = Grid1.SelectedRowIDArray;
int n = 0;
int j = 0;
int[] selections = new int[selectRowId.Count()];
foreach (GridRow row in Grid1.Rows)
{
if (selectRowId.Contains(row.DataKeys[0]))
{
selections[n] = j;
n++;
}
j++;
}
var select = selections.Distinct();
string jotIds = Request.Params["weldJointIds"];
if (!string.IsNullOrEmpty(jotIds))
{
string[] jots = jotIds.Split('|');
foreach (string jotId in jots)
{
itemsString += jotId + "|";
}
}
foreach (int i in select)
{
string rowID = Grid1.DataKeys[i][0].ToString();
if (!itemsString.Contains(rowID))
{
itemsString += rowID + "|";
}
}
foreach (var item in SelectedList)
{
itemsString += item + "|";
}
PageContext.RegisterStartupScript(ActiveWindow.GetWriteBackValueReference(itemsString)
+ ActiveWindow.GetHidePostBackReference());
}
#endregion
}
}