1643 lines
		
	
	
		
			81 KiB
		
	
	
	
		
			C#
		
	
	
	
			
		
		
	
	
			1643 lines
		
	
	
		
			81 KiB
		
	
	
	
		
			C#
		
	
	
	
using System;
 | 
						||
using System.Collections.Generic;
 | 
						||
using System.Data;
 | 
						||
using System.Linq;
 | 
						||
using BLL;
 | 
						||
using Newtonsoft.Json.Linq;
 | 
						||
 | 
						||
namespace FineUIPro.Web.WeldingProcess.WeldingManage
 | 
						||
{
 | 
						||
    public partial class WeldReportEdit : PageBase
 | 
						||
    {
 | 
						||
        #region 定义项
 | 
						||
        /// <summary>
 | 
						||
        /// 焊接日报主键
 | 
						||
        /// </summary>
 | 
						||
        public string WeldingDailyId
 | 
						||
        {
 | 
						||
            get
 | 
						||
            {
 | 
						||
                return (string)ViewState["WeldingDailyId"];
 | 
						||
            }
 | 
						||
            set
 | 
						||
            {
 | 
						||
                ViewState["WeldingDailyId"] = value;
 | 
						||
            }
 | 
						||
        }
 | 
						||
 | 
						||
        /// <summary>
 | 
						||
        /// 项目主键
 | 
						||
        /// </summary>
 | 
						||
        public string ProjectId
 | 
						||
        {
 | 
						||
            get
 | 
						||
            {
 | 
						||
                return (string)ViewState["ProjectId"];
 | 
						||
            }
 | 
						||
            set
 | 
						||
            {
 | 
						||
                ViewState["ProjectId"] = value;
 | 
						||
            }
 | 
						||
        }
 | 
						||
        #endregion
 | 
						||
 | 
						||
        #region 加载页面
 | 
						||
        /// <summary>
 | 
						||
        /// 加载页面
 | 
						||
        /// </summary>
 | 
						||
        /// <param name="sender"></param>
 | 
						||
        /// <param name="e"></param>
 | 
						||
        protected void Page_Load(object sender, EventArgs e)
 | 
						||
        {
 | 
						||
            if (!IsPostBack)
 | 
						||
            {
 | 
						||
                this.ProjectId = Request.Params["ProjectId"];
 | 
						||
                this.WeldingDailyId = Request.Params["WeldingDailyId"];
 | 
						||
 | 
						||
                ///焊缝类型
 | 
						||
                Base_WeldTypeService.InitWeldTypeDropDownList(this.drpWeldType, Resources.Lan.PleaseSelect, false);
 | 
						||
                this.drpWeldType.DataTextField = "WeldTypeCode";
 | 
						||
                this.drpWeldType.DataValueField = "WeldTypeCode";
 | 
						||
                this.drpWeldType.DataSource = from x in Funs.DB.Base_WeldType orderby x.WeldTypeCode select x;
 | 
						||
                this.drpWeldType.DataBind();
 | 
						||
              
 | 
						||
                ///焊接位置
 | 
						||
                this.drpWeldingLocationId.DataTextField = "WeldingLocationCode";
 | 
						||
                this.drpWeldingLocationId.DataValueField = "WeldingLocationCode";
 | 
						||
                this.drpWeldingLocationId.DataSource = from x in Funs.DB.Base_WeldingLocation orderby x.WeldingLocationCode select x;
 | 
						||
                this.drpWeldingLocationId.DataBind();
 | 
						||
                this.drpWeldingLocationId.SelectedIndex = 0;
 | 
						||
 | 
						||
                // 焊接方法
 | 
						||
                //this.drpWeldingMethod.DataTextField = "WeldingMethodCode";
 | 
						||
                //this.drpWeldingMethod.DataValueField = "WeldingMethodCode";
 | 
						||
                //this.drpWeldingMethod.DataSource = from x in Funs.DB.Base_WeldingMethod orderby x.WeldingMethodCode select x;
 | 
						||
                //this.drpWeldingMethod.DataBind();
 | 
						||
                //this.drpWeldingMethod.SelectedIndex = 0;
 | 
						||
 | 
						||
                ///材质1
 | 
						||
                Base_MaterialService.InitMaterialDropDownList(this.drpMaterial1);
 | 
						||
                ///材质2
 | 
						||
                Base_MaterialService.InitMaterialDropDownList(this.drpMaterial2);
 | 
						||
 | 
						||
                Base_DNCompareService.InitDNCompareDropDownList(this.drpANSISCH, false);
 | 
						||
                // 组件1
 | 
						||
                this.drpComponents1.DataTextField = "ComponentsCode";
 | 
						||
                this.drpComponents1.DataValueField = "ComponentsCode";
 | 
						||
                this.drpComponents1.DataSource = from x in Funs.DB.Base_Components orderby x.ComponentsCode select x;
 | 
						||
                this.drpComponents1.DataBind();
 | 
						||
                this.drpComponents1.SelectedIndex = 0;
 | 
						||
 | 
						||
                // 组件2
 | 
						||
                this.drpComponents2.DataTextField = "ComponentsCode";
 | 
						||
                this.drpComponents2.DataValueField = "ComponentsCode";
 | 
						||
                this.drpComponents2.DataSource = from x in Funs.DB.Base_Components orderby x.ComponentsCode select x;
 | 
						||
                this.drpComponents2.DataBind();
 | 
						||
                this.drpComponents2.SelectedIndex = 0;
 | 
						||
 | 
						||
                // 焊丝
 | 
						||
                //this.drpWeldSilkCode.DataTextField = "ConsumablesCode";
 | 
						||
                //this.drpWeldSilkCode.DataValueField = "ConsumablesCode";
 | 
						||
                //this.drpWeldSilkCode.DataSource = from x in Funs.DB.Base_Consumables where x.ConsumablesType=="1" orderby x.ConsumablesCode select x;
 | 
						||
                //this.drpWeldSilkCode.DataBind();
 | 
						||
                //Funs.FineUIPleaseSelect(drpWeldSilkCode);
 | 
						||
                //this.drpWeldSilkCode.SelectedIndex = 0;
 | 
						||
 | 
						||
                // 焊条
 | 
						||
                //this.drpWeldMatCode.DataTextField = "ConsumablesCode";
 | 
						||
                //this.drpWeldMatCode.DataValueField = "ConsumablesCode";
 | 
						||
                //this.drpWeldMatCode.DataSource = from x in Funs.DB.Base_Consumables where x.ConsumablesType == "2" orderby x.ConsumablesCode select x;
 | 
						||
                //this.drpWeldMatCode.DataBind();
 | 
						||
                //Funs.FineUIPleaseSelect(drpWeldMatCode);
 | 
						||
                //this.drpWeldMatCode.SelectedIndex = 0;
 | 
						||
 | 
						||
                ///焊接属性
 | 
						||
                this.drpJointAttribute.DataTextField = "Text";
 | 
						||
                this.drpJointAttribute.DataValueField = "Value";
 | 
						||
                this.drpJointAttribute.DataSource = BLL.DropListService.HJGL_JointAttributeItem();
 | 
						||
                this.drpJointAttribute.DataBind();
 | 
						||
 | 
						||
                var wpsList = from x in Funs.DB.WPQ_WPQList where x.ProjectId == CurrUser.LoginProjectId select x;
 | 
						||
                drpWPS.DataValueField = "WPQCode";
 | 
						||
                drpWPS.DataTextField = "WPQCode";
 | 
						||
                drpWPS.DataSource = wpsList.ToList().OrderBy(x => x.WPQCode);
 | 
						||
                drpWPS.DataBind();
 | 
						||
                Funs.FineUIPleaseSelect(drpWPS);
 | 
						||
 | 
						||
 | 
						||
                List<Model.SpWeldingDailyItem> GetWeldingDailyItem = BLL.Pipeline_WeldingDailyService.GetWeldingDailyItem(this.WeldingDailyId);
 | 
						||
                this.BindGrid(GetWeldingDailyItem);  // 初始化页面 
 | 
						||
                this.PageInfoLoad(); // 加载页面 
 | 
						||
                this.CalculationAmount();
 | 
						||
            }
 | 
						||
        }
 | 
						||
        #endregion
 | 
						||
 | 
						||
        #region 超量焊工提示
 | 
						||
        /// <summary>
 | 
						||
        ///  超量焊工提示
 | 
						||
        /// </summary>
 | 
						||
        private void CalculationAmount()
 | 
						||
        {
 | 
						||
            this.lbAmount.Hidden = true;
 | 
						||
            this.lbAmount.Text = string.Empty;
 | 
						||
            DateTime? date = Funs.GetNewDateTime(this.txtWeldingDate.Text);
 | 
						||
            string txtValue = string.Empty;
 | 
						||
            if (date.HasValue)
 | 
						||
            {
 | 
						||
                var weldJoints = BLL.Pipeline_WeldJointService.GetWeldlinesByWeldingDailyId(this.WeldingDailyId);
 | 
						||
                foreach (var item in weldJoints)
 | 
						||
                {
 | 
						||
                    bool cWelder = BLL.Pipeline_WeldJointService.GetWelderLimitDN(this.ProjectId, item.CoverWelderId, date.Value);
 | 
						||
                    bool bWelder = cWelder;
 | 
						||
                    if (item.BackingWelderId != item.CoverWelderId)
 | 
						||
                    {
 | 
						||
                        bWelder = BLL.Pipeline_WeldJointService.GetWelderLimitDN(this.ProjectId, item.BackingWelderId, date.Value);
 | 
						||
                    }
 | 
						||
                    if (cWelder || bWelder)
 | 
						||
                    {
 | 
						||
                        if (cWelder)
 | 
						||
                        {
 | 
						||
                            var coverWelder = BLL.WelderService.GetWelderById(item.CoverWelderId);
 | 
						||
                            if (coverWelder != null)
 | 
						||
                            {
 | 
						||
                                string txt = coverWelder.WelderCode + ";";
 | 
						||
                                if (!txtValue.Contains(txt))
 | 
						||
                                {
 | 
						||
                                    txtValue += txt;
 | 
						||
                                }
 | 
						||
                            }
 | 
						||
                        }
 | 
						||
                        if (bWelder)
 | 
						||
                        {
 | 
						||
                            var floorWelder = BLL.WelderService.GetWelderById(item.BackingWelderId);
 | 
						||
                            if (floorWelder != null)
 | 
						||
                            {
 | 
						||
                                string txt = floorWelder.WelderCode + ";";
 | 
						||
                                if (!txtValue.Contains(txt))
 | 
						||
                                {
 | 
						||
                                    txtValue += txt;
 | 
						||
                                }
 | 
						||
                            }
 | 
						||
                        }
 | 
						||
                    }
 | 
						||
                }
 | 
						||
            }
 | 
						||
            if (!string.IsNullOrEmpty(txtValue))
 | 
						||
            {
 | 
						||
                this.lbAmount.Text = txtValue;
 | 
						||
                this.lbAmount.Hidden = false;
 | 
						||
            }
 | 
						||
        }
 | 
						||
        #endregion
 | 
						||
 | 
						||
        #region 加载页面输入提交信息
 | 
						||
        /// <summary>
 | 
						||
        /// 加载页面输入提交信息
 | 
						||
        /// </summary>
 | 
						||
        private void PageInfoLoad()
 | 
						||
        {
 | 
						||
            var report = BLL.Pipeline_WeldingDailyService.GetPipeline_WeldingDailyByWeldingDailyId(this.WeldingDailyId);
 | 
						||
            if (report != null)
 | 
						||
            {
 | 
						||
                this.ProjectId = report.ProjectId;
 | 
						||
                BLL.Base_UnitService.InitProjectUnitDropDownList(this.drpUnit, true, this.ProjectId, BLL.Const.UnitType_5, Resources.Lan.PleaseSelect);
 | 
						||
                BLL.Project_InstallationService.InitInstallationDropDownList(this.drpInstallation, true, this.ProjectId, Resources.Lan.PleaseSelect);
 | 
						||
                this.txtWeldingDailyCode.Text = report.WeldingDailyCode;
 | 
						||
                if (!string.IsNullOrEmpty(report.UnitId))
 | 
						||
                {
 | 
						||
                    this.drpUnit.SelectedValue = report.UnitId;
 | 
						||
                    BLL.WelderService.InitProjectWelderCodeDropDownList(this.drpCoverWelderId, false, this.ProjectId, this.drpUnit.SelectedValue, Resources.Lan.PleaseSelect);
 | 
						||
                    BLL.WelderService.InitProjectWelderCodeDropDownList(this.drpBackingWelderId, false, this.ProjectId, this.drpUnit.SelectedValue, Resources.Lan.PleaseSelect);
 | 
						||
                }
 | 
						||
                if (!string.IsNullOrEmpty(report.InstallationId))
 | 
						||
                {
 | 
						||
                    this.drpInstallation.SelectedValue = report.InstallationId;
 | 
						||
                }
 | 
						||
                this.txtWeldingDate.Text = string.Format("{0:yyyy-MM-dd}", report.WeldingDate);
 | 
						||
                this.hdTablerId.Text = report.Tabler;
 | 
						||
                Model.Sys_User tabler = BLL.Sys_UserService.GetUsersByUserId(report.Tabler);
 | 
						||
                if (tabler != null)
 | 
						||
                {
 | 
						||
                    this.txtTabler.Text = tabler.UserName;
 | 
						||
                }
 | 
						||
                this.txtTableDate.Text = string.Format("{0:yyyy-MM-dd}", report.TableDate);
 | 
						||
                this.txtRemark.Text = report.Remark;
 | 
						||
            }
 | 
						||
            else
 | 
						||
            {
 | 
						||
                BLL.Base_UnitService.InitProjectUnitDropDownList(this.drpUnit, true, this.ProjectId, BLL.Const.UnitType_5, Resources.Lan.PleaseSelect);
 | 
						||
                var u = BLL.Project_UnitService.GetProject_UnitByProjectIdUnitId(CurrUser.LoginProjectId, CurrUser.UnitId);
 | 
						||
                if (u != null && u.UnitType == BLL.Const.UnitType_5)
 | 
						||
                {
 | 
						||
                    BLL.Project_InstallationService.InitInstallationDropDownList(this.drpInstallation, true, CurrUser.LoginProjectId, CurrUser.UnitId, Resources.Lan.PleaseSelect);
 | 
						||
                    drpUnit.SelectedValue = CurrUser.UnitId;
 | 
						||
                    drpUnit.Enabled = false;
 | 
						||
                }
 | 
						||
                else
 | 
						||
                {
 | 
						||
                    BLL.Project_InstallationService.InitInstallationDropDownList(this.drpInstallation, true, this.ProjectId, Resources.Lan.PleaseSelect);
 | 
						||
                }
 | 
						||
                
 | 
						||
                this.SimpleForm1.Reset(); ///重置所有字段
 | 
						||
                this.txtTabler.Text = this.CurrUser.UserName;
 | 
						||
                this.hdTablerId.Text = this.CurrUser.UserId;
 | 
						||
                this.txtWeldingDate.Text = string.Format("{0:yyyy-MM-dd}", System.DateTime.Now);
 | 
						||
                this.txtTableDate.Text = string.Format("{0:yyyy-MM-dd}", System.DateTime.Now);
 | 
						||
                string perfix = string.Format("{0:yyyyMMdd}", System.DateTime.Now) + "-";
 | 
						||
                this.txtWeldingDailyCode.Text = BLL.SQLHelper.RunProcNewId("SpGetThreeNumber", "dbo.Pipeline_WeldingDaily", "WeldingDailyCode", this.CurrUser.LoginProjectId, perfix);
 | 
						||
            }
 | 
						||
        }
 | 
						||
        #endregion
 | 
						||
 | 
						||
        #region 单位下拉框变化加载对应的焊工信息
 | 
						||
        /// <summary>
 | 
						||
        /// 单位下拉框变化加载对应的焊工信息
 | 
						||
        /// </summary>
 | 
						||
        /// <param name="sender"></param>
 | 
						||
        /// <param name="e"></param>
 | 
						||
        protected void drpUnit_SelectedIndexChanged(object sender, EventArgs e)
 | 
						||
        {
 | 
						||
            this.drpCoverWelderId.Items.Clear();
 | 
						||
            this.drpBackingWelderId.Items.Clear();
 | 
						||
            if (this.drpUnit.SelectedValue != BLL.Const._Null)
 | 
						||
            {
 | 
						||
                BLL.Project_InstallationService.InitInstallationDropDownList(this.drpInstallation, true, CurrUser.LoginProjectId, drpUnit.SelectedValue, Resources.Lan.PleaseSelect);
 | 
						||
                BLL.WelderService.InitProjectWelderCodeDropDownList(this.drpCoverWelderId, false, this.ProjectId, this.drpUnit.SelectedValue, Resources.Lan.PleaseSelect);
 | 
						||
                BLL.WelderService.InitProjectWelderCodeDropDownList(this.drpBackingWelderId, false, this.ProjectId, this.drpUnit.SelectedValue, Resources.Lan.PleaseSelect);
 | 
						||
            }
 | 
						||
        }
 | 
						||
        #endregion
 | 
						||
 | 
						||
        #region 数据绑定
 | 
						||
        /// <summary>
 | 
						||
        /// 数据绑定
 | 
						||
        /// </summary>
 | 
						||
        private void BindGrid(List<Model.SpWeldingDailyItem> GetWeldingDailyItem)
 | 
						||
        {
 | 
						||
            DataTable tb = this.LINQToDataTable(GetWeldingDailyItem);
 | 
						||
            // 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.SpWeldingDailyItem> GetWeldingDailyItem = this.CollectGridJointInfo();
 | 
						||
            this.BindGrid(GetWeldingDailyItem);
 | 
						||
        }
 | 
						||
        #endregion
 | 
						||
 | 
						||
        private static bool canSave;  //是否可以保存
 | 
						||
 | 
						||
        #region 焊接日报 提交事件
 | 
						||
        /// <summary>
 | 
						||
        /// 编辑焊接日报
 | 
						||
        /// </summary>
 | 
						||
        /// <param name="sender"></param>
 | 
						||
        /// <param name="e"></param>
 | 
						||
        protected void btnSave_Click(object sender, EventArgs e)
 | 
						||
        {
 | 
						||
            if (CommonService.GetAllButtonPowerList(this.ProjectId, this.CurrUser.UserId, Const.HJGL_WeldReportMenuId, Const.BtnSave))
 | 
						||
            {
 | 
						||
                if (BLL.Pipeline_WeldingDailyService.IsExistWeldingDailyCode(this.txtWeldingDailyCode.Text, !string.IsNullOrEmpty(this.WeldingDailyId) ? this.WeldingDailyId : "", this.ProjectId))
 | 
						||
                {
 | 
						||
                    ShowNotify(Resources.Lan.WeldingReportExists, MessageBoxIcon.Warning);
 | 
						||
                    return;
 | 
						||
                }
 | 
						||
                if (string.IsNullOrEmpty(this.txtWeldingDate.Text) || string.IsNullOrEmpty(this.txtWeldingDailyCode.Text.Trim()))
 | 
						||
                {
 | 
						||
                    ShowNotify(Resources.Lan.WeldingNumDateIsNotNull, MessageBoxIcon.Warning);
 | 
						||
                    return;
 | 
						||
                }
 | 
						||
 | 
						||
                // 焊工资质
 | 
						||
                string eventArg = string.Empty;
 | 
						||
 | 
						||
                // 验证错误
 | 
						||
                string errorCheck = string.Empty;
 | 
						||
                List<Model.SpWeldingDailyItem> GetWeldingDailyItem = this.CollectGridJointInfo();
 | 
						||
 | 
						||
                #region 和焊口信息及所能焊的WPS验证
 | 
						||
                int rowIndex = 1;
 | 
						||
                foreach (var item in GetWeldingDailyItem)
 | 
						||
                {
 | 
						||
                    var jot = BLL.Pipeline_WeldJointService.GetWeldJointByWeldJointId(item.WeldJointId);
 | 
						||
                    var wps = BLL.WPQListServiceService.GetWPQById(item.WPQId);
 | 
						||
 | 
						||
                    // 验证焊工资质
 | 
						||
                    if (item.BackingWelderId == item.CoverWelderId)
 | 
						||
                    {
 | 
						||
                        if (!wps.WelderIds.Contains(item.BackingWelderId))
 | 
						||
                        {
 | 
						||
                            if (!eventArg.Contains(item.BackingWelderId))
 | 
						||
                            {
 | 
						||
                                eventArg += rowIndex + "行,焊工:" + item.BackingWelderCode + "无资质,";
 | 
						||
                            }
 | 
						||
                        }
 | 
						||
                    }
 | 
						||
                    else
 | 
						||
                    {
 | 
						||
                        if (!wps.WelderIds.Contains(item.BackingWelderId))
 | 
						||
                        {
 | 
						||
                            if (!eventArg.Contains(item.BackingWelderId))
 | 
						||
                            {
 | 
						||
                                eventArg += rowIndex + "行,焊工:" + item.BackingWelderCode + "无资质,";
 | 
						||
                            }
 | 
						||
                        }
 | 
						||
                        if (!wps.WelderIds.Contains(item.CoverWelderId))
 | 
						||
                        {
 | 
						||
                            if (!eventArg.Contains(item.CoverWelderId))
 | 
						||
                            {
 | 
						||
                                eventArg += rowIndex + "行,焊工:" + item.CoverWelderId + "无资质,";
 | 
						||
                            }
 | 
						||
                        }
 | 
						||
                    }
 | 
						||
 | 
						||
                    // 验证数据是否一至
 | 
						||
                    if (!string.IsNullOrEmpty(item.WeldTypeId) && !string.IsNullOrEmpty(jot.WeldTypeId) && item.WeldTypeId != jot.WeldTypeId)
 | 
						||
                    {
 | 
						||
                        errorCheck += rowIndex + "行,焊缝类型:" + item.WeldTypeId + "验证不一至,";
 | 
						||
                    }
 | 
						||
                    if (!string.IsNullOrEmpty(item.JointAttribute) && !string.IsNullOrEmpty(jot.JointAttribute) && item.JointAttribute != jot.JointAttribute)
 | 
						||
                    {
 | 
						||
                        errorCheck += rowIndex + "行,焊口属性:" + item.JointAttribute + "验证不一至,";
 | 
						||
                    }
 | 
						||
 | 
						||
                    //if (!string.IsNullOrEmpty(item.WeldingLocationId) && !string.IsNullOrEmpty(jot.WeldingLocationId) && item.WeldingLocationId != jot.WeldingLocationId)
 | 
						||
                    //{
 | 
						||
                    //    errorCheck += rowIndex + "行,焊接位置:" + item.JointAttribute + "验证不一至,";
 | 
						||
                    //}
 | 
						||
 | 
						||
                    if (item.Size!=null && jot.Size!=null && item.Size != jot.Size)
 | 
						||
                    {
 | 
						||
                        errorCheck += rowIndex + "行,管径:" + item.JointAttribute + "验证不一至,";
 | 
						||
                    }
 | 
						||
 | 
						||
                    if (!string.IsNullOrEmpty(item.ANSISCH) && !string.IsNullOrEmpty(jot.ANSISCH) && item.ANSISCH != jot.ANSISCH)
 | 
						||
                    {
 | 
						||
                        errorCheck += rowIndex + "行,美标壁厚:" + item.ANSISCH + "验证不一至,";
 | 
						||
                    }
 | 
						||
 | 
						||
                    //if (!string.IsNullOrEmpty(item.MaterialId1) && !string.IsNullOrEmpty(jot.Material1Id) && jot.Material1Id != item.MaterialId1)
 | 
						||
                    //{
 | 
						||
                    //    errorCheck += rowIndex + "行,材质1:" + item.Material1Code + "验证不一至,";
 | 
						||
                    //}
 | 
						||
                    //if (!string.IsNullOrEmpty(item.MaterialId2) && !string.IsNullOrEmpty(jot.Material2Id) && jot.Material2Id != item.MaterialId2)
 | 
						||
                    //{
 | 
						||
                    //    errorCheck += rowIndex + "行,材质2:" + item.Material2Code + "验证不一至,";
 | 
						||
                    //}
 | 
						||
                    if (!string.IsNullOrEmpty(item.Components1Id) && !string.IsNullOrEmpty(jot.PipeAssembly1Id) && jot.PipeAssembly1Id != item.Components1Id)
 | 
						||
                    {
 | 
						||
                        errorCheck += rowIndex + "行,组件1:" + item.Components1Code + "验证不一至,";
 | 
						||
                    }
 | 
						||
                    if (!string.IsNullOrEmpty(item.Components2Id) && !string.IsNullOrEmpty(jot.PipeAssembly2Id) && jot.PipeAssembly2Id != item.Components2Id)
 | 
						||
                    {
 | 
						||
                        errorCheck += rowIndex + "行,组件2:" + item.Components2Code + "验证不一至,";
 | 
						||
                    }
 | 
						||
 | 
						||
                    //if (!string.IsNullOrEmpty(item.HeartNo1) && !string.IsNullOrEmpty(jot.HeartNo1) && jot.HeartNo1 != item.HeartNo1)
 | 
						||
                    //{
 | 
						||
                    //    errorCheck += rowIndex + "行,炉批号1:" + item.HeartNo1 + "验证不一至,";
 | 
						||
                    //}
 | 
						||
                    //if (!string.IsNullOrEmpty(item.HeartNo2) && !string.IsNullOrEmpty(jot.HeartNo2) && jot.HeartNo2 != item.HeartNo2)
 | 
						||
                    //{
 | 
						||
                    //    errorCheck += rowIndex + "行,炉批号2:" + item.HeartNo2 + "验证不一至,";
 | 
						||
                    //}
 | 
						||
                    if (!string.IsNullOrEmpty(item.PipeSegment) && !string.IsNullOrEmpty(jot.PipeSegment) && jot.PipeSegment != item.PipeSegment)
 | 
						||
                    {
 | 
						||
                        errorCheck += rowIndex + "行,所属管段:" + item.PipeSegment + "验证不一至,";
 | 
						||
                    }
 | 
						||
                    //if (!string.IsNullOrEmpty(item.WPQId) && !string.IsNullOrEmpty(jot.WPQId) && jot.WPQId != item.WPQId)
 | 
						||
                    //{
 | 
						||
                    //    errorCheck += rowIndex + "行,WPS编号:" + item.WPQCode + "验证不一至,";
 | 
						||
                    //}
 | 
						||
 | 
						||
                    rowIndex++;
 | 
						||
                }
 | 
						||
                #endregion
 | 
						||
 | 
						||
                #region 焊工资质判断,暂不用
 | 
						||
                //// 焊工资质
 | 
						||
                //foreach (var item in GetWeldingDailyItem)
 | 
						||
                //{
 | 
						||
                //    bool canSave = false;
 | 
						||
                //    var jot = BLL.Pipeline_WeldJointService.GetWeldJointByWeldJointId(item.WeldJointId);
 | 
						||
                //    var joty = BLL.Base_WeldTypeService.GetWeldTypeByWeldTypeId(jot.WeldTypeId);
 | 
						||
                //    string weldTypeGroup = joty.Flag;
 | 
						||
                //    string weldTypeCode = joty.WeldTypeCode;
 | 
						||
                //    string floorWelder = item.BackingWelderId;
 | 
						||
                //    string cellWelder = item.CoverWelderId;
 | 
						||
                //    decimal? dia = item.Dia;
 | 
						||
                //    decimal? sch = item.Thickness;
 | 
						||
                //    //string wme = item.WeldingMethodCode;
 | 
						||
                //    //string wmeCode = string.Empty;
 | 
						||
                //    //var wm = BLL.HJGL_WeldingMethodService.GetWeldMethodByWMEID(item.WME_ID);
 | 
						||
                //    //if (wm != null)
 | 
						||
                //    //{
 | 
						||
                //    //    wmeCode = wm.WME_Code;
 | 
						||
                //    //}
 | 
						||
 | 
						||
                //    string[] wmeCodes = item.WeldingMethodCode.Split('+');
 | 
						||
                //    string location = item.WeldingLocationCode;
 | 
						||
                //    string ste = jot.Material1Id;
 | 
						||
                //    var projectWelder = BLL.Welder_ProjectWelderService.GetProjectWelderByProjectIdAndWelderId(this.ProjectId,item.BackingWelderId);
 | 
						||
                //    var projectUnit = BLL.Project_UnitService.GetProject_UnitByProjectIdUnitId(this.ProjectId,projectWelder.UnitId);
 | 
						||
                //    if (projectUnit != null && projectUnit.WelderQueIsUse == true)
 | 
						||
                //    {
 | 
						||
                //        List<Model.Welder_WelderQualify> floorWelderQualifys = (from x in Funs.DB.Welder_WelderQualify
 | 
						||
                //                                                                where x.WelderId == floorWelder && x.WeldingMethodId != null
 | 
						||
                //                                                                               && x.WeldingLocationId != null && x.MaterialType != null
 | 
						||
                //                                                                               && x.WeldType != null
 | 
						||
                //                                                                               && x.ThicknessMax != null && x.SizesMin != null
 | 
						||
                //                                                                select x).ToList();
 | 
						||
 | 
						||
                //        List<Model.Welder_WelderQualify> cellWelderQualifys = (from x in Funs.DB.Welder_WelderQualify
 | 
						||
                //                                                               where x.WelderId == cellWelder && x.WeldingMethodId != null
 | 
						||
                //                                                                            && x.WeldingLocationId != null && x.MaterialType != null
 | 
						||
                //                                                                            && x.WeldType != null
 | 
						||
                //                                                                            && x.ThicknessMax != null && x.SizesMin != null
 | 
						||
                //                                                               select x).ToList();
 | 
						||
                //        // 打底和盖面同一焊工
 | 
						||
                //        if (floorWelder == cellWelder)
 | 
						||
                //        {
 | 
						||
                //            if (floorWelderQualifys != null && floorWelderQualifys.Count() > 0)
 | 
						||
                //            {
 | 
						||
                //                if (wmeCodes.Count() <= 1) // 一种焊接方法
 | 
						||
                //                {
 | 
						||
                //                    canSave = IsOK(floorWelderQualifys, wmeCodes[0], location, weldTypeGroup, ste, dia, sch);
 | 
						||
                //                }
 | 
						||
                //                else  // 大于一种焊接方法,如氩电联焊
 | 
						||
                //                {
 | 
						||
                //                    canSave = TwoWmeIsOK(floorWelderQualifys, cellWelderQualifys, wmeCodes[0], wmeCodes[1], location, weldTypeGroup, ste, dia, sch);
 | 
						||
                //                }
 | 
						||
                //            }
 | 
						||
                //        }
 | 
						||
                //        // 打底和盖面焊工不同
 | 
						||
                //        else
 | 
						||
                //        {
 | 
						||
                //            bool isok1 = false;
 | 
						||
                //            bool isok2 = false;
 | 
						||
 | 
						||
                //            if (wmeCodes.Count() <= 1) // 一种焊接方法
 | 
						||
                //            {
 | 
						||
                //                if (floorWelderQualifys != null && floorWelderQualifys.Count() > 0)
 | 
						||
                //                {
 | 
						||
                //                    isok1 = IsOK(floorWelderQualifys, wmeCodes[0], location, weldTypeGroup, ste, dia, sch);
 | 
						||
                //                }
 | 
						||
                //                if (cellWelderQualifys != null && cellWelderQualifys.Count() > 0)
 | 
						||
                //                {
 | 
						||
                //                    isok2 = IsOK(cellWelderQualifys, wmeCodes[0], location, weldTypeGroup, ste, dia, sch);
 | 
						||
                //                }
 | 
						||
                //                if (isok1 && isok2)
 | 
						||
                //                {
 | 
						||
                //                    canSave = true;
 | 
						||
                //                }
 | 
						||
                //            }
 | 
						||
                //            else
 | 
						||
                //            {
 | 
						||
                //                canSave = TwoWmeIsOK(floorWelderQualifys, cellWelderQualifys, wmeCodes[0], wmeCodes[1], location, weldTypeGroup, ste, dia, sch);
 | 
						||
                //            }
 | 
						||
                //        }
 | 
						||
                //    }
 | 
						||
                //    else
 | 
						||
                //    {
 | 
						||
                //        canSave = true;
 | 
						||
                //    }
 | 
						||
 | 
						||
                //    if (canSave == false)
 | 
						||
                //    {
 | 
						||
                //        eventArg = eventArg + jot.WeldJointCode + ",";
 | 
						||
                //    }
 | 
						||
                //}
 | 
						||
                #endregion
 | 
						||
 | 
						||
                #region 生成管线的随机数 不用了
 | 
						||
                //var pro = BLL.Base_ProjectService.GetProjectByProjectId(this.ProjectId);
 | 
						||
                //// 生成管线的随机数
 | 
						||
                //var romPipe = (from x in GetWeldingDailyItem
 | 
						||
                //               join y in Funs.DB.Pipeline_WeldJoint on x.WeldJointId equals y.WeldJointId
 | 
						||
                //               select y.PipelineId).Distinct();
 | 
						||
                //if (romPipe.Count() > 0)
 | 
						||
                //{
 | 
						||
                //    foreach (string pipeId in romPipe)
 | 
						||
                //    {
 | 
						||
                //        var iso = BLL.Pipeline_PipelineService.GetPipelineByPipelineId(pipeId);
 | 
						||
                //        var pipe = Funs.DB.View_Pipeline_Random.FirstOrDefault(x => x.PipelineId == pipeId);
 | 
						||
                //        int rate = Convert.ToInt32(pipe.DetectionRateValue);
 | 
						||
                //        if (rate != 0)
 | 
						||
                //        {
 | 
						||
                //            // RT 随机数
 | 
						||
                //            int rtTotalJotNum = Convert.ToInt32(pipe.RTTotalJointCount);
 | 
						||
                //            // 已焊焊口数
 | 
						||
                //            int rtWeldingJotNum = Convert.ToInt32(pipe.RTWeldingCount);
 | 
						||
                //            // 已点口数
 | 
						||
                //            int rtPointNum = Convert.ToInt32(pipe.RtPointCount);
 | 
						||
                //            int rtMinValue = rtWeldingJotNum + 1;
 | 
						||
                //            int rtMaxValue = rtTotalJotNum;
 | 
						||
 | 
						||
                //            if (pro.ProjectArea == "2")
 | 
						||
                //            {
 | 
						||
                //                // RT 活动口按管线比例
 | 
						||
                //                int rtPointTotalNum = Convert.ToInt32(Math.Ceiling((double)(rtTotalJotNum * rate) / (double)100));
 | 
						||
                //                int rtnum = rtPointTotalNum - rtPointNum;
 | 
						||
 | 
						||
                //                if (rtnum > 0)
 | 
						||
                //                {
 | 
						||
                //                    int[] r = Funs.GetRandomNum(rtnum, rtMinValue, rtMaxValue);
 | 
						||
                //                    var q = from x in r orderby x select x;
 | 
						||
                //                    string random = string.Empty;
 | 
						||
                //                    foreach (int i in q)
 | 
						||
                //                    {
 | 
						||
                //                        if (i <= rtMaxValue)
 | 
						||
                //                        {
 | 
						||
                //                            random = random + i.ToString() + ",";
 | 
						||
                //                        }
 | 
						||
                //                    }
 | 
						||
                //                    if (random.Length > 0)
 | 
						||
                //                    {
 | 
						||
                //                        string randomNum = random.Substring(0, random.Length - 1);
 | 
						||
                //                        Pipeline_PipelineService.UpdatePipelineRTRandom(pipeId, randomNum);
 | 
						||
                //                    }
 | 
						||
                //                }
 | 
						||
                //            }
 | 
						||
                //            else  //福建: RT检测先按比例分段点口
 | 
						||
                //            {
 | 
						||
                //                int oldRandomNum = 0;
 | 
						||
                //                if (iso != null && !string.IsNullOrEmpty(iso.RandomNum))
 | 
						||
                //                {
 | 
						||
                //                    oldRandomNum = iso.RandomNum.Split(',').Count();
 | 
						||
                //                }
 | 
						||
 | 
						||
                //                int totalJotNum = Convert.ToInt32(pipe.TotalJointCount);
 | 
						||
                //                // 分段num1为向上取整
 | 
						||
                //                int num1 = Convert.ToInt32(Math.Ceiling((double)(totalJotNum * rate) / (double)100));
 | 
						||
                //                // num2为向下取整
 | 
						||
                //                int num2 = Convert.ToInt32(Math.Floor((double)(totalJotNum * rate) / (double)100));
 | 
						||
 | 
						||
                //                // 如相等说明随机数已产生,并符合数量,否则重新计算
 | 
						||
                //                if (oldRandomNum != num1)
 | 
						||
                //                {
 | 
						||
                //                    int min = 1;
 | 
						||
                //                    int max = Convert.ToInt32(Math.Ceiling((double)(100) / (double)(rate)));
 | 
						||
                //                    string random = string.Empty;
 | 
						||
                //                    for (int i = 1; i <= num2; i++)
 | 
						||
                //                    {
 | 
						||
                //                        int[] r = Funs.GetRandomNum(1, min, max);
 | 
						||
                //                        random = random + r[0] + ",";
 | 
						||
                //                    }
 | 
						||
                //                    if (num1 > num2)
 | 
						||
                //                    {
 | 
						||
                //                        int y = totalJotNum - (num2 * max);
 | 
						||
                //                        int[] r = Funs.GetRandomNum(1, min, y);
 | 
						||
                //                        random = random + r[0] + ",";
 | 
						||
                //                    }
 | 
						||
 | 
						||
                //                    if (random.Length > 0)
 | 
						||
                //                    {
 | 
						||
                //                        string randomNum = random.Substring(0, random.Length - 1);
 | 
						||
                //                        Pipeline_PipelineService.UpdatePipelineRTRandom(pipeId, randomNum);
 | 
						||
                //                    }
 | 
						||
                //                }
 | 
						||
 | 
						||
                //                #region 暂不用:固定口(大于管线检测比例的40%,这里按50%计算) 随机数
 | 
						||
                //                // 先优先点固定口(大于管线检测比例的40%,这里按50%计算) 随机数
 | 
						||
                //                //int gdTotalJotNum = Convert.ToInt32(pipe.GDTotalJointCount);
 | 
						||
                //                //int gdWeldingJotNum = Convert.ToInt32(pipe.GDWeldingCount);
 | 
						||
                //                //int gdPointNum = Convert.ToInt32(pipe.GDPointCount);
 | 
						||
                //                //int gdMinValue = gdWeldingJotNum + 1;
 | 
						||
                //                //int gdMaxValue = gdTotalJotNum;
 | 
						||
 | 
						||
                //                //int gdPointTotalNum = Convert.ToInt32(Math.Ceiling((double)(totalJotNum * rate * 0.5) / (double)100));
 | 
						||
                //                //int gdnum = gdPointTotalNum - gdPointNum;
 | 
						||
 | 
						||
                //                //int gdRandomCount = 0;
 | 
						||
                //                //if (gdnum > 0)
 | 
						||
                //                //{
 | 
						||
                //                //    string random = string.Empty;
 | 
						||
                //                //    if (gdnum > gdMaxValue) // 说明固定口数量不够,所以所有固定口都点
 | 
						||
                //                //    {
 | 
						||
                //                //        for (int i = gdMinValue; i <= gdMaxValue; i++)
 | 
						||
                //                //        {
 | 
						||
                //                //            random = random + i.ToString() + ",";
 | 
						||
                //                //        }
 | 
						||
                //                //        gdRandomCount = gdMaxValue - gdMinValue + 1;
 | 
						||
                //                //    }
 | 
						||
                //                //    else
 | 
						||
                //                //    {
 | 
						||
                //                //        int[] r = Funs.GetRandomNum(gdnum, gdMinValue, gdMaxValue);
 | 
						||
                //                //        var q = from x in r orderby x select x;
 | 
						||
                //                //        foreach (int i in q)
 | 
						||
                //                //        {
 | 
						||
                //                //            if (i <= gdMaxValue)
 | 
						||
                //                //            {
 | 
						||
                //                //                random = random + i.ToString() + ",";
 | 
						||
                //                //            }
 | 
						||
                //                //        }
 | 
						||
                //                //        gdRandomCount = q.Count();
 | 
						||
                //                //    }
 | 
						||
                //                //    if (random.Length > 0)
 | 
						||
                //                //    {
 | 
						||
                //                //        string randomNum = random.Substring(0, random.Length - 1);
 | 
						||
                //                //        Pipeline_PipelineService.UpdatePipelineGDRandom(pipeId, randomNum);
 | 
						||
                //                //    }
 | 
						||
 | 
						||
                //                //}
 | 
						||
 | 
						||
                //                //// 活动口
 | 
						||
                //                //// RT 活动口按管线比例
 | 
						||
                //                //int pointTotalNum = Convert.ToInt32(Math.Ceiling((double)(totalJotNum * rate) / (double)100));
 | 
						||
                //                //int rtnum = pointTotalNum - rtPointNum - gdPointNum - gdRandomCount;
 | 
						||
 | 
						||
                //                //if (rtnum > 0)
 | 
						||
                //                //{
 | 
						||
                //                //    string random = string.Empty;
 | 
						||
                //                //    if (rtnum > rtMaxValue) // 说明活动口数量不够,所以所有活动口都点
 | 
						||
                //                //    {
 | 
						||
                //                //        for (int i = rtMinValue; i <= rtMaxValue; i++)
 | 
						||
                //                //        {
 | 
						||
                //                //            random = random + i.ToString() + ",";
 | 
						||
                //                //        }
 | 
						||
                //                //    }
 | 
						||
                //                //    else
 | 
						||
                //                //    {
 | 
						||
                //                //        int[] r = Funs.GetRandomNum(rtnum, rtMinValue, rtMaxValue);
 | 
						||
                //                //        var q = from x in r orderby x select x;
 | 
						||
                //                //        foreach (int i in q)
 | 
						||
                //                //        {
 | 
						||
                //                //            if (i <= rtMaxValue)
 | 
						||
                //                //            {
 | 
						||
                //                //                random = random + i.ToString() + ",";
 | 
						||
                //                //            }
 | 
						||
                //                //        }
 | 
						||
                //                //    }
 | 
						||
                //                //    if (random.Length > 0)
 | 
						||
                //                //    {
 | 
						||
                //                //        string randomNum = random.Substring(0, random.Length - 1);
 | 
						||
                //                //        Pipeline_PipelineService.UpdatePipelineRTRandom(pipeId, randomNum);
 | 
						||
                //                //    }
 | 
						||
                //                //}
 | 
						||
                //                #endregion
 | 
						||
                //            }
 | 
						||
 | 
						||
                //            // PT 随机数
 | 
						||
                //            int ptTotalJotNum = Convert.ToInt32(pipe.PTTotalJointCount);
 | 
						||
                //            int ptWeldingJotNum = Convert.ToInt32(pipe.PTWeldingCount);
 | 
						||
                //            int ptPointNum = Convert.ToInt32(pipe.PtPointCount);
 | 
						||
                //            int ptMinValue = ptWeldingJotNum + 1;
 | 
						||
                //            int ptMaxValue = ptTotalJotNum;
 | 
						||
 | 
						||
                //            int ptPointTotalNum = Convert.ToInt32(Math.Ceiling((double)(ptTotalJotNum * rate) / (double)100));
 | 
						||
                //            int ptnum = ptPointTotalNum - ptPointNum;
 | 
						||
 | 
						||
                //            if (ptnum > 0)
 | 
						||
                //            {
 | 
						||
                //                int[] r = Funs.GetRandomNum(ptnum, ptMinValue, ptMaxValue);
 | 
						||
                //                var q = from x in r orderby x select x;
 | 
						||
                //                string random = string.Empty;
 | 
						||
                //                foreach (int i in q)
 | 
						||
                //                {
 | 
						||
                //                    if (i <= ptMaxValue)
 | 
						||
                //                    {
 | 
						||
                //                        random = random + i.ToString() + ",";
 | 
						||
                //                    }
 | 
						||
                //                }
 | 
						||
                //                if (random.Length > 0)
 | 
						||
                //                {
 | 
						||
                //                    string randomNum = random.Substring(0, random.Length - 1);
 | 
						||
                //                    Pipeline_PipelineService.UpdatePipelinePTRandom(pipeId, randomNum);
 | 
						||
                //                }
 | 
						||
                //            }
 | 
						||
                //        }
 | 
						||
                //    }
 | 
						||
                //}
 | 
						||
                #endregion
 | 
						||
 | 
						||
                if (!string.IsNullOrEmpty(errorCheck))
 | 
						||
                {
 | 
						||
                    errorCheck = errorCheck + "请更正后再提交保存";
 | 
						||
                    ShowNotify(errorCheck, MessageBoxIcon.Warning, 10000);
 | 
						||
                    return;
 | 
						||
                }
 | 
						||
 | 
						||
                // 焊工资质都符合条件
 | 
						||
                if (eventArg == string.Empty)
 | 
						||
                {
 | 
						||
                    Model.Pipeline_WeldingDaily newWeldingDaily = new Model.Pipeline_WeldingDaily();
 | 
						||
                    newWeldingDaily.WeldingDailyCode = this.txtWeldingDailyCode.Text.Trim();
 | 
						||
                    newWeldingDaily.ProjectId = this.ProjectId;
 | 
						||
                    if (this.drpInstallation.SelectedValue != BLL.Const._Null)
 | 
						||
                    {
 | 
						||
                        newWeldingDaily.InstallationId = this.drpInstallation.SelectedValue;
 | 
						||
                    }
 | 
						||
                    newWeldingDaily.UnitId = this.drpUnit.SelectedValue;
 | 
						||
                    DateTime? weldDate = Funs.GetNewDateTime(this.txtWeldingDate.Text);
 | 
						||
                    if (weldDate.HasValue)
 | 
						||
                    {
 | 
						||
                        newWeldingDaily.WeldingDate = weldDate.Value;
 | 
						||
                    }
 | 
						||
                    else
 | 
						||
                    {
 | 
						||
                        newWeldingDaily.WeldingDate = System.DateTime.Now;
 | 
						||
                    }
 | 
						||
                    newWeldingDaily.Tabler = this.hdTablerId.Text;
 | 
						||
                    newWeldingDaily.TableDate = Funs.GetNewDateTime(this.txtTableDate.Text);
 | 
						||
                    newWeldingDaily.Remark = this.txtRemark.Text.Trim();
 | 
						||
 | 
						||
                    if (!string.IsNullOrEmpty(this.WeldingDailyId))
 | 
						||
                    {
 | 
						||
                        newWeldingDaily.WeldingDailyId = this.WeldingDailyId;
 | 
						||
                        BLL.Pipeline_WeldingDailyService.UpdatePipeline_WeldingDaily(newWeldingDaily);
 | 
						||
                        BLL.Sys_LogService.AddLog(BLL.Const.System_3, this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.HJGL_WeldReportMenuId, Const.BtnModify, this.WeldingDailyId);
 | 
						||
                    }
 | 
						||
                    else
 | 
						||
                    {
 | 
						||
                        this.WeldingDailyId = SQLHelper.GetNewID(typeof(Model.Pipeline_WeldingDaily));
 | 
						||
                        newWeldingDaily.WeldingDailyId = this.WeldingDailyId;
 | 
						||
                        BLL.Pipeline_WeldingDailyService.AddPipeline_WeldingDaily(newWeldingDaily);
 | 
						||
                        BLL.Sys_LogService.AddLog(BLL.Const.System_3, this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.HJGL_WeldReportMenuId, Const.BtnAdd, this.WeldingDailyId);
 | 
						||
                    }
 | 
						||
 | 
						||
                    foreach (var item in GetWeldingDailyItem)
 | 
						||
                    {
 | 
						||
                        var newWeldJoint = BLL.Pipeline_WeldJointService.GetWeldJointByWeldJointId(item.WeldJointId);
 | 
						||
                        //var pipeline = BLL.Pipeline_PipelineService.GetPipelineByPipelineId(newWeldJoint.PipelineId);
 | 
						||
                        //var joty = BLL.Base_WeldTypeService.GetWeldTypeByWeldTypeId(item.WeldTypeId);
 | 
						||
                        //string weldTypeCode = joty.WeldTypeCode;
 | 
						||
 | 
						||
                        newWeldJoint.WeldingDailyId = this.WeldingDailyId;
 | 
						||
                        newWeldJoint.WeldingDailyCode = this.txtWeldingDailyCode.Text.Trim();
 | 
						||
                        newWeldJoint.CoverWelderId = item.CoverWelderId;
 | 
						||
                        newWeldJoint.BackingWelderId = item.BackingWelderId;
 | 
						||
                        newWeldJoint.Size = item.Size;
 | 
						||
                        newWeldJoint.DoneDin = item.Size;
 | 
						||
                        newWeldJoint.ANSISCH = item.ANSISCH;
 | 
						||
 | 
						||
                        var dn = from x in Funs.DB.Base_DNCompare where x.PipeSize == item.Size select x;
 | 
						||
                        string ansi = item.ANSISCH;
 | 
						||
                        decimal? dia = null;
 | 
						||
                        decimal? sch = null;
 | 
						||
                        if (dn.Count() > 0)
 | 
						||
                        {
 | 
						||
                            if (dn.First().OutSizeDia != null)
 | 
						||
                            {
 | 
						||
                                dia = dn.First().OutSizeDia;
 | 
						||
                                newWeldJoint.Dia = dia;
 | 
						||
                            }
 | 
						||
 | 
						||
                            if (ansi == "5")
 | 
						||
                            {
 | 
						||
                                if (dn.First().SCH5 != null)
 | 
						||
                                {
 | 
						||
                                    sch = dn.First().SCH5;
 | 
						||
                                }
 | 
						||
                            }
 | 
						||
                            if (ansi == "5S")
 | 
						||
                            {
 | 
						||
                                if (dn.First().SCH5S != null)
 | 
						||
                                {
 | 
						||
                                    sch = dn.First().SCH5S;
 | 
						||
                                }
 | 
						||
                            }
 | 
						||
                            if (ansi == "10")
 | 
						||
                            {
 | 
						||
                                if (dn.First().SCH10 != null)
 | 
						||
                                {
 | 
						||
                                    sch = dn.First().SCH10;
 | 
						||
                                }
 | 
						||
                            }
 | 
						||
                            if (ansi == "10S")
 | 
						||
                            {
 | 
						||
                                if (dn.First().SCH10S != null)
 | 
						||
                                {
 | 
						||
                                    sch = dn.First().SCH10S;
 | 
						||
                                }
 | 
						||
                            }
 | 
						||
                            if (ansi == "20")
 | 
						||
                            {
 | 
						||
                                if (dn.First().SCH20 != null)
 | 
						||
                                {
 | 
						||
                                    sch = dn.First().SCH20;
 | 
						||
                                }
 | 
						||
                            }
 | 
						||
                            if (ansi == "30")
 | 
						||
                            {
 | 
						||
                                if (dn.First().SCH30 != null)
 | 
						||
                                {
 | 
						||
                                    sch = dn.First().SCH30;
 | 
						||
                                }
 | 
						||
                            }
 | 
						||
                            if (ansi == "40")
 | 
						||
                            {
 | 
						||
                                if (dn.First().SCH40 != null)
 | 
						||
                                {
 | 
						||
                                    sch = dn.First().SCH40;
 | 
						||
                                }
 | 
						||
                            }
 | 
						||
                            if (ansi == "40S")
 | 
						||
                            {
 | 
						||
                                if (dn.First().SCH40S != null)
 | 
						||
                                {
 | 
						||
                                    sch = dn.First().SCH40S;
 | 
						||
                                }
 | 
						||
                            }
 | 
						||
                            if (ansi == "STD")
 | 
						||
                            {
 | 
						||
                                if (dn.First().STD != null)
 | 
						||
                                {
 | 
						||
                                    sch = dn.First().STD;
 | 
						||
                                }
 | 
						||
                            }
 | 
						||
                            if (ansi == "60")
 | 
						||
                            {
 | 
						||
                                if (dn.First().SCH60 != null)
 | 
						||
                                {
 | 
						||
                                    sch = dn.First().SCH60;
 | 
						||
                                }
 | 
						||
                            }
 | 
						||
                            if (ansi == "80")
 | 
						||
                            {
 | 
						||
                                if (dn.First().SCH80 != null)
 | 
						||
                                {
 | 
						||
                                    sch = dn.First().SCH80;
 | 
						||
                                }
 | 
						||
                            }
 | 
						||
                            if (ansi == "80S")
 | 
						||
                            {
 | 
						||
                                if (dn.First().SCH80S != null)
 | 
						||
                                {
 | 
						||
                                    sch = dn.First().SCH80S;
 | 
						||
                                }
 | 
						||
                            }
 | 
						||
                            if (ansi == "XS")
 | 
						||
                            {
 | 
						||
                                if (dn.First().XS != null)
 | 
						||
                                {
 | 
						||
                                    sch = dn.First().XS;
 | 
						||
                                }
 | 
						||
                            }
 | 
						||
                            if (ansi == "100")
 | 
						||
                            {
 | 
						||
                                if (dn.First().SCH100 != null)
 | 
						||
                                {
 | 
						||
                                    sch = dn.First().SCH100;
 | 
						||
                                }
 | 
						||
                            }
 | 
						||
                            if (ansi == "120")
 | 
						||
                            {
 | 
						||
                                if (dn.First().SCH120 != null)
 | 
						||
                                {
 | 
						||
                                    sch = dn.First().SCH120;
 | 
						||
                                }
 | 
						||
                            }
 | 
						||
                            if (ansi == "140")
 | 
						||
                            {
 | 
						||
                                if (dn.First().SCH140 != null)
 | 
						||
                                {
 | 
						||
                                    sch = dn.First().SCH140;
 | 
						||
                                }
 | 
						||
                            }
 | 
						||
                            if (ansi == "160")
 | 
						||
                            {
 | 
						||
                                if (dn.First().SCH160 != null)
 | 
						||
                                {
 | 
						||
                                    sch = dn.First().SCH160;
 | 
						||
                                }
 | 
						||
                            }
 | 
						||
                            if (ansi == "XXS")
 | 
						||
                            {
 | 
						||
                                if (dn.First().XXS != null)
 | 
						||
                                {
 | 
						||
                                    sch = dn.First().XXS;
 | 
						||
                                }
 | 
						||
                            }
 | 
						||
 | 
						||
                            newWeldJoint.Thickness = sch;
 | 
						||
 | 
						||
                            if (dia != null && sch != null)
 | 
						||
                            {
 | 
						||
                                newWeldJoint.Specification = "Φ" + Funs.GetClearZero(dia.Value) + "×" + Funs.GetClearZero(sch.Value);
 | 
						||
                            }
 | 
						||
                        }
 | 
						||
 | 
						||
                        //newWeldJoint.Dia = item.Dia;
 | 
						||
                        //newWeldJoint.Thickness = item.Thickness;
 | 
						||
                        //if (item.Dia != null && item.Thickness != null)
 | 
						||
                        //{
 | 
						||
                        //    newWeldJoint.Specification = "Φ" + Funs.GetClearZero(item.Dia.Value) + "×" + Funs.GetClearZero(item.Thickness.Value);
 | 
						||
                        //}
 | 
						||
                        newWeldJoint.JointAttribute = item.JointAttribute;
 | 
						||
                        newWeldJoint.JointArea = item.JointArea;
 | 
						||
                        newWeldJoint.WeldingLocationId = item.WeldingLocationId;
 | 
						||
 | 
						||
                        newWeldJoint.Material1Id = item.MaterialId1;
 | 
						||
                        newWeldJoint.Material2Id = item.MaterialId2;
 | 
						||
                        newWeldJoint.HeartNo1 = item.HeartNo1;
 | 
						||
                        newWeldJoint.HeartNo2 = item.HeartNo2;
 | 
						||
                        newWeldJoint.PipeAssembly1Id = item.Components1Id;
 | 
						||
                        newWeldJoint.PipeAssembly2Id = item.Components2Id;
 | 
						||
                        //newWeldJoint.WeldingMethodId = item.WeldingMethodId;
 | 
						||
                        //newWeldJoint.WeldMatId = item.WeldMatId;
 | 
						||
                        //newWeldJoint.WeldSilkId = item.WeldSilkId;
 | 
						||
                        newWeldJoint.WeldingDate = newWeldingDaily.WeldingDate;
 | 
						||
                        newWeldJoint.PipeSegment = item.PipeSegment;
 | 
						||
                        newWeldJoint.WPQId = item.WPQId;
 | 
						||
 | 
						||
                        var wps = Funs.DB.WPQ_WPQList.FirstOrDefault(x => x.WPQId == item.WPQId);
 | 
						||
                        if (wps != null)
 | 
						||
                        {
 | 
						||
                            if (!string.IsNullOrEmpty(wps.WeldingMethodId))
 | 
						||
                            {
 | 
						||
                                newWeldJoint.WeldingMethodId = wps.WeldingMethodId;
 | 
						||
                            }
 | 
						||
                            if (!string.IsNullOrEmpty(wps.WeldMatId))
 | 
						||
                            {
 | 
						||
                                newWeldJoint.WeldMatId = wps.WeldMatId;
 | 
						||
                            }
 | 
						||
                            if (!string.IsNullOrEmpty(wps.WeldSilkId))
 | 
						||
                            {
 | 
						||
                                newWeldJoint.WeldSilkId = wps.WeldSilkId.Replace("|", ",");
 | 
						||
                            }
 | 
						||
                        }
 | 
						||
 | 
						||
                        BLL.Pipeline_WeldJointService.UpdateWeldJoint(newWeldJoint);
 | 
						||
 | 
						||
                        //更新焊口号 修改固定焊口号后 +G
 | 
						||
                        //BLL.Pipeline_WeldJointService.UpdateWeldJointAddG(newWeldJoint.WeldJointId, newWeldJoint.JointAttribute, Const.BtnAdd);
 | 
						||
 | 
						||
                        BLL.Batch_PointBatchItemService.InsertPointBatch(this.ProjectId, this.drpUnit.SelectedValue, this.drpInstallation.SelectedValue,item.BackingWelderId ,item.CoverWelderId, item.WeldJointId, newWeldingDaily.WeldingDate);
 | 
						||
 | 
						||
                    }
 | 
						||
 | 
						||
                    #region 新建日报及焊工每天超过60达因的提示(暂不用)
 | 
						||
                    //// 新建日报
 | 
						||
                    //if (weldlines.Count() == 0)
 | 
						||
                    //{
 | 
						||
                    //    foreach (var item in GetWeldingDailyItem)
 | 
						||
                    //    {
 | 
						||
                    //        errlog += InsertWeldingDailyItem(item, newWeldingDaily.WeldingDate, true);
 | 
						||
                    //    }
 | 
						||
                    //}
 | 
						||
 | 
						||
                    //// 日报已存在的情况
 | 
						||
                    //else
 | 
						||
                    //{
 | 
						||
                    //    var weldJoints = from x in weldlines select x.WeldJointId;
 | 
						||
                    //    foreach (var item in GetWeldingDailyItem)
 | 
						||
                    //    {
 | 
						||
                    //        // 如日报明细存在则只更新焊口信息,如进批条件改变,则只有删除后再重新增加
 | 
						||
                    //        if (weldJoints.Contains(item.WeldJointId))
 | 
						||
                    //        {
 | 
						||
                    //            var newWeldJoint = BLL.Pipeline_WeldJointService.GetWeldJointByWeldJointId(item.WeldJointId);
 | 
						||
                    //            newWeldJoint.WeldingDailyId = this.WeldingDailyId;
 | 
						||
                    //            newWeldJoint.WeldingDailyCode = this.txtWeldingDailyCode.Text.Trim();
 | 
						||
                    //            //newWeldJoint.CoverWelderId = item.CoverWelderId;
 | 
						||
                    //            //newWeldJoint.BackingWelderId = item.BackingWelderId;
 | 
						||
                    //            newWeldJoint.WeldTypeId = item.WeldTypeId;
 | 
						||
                    //            //newWeldJoint.JointArea = item.JointArea;
 | 
						||
                    //            newWeldJoint.DoneDin = item.DoneDin;
 | 
						||
                    //            if (!string.IsNullOrEmpty(item.JointAttribute))
 | 
						||
                    //            {
 | 
						||
                    //                newWeldJoint.JointAttribute = item.JointAttribute;
 | 
						||
                    //                if (item.JointAttribute == "活动S")
 | 
						||
                    //                {
 | 
						||
                    //                    newWeldJoint.JointArea = "S";
 | 
						||
                    //                }
 | 
						||
                    //                else
 | 
						||
                    //                {
 | 
						||
                    //                    newWeldJoint.JointArea = "F";
 | 
						||
                    //                }
 | 
						||
                    //            }
 | 
						||
 | 
						||
 | 
						||
                    //            newWeldJoint.WeldingLocationId = item.WeldingLocationId;
 | 
						||
                    //            BLL.Pipeline_WeldJointService.UpdateWeldJoint(newWeldJoint);
 | 
						||
                    //            //更新焊口号 修改固定焊口号后 +G
 | 
						||
                    //            //BLL.Pipeline_WeldJointService.UpdateWeldJointAddG(newWeldJoint.WeldJointId, newWeldJoint.JointAttribute, Const.BtnAdd);
 | 
						||
 | 
						||
                    //        }
 | 
						||
                    //        else
 | 
						||
                    //        {
 | 
						||
                    //            errlog += InsertWeldingDailyItem(item, newWeldingDaily.WeldingDate, true);
 | 
						||
                    //        }
 | 
						||
                    //    }
 | 
						||
                    //}
 | 
						||
 | 
						||
 | 
						||
 | 
						||
                    // 焊工每天超过60达因的提示(暂不用)
 | 
						||
                    //foreach (var item in GetWeldingDailyItem)
 | 
						||
                    //{
 | 
						||
                    //    if (!string.IsNullOrEmpty(item.CoverWelderId) && !string.IsNullOrEmpty(item.BackingWelderId))
 | 
						||
                    //    {
 | 
						||
                    //        bool cWelder = BLL.Pipeline_WeldJointService.GetWelderLimitDN(this.ProjectId, item.CoverWelderId, newWeldingDaily.WeldingDate.Value);
 | 
						||
                    //        bool bWelder = cWelder;
 | 
						||
                    //        if (item.CoverWelderId != item.BackingWelderId)
 | 
						||
                    //        {
 | 
						||
                    //            bWelder = BLL.Pipeline_WeldJointService.GetWelderLimitDN(this.ProjectId, item.BackingWelderId, newWeldingDaily.WeldingDate.Value);
 | 
						||
                    //        }
 | 
						||
 | 
						||
                    //        if (cWelder || bWelder)
 | 
						||
                    //        {
 | 
						||
                    //            if (cWelder)
 | 
						||
                    //            {
 | 
						||
                    //                var coverWelder = BLL.WelderService.GetWelderById(item.CoverWelderId);
 | 
						||
                    //                if (coverWelder != null)
 | 
						||
                    //                {
 | 
						||
                    //                    string txt = Resources.Lan.WelderCode + coverWelder.WelderCode + Resources.Lan.WeldingDiameter;
 | 
						||
                    //                    if (!errlog.Contains(txt))
 | 
						||
                    //                    {
 | 
						||
                    //                        errlog += txt;
 | 
						||
                    //                    }
 | 
						||
                    //                }
 | 
						||
                    //            }
 | 
						||
 | 
						||
                    //            if (bWelder)
 | 
						||
                    //            {
 | 
						||
                    //                var backingWelder = BLL.WelderService.GetWelderById(item.BackingWelderId);
 | 
						||
                    //                if (backingWelder != null)
 | 
						||
                    //                {
 | 
						||
                    //                    string txt = Resources.Lan.WelderCode + backingWelder.WelderCode + Resources.Lan.WeldingDiameter;
 | 
						||
                    //                    if (!errlog.Contains(txt))
 | 
						||
                    //                    {
 | 
						||
                    //                        errlog += txt;
 | 
						||
                    //                    }
 | 
						||
                    //                }
 | 
						||
                    //            }
 | 
						||
                    //        }
 | 
						||
                    //    }
 | 
						||
                    //}
 | 
						||
 | 
						||
                    #endregion
 | 
						||
 | 
						||
                    ShowNotify(Resources.Lan.SaveSuccessfully, MessageBoxIcon.Success);
 | 
						||
                    PageContext.RegisterStartupScript(ActiveWindow.GetHideRefreshReference());
 | 
						||
                }
 | 
						||
                else
 | 
						||
                {
 | 
						||
                    Alert.ShowInTop(Resources.Lan.NoQualification + "【" + eventArg + "】" + Resources.Lan.WeldingConditions, Resources.Lan.SubmitResults, MessageBoxIcon.Warning);
 | 
						||
                }
 | 
						||
            }
 | 
						||
            else
 | 
						||
            {
 | 
						||
                ShowNotify(Resources.Lan.NoPrivilegePrompt, MessageBoxIcon.Warning);
 | 
						||
                return;
 | 
						||
            }
 | 
						||
        }
 | 
						||
        #endregion
 | 
						||
 | 
						||
        #region 日报明细插入(更新焊口信息),组批等 (暂不用)
 | 
						||
        /// <summary>
 | 
						||
        /// 日报明细插入(更新焊口信息),组批等
 | 
						||
        /// </summary>
 | 
						||
        /// <param name="item"></param>
 | 
						||
        /// <param name="weldingDailyId"></param>
 | 
						||
        /// <returns></returns>
 | 
						||
        private string InsertWeldingDailyItem(Model.SpWeldingDailyItem item, DateTime? weldingDate, bool isSave)
 | 
						||
        {
 | 
						||
            string errlog = string.Empty;
 | 
						||
            var newWeldJoint = BLL.Pipeline_WeldJointService.GetWeldJointByWeldJointId(item.WeldJointId);
 | 
						||
            var pipeline = BLL.Pipeline_PipelineService.GetPipelineByPipelineId(newWeldJoint.PipelineId);
 | 
						||
 | 
						||
            if (newWeldJoint != null && string.IsNullOrEmpty(newWeldJoint.WeldingDailyId))
 | 
						||
            {
 | 
						||
                if (!string.IsNullOrEmpty(item.CoverWelderId) && !string.IsNullOrEmpty(item.BackingWelderId))
 | 
						||
                {
 | 
						||
                    
 | 
						||
                    canSave = true;
 | 
						||
 | 
						||
                    if (canSave ==true)   //全部条件符合
 | 
						||
                    {
 | 
						||
                        if (isSave)
 | 
						||
                        {
 | 
						||
                            newWeldJoint.WeldingDailyId = this.WeldingDailyId;
 | 
						||
                            newWeldJoint.WeldingDailyCode = this.txtWeldingDailyCode.Text.Trim();
 | 
						||
                            newWeldJoint.CoverWelderId = item.CoverWelderId;
 | 
						||
                            newWeldJoint.BackingWelderId = item.BackingWelderId;
 | 
						||
                            newWeldJoint.WeldTypeId = item.WeldTypeId;
 | 
						||
                            newWeldJoint.JointArea = item.JointArea;
 | 
						||
                            newWeldJoint.DoneDin = item.DoneDin;
 | 
						||
                            newWeldJoint.JointAttribute = item.JointAttribute;
 | 
						||
                            newWeldJoint.WeldingLocationId = item.WeldingLocationId;
 | 
						||
                            BLL.Pipeline_WeldJointService.UpdateWeldJoint(newWeldJoint);
 | 
						||
                            //更新焊口号 修改固定焊口号后 +G
 | 
						||
                            //BLL.Pipeline_WeldJointService.UpdateWeldJointAddG(newWeldJoint.WeldJointId, newWeldJoint.JointAttribute, Const.BtnAdd);
 | 
						||
 | 
						||
                            // 进批
 | 
						||
                            //BLL.Batch_PointBatchItemService.InsertPointBatch(this.ProjectId, this.drpUnit.SelectedValue, this.drpInstallation.SelectedValue, item.CoverWelderId, item.WeldJointId, weldingDate);
 | 
						||
                        }
 | 
						||
                    }
 | 
						||
                    else
 | 
						||
                    {
 | 
						||
                        errlog = Resources.Lan.NoQualification + "【" + newWeldJoint.WeldJointCode + "】" + Resources.Lan.WeldingConditions;
 | 
						||
                    }
 | 
						||
 | 
						||
 | 
						||
                }
 | 
						||
                else
 | 
						||
                {
 | 
						||
                    errlog = Resources.Lan.WeldingJoint + "【" + newWeldJoint.WeldJointCode + "】" + Resources.Lan.NoWelderSelected;
 | 
						||
                }
 | 
						||
            }
 | 
						||
 | 
						||
            return errlog;
 | 
						||
        }
 | 
						||
        #endregion
 | 
						||
 | 
						||
        #region 收集Grid页面信息
 | 
						||
        /// <summary>
 | 
						||
        /// 收集Grid页面信息
 | 
						||
        /// </summary>
 | 
						||
        /// <returns></returns>
 | 
						||
        private List<Model.SpWeldingDailyItem> CollectGridJointInfo()
 | 
						||
        {
 | 
						||
            List<Model.SpWeldingDailyItem> GetWeldingDailyItem = null;
 | 
						||
            List<Model.SpWeldingDailyItem> getNewWeldReportItem = new List<Model.SpWeldingDailyItem>();
 | 
						||
            if (!string.IsNullOrEmpty(this.hdItemsString.Text))
 | 
						||
            {
 | 
						||
                GetWeldingDailyItem = BLL.Pipeline_WeldingDailyService.GetWeldReportAddItem(this.hdItemsString.Text);
 | 
						||
            }
 | 
						||
            else if (string.IsNullOrEmpty(this.hdItemsString.Text) && this.WeldingDailyId != null)
 | 
						||
            {
 | 
						||
                GetWeldingDailyItem = BLL.Pipeline_WeldingDailyService.GetWeldingDailyItem(this.WeldingDailyId);
 | 
						||
            }
 | 
						||
 | 
						||
            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>("WeldJointId").ToString();
 | 
						||
                var item = GetWeldingDailyItem.FirstOrDefault(x => x.WeldJointId == rowID);
 | 
						||
                if (item != null)
 | 
						||
                {
 | 
						||
                    var coverWelderCode = (from x in Funs.DB.Welder_Welder
 | 
						||
                                           join y in Funs.DB.Welder_ProjectWelder
 | 
						||
                                           on x.WelderId equals y.WelderId
 | 
						||
                                           where y.ProjectId == this.ProjectId && x.WelderCode == values.Value<string>("CoverWelderId")
 | 
						||
                                           select x).FirstOrDefault();
 | 
						||
                    if (coverWelderCode != null)
 | 
						||
                    {
 | 
						||
                        item.CoverWelderCode = coverWelderCode.WelderCode;
 | 
						||
                        item.CoverWelderId = coverWelderCode.WelderId;
 | 
						||
                    }
 | 
						||
                    var backingWelderCode = (from x in Funs.DB.Welder_Welder
 | 
						||
                                             join y in Funs.DB.Welder_ProjectWelder
 | 
						||
                                             on x.WelderId equals y.WelderId
 | 
						||
                                             where y.ProjectId == this.ProjectId && x.WelderCode == values.Value<string>("BackingWelderId")
 | 
						||
                                             select x).FirstOrDefault();
 | 
						||
                    if (backingWelderCode != null)
 | 
						||
                    {
 | 
						||
                        item.BackingWelderCode = backingWelderCode.WelderCode;
 | 
						||
                        item.BackingWelderId = backingWelderCode.WelderId;
 | 
						||
                    }
 | 
						||
                    var weldType = (from x in Funs.DB.Base_WeldType
 | 
						||
                                    where x.WeldTypeCode == values.Value<string>("WeldTypeId")
 | 
						||
                                    select x).FirstOrDefault();
 | 
						||
                    if (weldType != null)
 | 
						||
                    {
 | 
						||
                        item.WeldTypeId = weldType.WeldTypeId;
 | 
						||
                    }
 | 
						||
                    //item.JointArea = values.Value<string>("JointArea").ToString();
 | 
						||
                    if (!string.IsNullOrEmpty(values.Value<string>("JointAttribute")))
 | 
						||
                    {
 | 
						||
                        item.JointAttribute = values.Value<string>("JointAttribute").ToString();
 | 
						||
                        if (item.JointAttribute == "活动S")
 | 
						||
                        {
 | 
						||
                            item.JointArea = "S";
 | 
						||
                        }
 | 
						||
                        else
 | 
						||
                        {
 | 
						||
                            item.JointArea = "F";
 | 
						||
                        }
 | 
						||
                    }
 | 
						||
                    var weldingLocation = (from x in Funs.DB.Base_WeldingLocation
 | 
						||
                                           where x.WeldingLocationCode == values.Value<string>("WeldingLocationId")
 | 
						||
                                           select x).FirstOrDefault();
 | 
						||
                    if (weldingLocation != null)
 | 
						||
                    {
 | 
						||
                        item.WeldingLocationCode = values.Value<string>("WeldingLocationId").ToString();
 | 
						||
                        item.WeldingLocationId = weldingLocation.WeldingLocationId;
 | 
						||
                    }
 | 
						||
                    item.Size = Funs.GetNewDecimalOrZero(values.Value<string>("DoneDin").ToString());
 | 
						||
                    item.DoneDin = Funs.GetNewDecimalOrZero(values.Value<string>("DoneDin").ToString());
 | 
						||
                    item.HeartNo1= values.Value<string>("HeartNo1").ToString();
 | 
						||
                    item.HeartNo2 = values.Value<string>("HeartNo2").ToString();
 | 
						||
                    item.Specification= values.Value<string>("Specification").ToString();
 | 
						||
                    //var wmt = (from x in Funs.DB.Base_WeldingMethod
 | 
						||
                    //                where x.WeldingMethodCode == values.Value<string>("WeldingMethodCode")
 | 
						||
                    //                select x).FirstOrDefault();
 | 
						||
                    //if (wmt != null)
 | 
						||
                    //{
 | 
						||
                    //    item.WeldingMethodId = wmt.WeldingMethodId;
 | 
						||
                    //}
 | 
						||
 | 
						||
                    var mat1= (from x in Funs.DB.Base_Material
 | 
						||
                              where x.MaterialCode == values.Value<string>("Material1Code")
 | 
						||
                              select x).FirstOrDefault();
 | 
						||
                    if (mat1 != null)
 | 
						||
                    {
 | 
						||
                        item.Material1Code = values.Value<string>("Material1Code").ToString();
 | 
						||
                        item.MaterialId1 = mat1.MaterialId;
 | 
						||
                    }
 | 
						||
 | 
						||
                    var mat2 = (from x in Funs.DB.Base_Material
 | 
						||
                                where x.MaterialCode == values.Value<string>("Material2Code")
 | 
						||
                                select x).FirstOrDefault();
 | 
						||
                    if (mat2 != null)
 | 
						||
                    {
 | 
						||
                        item.Material2Code = values.Value<string>("Material2Code").ToString();
 | 
						||
                        item.MaterialId2 = mat2.MaterialId;
 | 
						||
                    }
 | 
						||
 | 
						||
                    item.ANSISCH = values.Value<string>("ANSISCH");
 | 
						||
 | 
						||
                    var com1 = (from x in Funs.DB.Base_Components
 | 
						||
                                where x.ComponentsCode == values.Value<string>("Components1Code")
 | 
						||
                                    select x).FirstOrDefault();
 | 
						||
                    if (com1 != null)
 | 
						||
                    {
 | 
						||
                        item.Components1Code = values.Value<string>("Components1Code").ToString();
 | 
						||
                        item.Components1Id = com1.ComponentsId;
 | 
						||
                    }
 | 
						||
                    var com2 = (from x in Funs.DB.Base_Components
 | 
						||
                                where x.ComponentsCode == values.Value<string>("Components2Code")
 | 
						||
                                select x).FirstOrDefault();
 | 
						||
                    if (com2 != null)
 | 
						||
                    {
 | 
						||
                        item.Components2Code = values.Value<string>("Components2Code").ToString();
 | 
						||
                        item.Components2Id = com2.ComponentsId;
 | 
						||
                    }
 | 
						||
 | 
						||
                    //var weldSilk = (from x in Funs.DB.Base_Consumables
 | 
						||
                    //            where x.ConsumablesCode == values.Value<string>("WeldSilkCode")
 | 
						||
                    //            select x).FirstOrDefault();
 | 
						||
                    //string WeldSilkCodes = values.Value<string>("WeldSilkCode");
 | 
						||
                    //if (!string.IsNullOrEmpty(WeldSilkCodes))
 | 
						||
                    //{
 | 
						||
                    //    string weldSilkIds = string.Empty;
 | 
						||
                    //    string[] weldSilkCodes = WeldSilkCodes.Split(',');
 | 
						||
                    //    if (weldSilkCodes.Count() > 0)
 | 
						||
                    //    {
 | 
						||
                    //        foreach (string s in weldSilkCodes)
 | 
						||
                    //        {
 | 
						||
                    //            var silk = Funs.DB.Base_Consumables.FirstOrDefault(e => e.ConsumablesCode == s);
 | 
						||
                    //            if (silk != null)
 | 
						||
                    //            {
 | 
						||
                    //                weldSilkIds = weldSilkIds + silk.ConsumablesId + ',';
 | 
						||
                    //            }
 | 
						||
 | 
						||
                    //        }
 | 
						||
                    //        if (weldSilkIds.Length > 0)
 | 
						||
                    //        {
 | 
						||
                    //            weldSilkIds = weldSilkIds.Substring(0, weldSilkIds.Length - 1);
 | 
						||
                    //        }
 | 
						||
                    //    }
 | 
						||
                    //    item.WeldSilkId = weldSilkIds;
 | 
						||
                    //}
 | 
						||
                    //if (weldSilk != null)
 | 
						||
                    //{
 | 
						||
                    //    item.WeldSilkId = weldSilk.ConsumablesId;
 | 
						||
                    //}
 | 
						||
 | 
						||
                    //var weldMat = (from x in Funs.DB.Base_Consumables
 | 
						||
                    //                where x.ConsumablesCode == values.Value<string>("WeldMatCode")
 | 
						||
                    //                select x).FirstOrDefault();
 | 
						||
                    //if (weldMat != null)
 | 
						||
                    //{
 | 
						||
                    //    item.WeldMatId = weldMat.ConsumablesId;
 | 
						||
                    //}
 | 
						||
 | 
						||
                    item.PipeSegment = values.Value<string>("PipeSegment").ToString();
 | 
						||
 | 
						||
                    var wps = (from x in Funs.DB.WPQ_WPQList
 | 
						||
                                where x.WPQCode == values.Value<string>("WPQCode") && x.ProjectId==CurrUser.LoginProjectId
 | 
						||
                                select x).FirstOrDefault();
 | 
						||
                    if (wps != null)
 | 
						||
                    {
 | 
						||
                        item.WPQCode = values.Value<string>("WPQCode");
 | 
						||
                        item.WPQId = wps.WPQId;
 | 
						||
                        if (!string.IsNullOrEmpty(wps.WeldingMethodId))
 | 
						||
                        {
 | 
						||
                            item.WeldingMethodId = wps.WeldingMethodId;
 | 
						||
                        }
 | 
						||
                        if (!string.IsNullOrEmpty(wps.WeldMatId))
 | 
						||
                        {
 | 
						||
                            item.WeldMatId = wps.WeldMatId;
 | 
						||
                        }
 | 
						||
                        if (!string.IsNullOrEmpty(wps.WeldSilkId))
 | 
						||
                        {
 | 
						||
                            item.WeldSilkId = wps.WeldSilkId.Replace("|", ",");
 | 
						||
                        }
 | 
						||
                    }
 | 
						||
 | 
						||
                    getNewWeldReportItem.Add(item);
 | 
						||
                }
 | 
						||
 | 
						||
            }
 | 
						||
            return getNewWeldReportItem;
 | 
						||
        }
 | 
						||
        #endregion
 | 
						||
 | 
						||
        #region Grid 关闭弹出窗口事件
 | 
						||
        /// <summary>
 | 
						||
        /// 关闭弹出窗口
 | 
						||
        /// </summary>
 | 
						||
        /// <param name="sender"></param>
 | 
						||
        /// <param name="e"></param>
 | 
						||
        protected void Window1_Close(object sender, WindowCloseEventArgs e)
 | 
						||
        {
 | 
						||
            List<Model.SpWeldingDailyItem> GetWeldingDailyItem = BLL.Pipeline_WeldingDailyService.GetWeldReportAddItem(this.hdItemsString.Text);
 | 
						||
            this.BindGrid(GetWeldingDailyItem);
 | 
						||
            //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.SpWeldingDailyItem> GetWeldingDailyItem = this.CollectGridJointInfo();
 | 
						||
                foreach (int rowIndex in Grid1.SelectedRowIndexArray)
 | 
						||
                {
 | 
						||
                    string rowID = Grid1.DataKeys[rowIndex][0].ToString();
 | 
						||
                    var item = GetWeldingDailyItem.FirstOrDefault(x => x.WeldJointId == rowID);
 | 
						||
                    if (item != null && !BLL.Batch_NDEItemService.IsCheckedByWeldJoint(rowID))
 | 
						||
                    {
 | 
						||
                        GetWeldingDailyItem.Remove(item);
 | 
						||
                        // 删除焊口所在批和委托检测里信息
 | 
						||
                        BLL.Batch_NDEItemService.DeleteAllNDEInfoToWeldJoint(item.WeldJointId);
 | 
						||
 | 
						||
                        // 更新焊口信息
 | 
						||
                        var updateWeldJoint = BLL.Pipeline_WeldJointService.GetWeldJointByWeldJointId(item.WeldJointId);
 | 
						||
                        if (updateWeldJoint != null)
 | 
						||
                        {
 | 
						||
                            updateWeldJoint.WeldingDailyId = null;
 | 
						||
                            updateWeldJoint.WeldingDailyCode = null;
 | 
						||
                            updateWeldJoint.CoverWelderId = null;
 | 
						||
                            updateWeldJoint.BackingWelderId = null;
 | 
						||
                            BLL.Pipeline_WeldJointService.UpdateWeldJoint(updateWeldJoint);
 | 
						||
                        }
 | 
						||
                    }
 | 
						||
                    else
 | 
						||
                    {
 | 
						||
                        Alert.ShowInTop("不能删除,已检测并审核!", MessageBoxIcon.Warning);
 | 
						||
                    }
 | 
						||
                }
 | 
						||
 | 
						||
                BindGrid(GetWeldingDailyItem);
 | 
						||
                ShowNotify(Resources.Lan.DeletedSuccessfully, MessageBoxIcon.Success);
 | 
						||
            }
 | 
						||
        }
 | 
						||
        #endregion
 | 
						||
 | 
						||
        #region 资质分析
 | 
						||
        private bool IsOK(List<Model.Welder_WelderQualify> welderQualifys, string wmeCode, string location, string weldTypeGroup, string ste, decimal? dia, decimal? sch)
 | 
						||
        {
 | 
						||
            bool isok = false;
 | 
						||
            foreach (var welderQualify in welderQualifys)
 | 
						||
            {
 | 
						||
                int okNum = 0;
 | 
						||
 | 
						||
                if (!string.IsNullOrEmpty(wmeCode))   //焊接方法
 | 
						||
                {
 | 
						||
                    if (wmeCode.Contains(welderQualify.WeldingMethodId))
 | 
						||
                    {
 | 
						||
                        okNum++;
 | 
						||
                    }
 | 
						||
                }
 | 
						||
                else
 | 
						||
                {
 | 
						||
                    okNum++;
 | 
						||
                }
 | 
						||
 | 
						||
                if (welderQualify.WeldingLocationId == "ALL")   //焊接位置
 | 
						||
                {
 | 
						||
                    okNum++;
 | 
						||
                }
 | 
						||
                else
 | 
						||
                {
 | 
						||
                    if (!string.IsNullOrEmpty(location))
 | 
						||
                    {
 | 
						||
                        if (welderQualify.WeldingLocationId.Contains(location))
 | 
						||
                        {
 | 
						||
                            okNum++;
 | 
						||
                        }
 | 
						||
                    }
 | 
						||
                    else
 | 
						||
                    {
 | 
						||
                        okNum++;
 | 
						||
                    }
 | 
						||
                }
 | 
						||
 | 
						||
                if (!string.IsNullOrEmpty(weldTypeGroup))
 | 
						||
                {
 | 
						||
                    if (welderQualify.WeldType.Contains(weldTypeGroup))
 | 
						||
                    {
 | 
						||
                        okNum++;
 | 
						||
                    }
 | 
						||
                }
 | 
						||
                else
 | 
						||
                {
 | 
						||
                    okNum++;
 | 
						||
                }
 | 
						||
 | 
						||
                var steel = BLL.Base_MaterialService.GetMaterialByMaterialId(ste);
 | 
						||
                if (steel != null)   //钢材类型
 | 
						||
                {
 | 
						||
                    if (welderQualify.MaterialType.Contains(steel.MaterialType ?? ""))
 | 
						||
                    {
 | 
						||
                        okNum++;
 | 
						||
                    }
 | 
						||
                }
 | 
						||
                else
 | 
						||
                {
 | 
						||
                    okNum++;
 | 
						||
                }
 | 
						||
 | 
						||
                if (weldTypeGroup != "2") // 承插焊
 | 
						||
                {
 | 
						||
                    if (welderQualify.SizesMin == 0) // 0表示不限
 | 
						||
                    {
 | 
						||
                        okNum++;
 | 
						||
                    }
 | 
						||
                    else  //最小寸径
 | 
						||
                    {
 | 
						||
                        if (dia != null)
 | 
						||
                        {
 | 
						||
                            if (dia >= welderQualify.SizesMin)
 | 
						||
                            {
 | 
						||
                                okNum++;
 | 
						||
                            }
 | 
						||
                        }
 | 
						||
                        else
 | 
						||
                        {
 | 
						||
                            okNum++;
 | 
						||
                        }
 | 
						||
                    }
 | 
						||
 | 
						||
                    if (welderQualify.ThicknessMax == 0)  // 0表示不限
 | 
						||
                    {
 | 
						||
                        okNum++;
 | 
						||
                    }
 | 
						||
                    else
 | 
						||
                    {
 | 
						||
                        if (sch != null)   //最大壁厚
 | 
						||
                        {
 | 
						||
                            if (sch <= welderQualify.ThicknessMax)
 | 
						||
                            {
 | 
						||
                                okNum++;
 | 
						||
                            }
 | 
						||
                        }
 | 
						||
                        else
 | 
						||
                        {
 | 
						||
                            okNum++;
 | 
						||
                        }
 | 
						||
                    }
 | 
						||
                }
 | 
						||
                else  // 当为角焊缝时,管径和壁厚不限制
 | 
						||
                {
 | 
						||
                    okNum++;
 | 
						||
                    okNum++;
 | 
						||
                }
 | 
						||
 | 
						||
 | 
						||
                if (okNum == 6)   //全部条件符合
 | 
						||
                {
 | 
						||
                    isok = true;
 | 
						||
                    break;
 | 
						||
                }
 | 
						||
            }
 | 
						||
 | 
						||
            return isok;
 | 
						||
        }
 | 
						||
 | 
						||
        /// <summary>
 | 
						||
        /// 两种焊接方法的资质判断
 | 
						||
        /// </summary>
 | 
						||
        /// <param name="floorWelderQualifys"></param>
 | 
						||
        /// <param name="cellWelderQualifys"></param>
 | 
						||
        /// <param name="wmeCode1"></param>
 | 
						||
        /// <param name="wmeCode2"></param>
 | 
						||
        /// <param name="location"></param>
 | 
						||
        /// <param name="ste"></param>
 | 
						||
        /// <param name="dia"></param>
 | 
						||
        /// <param name="sch"></param>
 | 
						||
        /// <returns></returns>
 | 
						||
        private bool TwoWmeIsOK(List<Model.Welder_WelderQualify> floorWelderQualifys, List<Model.Welder_WelderQualify> cellWelderQualifys, string wmeCode1, string wmeCode2, string location, string weldTypeGroup, string ste, decimal? dia, decimal? sch)
 | 
						||
        {
 | 
						||
            bool isok = false;
 | 
						||
 | 
						||
            decimal? fThicknessMax = 0;
 | 
						||
            decimal? cThicknessMax = 0;
 | 
						||
 | 
						||
            var steel = BLL.Base_MaterialService.GetMaterialByMaterialId(ste);
 | 
						||
            var floorQ = from x in floorWelderQualifys
 | 
						||
                         where wmeCode1.Contains(x.WeldingMethodId)
 | 
						||
                         && (x.WeldingLocationId == "ALL" || (location == null || location == "" || x.WeldingLocationId.Contains(location)))
 | 
						||
                         && (steel == null || x.MaterialType.Contains(steel.MaterialType ?? ""))
 | 
						||
                         && (weldTypeGroup == null || x.WeldType.Contains(weldTypeGroup))
 | 
						||
                         // && (dia == null || x.SizesMin<=dia)
 | 
						||
                         select x;
 | 
						||
            var cellQ = from x in cellWelderQualifys
 | 
						||
                        where wmeCode2.Contains(x.WeldingMethodId)
 | 
						||
                         && (x.WeldingLocationId == "ALL" || (location == null || location == "" || x.WeldingLocationId.Contains(location)))
 | 
						||
                         && (steel == null || x.MaterialType.Contains(steel.MaterialType ?? ""))
 | 
						||
                         && (weldTypeGroup == null || x.WeldType.Contains(weldTypeGroup))
 | 
						||
                        // && (dia == null || x.SizesMin <= dia)
 | 
						||
                        select x;
 | 
						||
            if (floorQ.Count() > 0 && cellQ.Count() > 0)
 | 
						||
            {
 | 
						||
                if (weldTypeGroup != "2") // 当为角焊缝时,管径和壁厚不限制
 | 
						||
                {
 | 
						||
                    var floorDiaQ = floorQ.Where(x => x.SizesMin <= dia);
 | 
						||
                    var cellDiaQ = cellQ.Where(x => x.SizesMin <= dia);
 | 
						||
 | 
						||
                    if (floorDiaQ.Count() > 0 && cellDiaQ.Count() > 0)
 | 
						||
                    {
 | 
						||
                        var fThick = floorDiaQ.Where(x => x.ThicknessMax == 0);
 | 
						||
                        var cThick = cellDiaQ.Where(x => x.ThicknessMax == 0);
 | 
						||
 | 
						||
                        // 只要有一个不限(为0)就通过
 | 
						||
                        if (fThick.Count() > 0 || cThick.Count() > 0)
 | 
						||
                        {
 | 
						||
                            isok = true;
 | 
						||
                        }
 | 
						||
 | 
						||
                        else
 | 
						||
                        {
 | 
						||
                            fThicknessMax = floorQ.Max(x => x.ThicknessMax);
 | 
						||
                            cThicknessMax = cellQ.Max(x => x.ThicknessMax);
 | 
						||
 | 
						||
                            if ((fThicknessMax + cThicknessMax) >= sch)
 | 
						||
                            {
 | 
						||
                                isok = true;
 | 
						||
                            }
 | 
						||
                        }
 | 
						||
                    }
 | 
						||
                }
 | 
						||
                else
 | 
						||
                {
 | 
						||
                    isok = true;
 | 
						||
                }
 | 
						||
            }
 | 
						||
 | 
						||
            return isok;
 | 
						||
        }
 | 
						||
        #endregion
 | 
						||
 | 
						||
        #region 查找
 | 
						||
        /// <summary>
 | 
						||
        /// 查找未焊接焊口
 | 
						||
        /// </summary>
 | 
						||
        /// <param name="sender"></param>
 | 
						||
        /// <param name="e"></param>
 | 
						||
        protected void ckSelect_Click(object sender, EventArgs e)
 | 
						||
        {
 | 
						||
            string weldJointIds = string.Empty;
 | 
						||
 | 
						||
            for (int i = 0; i < Grid1.Rows.Count; i++)
 | 
						||
            {
 | 
						||
                string weldJointId = Grid1.DataKeys[i][0].ToString();
 | 
						||
                weldJointIds = weldJointIds + weldJointId + "|";
 | 
						||
            }
 | 
						||
 | 
						||
            if (weldJointIds != string.Empty)
 | 
						||
            {
 | 
						||
                weldJointIds = weldJointIds.Substring(0, weldJointIds.Length - 1);
 | 
						||
            }
 | 
						||
 | 
						||
            if (!string.IsNullOrEmpty(this.drpUnit.SelectedValue) && this.drpUnit.SelectedValue != BLL.Const._Null && !string.IsNullOrEmpty(this.drpInstallation.SelectedValue) && this.drpInstallation.SelectedValue != BLL.Const._Null)
 | 
						||
            {
 | 
						||
                string strList = this.drpInstallation.SelectedValue + "|" + this.drpUnit.SelectedValue + "|" + this.WeldingDailyId;
 | 
						||
                string window = String.Format("WeldReportItemEdit.aspx?strList={0}&weldJointIds={1}", strList, weldJointIds, "编辑 - ");
 | 
						||
                PageContext.RegisterStartupScript(Window1.GetSaveStateReference(hdItemsString.ClientID) + Window1.GetShowReference(window));
 | 
						||
            }
 | 
						||
            else
 | 
						||
            {
 | 
						||
                Alert.ShowInTop(Resources.Lan.PleaseUnitAndInstallation, MessageBoxIcon.Warning);
 | 
						||
            }
 | 
						||
        }
 | 
						||
        #endregion
 | 
						||
    }
 | 
						||
} |