778 lines
		
	
	
		
			36 KiB
		
	
	
	
		
			C#
		
	
	
	
			
		
		
	
	
			778 lines
		
	
	
		
			36 KiB
		
	
	
	
		
			C#
		
	
	
	
using System;
 | 
						||
using System.Collections.Generic;
 | 
						||
using System.Data;
 | 
						||
using System.Data.SqlClient;
 | 
						||
using System.Linq;
 | 
						||
using BLL;
 | 
						||
using Newtonsoft.Json.Linq;
 | 
						||
 | 
						||
namespace FineUIPro.Web.HJGL.TrustManage
 | 
						||
{
 | 
						||
    public partial class TrustManageEditAdd : PageBase
 | 
						||
    {
 | 
						||
        #region 定义项
 | 
						||
        /// <summary>
 | 
						||
        /// 无损委托主键
 | 
						||
        /// </summary>
 | 
						||
        public string CH_TrustID
 | 
						||
        {
 | 
						||
            get
 | 
						||
            {
 | 
						||
                return (string)ViewState["CH_TrustID"];
 | 
						||
            }
 | 
						||
            set
 | 
						||
            {
 | 
						||
                ViewState["CH_TrustID"] = value;
 | 
						||
            }
 | 
						||
        }
 | 
						||
 | 
						||
        #endregion
 | 
						||
 | 
						||
        #region 加载页面
 | 
						||
        /// <summary>
 | 
						||
        /// 加载页面
 | 
						||
        /// </summary>
 | 
						||
        /// <param name="sender"></param>
 | 
						||
        /// <param name="e"></param>
 | 
						||
        protected void Page_Load(object sender, EventArgs e)
 | 
						||
        {
 | 
						||
            if (!IsPostBack)
 | 
						||
            {
 | 
						||
                this.CH_TrustID = Request.Params["CH_TrustID"];
 | 
						||
                List<Model.View_CH_TrustItem> GetTrustItem = BLL.TrustManageEditService.GetView_CH_TrustItemByCH_TrustID(this.CH_TrustID);
 | 
						||
                this.BindGrid(GetTrustItem);  // 初始化页面 
 | 
						||
                this.PageInfoLoad(); // 加载页面 
 | 
						||
            }
 | 
						||
        }
 | 
						||
        #endregion
 | 
						||
 | 
						||
        #region 加载页面输入提交信息
 | 
						||
        /// <summary>
 | 
						||
        /// 加载页面输入提交信息
 | 
						||
        /// </summary>
 | 
						||
        private void PageInfoLoad()
 | 
						||
        {
 | 
						||
            this.drpCH_TrustUnit.Items.Clear();
 | 
						||
            var pUnit = BLL.UnitService.GetUnitByProjectIdUnitTypeList(this.CurrUser.LoginProjectId, BLL.Const.ProjectUnitType_2);
 | 
						||
            if (pUnit != null)
 | 
						||
            {
 | 
						||
                this.drpCH_TrustUnit.DataTextField = "UnitName";
 | 
						||
                this.drpCH_TrustUnit.DataValueField = "UnitId";
 | 
						||
                this.drpCH_TrustUnit.DataSource = pUnit;
 | 
						||
                this.drpCH_TrustUnit.DataBind();
 | 
						||
                this.drpCH_TrustUnit.SelectedValue = CurrUser.UnitId;
 | 
						||
 | 
						||
                if (CurrUser.UnitId != Const.UnitId_CD && CurrUser.UserId != Const.hfnbdId)
 | 
						||
                {
 | 
						||
                    this.drpCH_TrustUnit.Enabled = false;
 | 
						||
                }
 | 
						||
            }
 | 
						||
            this.drpCH_CheckUnit.Items.Clear();
 | 
						||
            var cUnit = BLL.UnitService.GetUnitByProjectIdUnitTypeList(this.CurrUser.LoginProjectId, BLL.Const.ProjectUnitType_5);
 | 
						||
            if (cUnit != null)
 | 
						||
            {
 | 
						||
                this.drpCH_CheckUnit.DataTextField = "UnitName";
 | 
						||
                this.drpCH_CheckUnit.DataValueField = "UnitId";
 | 
						||
                this.drpCH_CheckUnit.DataSource = cUnit;
 | 
						||
                this.drpCH_CheckUnit.DataBind();
 | 
						||
            }
 | 
						||
            BLL.Project_InstallationService.InitInstallationsDropDownList(this.drpInstallation, this.CurrUser.LoginProjectId, true);
 | 
						||
            BLL.Base_DetectionRateService.InitDetectionRateDropDownList(this.drpCH_NDTRate, true);//探伤比例
 | 
						||
            BLL.Base_DetectionTypeService.InitDetectionTypeDropDownList(this.drpCH_NDTMethod, true);//探伤类型                                                                                      ///委托人
 | 
						||
            this.drpCH_TrustMan.DataTextField = "UserName";
 | 
						||
            this.drpCH_TrustMan.DataValueField = "UserId";
 | 
						||
            this.drpCH_TrustMan.DataSource = BLL.UserService.GetProjectUserListByProjectId(this.CurrUser.LoginProjectId);
 | 
						||
            this.drpCH_TrustMan.DataBind();
 | 
						||
            Funs.FineUIPleaseSelect(this.drpCH_TrustMan);
 | 
						||
            this.drpCH_AcceptGrade.DataTextField = "Text";
 | 
						||
            this.drpCH_AcceptGrade.DataValueField = "Value";
 | 
						||
            this.drpCH_AcceptGrade.DataSource = BLL.TrustManageEditService.GetAcceptGradeList();
 | 
						||
            this.drpCH_AcceptGrade.DataBind();
 | 
						||
            Funs.FineUIPleaseSelect(this.drpCH_AcceptGrade);
 | 
						||
            this.drpCH_Tabler.DataTextField = "UserName";
 | 
						||
            this.drpCH_Tabler.DataValueField = "UserId";
 | 
						||
            this.drpCH_Tabler.DataSource = BLL.UserService.GetProjectUserListByProjectId(this.CurrUser.LoginProjectId);
 | 
						||
            this.drpCH_Tabler.DataBind();
 | 
						||
            Funs.FineUIPleaseSelect(this.drpCH_Tabler);
 | 
						||
            this.drpCH_SlopeType.DataTextField = "UserName";
 | 
						||
            this.drpCH_SlopeType.DataValueField = "UserId";
 | 
						||
            this.drpCH_SlopeType.DataSource = BLL.UserService.GetProjectUserListByProjectId(this.CurrUser.LoginProjectId);
 | 
						||
            this.drpCH_SlopeType.DataBind();
 | 
						||
            Funs.FineUIPleaseSelect(this.drpCH_SlopeType);
 | 
						||
            BLL.Base_GrooveTypeService.InitGrooveTypeDropDownList(this.drpCH_SlopeType, true); //坡口类型
 | 
						||
            BLL.Base_WeldingMethodService.InitWeldingMethodDropDownList(this.drpCH_WeldMethod, true);//焊接方法
 | 
						||
            if (this.CurrUser.UserId != Const.sysglyId && this.CurrUser.UserId != BLL.Const.hfnbdId)
 | 
						||
            {
 | 
						||
                this.drpCH_TrustMan.SelectedValue = this.CurrUser.UserId;
 | 
						||
                this.drpCH_Tabler.SelectedValue = this.CurrUser.UserId;
 | 
						||
            }
 | 
						||
            var trust = BLL.TrustManageEditService.GetCH_TrustByID(this.CH_TrustID);
 | 
						||
            if (trust != null)
 | 
						||
            {
 | 
						||
                this.txtCH_TrustCode.Text = trust.CH_TrustCode;
 | 
						||
                if (!string.IsNullOrEmpty(trust.CH_TrustUnit))
 | 
						||
                {
 | 
						||
                    this.drpCH_TrustUnit.SelectedValue = trust.CH_TrustUnit;
 | 
						||
                }
 | 
						||
                if (!string.IsNullOrEmpty(trust.InstallationId))
 | 
						||
                {
 | 
						||
                    this.drpInstallation.SelectedValue = trust.InstallationId;
 | 
						||
                }
 | 
						||
                if (trust.CH_TrustDate != null)
 | 
						||
                {
 | 
						||
                    this.txtCH_TrustDate.Text = string.Format("{0:yyyy-MM-dd}", trust.CH_TrustDate);
 | 
						||
                }
 | 
						||
                this.txtCH_Press.Text = trust.CH_Press;
 | 
						||
                if (!string.IsNullOrEmpty(trust.CH_NDTRate))
 | 
						||
                {
 | 
						||
                    this.drpCH_NDTRate.SelectedValue = trust.CH_NDTRate;
 | 
						||
                }
 | 
						||
                this.txtCH_WorkNo.Text = trust.CH_WorkNo;
 | 
						||
                if (!string.IsNullOrEmpty(trust.CH_NDTMethod))
 | 
						||
                {
 | 
						||
                    this.drpCH_NDTMethod.SelectedValue = trust.CH_NDTMethod;
 | 
						||
                }
 | 
						||
                if (!string.IsNullOrEmpty(trust.CH_TrustMan))
 | 
						||
                {
 | 
						||
                    this.drpCH_TrustMan.SelectedValue = trust.CH_TrustMan;
 | 
						||
                }
 | 
						||
                this.txtCH_ItemName.Text = trust.CH_ItemName;
 | 
						||
                if (!string.IsNullOrEmpty(trust.CH_AcceptGrade))
 | 
						||
                {
 | 
						||
                    this.drpCH_AcceptGrade.SelectedValue = trust.CH_AcceptGrade;
 | 
						||
                }
 | 
						||
                if (!string.IsNullOrEmpty(trust.CH_Tabler))
 | 
						||
                {
 | 
						||
                    this.drpCH_Tabler.SelectedValue = trust.CH_Tabler;
 | 
						||
                }
 | 
						||
                if (!string.IsNullOrEmpty(trust.CH_SlopeType))
 | 
						||
                {
 | 
						||
                    this.drpCH_SlopeType.SelectedValue = trust.CH_SlopeType;
 | 
						||
                }
 | 
						||
                this.txtCH_NDTCriteria.Text = trust.CH_NDTCriteria;
 | 
						||
                if (!string.IsNullOrEmpty(trust.CH_WeldMethod))
 | 
						||
                {
 | 
						||
                    this.drpCH_WeldMethod.SelectedValue = trust.CH_WeldMethod;
 | 
						||
                }
 | 
						||
                this.txtCH_ServiceTemp.Text = trust.CH_ServiceTemp;
 | 
						||
                if (!string.IsNullOrEmpty(trust.CH_CheckUnit))
 | 
						||
                {
 | 
						||
                    this.drpCH_CheckUnit.SelectedValue = trust.CH_CheckUnit;
 | 
						||
                }
 | 
						||
                if (trust.CH_RequestDate != null)
 | 
						||
                {
 | 
						||
                    this.txtCH_RequestDate.Text = string.Format("{0:yyyy-MM-dd}", trust.CH_RequestDate);
 | 
						||
                }
 | 
						||
                this.txtCH_Remark.Text = trust.CH_Remark;
 | 
						||
            }
 | 
						||
            else
 | 
						||
            {
 | 
						||
                this.SimpleForm1.Reset(); ///重置所有字段
 | 
						||
 | 
						||
 | 
						||
                this.txtCH_TrustDate.Text = string.Format("{0:yyyy-MM-dd}", System.DateTime.Now);
 | 
						||
                this.txtCH_RequestDate.Text = string.Format("{0:yyyy-MM-dd}", System.DateTime.Now);
 | 
						||
            }
 | 
						||
        }
 | 
						||
        #endregion
 | 
						||
 | 
						||
        #region 数据绑定
 | 
						||
        /// <summary>
 | 
						||
        /// 数据绑定
 | 
						||
        /// </summary>
 | 
						||
        private void BindGrid(List<Model.View_CH_TrustItem> GetTrustItem)
 | 
						||
        {
 | 
						||
            DataTable tb = this.LINQToDataTable(GetTrustItem);
 | 
						||
            // 2.获取当前分页数据
 | 
						||
            //var table = this.GetPagedDataTable(GridNewDynamic, tb1);
 | 
						||
            Grid1.RecordCount = tb.Rows.Count;
 | 
						||
            tb = GetFilteredTable(Grid1.FilteredData, tb);
 | 
						||
            var table = this.GetPagedDataTable(Grid1, tb);
 | 
						||
 | 
						||
            Grid1.DataSource = table;
 | 
						||
            Grid1.DataBind();
 | 
						||
        }
 | 
						||
        #endregion
 | 
						||
 | 
						||
        #region 排序
 | 
						||
        /// <summary>
 | 
						||
        /// 排序
 | 
						||
        /// </summary>
 | 
						||
        /// <param name="sender"></param>
 | 
						||
        /// <param name="e"></param>
 | 
						||
        protected void Grid1_Sort(object sender, GridSortEventArgs e)
 | 
						||
        {
 | 
						||
            List<Model.View_CH_TrustItem> GetTrustItem = this.CollectGridJointInfo();
 | 
						||
            this.BindGrid(GetTrustItem);
 | 
						||
        }
 | 
						||
        #endregion
 | 
						||
 | 
						||
        #region 无损委托 提交事件
 | 
						||
        /// <summary>
 | 
						||
        /// 编辑无损委托
 | 
						||
        /// </summary>
 | 
						||
        /// <param name="sender"></param>
 | 
						||
        /// <param name="e"></param>
 | 
						||
        protected void btnSave_Click(object sender, EventArgs e)
 | 
						||
        {
 | 
						||
            if (CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.HJGL_WeldReportMenuId, Const.BtnSave))
 | 
						||
            {
 | 
						||
                if (string.IsNullOrEmpty(this.txtCH_TrustCode.Text))
 | 
						||
                {
 | 
						||
                    Alert.ShowInTop("请输入委托单号!", MessageBoxIcon.Warning);
 | 
						||
                    return;
 | 
						||
                }
 | 
						||
                if (this.drpCH_TrustUnit.SelectedValue == BLL.Const._Null || string.IsNullOrEmpty(this.drpCH_TrustUnit.SelectedValue))
 | 
						||
                {
 | 
						||
                    Alert.ShowInTop("请选择委托单位!", MessageBoxIcon.Warning);
 | 
						||
                    return;
 | 
						||
                }
 | 
						||
 | 
						||
                if (this.drpInstallation.SelectedValue == BLL.Const._Null || string.IsNullOrEmpty(this.drpInstallation.SelectedValue))
 | 
						||
                {
 | 
						||
                    Alert.ShowInTop("请选择装置名称!", MessageBoxIcon.Warning);
 | 
						||
                    return;
 | 
						||
                }
 | 
						||
                if (string.IsNullOrEmpty(this.txtCH_TrustDate.Text))
 | 
						||
                {
 | 
						||
                    Alert.ShowInTop("请选择委托日期!", MessageBoxIcon.Warning);
 | 
						||
                    return;
 | 
						||
                }
 | 
						||
                //if (string.IsNullOrEmpty(this.txtCH_Press.Text))
 | 
						||
                //{
 | 
						||
                //    Alert.ShowInTop("请输入压力!", MessageBoxIcon.Warning);
 | 
						||
                //    return;
 | 
						||
                //}
 | 
						||
                if (this.drpCH_NDTRate.SelectedValue == BLL.Const._Null || string.IsNullOrEmpty(this.drpCH_NDTRate.SelectedValue))
 | 
						||
                {
 | 
						||
                    Alert.ShowInTop("请选择探伤比例!", MessageBoxIcon.Warning);
 | 
						||
                    return;
 | 
						||
                }
 | 
						||
                if (this.drpCH_NDTMethod.SelectedValue == BLL.Const._Null || string.IsNullOrEmpty(this.drpCH_NDTMethod.SelectedValue))
 | 
						||
                {
 | 
						||
                    Alert.ShowInTop("请选择检测方法!", MessageBoxIcon.Warning);
 | 
						||
                    return;
 | 
						||
                }
 | 
						||
                if (this.drpCH_SlopeType.SelectedValue == BLL.Const._Null || string.IsNullOrEmpty(this.drpCH_SlopeType.SelectedValue))
 | 
						||
                {
 | 
						||
                    Alert.ShowInTop("请选择坡口类型!", MessageBoxIcon.Warning);
 | 
						||
                    return;
 | 
						||
                }
 | 
						||
                if (this.drpCH_AcceptGrade.SelectedValue == BLL.Const._Null || string.IsNullOrEmpty(this.drpCH_AcceptGrade.SelectedValue))
 | 
						||
                {
 | 
						||
                    Alert.ShowInTop("请选择合格等级!", MessageBoxIcon.Warning);
 | 
						||
                    return;
 | 
						||
                }
 | 
						||
                if (this.drpCH_WeldMethod.SelectedValue == BLL.Const._Null || string.IsNullOrEmpty(this.drpCH_WeldMethod.SelectedValue))
 | 
						||
                {
 | 
						||
                    Alert.ShowInTop("请选择焊接方法!", MessageBoxIcon.Warning);
 | 
						||
                    return;
 | 
						||
                }
 | 
						||
 | 
						||
                Model.CH_Trust newTrust = new Model.CH_Trust();
 | 
						||
                newTrust.ProjectId = this.CurrUser.LoginProjectId;
 | 
						||
                newTrust.CH_TrustCode = this.txtCH_TrustCode.Text.Trim();
 | 
						||
                if (this.drpCH_TrustUnit.SelectedValue != BLL.Const._Null)
 | 
						||
                {
 | 
						||
                    newTrust.CH_TrustUnit = this.drpCH_TrustUnit.SelectedValue;
 | 
						||
                }
 | 
						||
                if (this.drpInstallation.SelectedValue != BLL.Const._Null)
 | 
						||
                {
 | 
						||
                    newTrust.InstallationId = this.drpInstallation.SelectedValue;
 | 
						||
                }
 | 
						||
                newTrust.CH_TrustDate = Funs.GetNewDateTime(this.txtCH_TrustDate.Text);
 | 
						||
                newTrust.CH_Press = this.txtCH_Press.Text.Trim();
 | 
						||
                if (this.drpCH_NDTRate.SelectedValue != BLL.Const._Null)
 | 
						||
                {
 | 
						||
                    newTrust.CH_NDTRate = this.drpCH_NDTRate.SelectedValue;
 | 
						||
                }
 | 
						||
                newTrust.CH_TrustType = "1";
 | 
						||
                newTrust.CH_WorkNo = this.txtCH_WorkNo.Text.Trim();
 | 
						||
                if (this.drpCH_NDTMethod.SelectedValue != BLL.Const._Null)
 | 
						||
                {
 | 
						||
                    newTrust.CH_NDTMethod = this.drpCH_NDTMethod.SelectedValue;
 | 
						||
                }
 | 
						||
                if (this.drpCH_TrustMan.SelectedValue != BLL.Const._Null)
 | 
						||
                {
 | 
						||
                    newTrust.CH_TrustMan = this.drpCH_TrustMan.SelectedValue;
 | 
						||
                }
 | 
						||
                newTrust.CH_ItemName = this.txtCH_ItemName.Text.Trim();
 | 
						||
                if (this.drpCH_AcceptGrade.SelectedValue != BLL.Const._Null)
 | 
						||
                {
 | 
						||
                    newTrust.CH_AcceptGrade = this.drpCH_AcceptGrade.SelectedValue;
 | 
						||
                }
 | 
						||
                if (this.drpCH_Tabler.SelectedValue != BLL.Const._Null)
 | 
						||
                {
 | 
						||
                    newTrust.CH_Tabler = this.drpCH_Tabler.SelectedValue;
 | 
						||
                }
 | 
						||
                if (this.drpCH_SlopeType.SelectedValue != BLL.Const._Null)
 | 
						||
                {
 | 
						||
                    newTrust.CH_SlopeType = this.drpCH_SlopeType.SelectedValue;
 | 
						||
                }
 | 
						||
                newTrust.CH_NDTCriteria = this.txtCH_NDTCriteria.Text.Trim();
 | 
						||
                if (this.drpCH_WeldMethod.SelectedValue != BLL.Const._Null)
 | 
						||
                {
 | 
						||
                    newTrust.CH_WeldMethod = this.drpCH_WeldMethod.SelectedValue;
 | 
						||
                }
 | 
						||
                newTrust.CH_ServiceTemp = this.txtCH_ServiceTemp.Text.Trim();
 | 
						||
                if (this.drpCH_CheckUnit.SelectedValue != BLL.Const._Null)
 | 
						||
                {
 | 
						||
                    newTrust.CH_CheckUnit = this.drpCH_CheckUnit.SelectedValue;
 | 
						||
                }
 | 
						||
                newTrust.CH_RequestDate = Funs.GetNewDateTime(this.txtCH_RequestDate.Text);
 | 
						||
                newTrust.CH_Remark = this.txtCH_Remark.Text.Trim();
 | 
						||
 | 
						||
                if (!string.IsNullOrEmpty(this.CH_TrustID))
 | 
						||
                {
 | 
						||
                    newTrust.CH_TrustID = this.CH_TrustID;
 | 
						||
                    BLL.TrustManageEditService.UpdateCH_Trust(newTrust);
 | 
						||
                    BLL.LogService.AddSys_Log(this.CurrUser, newTrust.CH_TrustCode, this.CH_TrustID, BLL.Const.HJGL_WeldReportMenuId, "修改无损委托信息");
 | 
						||
                }
 | 
						||
                else
 | 
						||
                {
 | 
						||
                    if (BLL.TrustManageEditService.IsExistTrustCode(this.CurrUser.LoginProjectId, this.txtCH_TrustCode.Text.Trim()))
 | 
						||
                    {
 | 
						||
                        ShowNotify("此委托单号已经存在!", MessageBoxIcon.Warning);
 | 
						||
                        return;
 | 
						||
                    }
 | 
						||
                    this.CH_TrustID = SQLHelper.GetNewID(typeof(Model.CH_Trust));
 | 
						||
                    newTrust.CH_TrustID = this.CH_TrustID;
 | 
						||
                    BLL.TrustManageEditService.AddCH_Trust(newTrust);
 | 
						||
                    BLL.LogService.AddSys_Log(this.CurrUser, newTrust.CH_TrustCode, this.CH_TrustID, BLL.Const.HJGL_WeldReportMenuId, "添加无损委托信息");
 | 
						||
                }
 | 
						||
                //删除明细
 | 
						||
                //var trustItems = BLL.TrustManageEditService.GetView_CH_TrustItemByCH_TrustID(this.CH_TrustID);
 | 
						||
                //foreach (var item in trustItems)
 | 
						||
                //{
 | 
						||
                //    BLL.TrustManageEditService.UpdateJOT_TrustFlag(item.JOT_ID, "2");
 | 
						||
                //}
 | 
						||
                //BLL.TrustManageEditService.DeleteCH_TrustItemByCH_TrustID(this.CH_TrustID);
 | 
						||
                //添加明细
 | 
						||
                //List<Model.View_CH_TrustItem> GetTrustItem = this.CollectGridJointInfo();
 | 
						||
                //foreach (var item in GetTrustItem)
 | 
						||
                //{
 | 
						||
                //    Model.CH_TrustItem newitem = new Model.CH_TrustItem();
 | 
						||
                //    newitem.CH_TrustID = this.CH_TrustID;
 | 
						||
                //    newitem.JOT_ID = item.JOT_ID;
 | 
						||
                //    newitem.CH_Remark = item.CH_Remark;
 | 
						||
                //    BLL.TrustManageEditService.AddCH_TrustItem(newitem);
 | 
						||
                //    BLL.TrustManageEditService.UpdateJOT_TrustFlag(newitem.JOT_ID, "1");
 | 
						||
                //}
 | 
						||
 | 
						||
                List<Model.View_CH_TrustItem> GetTrustItem = this.CollectGridJointInfo();
 | 
						||
                List<Model.CH_TrustItem> TrustItem = new List<Model.CH_TrustItem>();
 | 
						||
                foreach (var item in GetTrustItem)
 | 
						||
                {
 | 
						||
                    Model.CH_TrustItem newitem = new Model.CH_TrustItem();
 | 
						||
                    newitem.CH_TrustID = this.CH_TrustID;
 | 
						||
                    newitem.JOT_ID = item.JOT_ID;
 | 
						||
                    newitem.CH_Remark = item.CH_Remark;
 | 
						||
                    TrustItem.Add(newitem);
 | 
						||
                     
 | 
						||
                }
 | 
						||
                BLL.TrustManageEditService.upDataCH_TrustItem(this.CH_TrustID,TrustItem);
 | 
						||
 | 
						||
                ShowNotify("提交成功!", MessageBoxIcon.Success);
 | 
						||
                PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
 | 
						||
            }
 | 
						||
            else
 | 
						||
            {
 | 
						||
                ShowNotify("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning);
 | 
						||
                return;
 | 
						||
            }
 | 
						||
        }
 | 
						||
        #endregion
 | 
						||
 | 
						||
        #region 收集Grid页面信息
 | 
						||
        /// <summary>
 | 
						||
        /// 收集Grid页面信息
 | 
						||
        /// </summary>
 | 
						||
        /// <returns></returns>
 | 
						||
        private List<Model.View_CH_TrustItem> CollectGridJointInfo()
 | 
						||
        {
 | 
						||
            List<Model.View_CH_TrustItem> GetTrustItem = null;
 | 
						||
            List<Model.View_CH_TrustItem> getNewTrustItem = new List<Model.View_CH_TrustItem>();
 | 
						||
            if (!string.IsNullOrEmpty(this.hdItemsString.Text))
 | 
						||
            {
 | 
						||
                GetTrustItem = BLL.TrustManageEditService.GetTrustAddItem(this.hdItemsString.Text);
 | 
						||
            }
 | 
						||
            else if (string.IsNullOrEmpty(this.hdItemsString.Text) && this.CH_TrustID != null)
 | 
						||
            {
 | 
						||
                GetTrustItem = BLL.TrustManageEditService.GetView_CH_TrustItemByCH_TrustID(this.CH_TrustID);
 | 
						||
            }
 | 
						||
 | 
						||
            JArray mergedData = Grid1.GetMergedData();
 | 
						||
            foreach (JObject mergedRow in mergedData)
 | 
						||
            {
 | 
						||
                string status = mergedRow.Value<string>("status");
 | 
						||
                JObject values = mergedRow.Value<JObject>("values");
 | 
						||
 | 
						||
                string rowID = values.Value<string>("JOT_ID").ToString();
 | 
						||
                var item = GetTrustItem.FirstOrDefault(x => x.JOT_ID == rowID);
 | 
						||
                if (item != null)
 | 
						||
                {
 | 
						||
                    item.CH_Remark = values.Value<string>("CH_Remark").ToString();
 | 
						||
                    getNewTrustItem.Add(item);
 | 
						||
                }
 | 
						||
 | 
						||
            }
 | 
						||
            return getNewTrustItem;
 | 
						||
        }
 | 
						||
        #endregion
 | 
						||
 | 
						||
        #region Grid 关闭弹出窗口事件
 | 
						||
        /// <summary>
 | 
						||
        /// 关闭弹出窗口
 | 
						||
        /// </summary>
 | 
						||
        /// <param name="sender"></param>
 | 
						||
        /// <param name="e"></param>
 | 
						||
        protected void Window1_Close(object sender, WindowCloseEventArgs e)
 | 
						||
        {
 | 
						||
            List<string> list = Funs.GetStrListByStr(hdItemsString.Text, '#');
 | 
						||
            if (list.Count() == 2)
 | 
						||
            {
 | 
						||
                string welderLists = list[0];
 | 
						||
                List<string> welder = Funs.GetStrListByStr(welderLists, '|');
 | 
						||
 | 
						||
                string jotLists = list[1];
 | 
						||
                List<string> jot = Funs.GetStrListByStr(jotLists, '|');
 | 
						||
                //if (welder.Count() > 0 && jot.Count() > 0)
 | 
						||
                //{
 | 
						||
                //    this.SetDailyReportNo(jot[0], welder[0]);
 | 
						||
                //}
 | 
						||
            }
 | 
						||
            List<Model.View_CH_TrustItem> GetTrustItem = BLL.TrustManageEditService.GetTrustAddItem(this.hdItemsString.Text);
 | 
						||
            this.BindGrid(GetTrustItem);
 | 
						||
            if (GetTrustItem.Count > 0)
 | 
						||
            {
 | 
						||
                var join = Funs.DB.PW_JointInfo.FirstOrDefault(x => x.JOT_ID == GetTrustItem[0].JOT_ID);
 | 
						||
                var iso = Funs.DB.PW_IsoInfo.FirstOrDefault(x => x.ISO_IsoNo == GetTrustItem[0].ISO_IsoNo);
 | 
						||
 | 
						||
 | 
						||
                var trustUnit = Funs.DB.Base_Unit.FirstOrDefault(x => x.UnitId == this.drpCH_TrustUnit.SelectedValue);
 | 
						||
                if (iso.Is_Standard)
 | 
						||
                {
 | 
						||
                    this.drpCH_NDTRate.SelectedValue = join.DetectionRateId;
 | 
						||
                    //this.drpCH_NDTMethod.SelectedValue = iso.DetectionTypeId;
 | 
						||
                    if (this.drpCH_SlopeType.SelectedValue != BLL.Const._Null)
 | 
						||
                    {
 | 
						||
                        this.drpCH_SlopeType.SelectedValue = join.JST_ID;
 | 
						||
                    }
 | 
						||
                    if (this.drpCH_WeldMethod.SelectedValue != BLL.Const._Null)
 | 
						||
                    {
 | 
						||
                        this.drpCH_WeldMethod.SelectedValue = join.WME_ID;
 | 
						||
                    }
 | 
						||
                    var workArea = Funs.DB.ProjectData_WorkArea.FirstOrDefault(x => x.WorkAreaId == iso.WorkAreaId);
 | 
						||
                    var NDTMethod = Funs.DB.Base_DetectionType.FirstOrDefault(x => x.DetectionTypeId == this.drpCH_NDTMethod.SelectedValue);
 | 
						||
                    if (trustUnit != null && workArea != null && NDTMethod != null)
 | 
						||
                    {
 | 
						||
                        string code = "CD-" + trustUnit.UnitCode + "-" + workArea.WorkAreaCode + "-" + NDTMethod.DetectionTypeCode + "-";
 | 
						||
                        this.txtCH_TrustCode.Text = BLL.SQLHelper.RunProcNewId("SpGetNewCode5ByProjectId", "dbo.CH_Trust", "CH_TrustCode", this.CurrUser.LoginProjectId, code);
 | 
						||
                    }
 | 
						||
                }
 | 
						||
                else
 | 
						||
                {
 | 
						||
                    if (this.drpCH_NDTRate.SelectedValue != BLL.Const._Null)
 | 
						||
                    {
 | 
						||
                        this.drpCH_NDTRate.SelectedValue = iso.DetectionRateId;
 | 
						||
                    }
 | 
						||
                    //this.drpCH_NDTMethod.SelectedValue = iso.DetectionTypeId;
 | 
						||
                    if (this.drpCH_SlopeType.SelectedValue != BLL.Const._Null)
 | 
						||
                    {
 | 
						||
                        this.drpCH_SlopeType.SelectedValue = join.JST_ID;
 | 
						||
                    }
 | 
						||
                    if (this.drpCH_WeldMethod.SelectedValue != BLL.Const._Null)
 | 
						||
                    {
 | 
						||
                        this.drpCH_WeldMethod.SelectedValue = join.WME_ID;
 | 
						||
                    }
 | 
						||
                    var NDTMethod = Funs.DB.Base_DetectionType.FirstOrDefault(x => x.DetectionTypeId == this.drpCH_NDTMethod.SelectedValue);
 | 
						||
                    if (trustUnit != null && NDTMethod != null)
 | 
						||
                    {
 | 
						||
                        string code = trustUnit.UnitCode + "-" + iso.ISO_IsoNo + "-" + NDTMethod.DetectionTypeCode + "-";
 | 
						||
                        this.txtCH_TrustCode.Text = BLL.SQLHelper.RunProcNewId("SpGetNewCode5ByProjectId", "dbo.CH_Trust", "CH_TrustCode", this.CurrUser.LoginProjectId, code);
 | 
						||
                    }
 | 
						||
                }
 | 
						||
 | 
						||
            }
 | 
						||
            //SetDrpByDrpUnitChange();             
 | 
						||
            //this.hdItemsString.Text = string.Empty;
 | 
						||
        }
 | 
						||
        #endregion
 | 
						||
 | 
						||
        #region 右键删除事件
 | 
						||
        /// <summary>
 | 
						||
        /// 右键删除事件
 | 
						||
        /// </summary>
 | 
						||
        /// <param name="sender"></param>
 | 
						||
        /// <param name="e"></param>
 | 
						||
        protected void btnMenuDelete_Click(object sender, EventArgs e)
 | 
						||
        {
 | 
						||
            if (Grid1.SelectedRowIndexArray.Length > 0)
 | 
						||
            {
 | 
						||
                List<Model.View_CH_TrustItem> GetTrustItem = this.CollectGridJointInfo();
 | 
						||
                foreach (int rowIndex in Grid1.SelectedRowIndexArray)
 | 
						||
                {
 | 
						||
                    string rowID = Grid1.DataKeys[rowIndex][0].ToString();
 | 
						||
                    var trust = BLL.TrustManageEditService.GetCH_TrustByID(CH_TrustID);
 | 
						||
                    if (trust != null && trust.CH_AuditDate.HasValue)
 | 
						||
                    {
 | 
						||
                        Alert.ShowInTop("此委托单已审核不能删除!", MessageBoxIcon.Warning);
 | 
						||
                    }
 | 
						||
                    else
 | 
						||
                    {
 | 
						||
                        foreach (Model.View_CH_TrustItem info in GetTrustItem)
 | 
						||
                        {
 | 
						||
                            if (info.JOT_ID == rowID)
 | 
						||
                            {
 | 
						||
                                var item = GetTrustItem.FirstOrDefault(x => x.JOT_ID == rowID);
 | 
						||
                                if (item != null)
 | 
						||
                                {
 | 
						||
                                    BLL.TrustManageEditService.UpdateJOT_TrustFlag(rowID, "2");
 | 
						||
                                }
 | 
						||
                                GetTrustItem.Remove(item);
 | 
						||
                                break;
 | 
						||
                            }
 | 
						||
                        }
 | 
						||
                    }
 | 
						||
                }
 | 
						||
 | 
						||
                BindGrid(GetTrustItem);
 | 
						||
                ShowNotify("操作完成!", MessageBoxIcon.Success);
 | 
						||
            }
 | 
						||
        }
 | 
						||
        #endregion
 | 
						||
 | 
						||
        #region 查找
 | 
						||
        /// <summary>
 | 
						||
        /// 查找未焊接焊口
 | 
						||
        /// </summary>
 | 
						||
        /// <param name="sender"></param>
 | 
						||
        /// <param name="e"></param>
 | 
						||
        protected void ckSelect_Click(object sender, EventArgs e)
 | 
						||
        {
 | 
						||
            string jotIds = string.Empty;
 | 
						||
 | 
						||
            for (int i = 0; i < Grid1.Rows.Count; i++)
 | 
						||
            {
 | 
						||
                string jotId = Grid1.DataKeys[i][0].ToString();
 | 
						||
                jotIds = jotIds + jotId + "|";
 | 
						||
            }
 | 
						||
 | 
						||
            if (jotIds != string.Empty)
 | 
						||
            {
 | 
						||
                jotIds = jotIds.Substring(0, jotIds.Length - 1);
 | 
						||
            }
 | 
						||
 | 
						||
            if (!string.IsNullOrEmpty(this.drpCH_TrustUnit.SelectedValue) && this.drpCH_TrustUnit.SelectedValue != BLL.Const._Null && !string.IsNullOrEmpty(this.drpInstallation.SelectedValue) && this.drpInstallation.SelectedValue != BLL.Const._Null)
 | 
						||
            {
 | 
						||
                string strList = this.CurrUser.LoginProjectId + "|" + this.drpCH_TrustUnit.SelectedValue + "|" + this.CH_TrustID + "|" + this.drpInstallation.SelectedValue;
 | 
						||
                string window = String.Format("ShowTrustSearch.aspx?strList={0}&jotIds={1}", strList, jotIds, "编辑 - ");
 | 
						||
                PageContext.RegisterStartupScript(Window1.GetSaveStateReference(hdItemsString.ClientID) + Window1.GetShowReference(window));
 | 
						||
            }
 | 
						||
            else
 | 
						||
            {
 | 
						||
                Alert.ShowInTop("请选择单位和装置!", MessageBoxIcon.Warning);
 | 
						||
            }
 | 
						||
        }
 | 
						||
        #endregion
 | 
						||
        protected void drpCH_NDTMethod_SelectedIndexChanged(object sender, EventArgs e)
 | 
						||
        {
 | 
						||
            hangedCH_NDTCriteria(sender, e);
 | 
						||
            needChangeCode(sender, e);
 | 
						||
        }
 | 
						||
        protected void drpCH_AcceptGrade_SelectedIndexChanged(object sender, EventArgs e)
 | 
						||
        {
 | 
						||
            hangedCH_NDTCriteria(sender, e);
 | 
						||
        }
 | 
						||
        protected void hangedCH_NDTCriteria(object sender, EventArgs e)
 | 
						||
        {
 | 
						||
 | 
						||
            if (drpCH_NDTMethod.SelectedValue != BLL.Const._Null)
 | 
						||
            {
 | 
						||
                var detectionType = Base_DetectionTypeService.GetDetectionTypeByDetectionTypeId(drpCH_NDTMethod.SelectedValue);
 | 
						||
                string type = detectionType.DetectionTypeCode.Split('\\')[0];
 | 
						||
                switch (type)
 | 
						||
                {
 | 
						||
 | 
						||
                    case "RT":
 | 
						||
                        // RT采用标准--NB / T47013.2 - 2015   II级
 | 
						||
                        //UT采用标准--NB / T47013.3 - 2015   I级
 | 
						||
                        //MT采用标准--NB / T47013.4 - 2015  I级
 | 
						||
                        //PT采用标准--NB / T47013.5 - 2015   I级
 | 
						||
                        //    TOFD采用标准--NB / T47013.10 - 2015   II级
 | 
						||
                        //3D - TFM--NB / T47013.15 - 2021  II级
 | 
						||
 | 
						||
 | 
						||
                        if (this.drpCH_AcceptGrade.SelectedValue != BLL.Const._Null)
 | 
						||
                        {
 | 
						||
                            txtCH_NDTCriteria.Text = "NB/T47013.2-2015" + "(" + this.drpCH_AcceptGrade.SelectedItem.Text + ")";
 | 
						||
                        }
 | 
						||
 | 
						||
                        else
 | 
						||
                        {
 | 
						||
                            txtCH_NDTCriteria.Text = "NB/T47013.2-2015";
 | 
						||
 | 
						||
                        }
 | 
						||
                        break;
 | 
						||
                    case "UT":
 | 
						||
 | 
						||
                        if (this.drpCH_AcceptGrade.SelectedValue != BLL.Const._Null)
 | 
						||
                        {
 | 
						||
                            txtCH_NDTCriteria.Text = "NB/T47013.3-2015" + "(" + this.drpCH_AcceptGrade.SelectedItem.Text + ")";
 | 
						||
                        }
 | 
						||
 | 
						||
                        else
 | 
						||
                        {
 | 
						||
                            txtCH_NDTCriteria.Text = "NB/T47013.3-2015";
 | 
						||
 | 
						||
                        }
 | 
						||
                        break;
 | 
						||
                    case "MT":
 | 
						||
                        if (this.drpCH_AcceptGrade.SelectedValue != BLL.Const._Null)
 | 
						||
                        {
 | 
						||
                            txtCH_NDTCriteria.Text = "NB/T47013.4-2015" + "(" + this.drpCH_AcceptGrade.SelectedItem.Text + ")";
 | 
						||
                        }
 | 
						||
 | 
						||
                        else
 | 
						||
                        {
 | 
						||
                            txtCH_NDTCriteria.Text = "NB/T47013.4-2015";
 | 
						||
 | 
						||
                        }
 | 
						||
                        break;
 | 
						||
                    case "PT":
 | 
						||
                        if (this.drpCH_AcceptGrade.SelectedValue != BLL.Const._Null)
 | 
						||
                        {
 | 
						||
                            txtCH_NDTCriteria.Text = "NB/T47013.5-2015" + "(" + this.drpCH_AcceptGrade.SelectedItem.Text + ")";
 | 
						||
                        }
 | 
						||
 | 
						||
                        else
 | 
						||
                        {
 | 
						||
                            txtCH_NDTCriteria.Text = "NB/T47013.5-2015";
 | 
						||
 | 
						||
                        }
 | 
						||
                        break;
 | 
						||
                    case "TOFD":
 | 
						||
                        if (this.drpCH_AcceptGrade.SelectedValue != BLL.Const._Null)
 | 
						||
                        {
 | 
						||
                            txtCH_NDTCriteria.Text = "NB/T47013.10-2015" + "(" + this.drpCH_AcceptGrade.SelectedItem.Text + ")";
 | 
						||
                        }
 | 
						||
 | 
						||
                        else
 | 
						||
                        {
 | 
						||
                            txtCH_NDTCriteria.Text = "NB/T47013.10-2015";
 | 
						||
 | 
						||
                        }
 | 
						||
                        break;
 | 
						||
                    case "3D-TFM":
 | 
						||
                        if (this.drpCH_AcceptGrade.SelectedValue != BLL.Const._Null)
 | 
						||
                        {
 | 
						||
                            txtCH_NDTCriteria.Text = "NB/T47013.15-2015" + "(" + this.drpCH_AcceptGrade.SelectedItem.Text + ")";
 | 
						||
                        }
 | 
						||
 | 
						||
                        else
 | 
						||
                        {
 | 
						||
                            txtCH_NDTCriteria.Text = "NB/T47013.15-2015";
 | 
						||
 | 
						||
                        }
 | 
						||
                        break;
 | 
						||
                }
 | 
						||
            }
 | 
						||
        }
 | 
						||
 | 
						||
        protected void needChangeCode(object sender, EventArgs e)
 | 
						||
        {
 | 
						||
            var trust = BLL.TrustManageEditService.GetCH_TrustByID(this.CH_TrustID);
 | 
						||
            if (trust == null)
 | 
						||
            {
 | 
						||
                List<Model.View_CH_TrustItem> GetTrustItem = BLL.TrustManageEditService.GetTrustAddItem(this.hdItemsString.Text);                 
 | 
						||
                if (GetTrustItem.Count > 0)
 | 
						||
                {
 | 
						||
                    var join = Funs.DB.PW_JointInfo.FirstOrDefault(x => x.JOT_ID == GetTrustItem[0].JOT_ID);
 | 
						||
                    var iso = Funs.DB.PW_IsoInfo.FirstOrDefault(x => x.ISO_IsoNo == GetTrustItem[0].ISO_IsoNo);     
 | 
						||
                    var trustUnit = Funs.DB.Base_Unit.FirstOrDefault(x => x.UnitId == this.drpCH_TrustUnit.SelectedValue);
 | 
						||
 | 
						||
                    if (!iso.Is_Standard)
 | 
						||
                    {
 | 
						||
                        if (this.drpCH_NDTRate.SelectedValue != BLL.Const._Null)
 | 
						||
                        { this.drpCH_NDTRate.SelectedValue = iso.DetectionRateId;
 | 
						||
                        }
 | 
						||
                        if (this.drpCH_NDTMethod.SelectedValue == BLL.Const._Null)
 | 
						||
                        {
 | 
						||
                            this.drpCH_NDTMethod.SelectedValue = iso.DetectionTypeId;
 | 
						||
                        }
 | 
						||
                        if (this.drpCH_SlopeType.SelectedValue == BLL.Const._Null)
 | 
						||
                        {
 | 
						||
                            this.drpCH_SlopeType.SelectedValue = join.JST_ID;
 | 
						||
                        }
 | 
						||
                        if (this.drpCH_WeldMethod.SelectedValue == BLL.Const._Null)
 | 
						||
                        {
 | 
						||
                            this.drpCH_WeldMethod.SelectedValue = join.WME_ID;
 | 
						||
                        }
 | 
						||
                        switch (iso.ISO_NDTClass)
 | 
						||
                        {
 | 
						||
                            case "Ⅰ":
 | 
						||
                                this.drpCH_AcceptGrade.SelectedValue = "1"; break;
 | 
						||
                            case "Ⅱ":
 | 
						||
                                this.drpCH_AcceptGrade.SelectedValue = "2"; break;
 | 
						||
                            case "Ⅲ":
 | 
						||
                                this.drpCH_AcceptGrade.SelectedValue = "3"; break;
 | 
						||
                            case "Ⅳ":
 | 
						||
                                this.drpCH_AcceptGrade.SelectedValue = "4"; break;
 | 
						||
                            case "Ⅴ":
 | 
						||
                                this.drpCH_AcceptGrade.SelectedValue = "5"; break;
 | 
						||
                        }
 | 
						||
 | 
						||
 | 
						||
                        var workArea = Funs.DB.ProjectData_WorkArea.FirstOrDefault(x => x.WorkAreaId == iso.WorkAreaId);
 | 
						||
                        var NDTMethod = Funs.DB.Base_DetectionType.FirstOrDefault(x => x.DetectionTypeId == this.drpCH_NDTMethod.SelectedValue);
 | 
						||
                        if (trustUnit != null && workArea != null && NDTMethod != null)
 | 
						||
                        {
 | 
						||
                            string code = "CD-" + trustUnit.UnitCode + "-" + workArea.WorkAreaCode + "-" + NDTMethod.DetectionTypeCode + "-";
 | 
						||
                            this.txtCH_TrustCode.Text = BLL.SQLHelper.RunProcNewId("SpGetNewCode5ByProjectId", "dbo.CH_Trust", "CH_TrustCode", this.CurrUser.LoginProjectId, code);
 | 
						||
                        }
 | 
						||
                    }
 | 
						||
                    else
 | 
						||
                    {
 | 
						||
                        if (this.drpCH_NDTRate.SelectedValue != BLL.Const._Null)
 | 
						||
                        {
 | 
						||
                            this.drpCH_NDTRate.SelectedValue = join.DetectionRateId;
 | 
						||
                        }
 | 
						||
                        if (this.drpCH_NDTMethod.SelectedValue != BLL.Const._Null)
 | 
						||
                        {
 | 
						||
                            this.drpCH_NDTMethod.SelectedValue = join.DetectionTypeId;
 | 
						||
                        }
 | 
						||
                        if (this.drpCH_WeldMethod.SelectedValue != BLL.Const._Null)
 | 
						||
                        {
 | 
						||
                            this.drpCH_SlopeType.SelectedValue = join.JST_ID;
 | 
						||
                        }
 | 
						||
                        if (this.drpCH_WeldMethod.SelectedValue != BLL.Const._Null)
 | 
						||
                        {
 | 
						||
                            this.drpCH_WeldMethod.SelectedValue = join.WME_ID;
 | 
						||
                        }
 | 
						||
                        switch (iso.ISO_NDTClass)
 | 
						||
                        {
 | 
						||
                            case "Ⅰ":
 | 
						||
                                this.drpCH_AcceptGrade.SelectedValue = "1"; break;
 | 
						||
                            case "Ⅱ":
 | 
						||
                                this.drpCH_AcceptGrade.SelectedValue = "2"; break;
 | 
						||
                            case "Ⅲ":
 | 
						||
                                this.drpCH_AcceptGrade.SelectedValue = "3"; break;
 | 
						||
                            case "Ⅳ":
 | 
						||
                                this.drpCH_AcceptGrade.SelectedValue = "4"; break;
 | 
						||
                            case "Ⅴ":
 | 
						||
                                this.drpCH_AcceptGrade.SelectedValue = "5"; break;
 | 
						||
                        }
 | 
						||
 | 
						||
 | 
						||
                        var NDTMethod = Funs.DB.Base_DetectionType.FirstOrDefault(x => x.DetectionTypeId == this.drpCH_NDTMethod.SelectedValue);
 | 
						||
                        if (trustUnit  != null && NDTMethod != null)
 | 
						||
                        {
 | 
						||
                            string code =  trustUnit.UnitCode + "-" + iso.ISO_IsoNo + "-" + NDTMethod.DetectionTypeCode + "-";
 | 
						||
                            this.txtCH_TrustCode.Text = BLL.SQLHelper.RunProcNewId("SpGetNewCode5ByProjectId", "dbo.CH_Trust", "CH_TrustCode", this.CurrUser.LoginProjectId, code);
 | 
						||
                        }
 | 
						||
                    }
 | 
						||
                }
 | 
						||
            }
 | 
						||
        }
 | 
						||
    }
 | 
						||
} |