217 lines
		
	
	
		
			7.3 KiB
		
	
	
	
		
			C#
		
	
	
	
			
		
		
	
	
			217 lines
		
	
	
		
			7.3 KiB
		
	
	
	
		
			C#
		
	
	
	
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)
 | 
						|
        {
 | 
						|
            this.UnitId = Request.Params["unitId"] ?? "";
 | 
						|
            this.ProjectId = this.CurrUser.LoginProjectId;
 | 
						|
            this.PMIId = Request.Params["PMIId"] ?? "";
 | 
						|
            this.weldJointIds = Request.Params["weldJointIds"] ?? "";
 | 
						|
            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()
 | 
						|
        {
 | 
						|
            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();
 | 
						|
 | 
						|
            string[] arr = this.weldJointIds.Split('|');
 | 
						|
            var query = Funs.DB.View_Pipeline_WeldJoint.Where(t => t.IsPMI == true);
 | 
						|
            if (arr.Length > 0)
 | 
						|
            {
 | 
						|
                listData.Add(arr[0]);
 | 
						|
            }
 | 
						|
            if (listData.Count > 0)
 | 
						|
            {
 | 
						|
                query = query.Where(t => !listData.Contains(t.WeldJointId));
 | 
						|
            }
 | 
						|
            if (!string.IsNullOrEmpty(this.txtJointNo.Text))
 | 
						|
            {
 | 
						|
                query = query.Where(t => t.WeldJointCode == this.txtJointNo.Text);
 | 
						|
            }
 | 
						|
            if (!string.IsNullOrEmpty(this.tvControlItem.SelectedNodeID))
 | 
						|
            {
 | 
						|
                query = query.Where(t => t.PipelineId == this.tvControlItem.SelectedNodeID);
 | 
						|
            }
 | 
						|
            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;
 | 
						|
            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
 | 
						|
    }
 | 
						|
} |