Basf_TCC7/HJGL/FineUIPro.Web/WeldingProcess/PMI/PMISelectList.aspx.cs

217 lines
7.3 KiB
C#
Raw Normal View History

2024-05-12 12:05:01 +08:00
using BLL;
using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace FineUIPro.Web.WeldingProcess.PMI
{
public partial class PMISelectList : PageBase
{
string UnitId = string.Empty;
string ProjectId = string.Empty;
string PMIId = string.Empty;
string weldJointIds=string.Empty;
#region
/// <summary>
/// 加载页面
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Page_Load(object sender, EventArgs e)
{
2024-05-12 22:53:47 +08:00
this.UnitId = Request.Params["unitId"] ?? "";
this.ProjectId = this.CurrUser.LoginProjectId;
this.PMIId = Request.Params["PMIId"] ?? "";
this.weldJointIds = Request.Params["weldJointIds"] ?? "";
2024-05-12 12:05:01 +08:00
if (!IsPostBack)
{
this.InitTreeMenu();//加载树
this.BindGrid();
}
}
#endregion
#region 线
/// <summary>
/// 加载树
/// </summary>
private void InitTreeMenu()
{
this.tvControlItem.Nodes.Clear();
TreeNode rootNode = new TreeNode();
rootNode.Text = Resources.Lan.PipelineCode;
rootNode.NodeID = "0";
rootNode.ToolTip = Resources.Lan.SeachTip;
rootNode.Expanded = true;
this.tvControlItem.Nodes.Add(rootNode);
//排除已经委托过的
var listData= (from a in Funs.DB.PMI_Delegation.AsQueryable() join
b in Funs.DB.PMI_DelegationDetails.AsQueryable() on
a.Id equals b.PMIId
select b.JointId
).Distinct().ToList();
//查询带有PMI处理的管线数据
var iso = from x in Funs.DB.View_Pipeline_WeldJoint
where x.ProjectId == this.ProjectId && x.IsPMI == true && x.UnitId == this.UnitId
select new { x.PipelineCode, x.PipelineId,x.WeldJointId }; //from x in Funs.DB.Pipeline_Pipeline where x.ProjectId == this.ProjectId && x.UnitId == this.UnitId select x;
if (listData.Count > 0)
{
iso = iso.Where(e => !listData.Contains(e.WeldJointId));
}
if (!string.IsNullOrEmpty(this.txtIsono.Text))
{
iso = iso.Where(e => e.PipelineCode.Contains(this.txtIsono.Text.Trim()));
}
var isoList = iso.Select(x => new {x.PipelineId,x.PipelineCode }).OrderBy(x => x.PipelineCode).Distinct().ToList();
if (isoList.Count > 0)
{
foreach (var q in isoList)
{
TreeNode newNode = new TreeNode();
newNode.NodeID = q.PipelineId;
newNode.Text = q.PipelineCode;
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();
}
protected void Tree2_TextChanged(object sender, EventArgs e)
{
this.BindGrid();
}
#endregion
#region TreeView
/// <summary>
/// 点击TreeView
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void tvControlItem_NodeCommand(object sender, TreeCommandEventArgs e)
{
this.BindGrid();
}
#endregion
#region
/// <summary>
/// 数据绑定
/// </summary>
private void BindGrid()
{
2024-05-12 15:28:06 +08:00
var listData = (from a in Funs.DB.PMI_Delegation.AsQueryable()
join
b in Funs.DB.PMI_DelegationDetails.AsQueryable() on
a.Id equals b.PMIId
select b.JointId
).Distinct().ToList();
2024-05-12 12:05:01 +08:00
2024-05-12 22:53:47 +08:00
string[] arr = this.weldJointIds.Split('|');
2024-05-12 15:28:06 +08:00
var query = Funs.DB.View_Pipeline_WeldJoint.Where(t => t.IsPMI == true);
2024-05-12 22:53:47 +08:00
if (arr.Length > 0)
{
listData.Add(arr[0]);
}
2024-05-12 15:28:06 +08:00
if (listData.Count > 0)
{
query = query.Where(t => !listData.Contains(t.WeldJointId));
}
2024-05-12 12:05:01 +08:00
if (!string.IsNullOrEmpty(this.txtJointNo.Text))
{
2024-05-12 15:28:06 +08:00
query = query.Where(t => t.WeldJointCode == this.txtJointNo.Text);
2024-05-12 12:05:01 +08:00
}
if (!string.IsNullOrEmpty(this.tvControlItem.SelectedNodeID))
{
2024-05-12 15:28:06 +08:00
query = query.Where(t => t.PipelineId == this.tvControlItem.SelectedNodeID);
2024-05-12 12:05:01 +08:00
}
2024-05-12 22:53:47 +08:00
var data= query.ToList() ;
if (!string.IsNullOrEmpty(weldJointIds))
{
string[] jots = weldJointIds.Split('|');
data = data.Where(t => !jots.Contains(t.WeldJointId)).ToList();
}
data = data.OrderBy(t => t.WeldJointCode).ToList();
Grid1.DataSource = data;
2024-05-12 12:05:01 +08:00
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 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["jotIds"];
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 + "|";
}
}
PageContext.RegisterStartupScript(ActiveWindow.GetWriteBackValueReference(itemsString)
+ ActiveWindow.GetHidePostBackReference());
}
#endregion
}
}