ChengDa_English/SGGL/FineUIPro.Web/HJGL/RepairManage/ShowRepairSearch.aspx.cs

390 lines
13 KiB
C#

using BLL;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Web.UI.WebControls;
namespace FineUIPro.Web.HJGL.RepairManage
{
public partial class ShowRepairSearch : PageBase
{
#region
/// <summary>
/// 单位ID
/// </summary>
public string UnitId
{
get
{
return (string)ViewState["UnitId"];
}
set
{
ViewState["UnitId"] = value;
}
}
/// <summary>
/// 装置id
/// </summary>
public string InstallationId
{
get
{
return (string)ViewState["InstallationId"];
}
set
{
ViewState["InstallationId"] = value;
}
}
/// <summary>
/// 委托id
/// </summary>
public string CH_TrustID
{
get
{
return (string)ViewState["CH_TrustID"];
}
set
{
ViewState["CH_TrustID"] = value;
}
}
/// <summary>
/// 选择列表
/// </summary>
public List<string> jotList
{
get
{
return (List<string>)ViewState["jotList"];
}
set
{
ViewState["jotList"] = value;
}
}
/// <summary>
/// 选择列表
/// </summary>
public List<string> CheckList
{
get
{
return (List<string>)ViewState["CheckList"];
}
set
{
ViewState["CheckList"] = value;
}
}
private static List<Model.View_CH_RepairSearch> repairSearchViewLists = new List<Model.View_CH_RepairSearch>();
#endregion
#region
/// <summary>
/// 加载页面
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
this.UnitId = Request.Params["unitId"];
this.InstallationId = Request.Params["installationId"];
this.CH_TrustID = Request.Params["ch_TrustID"];
BLL.WorkAreaService.InitWorkAreaProjectInstallUnitDropDownList(this.drpWorkArea, this.CurrUser.LoginProjectId, this.InstallationId, this.UnitId, true);
}
}
#endregion
#region
/// <summary>
/// 查询
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnSearch_Click(object sender, EventArgs e)
{
string workAreaId = string.Empty;
if (this.drpWorkArea.SelectedValue != BLL.Const._Null && !string.IsNullOrEmpty(this.drpWorkArea.SelectedValue))
{
workAreaId = this.drpWorkArea.SelectedValue;
}
this.InitTreeMenu(workAreaId);//加载树
}
#endregion
#region
/// <summary>
/// 加载树
/// </summary>
/// <param name="selectedValue"></param>
private void InitTreeMenu(string workAreaId)
{
if (!string.IsNullOrEmpty(workAreaId))
{
this.tvControlItem.Nodes.Clear();
TreeNode rootNode = new TreeNode();
rootNode.Text = BLL.WorkAreaService.GetWorkAreaCodeByWorkAreaId(workAreaId);
rootNode.NodeID = workAreaId;
rootNode.Expanded = true;
this.tvControlItem.Nodes.Add(rootNode);
GetNodes(workAreaId, rootNode);
}
else
{
var workAreas = (from x in Funs.DB.ProjectData_WorkArea
where x.ProjectId == this.CurrUser.LoginProjectId && x.UnitId == UnitId && x.InstallationId == InstallationId
select x).ToList();
foreach (var q in workAreas)
{
var trustSearch = from x in Funs.DB.View_CH_RepairSearch
where x.ProjectId == this.CurrUser.LoginProjectId && x.UnitId == UnitId && x.WorkAreaId == q.WorkAreaId
select x;
if (trustSearch.Count() > 0)
{
TreeNode rootNode = new TreeNode();
rootNode.Text = q.WorkAreaCode;
rootNode.NodeID = q.WorkAreaId;
rootNode.Expanded = true;
this.tvControlItem.Nodes.Add(rootNode);
GetNodes(q.WorkAreaId, rootNode);
}
}
}
}
/// <summary>
/// 遍历节点
/// </summary>
/// <param name="workAreaId"></param>
/// <param name="rootNode"></param>
private void GetNodes(string workAreaId, TreeNode rootNode)
{
var trustSearch = from x in Funs.DB.View_CH_RepairSearch
where x.ProjectId == this.CurrUser.LoginProjectId && x.UnitId == UnitId
&& x.WorkAreaId == workAreaId && (x.RepairTrustId == null || x.RepairTrustId == this.CH_TrustID)
select x;
if (!string.IsNullOrEmpty(this.txtISO_ID.Text.Trim()))
{
trustSearch = trustSearch.Where(x => x.ISO_IsoNo.Contains(this.txtISO_ID.Text.Trim()));
}
var checkID = (from x in trustSearch select x.CHT_CheckID).Distinct();
if (checkID.Count() > 0)
{
foreach (var id in checkID)
{
var point = from x in Funs.DB.CH_Check
where x.CHT_CheckID == id.ToString()
select x;
foreach (var item in point)
{
TreeNode newNode = new TreeNode();
newNode.Text = item.CHT_CheckCode;
newNode.NodeID = item.CHT_CheckID;
newNode.Expanded = true;
//newNode.EnableClickEvent = true;
//newNode.EnableCheckBox = true;
newNode.EnableCheckEvent = true;
rootNode.Nodes.Add(newNode);
}
}
}
}
#endregion
#region Tree选中事件
/// <summary>
/// Tree选中事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void tvControlItem_NodeCheck(object sender, TreeCheckEventArgs e)
{
CheckList = new List<string>();
TreeNode[] nodes = tvControlItem.GetCheckedNodes();
if (nodes.Length > 0)
{
StringBuilder sb = new StringBuilder();
foreach (TreeNode node in nodes)
{
CheckList.Add(node.NodeID);
}
}
BindGrid(CheckList);
BindGrid2();
}
#endregion
#region
private void BindGrid(List<string> checkList)
{
repairSearchViewLists = (from x in Funs.DB.View_CH_RepairSearch where x.ProjectId == this.CurrUser.LoginProjectId select x).ToList();
if (!string.IsNullOrEmpty(this.CH_TrustID))
{
repairSearchViewLists = repairSearchViewLists.Where(e => e.RepairTrustId == this.CH_TrustID || e.RepairTrustId is null).ToList();
}
else
{
repairSearchViewLists = repairSearchViewLists.Where(e => e.RepairTrustId is null).ToList();
}
if (checkList != null)
{
repairSearchViewLists = repairSearchViewLists.Where(e => checkList.Contains(e.CHT_CheckID)).ToList();
}
this.Grid1.DataSource = repairSearchViewLists;
this.Grid1.DataBind();
this.GetCheckgvList();
}
/// <summary>
/// 选择列表某项事件
/// </summary>
private void GetCheckgvList()
{
jotList = new List<string>();
foreach (var item in repairSearchViewLists)
{
jotList.Add(item.JOT_ID);
}
}
/// <summary>
/// 数据绑定2
/// </summary>
private void BindGrid2()
{
List<Model.PW_JointInfo> SpRepairSearchItems = new List<Model.PW_JointInfo>();
if (jotList != null)
{
var IsoInfo = from x in Funs.DB.PW_IsoInfo where x.ProjectId == this.CurrUser.LoginProjectId && x.WorkAreaId == this.drpWorkArea.SelectedValue && x.UnitId == this.UnitId select x;
if (this.ckISO.Checked)
{
var isoList = (from x in Funs.DB.PW_JointInfo where jotList.Contains(x.JOT_ID) select x.ISO_ID).Distinct().ToList();
IsoInfo = IsoInfo.Where(x => isoList.Contains(x.ISO_ID));
}
if (IsoInfo.Count() > 0)
{
foreach (var isoItem in IsoInfo)
{
var jots = from x in Funs.DB.PW_JointInfo where x.ISO_ID == isoItem.ISO_ID && x.JOT_JointStatus == "100" && x.DReportID != null select x;
if (this.ckWeld.Checked)
{
var weldList = (from x in Funs.DB.PW_JointInfo where jotList.Contains(x.JOT_ID) select x.JOT_CellWelder).Distinct().ToList();
jots = jots.Where(x => weldList.Contains(x.JOT_CellWelder)).Distinct();
}
if (jots.Count() > 0)
{
foreach (var jotItem in jots)
{
if (!jotList.Contains(jotItem.JOT_ID))
{
Model.PW_JointInfo SpRepairSearchItem = new Model.PW_JointInfo();
SpRepairSearchItem.JOT_ID = jotItem.JOT_ID;
SpRepairSearchItem.JOT_JointNo = jotItem.JOT_JointNo;
SpRepairSearchItem.ISO_ID = jotItem.ISO_ID;
SpRepairSearchItem.JOT_CellWelder = jotItem.JOT_CellWelder;
SpRepairSearchItems.Add(SpRepairSearchItem);
}
}
}
}
}
}
this.Grid2.DataSource = SpRepairSearchItems;
this.Grid2.DataBind();
}
#endregion
#region 线
/// <summary>
/// 是否默认同管线
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void ckISO_CheckedChanged(object sender, CheckedEventArgs e)
{
GetCheckgvList();
}
/// <summary>
/// 是否同焊工
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void ckWeld_CheckedChanged(object sender, CheckedEventArgs e)
{
GetCheckgvList();
}
#endregion
#region
/// <summary>
/// 确定按钮
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnSure_Click(object sender, EventArgs e)
{
string selectedList = string.Empty;
foreach (var item in repairSearchViewLists)
{
selectedList += item.JOT_ID + ",";
}
if (repairSearchViewLists.Count > 0)
{
foreach (var jotId in Grid2.SelectedRowIDArray)
{
selectedList += jotId + ",";
}
if (!string.IsNullOrEmpty(selectedList))
{
selectedList = selectedList.Substring(0, selectedList.LastIndexOf(","));
}
else
{
Alert.ShowInTop("请选择焊口再保存!", MessageBoxIcon.Warning);
return;
}
}
PageContext.RegisterStartupScript(ActiveWindow.GetWriteBackValueReference(selectedList)
+ ActiveWindow.GetHidePostBackReference());
}
#endregion
#region
/// <summary>
/// 根据管线Id获取管线号
/// </summary>
/// <param name="ISO_ID"></param>
/// <returns></returns>
protected string ConvertIsoNo(object ISO_ID)
{
if (ISO_ID != null)
{
return BLL.PW_IsoInfoService.GetIsoInfoByIsoInfoId(ISO_ID.ToString()).ISO_IsoNo;
}
else
{
return "";
}
}
#endregion
}
}