211 lines
		
	
	
		
			10 KiB
		
	
	
	
		
			C#
		
	
	
	
		
		
			
		
	
	
			211 lines
		
	
	
		
			10 KiB
		
	
	
	
		
			C#
		
	
	
	
| 
								 | 
							
								using System;
							 | 
						|||
| 
								 | 
							
								using System.Collections.Generic;
							 | 
						|||
| 
								 | 
							
								using System.Data;
							 | 
						|||
| 
								 | 
							
								using System.Data.SqlClient;
							 | 
						|||
| 
								 | 
							
								using System.Linq;
							 | 
						|||
| 
								 | 
							
								using BLL;
							 | 
						|||
| 
								 | 
							
								using Newtonsoft.Json.Linq;
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								namespace FineUIPro.Web.HJGL.MaterialManage
							 | 
						|||
| 
								 | 
							
								{
							 | 
						|||
| 
								 | 
							
								    public partial class ElectrodeSecondaryBakeRecordEditNew : PageBase
							 | 
						|||
| 
								 | 
							
								    {
							 | 
						|||
| 
								 | 
							
								        #region 定义项
							 | 
						|||
| 
								 | 
							
								        /// <summary>
							 | 
						|||
| 
								 | 
							
								        /// 主键
							 | 
						|||
| 
								 | 
							
								        /// </summary>
							 | 
						|||
| 
								 | 
							
								        public string ElectrodeID
							 | 
						|||
| 
								 | 
							
								        {
							 | 
						|||
| 
								 | 
							
								            get
							 | 
						|||
| 
								 | 
							
								            {
							 | 
						|||
| 
								 | 
							
								                return (string)ViewState["ElectrodeID"];
							 | 
						|||
| 
								 | 
							
								            }
							 | 
						|||
| 
								 | 
							
								            set
							 | 
						|||
| 
								 | 
							
								            {
							 | 
						|||
| 
								 | 
							
								                ViewState["ElectrodeID"] = value;
							 | 
						|||
| 
								 | 
							
								            }
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								        public string UnitId
							 | 
						|||
| 
								 | 
							
								        {
							 | 
						|||
| 
								 | 
							
								            get
							 | 
						|||
| 
								 | 
							
								            {
							 | 
						|||
| 
								 | 
							
								                return (string)ViewState["UnitId"];
							 | 
						|||
| 
								 | 
							
								            }
							 | 
						|||
| 
								 | 
							
								            set
							 | 
						|||
| 
								 | 
							
								            {
							 | 
						|||
| 
								 | 
							
								                ViewState["UnitId"] = value;
							 | 
						|||
| 
								 | 
							
								            }
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        private bool AppendToEnd = false;
							 | 
						|||
| 
								 | 
							
								        #endregion
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        #region 加载页面
							 | 
						|||
| 
								 | 
							
								        /// <summary>
							 | 
						|||
| 
								 | 
							
								        /// 加载页面
							 | 
						|||
| 
								 | 
							
								        /// </summary>
							 | 
						|||
| 
								 | 
							
								        /// <param name="sender"></paramtxtCardCode
							 | 
						|||
| 
								 | 
							
								        /// <param name="e"></param>
							 | 
						|||
| 
								 | 
							
								        protected void Page_Load(object sender, EventArgs e)
							 | 
						|||
| 
								 | 
							
								        {
							 | 
						|||
| 
								 | 
							
								            if (!IsPostBack)
							 | 
						|||
| 
								 | 
							
								            {
							 | 
						|||
| 
								 | 
							
								                this.ElectrodeID = Request.Params["ElectrodeID"];
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								                string perfix = string.Empty;
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								                perfix = "HK2-";
							 | 
						|||
| 
								 | 
							
								                this.txtBatchCode.Text = BLL.SQLHelper.RunProcNewId("SpGetNewCode5ByProjectId", "dbo.HJGL_ElectrodeSecondaryBake", "BatchCode", this.CurrUser.LoginProjectId, perfix);
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								                var units = UnitService.GetUnitByProjectIdUnitTypeList(this.CurrUser.LoginProjectId, BLL.Const.ProjectUnitType_2);
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								                this.dpUnit.DataTextField = "UnitName";
							 | 
						|||
| 
								 | 
							
								                this.dpUnit.DataValueField = "UnitId";
							 | 
						|||
| 
								 | 
							
								                this.dpUnit.DataSource = units;
							 | 
						|||
| 
								 | 
							
								                this.dpUnit.DataBind();
							 | 
						|||
| 
								 | 
							
								                Funs.FineUIPleaseSelect(dpUnit);
							 | 
						|||
| 
								 | 
							
								                ///焊条 
							 | 
						|||
| 
								 | 
							
								                this.drpWME_ID.DataTextField = "ConsumablesName";
							 | 
						|||
| 
								 | 
							
								                this.drpWME_ID.DataValueField = "ConsumablesId";
							 | 
						|||
| 
								 | 
							
								                var totalWeldMaterials = from x in Funs.DB.Base_Consumables select x;
							 | 
						|||
| 
								 | 
							
								                this.drpWME_ID.DataSource = totalWeldMaterials;
							 | 
						|||
| 
								 | 
							
								                this.drpWME_ID.DataBind();
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								                this.cbJOTSch.DataTextField = "Text";
							 | 
						|||
| 
								 | 
							
								                this.cbJOTSch.DataValueField = "Value";
							 | 
						|||
| 
								 | 
							
								                this.cbJOTSch.DataSource = BLL.PW_JointInfoService.GetJOTSchList();
							 | 
						|||
| 
								 | 
							
								                this.cbJOTSch.DataBind();
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								                if (!string.IsNullOrEmpty(this.ElectrodeID))
							 | 
						|||
| 
								 | 
							
								                {
							 | 
						|||
| 
								 | 
							
								                    var electrode = BLL.HJGL_ElectrodeBakeService.GetElecrodeBakeByElectrodeId(this.ElectrodeID);
							 | 
						|||
| 
								 | 
							
								                    if (electrode != null)
							 | 
						|||
| 
								 | 
							
								                    {
							 | 
						|||
| 
								 | 
							
								                        if (!string.IsNullOrEmpty(electrode.Specifications))
							 | 
						|||
| 
								 | 
							
								                        {
							 | 
						|||
| 
								 | 
							
								                            this.dpSpecificationsModel.Values = electrode.Specifications.Split(',');
							 | 
						|||
| 
								 | 
							
								                        }
							 | 
						|||
| 
								 | 
							
								                        ;
							 | 
						|||
| 
								 | 
							
								                        if (!string.IsNullOrEmpty(electrode.UnitId))
							 | 
						|||
| 
								 | 
							
								                        {
							 | 
						|||
| 
								 | 
							
								                            this.dpUnit.SelectedValue = electrode.UnitId;
							 | 
						|||
| 
								 | 
							
								                        }
							 | 
						|||
| 
								 | 
							
								                    
							 | 
						|||
| 
								 | 
							
								                        //txtCardCode.Text = electrode.CardCode;
							 | 
						|||
| 
								 | 
							
								                        this.drpWME_ID.SelectedValue = electrode.WMT_ID;
							 | 
						|||
| 
								 | 
							
								                        txtBatchCode.Text = electrode.BatchCode;
							 | 
						|||
| 
								 | 
							
								                  
							 | 
						|||
| 
								 | 
							
								                        //   txtSpecifications.Text = electrode.Specifications;
							 | 
						|||
| 
								 | 
							
								                        if (electrode.ElectrodeCount.HasValue)
							 | 
						|||
| 
								 | 
							
								                            txtElectrodeCount.Text = electrode.ElectrodeCount.Value.ToString();
							 | 
						|||
| 
								 | 
							
								                        if (electrode.OvenElectricHours.HasValue && electrode.OvenElectricMinute.HasValue)
							 | 
						|||
| 
								 | 
							
								                            tpOvenElectricTime.Text = electrode.OvenElectricHours.Value.ToString("D2") + ":" + electrode.OvenElectricMinute.Value.ToString("D2");
							 | 
						|||
| 
								 | 
							
								                        if (electrode.OvenElectricTemperature.HasValue)
							 | 
						|||
| 
								 | 
							
								                            txtOvenElectricTemperature.Text = electrode.OvenElectricTemperature.Value.ToString();
							 | 
						|||
| 
								 | 
							
								                        if (electrode.ConstantTemperature.HasValue)
							 | 
						|||
| 
								 | 
							
								                            txtConstantTemperature.Text = electrode.ConstantTemperature.Value.ToString();
							 | 
						|||
| 
								 | 
							
								                        if (electrode.ConstantStartHours.HasValue && electrode.ConstantStartMinute.HasValue)
							 | 
						|||
| 
								 | 
							
								                            tpConstantStartTime.Text = electrode.ConstantStartHours.Value.ToString("D2") + ":" + electrode.ConstantStartMinute.Value.ToString("D2");
							 | 
						|||
| 
								 | 
							
								                        if (electrode.ConstantEndHours.HasValue && electrode.ConstantEndMinute.HasValue)
							 | 
						|||
| 
								 | 
							
								                            tpConstantEndTime.Text = electrode.ConstantEndHours.Value.ToString("D2") + ":" + electrode.ConstantEndMinute.Value.ToString("D2");
							 | 
						|||
| 
								 | 
							
								                        if (electrode.MoveInBoxHours.HasValue && electrode.MoveInBoxMinute.HasValue)
							 | 
						|||
| 
								 | 
							
								                            tpMoveInBoxHours.Text = electrode.MoveInBoxHours.Value.ToString("D2") + ":" + electrode.MoveInBoxMinute.Value.ToString("D2");
							 | 
						|||
| 
								 | 
							
								                        if (electrode.MoveInTemperature.HasValue)
							 | 
						|||
| 
								 | 
							
								                            txtMoveInTemperature.Text = electrode.MoveInTemperature.Value.ToString();
							 | 
						|||
| 
								 | 
							
								                        txtBakeHead.Text = electrode.BakeHead;
							 | 
						|||
| 
								 | 
							
								                    }
							 | 
						|||
| 
								 | 
							
								                }
							 | 
						|||
| 
								 | 
							
								                else
							 | 
						|||
| 
								 | 
							
								                {
							 | 
						|||
| 
								 | 
							
								                }
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								                // 删除选中单元格的客户端脚本
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								            }
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								        #endregion
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        protected void txtInLibCode_OnTextChanged(object sender, EventArgs e)
							 | 
						|||
| 
								 | 
							
								        {
							 | 
						|||
| 
								 | 
							
								          
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        /// <summary>
							 | 
						|||
| 
								 | 
							
								        /// 
							 | 
						|||
| 
								 | 
							
								        /// </summary>
							 | 
						|||
| 
								 | 
							
								        /// <param name="sender"></param>
							 | 
						|||
| 
								 | 
							
								        /// <param name="e"></param>
							 | 
						|||
| 
								 | 
							
								        protected void btnSave_Click(object sender, EventArgs e)
							 | 
						|||
| 
								 | 
							
								        {
							 | 
						|||
| 
								 | 
							
								            if (!CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.HJGL_ElectrodeBakeMenuId, Const.BtnSave))
							 | 
						|||
| 
								 | 
							
								            {
							 | 
						|||
| 
								 | 
							
								                ShowNotify("您没有这个权限,请与管理员联系!");
							 | 
						|||
| 
								 | 
							
								                return;
							 | 
						|||
| 
								 | 
							
								            }
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								            Model.HJGL_ElectrodeSecondaryBake newElectrodeBake = new Model.HJGL_ElectrodeSecondaryBake();
							 | 
						|||
| 
								 | 
							
								            newElectrodeBake.CompileDate = DateTime.Now;
							 | 
						|||
| 
								 | 
							
								            newElectrodeBake.CompileMan = this.CurrUser.UserId;
							 | 
						|||
| 
								 | 
							
								            newElectrodeBake.UnitId = this.dpUnit.SelectedValue;
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								            if (this.dpSpecificationsModel.Values != null && this.dpSpecificationsModel.Values.Length > 0)
							 | 
						|||
| 
								 | 
							
								            {
							 | 
						|||
| 
								 | 
							
								                newElectrodeBake.Specifications = string.Join(",", this.dpSpecificationsModel.Values);
							 | 
						|||
| 
								 | 
							
								            }
							 | 
						|||
| 
								 | 
							
								            //newElectrodeBake.CardCode = txtCardCode.Text.Trim();
							 | 
						|||
| 
								 | 
							
								            newElectrodeBake.WMT_ID = this.drpWME_ID.SelectedValue;
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								            newElectrodeBake.BatchCode = txtBatchCode.Text.Trim();
							 | 
						|||
| 
								 | 
							
								            //newElectrodeBake.Specifications = txtSpecifications.Text.Trim();
							 | 
						|||
| 
								 | 
							
								            newElectrodeBake.ElectrodeCount = Funs.GetNewDouble(txtElectrodeCount.Text.Trim());
							 | 
						|||
| 
								 | 
							
								            newElectrodeBake.OvenElectricHours = Funs.GetNewInt(tpOvenElectricTime.Text.Split(':')[0]);
							 | 
						|||
| 
								 | 
							
								            newElectrodeBake.OvenElectricMinute = Funs.GetNewInt(tpOvenElectricTime.Text.Split(':')[1]);
							 | 
						|||
| 
								 | 
							
								            newElectrodeBake.OvenElectricTemperature = Funs.GetNewInt(txtOvenElectricTemperature.Text.Trim());
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								            newElectrodeBake.ConstantTemperature = Funs.GetNewInt(txtConstantTemperature.Text.Trim());
							 | 
						|||
| 
								 | 
							
								            newElectrodeBake.ConstantStartHours = Funs.GetNewInt(tpConstantStartTime.Text.Split(':')[0]);
							 | 
						|||
| 
								 | 
							
								            newElectrodeBake.ConstantStartMinute = Funs.GetNewInt(tpConstantStartTime.Text.Split(':')[1]);
							 | 
						|||
| 
								 | 
							
								            newElectrodeBake.ConstantEndHours = Funs.GetNewInt(tpConstantEndTime.Text.Split(':')[0]);
							 | 
						|||
| 
								 | 
							
								            newElectrodeBake.ConstantEndMinute = Funs.GetNewInt(tpConstantEndTime.Text.Split(':')[1]);
							 | 
						|||
| 
								 | 
							
								            newElectrodeBake.MoveInBoxHours = Funs.GetNewInt(tpMoveInBoxHours.Text.Split(':')[0]);
							 | 
						|||
| 
								 | 
							
								            newElectrodeBake.MoveInBoxMinute = Funs.GetNewInt(tpMoveInBoxHours.Text.Split(':')[1]);
							 | 
						|||
| 
								 | 
							
								            newElectrodeBake.MoveInTemperature = Funs.GetNewInt(txtMoveInTemperature.Text.Trim());
							 | 
						|||
| 
								 | 
							
								            newElectrodeBake.BakeHead = txtBakeHead.Text.Trim();
							 | 
						|||
| 
								 | 
							
								            newElectrodeBake.ProjectId = this.CurrUser.LoginProjectId;
							 | 
						|||
| 
								 | 
							
								            if (!string.IsNullOrEmpty(ElectrodeID))
							 | 
						|||
| 
								 | 
							
								            {
							 | 
						|||
| 
								 | 
							
								                newElectrodeBake.ElectrodeID = ElectrodeID;
							 | 
						|||
| 
								 | 
							
								                var oldEelectrode = BLL.HJGL_ElectrodeBakeService.GetElecrodeBakeByElectrodeId(this.ElectrodeID);
							 | 
						|||
| 
								 | 
							
								             //   BLL.HJGL_EMInventoryRecordsService.UpdateEMInventoryRecords(this.CurrUser.LoginProjectId, oldEelectrode.UnitId, oldEelectrode.WMT_ID, "", "", decimal.Parse(oldEelectrode.ElectrodeCount.Value.ToString("0.##")));
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								                BLL.HJGL_ElectrodeSecondaryBakeService.UpdateElectrodeBake(newElectrodeBake); //修改焊丝烘烤记录
							 | 
						|||
| 
								 | 
							
								             //   BLL.HJGL_EMInventoryRecordsService.UpdateEMInventoryRecords(this.CurrUser.LoginProjectId, newElectrodeBake.UnitId, newElectrodeBake.WMT_ID, "", "", -decimal.Parse(newElectrodeBake.ElectrodeCount.Value.ToString("0.##")));
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								                // BLL.HJGL_ElectrodeBakeService.DeleteElectrodeBakeItem(this.ElectrodeID);
							 | 
						|||
| 
								 | 
							
								                //BLL.Sys_LogService.AddLog(BLL.Const.System_7, this.CurrUser.LoginProjectId, this.CurrUser.UserId, "修改焊丝烘烤记录!");
							 | 
						|||
| 
								 | 
							
								            }
							 | 
						|||
| 
								 | 
							
								            else
							 | 
						|||
| 
								 | 
							
								            {
							 | 
						|||
| 
								 | 
							
								                //BLL.HJGL_EMInventoryRecordsService.UpdateEMInventoryRecords(this.CurrUser.LoginProjectId, newElectrodeBake.UnitId, newElectrodeBake.WMT_ID, "", "", -decimal.Parse(newElectrodeBake.ElectrodeCount.Value.ToString("0.##")));
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								                newElectrodeBake.ElectrodeID = SQLHelper.GetNewID(typeof(Model.HJGL_ElectrodeBake));
							 | 
						|||
| 
								 | 
							
								                BLL.HJGL_ElectrodeSecondaryBakeService.AddElectrodeBake(newElectrodeBake); //添加焊丝烘烤记录主表信息  
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								                // BLL.Sys_LogService.AddLog(BLL.Const.System_7, this.CurrUser.LoginProjectId, this.CurrUser.UserId, "添加焊丝烘烤记录!");
							 | 
						|||
| 
								 | 
							
								            }
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								            // Alert.ShowInTop("保存成功!", MessageBoxIcon.Success);
							 | 
						|||
| 
								 | 
							
								            PageContext.RegisterStartupScript(ActiveWindow.GetHideRefreshReference());
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								    }
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								}
							 |