using BLL;
using Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace FineUIPro.Web.HJGL.WeldingManage
{
    public partial class JointInfoEdit : PageBase
    {
        #region 定义项
        /// 
        /// 管线主键
        /// 
        private string ISO_ID
        {
            get
            {
                return (string)ViewState["ISO_ID"];
            }
            set
            {
                ViewState["ISO_ID"] = value;
            }
        }
        /// 
        /// 区域信息主键
        /// 
        public string JOT_ID
        {
            get
            {
                return (string)ViewState["JOT_ID"];
            }
            set
            {
                ViewState["JOT_ID"] = value;
            }
        }
        /// 
        /// 区域ID
        /// 
        public string WorkAreaId
        {
            get
            {
                return (string)ViewState["WorkAreaId"];
            }
            set
            {
                ViewState["WorkAreaId"] = value;
            }
        }
        #endregion
        #region 加载
        /// 
        /// 加载页面
        /// 
        /// 
        /// 
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                this.btnClose.OnClientClick = ActiveWindow.GetHideReference();
                #region 初始化下拉框
                BLL.Base_MaterialService.InitMaterialDropDownList(this.ddlSTE1, true, this.CurrUser.LoginProjectId);//材质1
                BLL.Base_MaterialService.InitMaterialDropDownList(this.ddlSTE2, true, this.CurrUser.LoginProjectId);//材质2
                BLL.Base_ComponentsService.InitComponentsDropDownList(this.ddlComponent1, true);//组件1
                BLL.Base_ComponentsService.InitComponentsDropDownList(this.ddlComponent2, true);//组件2
                BLL.Base_WeldTypeService.InitWeldTypeDropDownList(this.ddlJOTY_ID, true);//焊缝类型
                BLL.Base_GrooveTypeService.InitGrooveTypeDropDownList(this.ddlJST_ID, true); //坡口类型
                BLL.Base_TemperatureSetService.InitTemperatureDropDownList(this.drpCellTemp, "2", true);//层间温度
                BLL.Base_TemperatureSetService.InitTemperatureDropDownList(this.drpPrepareTemp, "1", true);//预热温度
                BLL.Base_WeldingMethodService.InitWeldingMethodDropDownList(this.ddlWME_ID, true);//焊接方法
                BLL.Base_ConsumablesService.InitConsumablesDropDownList(this.ddlWeldSilk, true, "1");//焊丝
                BLL.Base_ConsumablesService.InitConsumablesDropDownList(this.ddlWeldMat, true, "2");//焊条
                BLL.ConstValue.InitConstNameDropDownList(this.dpISOType, ConstValue.GroupId_ISOType, true);//
 
                //焊口状态
                this.ddlJointStatus.DataTextField = "Text";
                this.ddlJointStatus.DataValueField = "Value";
                this.ddlJointStatus.DataSource = BLL.DropListService.HJGL_JointStatus();
                this.ddlJointStatus.DataBind();
                //委托情况
                this.ddlTrustFlag.DataTextField = "Text";
                this.ddlTrustFlag.DataValueField = "Value";
                this.ddlTrustFlag.DataSource = BLL.DropListService.HJGL_TrustFlag();
                this.ddlTrustFlag.DataBind();
                //探伤情况
                this.ddlCheckFlag.DataTextField = "Text";
                this.ddlCheckFlag.DataValueField = "Value";
                this.ddlCheckFlag.DataSource = BLL.DropListService.HJGL_CheckFlag();
                this.ddlCheckFlag.DataBind();
                #endregion
                BLL.Base_MaterialTypeService.InitMaterialDropDownList(this.dpMaterialType, true);//材质类型
                BLL.Base_DetectionRateService.InitDetectionRateDropDownList(this.drpNDTRate, true);//探伤比例
                BLL.Base_DetectionTypeService.InitDetectionTypeDropDownList(this.drpNDTName, true);//探伤类型
                this.ISO_ID = Request.Params["ISO_ID"];
                this.JOT_ID = Request.Params["JOT_ID"];
                if (!string.IsNullOrEmpty(this.JOT_ID))
                {
                    Model.PW_JointInfo jointInfo = BLL.PW_JointInfoService.GetJointInfoByJotID(this.JOT_ID);
                    if (jointInfo != null)
                    {
                        this.ISO_ID = jointInfo.ISO_ID;
                        ////初始化页面信息
                        this.LoadPageInfo(jointInfo);
                    }
                }
                else
                {
                    this.lblReport.Text = "未焊接";
                    this.lblPoint.Text = "未点口";
                }
                if (!string.IsNullOrEmpty(this.ISO_ID))
                {
                    var isoInfo = BLL.PW_IsoInfoService.GetIsoInfoByIsoInfoId(this.ISO_ID);
                    if (isoInfo != null)
                    {
                        this.txtISONO.Text = isoInfo.ISO_IsoNo;
                        if (!string.IsNullOrEmpty(isoInfo.WorkAreaId))
                            this.WorkAreaId = isoInfo.WorkAreaId;
                        var workArea = BLL.WorkAreaService.getWorkAreaByWorkAreaId(this.WorkAreaId);
                        if (workArea != null)
                        {
                            this.txtWorkAreaId.Text = workArea.WorkAreaCode;
                        }
                        if (isoInfo.Is_Standard.HasValue && !isoInfo.Is_Standard.Value)
                        {
                            this.drpNDTName.Hidden = true;
                            this.drpNDTRate.Hidden = true;
                            this.txtWallBoard.Hidden = true;
                        }
                    }
                }
               
                if (this.lblReport.Text.Trim() == "已焊接")
                {
                    TextIsReadOnly(true);
                }
                else if (this.lblPoint.Text.Trim() == "已点口")
                {
                    TextIsReadOnly(true);
                }
                if (this.CurrUser.Account == Const.sysglyId||this.CurrUser.UnitId==Const.UnitId_TCC)//如果当前账号是管理员,可以修改达因数
                {
                    TextIsReadOnly(false);
                    this.txtDoneDia.Readonly = false;
                }
            }
        }
        #endregion
        #region 文本框是否可编辑
        /// 
        /// 文本框是否可编辑
        /// 
        /// 
        private void TextIsReadOnly(bool readOnly)
        {
             this.txtJointNo.Enabled = !readOnly;
            this.ddlWLO_CODE.Enabled = !readOnly;
            this.txtBelongPipe.Enabled = !readOnly;
            if (this.CurrUser.Account != Const.sysglyId)
            {
                this.txtSize.Enabled = !readOnly; //兰化项目寸径存在空的情况,需要修改为可修改。
            }
            this.ddlJointAttribute.Enabled = !readOnly;
        }
        #endregion
        #region 初始化页面信息
        /// 
        /// 初始化页面信息
        /// 
        /// 
        private void LoadPageInfo(PW_JointInfo jointInfo)
        {
            if (jointInfo != null)
            {
                this.txtJointNo.Text = jointInfo.JOT_JointNo;
                this.txtWallBoard.Text = jointInfo.WallBoard;
                if (!string.IsNullOrEmpty(jointInfo.WLO_Code))
                {
                    this.ddlWLO_CODE.SelectedValue = jointInfo.WLO_Code;
                }
                if (!string.IsNullOrEmpty(jointInfo.MaterialId))
                {
                    this.ddlSTE1.SelectedValue = jointInfo.MaterialId;
                }
                if (!string.IsNullOrEmpty(jointInfo.MaterialId2))
                {
                    this.ddlSTE2.SelectedValue = jointInfo.MaterialId2;
                }
                if (!string.IsNullOrEmpty(jointInfo.ISO_Type))
                {
                    this.dpISOType.SelectedValue = jointInfo.ISO_Type;
                } 
                
                this.txtBelongPipe.Text = jointInfo.JOT_BelongPipe;
                if (!string.IsNullOrEmpty(jointInfo.JOT_Component1))
                {
                    this.ddlComponent1.SelectedValue = jointInfo.JOT_Component1;
                }
                if (!string.IsNullOrEmpty(jointInfo.JOT_Component2))
                {
                    this.ddlComponent2.SelectedValue = jointInfo.JOT_Component2;
                }
                this.txtJointDesc.Text = jointInfo.JOT_JointDesc;
                this.txtHeartNo1.Text = jointInfo.JOT_HeartNo1;
                this.txtHeartNo2.Text = jointInfo.JOT_HeartNo2;
                if (!string.IsNullOrEmpty(jointInfo.DetectionRateId))
                {
                    this.drpNDTRate.SelectedValue = jointInfo.DetectionRateId;
                }
                if (!string.IsNullOrEmpty(jointInfo.DetectionTypeId))
                {
                    this.drpNDTName.SelectedValue = jointInfo.DetectionTypeId;
                }
                if (!string.IsNullOrEmpty(jointInfo.JOTY_ID))
                {
                    this.ddlJOTY_ID.SelectedValue = jointInfo.JOTY_ID;
                }
                this.txtSize.Text = jointInfo.JOT_Size.HasValue ? jointInfo.JOT_Size.ToString() : "";
                this.txtDia.Text = jointInfo.JOT_Dia.HasValue ? jointInfo.JOT_Dia.ToString() : "";
                if (!string.IsNullOrEmpty(jointInfo.JST_ID))
                {
                    this.ddlJST_ID.SelectedValue = jointInfo.JST_ID;
                }
                this.txtExtendLength.Text = jointInfo.Extend_Length;
                this.txtSch.Text = jointInfo.JOT_Sch;
                this.txtFactSch.Text = jointInfo.JOT_FactSch.HasValue ? jointInfo.JOT_FactSch.ToString() : "";
                this.txtLastTemp.Text = jointInfo.JOT_LastTemp.HasValue ? jointInfo.JOT_LastTemp.ToString() : "";
                if (jointInfo.JOT_CellTemp.HasValue)
                {
                    var tem = BLL.Base_TemperatureSetService.GetTemperatureByTemAndType(jointInfo.JOT_CellTemp, "2");
                    if (tem != null)
                    {
                        this.drpCellTemp.SelectedValue = tem.TemperatureSetId;
                    }
                }
                if (jointInfo.JOT_PrepareTemp.HasValue)
                {
                    var tem = BLL.Base_TemperatureSetService.GetTemperatureByTemAndType(jointInfo.JOT_PrepareTemp, "1");
                    if (tem != null)
                    {
                        this.drpPrepareTemp.SelectedValue = tem.TemperatureSetId;
                    }
                }
                if (!string.IsNullOrEmpty(jointInfo.JOT_JointAttribute))
                {
                    this.ddlJointAttribute.SelectedValue = jointInfo.JOT_JointAttribute;
                }
                if (!string.IsNullOrEmpty(jointInfo.WME_ID))
                {
                    this.ddlWME_ID.SelectedValue = jointInfo.WME_ID;
                }
                if (!string.IsNullOrEmpty(jointInfo.JOT_WeldSilk))
                {
                    this.ddlWeldSilk.SelectedValue = jointInfo.JOT_WeldSilk;
                }
                if (!string.IsNullOrEmpty(jointInfo.JOT_WeldMat))
                {
                    this.ddlWeldMat.SelectedValue = jointInfo.JOT_WeldMat;
                }
                this.txtElectricity.Text = jointInfo.JOT_Electricity;
                this.txtVoltage.Text = jointInfo.JOT_Voltage;
                if (!string.IsNullOrEmpty(jointInfo.IS_Proess))
                {
                    this.drpIS_Proess.SelectedValue = jointInfo.IS_Proess;
                }
                this.txtRemark.Text = jointInfo.JOT_Remark;
                if (!string.IsNullOrEmpty(jointInfo.DReportID))
                {
                    this.ddlReportCode.SelectedValue = jointInfo.DReportID;
                    this.txtReportDate.Text = Convert.ToString(BLL.PW_JointInfoService.GetReportDateByDReportID(jointInfo.DReportID));
                    this.lblReport.Text = "已焊接";
                }
                else
                {
                    this.lblReport.Text = "未焊接";
                    this.ddlReportCode.SelectedValue = BLL.Const._Null;
                }
                //日报日期
                if (!String.IsNullOrEmpty(jointInfo.JOT_FloorWelder))
                {
                    var floorWelder = BLL.WelderService.GetWelderById(jointInfo.JOT_FloorWelder);
                    if (floorWelder != null)
                    {
                        this.txtFloorWelder.Text = floorWelder.WED_Code;
                        this.txtFloorWelderName.Text = floorWelder.WED_Name;
                    }
                }
                if (!String.IsNullOrEmpty(jointInfo.JOT_CellWelder))
                {
                    var cellWelder = BLL.WelderService.GetWelderById(jointInfo.JOT_CellWelder);
                    this.txtCellWelder.Text = cellWelder.WED_Code;
                    this.txtCellWelderName.Text = cellWelder.WED_Name;
                }
                this.txtDoneDia.Text = jointInfo.JOT_DoneDin.HasValue ? jointInfo.JOT_DoneDin.ToString() : "";
                if (!string.IsNullOrEmpty(jointInfo.PW_PointID))
                {
                    this.lblPoint.Text = "已点口";
                }
                else
                {
                    this.lblPoint.Text = "未点口";
                }
                if (!string.IsNullOrEmpty(jointInfo.JOT_TrustFlag))
                {
                    this.ddlTrustFlag.SelectedValue = jointInfo.JOT_TrustFlag;
                }
                else
                {
                    this.ddlTrustFlag.SelectedValue = "00";
                }
                if (!string.IsNullOrEmpty(jointInfo.JOT_CheckFlag))
                {
                    this.ddlCheckFlag.SelectedValue = jointInfo.JOT_CheckFlag;
                }
                else
                {
                    this.ddlCheckFlag.SelectedValue = "00";
                }
                if (!string.IsNullOrEmpty(jointInfo.JOT_JointStatus))
                {
                    this.ddlJointStatus.SelectedValue = jointInfo.JOT_JointStatus;
                }
                this.txtWeldingGasProtection.Text = jointInfo.WeldingGasProtection;
                this.txtWeldingSpeed.Text = jointInfo.WeldingSpeed;
                if (jointInfo.ActualPrepareTemp.HasValue)
                {
                    this.txtActualPrepareTemp.Text = jointInfo.ActualPrepareTemp.ToString();
                }
                this.txtComponentNum.Text = jointInfo.ComponentNum;
                if (!string.IsNullOrEmpty(jointInfo.MaterialType))
                {
                    this.ddlJointStatus.SelectedValue = jointInfo.MaterialType;
                }
                this.txtMaterial1.Text = jointInfo.Material1;
                this.txtMaterial2.Text = jointInfo.Material2;
            }
        }
        #endregion
        #region 保存
        /// 
        /// 保存按钮
        /// 
        /// 
        /// 
        protected void btnSave_Click(object sender, EventArgs e)
        {
            if (this.ddlSTE1.SelectedValue == BLL.Const._Null || string.IsNullOrEmpty(this.ddlSTE1.SelectedValue))
            {
                Alert.ShowInTop("请选择材质1!", MessageBoxIcon.Warning);
                return;
            }
            if (this.ddlJOTY_ID.SelectedValue == BLL.Const._Null || string.IsNullOrEmpty(this.ddlJOTY_ID.SelectedValue))
            {
                Alert.ShowInTop("请选择焊缝类型!", MessageBoxIcon.Warning);
                return;
            }
            if (this.ddlJST_ID.SelectedValue == BLL.Const._Null || string.IsNullOrEmpty(this.ddlJST_ID.SelectedValue))
            {
                Alert.ShowInTop("请选择坡口类型!", MessageBoxIcon.Warning);
                return;
            }
            if (this.ddlWME_ID.SelectedValue == BLL.Const._Null || string.IsNullOrEmpty(this.ddlWME_ID.SelectedValue))
            {
                Alert.ShowInTop("请选择焊接方法!", MessageBoxIcon.Warning);
                return;
            }
            if (!this.drpNDTRate.Hidden && (this.drpNDTRate.SelectedValue == BLL.Const._Null || string.IsNullOrEmpty(this.drpNDTRate.SelectedValue)))
            {
                Alert.ShowInTop("请选择探伤比例!", MessageBoxIcon.Warning);
                return;
            }
            Model.PW_JointInfo jointInfo = new Model.PW_JointInfo();
            jointInfo.ProjectId = this.CurrUser.LoginProjectId;
            jointInfo.JOT_JointNo = this.txtJointNo.Text.Trim();
            jointInfo.ISO_ID = this.ISO_ID;
            jointInfo.WallBoard = this.txtWallBoard.Text.Trim();
            if (this.drpNDTName.SelectedValue != BLL.Const._Null && !string.IsNullOrEmpty(this.drpNDTName.SelectedValue))
            {
                jointInfo.DetectionTypeId = this.drpNDTName.SelectedValue;
            }
            if (this.dpISOType.SelectedValue != BLL.Const._Null && !string.IsNullOrEmpty(this.dpISOType.SelectedValue))
            {
                jointInfo.ISO_Type = this.dpISOType.SelectedValue;
            }
            if (this.drpNDTRate.SelectedValue != BLL.Const._Null && !string.IsNullOrEmpty(this.drpNDTRate.SelectedValue))
            {
                jointInfo.DetectionRateId = this.drpNDTRate.SelectedValue;
            }
            if (this.ddlReportCode.SelectedValue != BLL.Const._Null && !string.IsNullOrEmpty(this.ddlReportCode.SelectedValue))
            {
                jointInfo.DReportID = this.ddlReportCode.SelectedValue.Trim();
            }
            if (this.ddlSTE1.SelectedValue != BLL.Const._Null && !string.IsNullOrEmpty(this.ddlSTE1.SelectedValue))
            {
                jointInfo.MaterialId = this.ddlSTE1.SelectedValue;
            }
            if (this.ddlSTE2.SelectedValue != BLL.Const._Null && !string.IsNullOrEmpty(this.ddlSTE2.SelectedValue))
            {
                jointInfo.MaterialId2 = this.ddlSTE2.SelectedValue;
            }
            jointInfo.WLO_Code = this.ddlWLO_CODE.SelectedValue;
            if (this.ddlComponent1.SelectedValue != BLL.Const._Null && !string.IsNullOrEmpty(this.ddlComponent1.SelectedValue))
            {
                jointInfo.JOT_Component1 = this.ddlComponent1.SelectedValue;
            }
            if (this.ddlComponent2.SelectedValue != BLL.Const._Null && !string.IsNullOrEmpty(this.ddlComponent2.SelectedValue))
            {
                jointInfo.JOT_Component2 = this.ddlComponent2.SelectedValue;
            }
            jointInfo.JOT_HeartNo1 = this.txtHeartNo1.Text.Trim();
            jointInfo.JOT_HeartNo2 = this.txtHeartNo2.Text.Trim();
            if (this.ddlWeldMat.SelectedValue != BLL.Const._Null && !string.IsNullOrEmpty(this.ddlWeldMat.SelectedValue))
            {
                jointInfo.JOT_WeldMat = this.ddlWeldMat.SelectedValue;
            }
            jointInfo.JOT_Dia = Funs.GetNewDecimal(this.txtDia.Text.Trim());
            jointInfo.JOT_Size = Funs.GetNewDecimal(this.txtSize.Text.Trim());
            jointInfo.JOT_Sch = this.txtSch.Text.Trim();
            jointInfo.Extend_Length = this.txtExtendLength.Text.Trim();
            jointInfo.JOT_FactSch = Funs.GetNewDecimal(this.txtFactSch.Text.Trim());
            jointInfo.JOT_JointDesc = this.txtJointDesc.Text.Trim();
            if (this.ddlWeldSilk.SelectedValue != BLL.Const._Null && !string.IsNullOrEmpty(this.ddlWeldSilk.SelectedValue))
            {
                jointInfo.JOT_WeldSilk = this.ddlWeldSilk.SelectedValue.ToString();
            }
            if (this.ddlJOTY_ID.SelectedValue != BLL.Const._Null && !string.IsNullOrEmpty(this.ddlJOTY_ID.SelectedValue))
            {
                jointInfo.JOTY_ID = this.ddlJOTY_ID.SelectedValue.ToString();
            }
            jointInfo.JOT_RepairFlag = null;
            if (ddlWME_ID.SelectedValue != BLL.Const._Null && !string.IsNullOrEmpty(this.ddlWME_ID.SelectedValue))
            {
                jointInfo.WME_ID = this.ddlWME_ID.SelectedValue;
            }
            if (ddlJST_ID.SelectedValue != BLL.Const._Null && !string.IsNullOrEmpty(this.ddlJST_ID.SelectedValue))
            {
                jointInfo.JST_ID = this.ddlJST_ID.SelectedValue;
            }
            if (this.drpPrepareTemp.SelectedValue != BLL.Const._Null && !string.IsNullOrEmpty(this.drpPrepareTemp.SelectedValue))
            {
                var tem = BLL.Base_TemperatureSetService.GetTemperatureSetById(this.drpPrepareTemp.SelectedValue);
                if (tem != null)
                {
                    jointInfo.JOT_PrepareTemp = tem.Temperature;
                }
            }
            if (this.drpCellTemp.SelectedValue != BLL.Const._Null && !string.IsNullOrEmpty(this.drpCellTemp.SelectedValue))
            {
                var tem = BLL.Base_TemperatureSetService.GetTemperatureSetById(this.drpCellTemp.SelectedValue);
                if (tem != null)
                {
                    jointInfo.JOT_CellTemp = tem.Temperature;
                }
            }
            if (!string.IsNullOrEmpty(this.txtLastTemp.Text.Trim()))
            {
                jointInfo.JOT_LastTemp = Convert.ToDecimal(this.txtLastTemp.Text.Trim());
            }
            jointInfo.JOT_JointAttribute = this.ddlJointAttribute.SelectedValue;
            jointInfo.IS_Proess = this.drpIS_Proess.SelectedValue;
            jointInfo.JOT_Remark = this.txtRemark.Text.Trim();
            jointInfo.WeldingGasProtection = this.txtWeldingGasProtection.Text.Trim();
            jointInfo.WeldingSpeed = this.txtWeldingSpeed.Text.Trim();
            jointInfo.ActualPrepareTemp = Funs.GetNewDecimal(this.txtActualPrepareTemp.Text.Trim());
            jointInfo.JOT_Electricity = this.txtElectricity.Text.Trim();
            jointInfo.JOT_Voltage = this.txtVoltage.Text.Trim();
            jointInfo.ComponentNum = this.txtComponentNum.Text.Trim();
            jointInfo.JOT_JointStatus = this.ddlJointStatus.SelectedValue;
            jointInfo.JOT_DoneDin = Funs.GetNewDecimalOrZero(this.txtDoneDia.Text.Trim());
            if (!string.IsNullOrEmpty(this.JOT_ID))
            {
                jointInfo.JOT_ID = this.JOT_ID;
                BLL.PW_JointInfoService.UpdateJointInfo(jointInfo);
                //BLL.LogService.AddLog(this.CurrUser.UserId, "修改焊口信息!");
            }
            else
            {
                BLL.PW_JointInfoService.AddJointInfo(jointInfo);
                //BLL.LogService.AddLog(this.CurrUser.UserId, "添加焊口信息!");
            }
            ShowNotify("保存成功!", MessageBoxIcon.Success);
            PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
        }
        #endregion
        #region 复制
        /// 
        /// 复制按钮
        /// 
        /// 
        /// 
        protected void btnCopy_Click(object sender, EventArgs e)
        {
            if (this.ddlSTE1.SelectedValue == BLL.Const._Null || string.IsNullOrEmpty(this.ddlSTE1.SelectedValue))
            {
                Alert.ShowInTop("请选择材质1!", MessageBoxIcon.Warning);
                return;
            }
            if (this.ddlJOTY_ID.SelectedValue == BLL.Const._Null || string.IsNullOrEmpty(this.ddlJOTY_ID.SelectedValue))
            {
                Alert.ShowInTop("请选择焊缝类型!", MessageBoxIcon.Warning);
                return;
            }
            if (this.ddlJST_ID.SelectedValue == BLL.Const._Null || string.IsNullOrEmpty(this.ddlJST_ID.SelectedValue))
            {
                Alert.ShowInTop("请选择坡口类型!", MessageBoxIcon.Warning);
                return;
            }
            if (this.ddlWME_ID.SelectedValue == BLL.Const._Null || string.IsNullOrEmpty(this.ddlWME_ID.SelectedValue))
            {
                Alert.ShowInTop("请选择焊接方法!", MessageBoxIcon.Warning);
                return;
            }
            if (!this.drpNDTRate.Hidden && (this.drpNDTRate.SelectedValue == BLL.Const._Null || string.IsNullOrEmpty(this.drpNDTRate.SelectedValue)))
            {
                Alert.ShowInTop("请选择探伤比例!", MessageBoxIcon.Warning);
                return;
            }
            Model.PW_JointInfo jointInfo = new Model.PW_JointInfo();
            jointInfo.ProjectId = this.CurrUser.LoginProjectId;
            jointInfo.JOT_JointNo = this.txtJointNo.Text.Trim() + "-Copy";
            jointInfo.ISO_ID = this.ISO_ID;
            jointInfo.WallBoard = this.txtWallBoard.Text.Trim();
            if (this.drpNDTName.SelectedValue != BLL.Const._Null && !string.IsNullOrEmpty(this.drpNDTName.SelectedValue))
            {
                jointInfo.DetectionTypeId = this.drpNDTName.SelectedValue;
            }
            if (this.dpISOType.SelectedValue != BLL.Const._Null && !string.IsNullOrEmpty(this.dpISOType.SelectedValue))
            {
                jointInfo.ISO_Type = this.dpISOType.SelectedValue;
            }
            if (this.drpNDTRate.SelectedValue != BLL.Const._Null && !string.IsNullOrEmpty(this.drpNDTRate.SelectedValue))
            {
                jointInfo.DetectionRateId = this.drpNDTRate.SelectedValue;
            }
            if (this.ddlReportCode.SelectedValue != BLL.Const._Null && !string.IsNullOrEmpty(this.ddlReportCode.SelectedValue))
            {
                jointInfo.DReportID = this.ddlReportCode.SelectedValue.Trim();
            }
            if (this.ddlSTE1.SelectedValue != BLL.Const._Null && !string.IsNullOrEmpty(this.ddlSTE1.SelectedValue))
            {
                jointInfo.MaterialId = this.ddlSTE1.SelectedValue;
            }
            if (this.ddlSTE2.SelectedValue != BLL.Const._Null && !string.IsNullOrEmpty(this.ddlSTE2.SelectedValue))
            {
                jointInfo.MaterialId2 = this.ddlSTE2.SelectedValue;
            }
            jointInfo.WLO_Code = this.ddlWLO_CODE.SelectedValue;
            if (this.ddlComponent1.SelectedValue != BLL.Const._Null && !string.IsNullOrEmpty(this.ddlComponent1.SelectedValue))
            {
                jointInfo.JOT_Component1 = this.ddlComponent1.SelectedValue;
            }
            if (this.ddlComponent2.SelectedValue != BLL.Const._Null && !string.IsNullOrEmpty(this.ddlComponent2.SelectedValue))
            {
                jointInfo.JOT_Component2 = this.ddlComponent2.SelectedValue;
            }
            jointInfo.JOT_HeartNo1 = this.txtHeartNo1.Text.Trim();
            jointInfo.JOT_HeartNo2 = this.txtHeartNo2.Text.Trim();
            if (this.ddlWeldMat.SelectedValue != BLL.Const._Null && !string.IsNullOrEmpty(this.ddlWeldMat.SelectedValue))
            {
                jointInfo.JOT_WeldMat = this.ddlWeldMat.SelectedValue;
            }
            jointInfo.JOT_Dia = Funs.GetNewDecimal(this.txtDia.Text.Trim());
            jointInfo.JOT_Size = Funs.GetNewDecimal(this.txtSize.Text.Trim());
            jointInfo.JOT_Sch = this.txtSch.Text.Trim();
            jointInfo.Extend_Length = this.txtExtendLength.Text.Trim();
            jointInfo.JOT_FactSch = Funs.GetNewDecimal(this.txtFactSch.Text.Trim());
            jointInfo.JOT_JointDesc = this.txtJointDesc.Text.Trim();
            if (this.ddlWeldSilk.SelectedValue != BLL.Const._Null && !string.IsNullOrEmpty(this.ddlWeldSilk.SelectedValue))
            {
                jointInfo.JOT_WeldSilk = this.ddlWeldSilk.SelectedValue.ToString();
            }
            if (this.ddlJOTY_ID.SelectedValue != BLL.Const._Null && !string.IsNullOrEmpty(this.ddlJOTY_ID.SelectedValue))
            {
                jointInfo.JOTY_ID = this.ddlJOTY_ID.SelectedValue.ToString();
            }
            jointInfo.JOT_RepairFlag = null;
            if (ddlWME_ID.SelectedValue != BLL.Const._Null && !string.IsNullOrEmpty(this.ddlWME_ID.SelectedValue))
            {
                jointInfo.WME_ID = this.ddlWME_ID.SelectedValue;
            }
            if (ddlJST_ID.SelectedValue != BLL.Const._Null && !string.IsNullOrEmpty(this.ddlJST_ID.SelectedValue))
            {
                jointInfo.JST_ID = this.ddlJST_ID.SelectedValue;
            }
            if (this.drpPrepareTemp.SelectedValue != BLL.Const._Null && !string.IsNullOrEmpty(this.drpPrepareTemp.SelectedValue))
            {
                var tem = BLL.Base_TemperatureSetService.GetTemperatureSetById(this.drpPrepareTemp.SelectedValue);
                if (tem != null)
                {
                    jointInfo.JOT_PrepareTemp = tem.Temperature;
                }
            }
            if (this.drpCellTemp.SelectedValue != BLL.Const._Null && !string.IsNullOrEmpty(this.drpCellTemp.SelectedValue))
            {
                var tem = BLL.Base_TemperatureSetService.GetTemperatureSetById(this.drpCellTemp.SelectedValue);
                if (tem != null)
                {
                    jointInfo.JOT_CellTemp = tem.Temperature;
                }
            }
            if (!string.IsNullOrEmpty(this.txtLastTemp.Text.Trim()))
            {
                jointInfo.JOT_LastTemp = Convert.ToDecimal(this.txtLastTemp.Text.Trim());
            }
            jointInfo.JOT_JointAttribute = this.ddlJointAttribute.SelectedValue;
            jointInfo.IS_Proess = this.drpIS_Proess.SelectedValue;
            jointInfo.JOT_Remark = this.txtRemark.Text.Trim();
            jointInfo.WeldingGasProtection = this.txtWeldingGasProtection.Text.Trim();
            jointInfo.WeldingSpeed = this.txtWeldingSpeed.Text.Trim();
            jointInfo.ActualPrepareTemp = Funs.GetNewDecimal(this.txtActualPrepareTemp.Text.Trim());
            jointInfo.JOT_Electricity = this.txtElectricity.Text.Trim();
            jointInfo.JOT_Voltage = this.txtVoltage.Text.Trim();
            jointInfo.ComponentNum = this.txtComponentNum.Text.Trim();
            jointInfo.JOT_JointStatus = this.ddlJointStatus.SelectedValue;
            jointInfo.JOT_DoneDin = Funs.GetNewDecimalOrZero(this.txtDoneDia.Text.Trim());
            //if (!string.IsNullOrEmpty(this.JOT_ID))
            //{
            //    jointInfo.JOT_ID = this.JOT_ID;
            //    BLL.PW_JointInfoService.UpdateJointInfo(jointInfo);
            //    //BLL.LogService.AddLog(this.CurrUser.UserId, "修改焊口信息!");
            //}
            //else
            {
                this.JOT_ID = BLL.PW_JointInfoService.AddJointInfo(jointInfo);
                jointInfo.JOT_ID = this.JOT_ID;
                //BLL.LogService.AddLog(this.CurrUser.UserId, "添加焊口信息!");
            }
            if (!string.IsNullOrEmpty(this.JOT_ID))
            {
                ShowNotify("复制成功!", MessageBoxIcon.Success);
                this.txtJointNo.Text = jointInfo.JOT_JointNo ;
            }
            else
            {
                ShowNotify("复制失败!", MessageBoxIcon.Success);
            }
        }
        #endregion
    }
}