/******************************************************************************* * Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential * 类的信息: * 1.程序名称:F_MST_0502.cs * 2.功能描述:新建或编辑产品档案信息 * 编辑履历: * 作者 日期 版本 修改内容 * 庄天威 2014/09/13 1.00 新建 *******************************************************************************/ using Dongke.IBOSS.PRD.Basics.BaseControls; using Dongke.IBOSS.PRD.Basics.BaseResources; using Dongke.IBOSS.PRD.Client.CommonModule; using Dongke.IBOSS.PRD.Client.CommonModule.FormCommon; using Dongke.IBOSS.PRD.WCF.DataModels; using Dongke.IBOSS.PRD.WCF.Proxys; using System; using System.Collections.Generic; using System.Data; using System.Drawing; using System.Drawing.Drawing2D; using System.Drawing.Imaging; using System.IO; using System.Windows.Forms; namespace Dongke.IBOSS.PRD.Client.SystemModule { /// /// 新建或编辑产品档案信息 /// public partial class F_MST_0502 : FormBase { #region 成员变量 //页面状态 private Constant.FormMode _formStatus; // 产品ID private int _formGoodsId; // 产品图片二进制集合 private List _picByteList = new List(); // 产品图片缩略图二进制集合 private List _smallByteList = new List(); // 产品图片实体集合 private List _imgList = new List(); // 已存在的图片实体集合(修改) private List _updateImgList = new List(); // 产品附件实体集合 private List _attList = new List(); // 当前编辑实体 private GoodsEntity _thisGoodsEntity = new GoodsEntity(); private DataTable _sapInfo = null; private int _enitstuts; #endregion #region 构造函数 /// /// 新建/编辑产品档案窗体构造 /// /// 窗体模式,0为新建,1为编辑 /// 编辑产品ID public F_MST_0502(Constant.FormMode status, int goodsId,int enitstuts) { InitializeComponent(); _enitstuts = enitstuts; this.dgvGoodsSap.AutoGenerateColumns = false; this._formStatus = status; this._formGoodsId = goodsId; if (this._formStatus == Constant.FormMode.Add) { this.Text = FormTitles.F_MST_0502_ADD; } else { this.Text = FormTitles.F_MST_0502_EDIT; } this.btnSave.Text = ButtonText.BTN_SAVE; this.btnCancel.Text = ButtonText.BTN_CLOSE; this.btnUpload.Text = ButtonText.BTN_UPLOAD; this.btnDelete.Text = ButtonText.BTN_DELETE; this.cbGLTDetail.Enabled = this.chkGLT.Checked; } #endregion #region 事件 /// /// 窗体加载 /// private void F_MST_0702_Load(object sender, EventArgs e) { try { this.scbGoodsType.IsOnlyDisplayEnd = true; LoadDataSource(); if (this._formStatus == Constant.FormMode.Edit) { // 产品编码不能编辑 add by chenxy 2016-08-16 begin this.txtGoodsCode.ReadOnly = true; // 产品编码不能编辑 add by chenxy 2016-08-16 end //根据goodsId查询对应的产品信息 this._thisGoodsEntity.GoodsID = this._formGoodsId; DataSet updateGoods = SystemModuleProxy.Service.SerachGoods(this._thisGoodsEntity); if (updateGoods.Tables[0].Rows.Count != Constant.INT_IS_ZERO) { //把值绑入实体 DataRow drGoods = updateGoods.Tables[0].Rows[0]; this._thisGoodsEntity.GoodsCode = drGoods["GoodsCode"].ToString(); this._thisGoodsEntity.GoodsTypeID = Convert.ToInt32(drGoods["GOODSTYPEID"]); this._thisGoodsEntity.GlazeTypeID = Convert.ToInt32(drGoods["GLAZETYPEID"]); this._thisGoodsEntity.CeaseFlag = Convert.ToInt32(drGoods["CEASEFLAG"]); this._thisGoodsEntity.SecurityCodeBindFlag = Convert.ToInt32(drGoods["SECURITYCODEBINDFLAG"]); this._thisGoodsEntity.SecurityCodeCheckFlag = Convert.ToInt32(drGoods["SECURITYCODECHECKFLAG"]); this._thisGoodsEntity.Remarks = drGoods["Remarks"].ToString(); this._thisGoodsEntity.AccountID = Convert.ToInt32(drGoods["AccountID"]); this._thisGoodsEntity.ValueFlag = Convert.ToInt32(drGoods["ValueFlag"]); this._thisGoodsEntity.CreateTime = Convert.ToDateTime(drGoods["CreateTime"]); this._thisGoodsEntity.CreateUserID = Convert.ToInt32(drGoods["CreateUserID"]); this._thisGoodsEntity.UpdateTime = Convert.ToDateTime(drGoods["UpdateTime"]); this._thisGoodsEntity.UpdateUserID = Convert.ToInt32(drGoods["UpdateUserID"]); this._thisGoodsEntity.OPTimeStamp = Convert.ToDateTime(drGoods["OPTimeStamp"]); this._thisGoodsEntity.StartingDate = Convert.ToDateTime(drGoods["StartingDate"]); this._thisGoodsEntity.AutoLossCycle = Convert.ToInt32(drGoods["AutoLossCycle"]); this._thisGoodsEntity.DeliverLimitCycle = Convert.ToInt32(drGoods["DeliverLimitCycle"]); this._thisGoodsEntity.PlateLimitNum = Convert.ToInt32(drGoods["PlateLimitNum"]); this._thisGoodsEntity.PlateLimitNumNew = Convert.ToInt32(drGoods["PlateLimitNumNew"]); this._thisGoodsEntity.UnitPrice = Convert.ToDecimal(drGoods["UnitPrice"]); this._thisGoodsEntity.ReservedDays = Convert.ToInt32(drGoods["ReservedDays"]); this._thisGoodsEntity.MouldOutputCount = Convert.ToInt32(drGoods["MouldOutputCount"]); this._thisGoodsEntity.StandardGroutingNum = Convert.ToInt32(drGoods["StandardGroutingNum"]); this._thisGoodsEntity.STD_GNUM_MAX = Convert.ToInt32(drGoods["STD_GNUM_MAX"]); this._thisGoodsEntity.MouldMaterialCode = drGoods["MouldMaterialCode"] + ""; this._thisGoodsEntity.WaterLabelCode = drGoods["WaterLabelCode"] + ""; if (drGoods["PROTECTDAMRATE"].ToString() != null && drGoods["PROTECTDAMRATE"].ToString() != "") { this._thisGoodsEntity.ProtectdaMrate = Convert.ToDecimal(drGoods["PROTECTDAMRATE"].ToString());//保坯率 } if (drGoods["ATTENDANCE"].ToString() != null && drGoods["ATTENDANCE"].ToString() != "") { this._thisGoodsEntity.Attendance = Convert.ToDecimal(drGoods["ATTENDANCE"].ToString());//保坯率 } if (drGoods["PRODUCEDAYS"].ToString() != null && drGoods["PRODUCEDAYS"].ToString() != "") { this._thisGoodsEntity.ProductDays = Convert.ToDecimal(drGoods["PRODUCEDAYS"].ToString());//保坯率 } if (drGoods["DAYGROUTINGNUMBER"].ToString() != null && drGoods["DAYGROUTINGNUMBER"].ToString() != "") { this._thisGoodsEntity.DaygroutingNumber = Convert.ToDecimal(drGoods["DAYGROUTINGNUMBER"].ToString());//保坯率 } if (!string.IsNullOrEmpty(drGoods["MudStoreType"] + "")) { this._thisGoodsEntity.MudStoreType = Convert.ToInt32(drGoods["MudStoreType"]); } //将实体的值赋给各控件 this.txtGoodsCode.Text = drGoods["GoodsCode"].ToString(); this.txtGoodsName.Text = drGoods["GoodsName"].ToString(); this.txtGoodsSpecification.Text = drGoods["GoodsSpecification"].ToString(); this.txtGoodsModel.Text = drGoods["GoodsModel"].ToString(); this.scbGoodsType.CheckedData = updateGoods.Tables[0]; //this.scbGoodsType.InitValue(drGoods["GoodsTypeName"].ToString(), _thisGoodsEntity.GoodsTypeID); this.scbGoodsType.Text = drGoods["GoodsTypeName"].ToString(); this.ddlGlazeTypeID.SelectedValue = _thisGoodsEntity.GlazeTypeID; if (_thisGoodsEntity.MudStoreType != null) { this.ddlMudStoreType.SelectedValue = _thisGoodsEntity.MudStoreType; } this.txtMudWeight.Text = drGoods["MudWeight"].ToString(); this.txtGlazeWeight.Text = drGoods["GlazeWeight"].ToString(); this.txtLusterwareWeight.Text = drGoods["LusterwareWeight"].ToString(); this.txtProductionCycle.Text = drGoods["ProductionCycle"].ToString(); this.cbCeaseFlag.Checked = (_thisGoodsEntity.CeaseFlag == Constant.INT_IS_ONE); this.cbSecurityCodeBindFlag.Checked = (_thisGoodsEntity.SecurityCodeBindFlag == Constant.INT_IS_ONE); this.cbSecurityCodeCheckFlag.Checked = (_thisGoodsEntity.SecurityCodeCheckFlag == Constant.INT_IS_ONE); this.cbValueFlag.Checked = (this._thisGoodsEntity.ValueFlag == Constant.INT_IS_ONE); this.txtRemarks.Text = this._thisGoodsEntity.Remarks; this.dtpStartingDate.Value = this._thisGoodsEntity.StartingDate; this.txtSPM001.DataValue = this._thisGoodsEntity.AutoLossCycle; this.txtSPM002.DataValue = this._thisGoodsEntity.DeliverLimitCycle; this.txtMouldOutputCount.DataValue = this._thisGoodsEntity.MouldOutputCount; this.txtStandardGroutingNum.DataValue = this._thisGoodsEntity.StandardGroutingNum; this.txtstd_gnum_max.DataValue = this._thisGoodsEntity.STD_GNUM_MAX; this.txtMouldMaterialCode.Text = this._thisGoodsEntity.MouldMaterialCode; this.txtWaterLabelCode.Text = this._thisGoodsEntity.WaterLabelCode; this.txtCertificateCode.Text = this._thisGoodsEntity.CertificateCode; this.txtPlateLimitNum1.DataValue = this._thisGoodsEntity.PlateLimitNum; this.txtPlateLimitNumNew1.DataValue = this._thisGoodsEntity.PlateLimitNumNew; this.txtUnitPrice.DataValue = this._thisGoodsEntity.UnitPrice; this.txtReservedDays.DataValue = this._thisGoodsEntity.ReservedDays; this.chkGLT.Checked = (drGoods["GOODS_LINE_TYPE"] + "" == "1"); this.cbGLTDetail.Enabled = this.chkGLT.Checked; this.cbGLTDetail.SelectedValue = (drGoods["GOODS_LINE_CODE"] + ""); this.txtPackageNum.Text = drGoods["PackageNum"].ToString(); this.txtOutletDistance.Text = drGoods["OutletDistance"].ToString(); this.scbSAPCode1.Text = drGoods["MaterialCode"].ToString(); this.txtMaterialRemark.Text = drGoods["MaterialRemark"].ToString(); this.txtCopies.Text = drGoods["printcopies"].ToString(); this.ftcLogo.InitValue(drGoods["logoname"] + "", drGoods["logoid"]); if (drGoods["MouldWeight"] != DBNull.Value) { this.txtMouldWeight.DataValue = Convert.ToDecimal(drGoods["MouldWeight"]); } if (drGoods["MouldCost"] != DBNull.Value) { this.txtMouldCost.DataValue = Convert.ToDecimal(drGoods["MouldCost"]); } this.chkScrapSumFlag.Checked = (drGoods["ScrapSumFlag"] + "" == "1"); this.cbPlanFlag.Checked = (drGoods["PlanFlag"] + "" == "1"); if (drGoods["SeatCoverCode"] != DBNull.Value) { this.txtSEATCOVERCODE.DataValue = Convert.ToInt32(drGoods["SeatCoverCode"]); } if (this._thisGoodsEntity.ProductDays.ToString() != null && this._thisGoodsEntity.ProductDays.ToString() != "") { this.txtproductDays.Text = this._thisGoodsEntity.ProductDays.ToString(); } if (this._thisGoodsEntity.Attendance.ToString() != null && this._thisGoodsEntity.Attendance.ToString() != "") { this.txtattendance.Text = this._thisGoodsEntity.Attendance.ToString(); } if (this._thisGoodsEntity.DaygroutingNumber.ToString() != null && this._thisGoodsEntity.DaygroutingNumber.ToString() != "") { this.txtdaygroutingNumber.Text = this._thisGoodsEntity.DaygroutingNumber.ToString(); } if (this._thisGoodsEntity.ProtectdaMrate.ToString() != null && this._thisGoodsEntity.ProtectdaMrate.ToString() != "") { this.txtprotectdaMrate.Text = this._thisGoodsEntity.ProtectdaMrate.ToString(); } //查询对应的图片 DataSet dsImg = SystemModuleProxy.Service.getImageByGoodsId(this._formGoodsId); BindByteImage(dsImg); } if (_enitstuts == 1) { DisableControl(); } } // 产品物料信息 ClientRequestEntity cre = new ClientRequestEntity(); cre.NameSpace = "MST_Goods"; cre.Name = "GetGoodsSAPByEdit"; cre.Request = this._formGoodsId; // 调用服务器端获取数据集 ServiceResultEntity sre = SystemModuleProxy.Service.DoRequest(cre); if (sre != null && sre.Data != null && sre.Data.Tables.Count > 0) { this._sapInfo = sre.Data.Tables[0]; this.dgvGoodsSap.DataSource = this._sapInfo; } this.txtGoodsCode.Focus(); } catch (Exception ex) { // 对异常进行共通处理 ExceptionManager.HandleEventException(this.ToString(), System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex); } } /// /// 获取数据事件 /// private void btnSave_Click(object sender, EventArgs e) { try { //基础数据验证 int ErrorId = ValidationText(); if (ErrorId != Constant.INT_IS_ZERO) { string errorAddress = ""; switch (ErrorId) { case 1: this.txtGoodsCode.Focus(); errorAddress = "产品编码"; break; case 3: this.txtGoodsName.Focus(); errorAddress = "产品名称"; break; case 6: this.scbGoodsType.Focus(); errorAddress = "产品类别"; break; case 7: this.ddlGlazeTypeID.Focus(); errorAddress = "釉料类别"; break; default: break; }; MessageBox.Show(string.Format(Messages.MSG_CMN_W005, errorAddress), this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1); return; } if (string.IsNullOrEmpty(scbSAPCode1.Text)) { this.scbSAPCode1.Focus(); MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "物料编码"), this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1); return; } //if (string.IsNullOrEmpty(txtGroutmaterialcode.Text)) //{ // this.txtGroutmaterialcode.Focus(); // MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "注浆初始物料编码"), // this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1); // return; //} if (string.IsNullOrEmpty(ftcLogo.SelectedValue + "")) { this.ftcLogo.Focus(); MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "注浆商标"), this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1); return; } //查询产品编号唯一性 if ((this.txtGoodsCode.Text.Trim() != this._thisGoodsEntity.GoodsCode && _formStatus == Constant.FormMode.Edit) || this._formStatus == Constant.FormMode.Add) { if (ValidationCode(this.txtGoodsCode.Text.Trim()) == false) { MessageBox.Show(string.Format(Messages.MSG_CMN_W006, "产品编码"), this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } } //实体赋值 if (this._thisGoodsEntity == null) { this._thisGoodsEntity = new GoodsEntity(); } this._thisGoodsEntity.GoodsCode = this.txtGoodsCode.Text.Trim(); this._thisGoodsEntity.GoodsModel = this.txtGoodsModel.Text.Trim(); this._thisGoodsEntity.GoodsName = this.txtGoodsName.Text.Trim(); this._thisGoodsEntity.GoodsSpecification = this.txtGoodsSpecification.Text; this._thisGoodsEntity.GoodsTypeID = Convert.ToInt32(scbGoodsType.SearchedItem["GoodsTypeID"]); this._thisGoodsEntity.GlazeTypeID = this.ddlGlazeTypeID.SelectedValue.ToString() == "" ? null : (int?)Convert.ToInt32(this.ddlGlazeTypeID.SelectedValue); this._thisGoodsEntity.MudStoreType = this.ddlMudStoreType.SelectedValue.ToString() == "" ? null : (int?)Convert.ToInt32(this.ddlMudStoreType.SelectedValue); this._thisGoodsEntity.MudQuantity = this.txtMudWeight.Text == "" ? Constant.INT_IS_ZERO : Convert.ToDecimal(this.txtMudWeight.Text); this._thisGoodsEntity.GlazeQuantity = this.txtGlazeWeight.Text == "" ? Constant.INT_IS_ZERO : Convert.ToDecimal(this.txtGlazeWeight.Text); this._thisGoodsEntity.LusterwareWeight = this.txtLusterwareWeight.Text == "" ? Constant.INT_IS_ZERO : Convert.ToDecimal(this.txtLusterwareWeight.Text); this._thisGoodsEntity.ProductionCycle = this.txtProductionCycle.Text == "" ? Constant.INT_IS_ZERO : Convert.ToDecimal(this.txtProductionCycle.Text); this._thisGoodsEntity.StartingDate = this.dtpStartingDate.Value.Date; this._thisGoodsEntity.AutoLossCycle = (this.txtSPM001.DataValue.HasValue ? Convert.ToInt32(this.txtSPM001.DataValue) : 0); this._thisGoodsEntity.DeliverLimitCycle = (this.txtSPM002.DataValue.HasValue ? Convert.ToInt32(this.txtSPM002.DataValue) : 0); this._thisGoodsEntity.MouldOutputCount = (this.txtMouldOutputCount.DataValue.HasValue ? Convert.ToInt32(this.txtMouldOutputCount.DataValue) : 1); this._thisGoodsEntity.StandardGroutingNum = (this.txtStandardGroutingNum.DataValue.HasValue ? Convert.ToInt32(this.txtStandardGroutingNum.DataValue) : 0); this._thisGoodsEntity.STD_GNUM_MAX = (this.txtstd_gnum_max.DataValue.HasValue ? Convert.ToInt32(this.txtstd_gnum_max.DataValue) : 0); this._thisGoodsEntity.MouldMaterialCode = this.txtMouldMaterialCode.Text.Trim(); this._thisGoodsEntity.WaterLabelCode = this.txtWaterLabelCode.Text; this._thisGoodsEntity.CertificateCode = this.txtCertificateCode.Text; this._thisGoodsEntity.PlateLimitNum = (this.txtPlateLimitNum1.DataValue.HasValue ? Convert.ToInt32(this.txtPlateLimitNum1.DataValue) : 0); this._thisGoodsEntity.PlateLimitNumNew = (this.txtPlateLimitNumNew1.DataValue.HasValue ? Convert.ToInt32(this.txtPlateLimitNumNew1.DataValue) : 0); this._thisGoodsEntity.UnitPrice = (this.txtUnitPrice.DataValue.HasValue ? this.txtUnitPrice.DataValue.Value : 0); this._thisGoodsEntity.ReservedDays = (this.txtReservedDays.DataValue.HasValue ? Convert.ToInt32(this.txtReservedDays.DataValue) : 0); this._thisGoodsEntity.PackageNum = this.txtPackageNum.Text.Trim(); this._thisGoodsEntity.OutletDistance = this.txtOutletDistance.Text.Trim(); this._thisGoodsEntity.MaterialCode = this.scbSAPCode1.Text.Trim(); this._thisGoodsEntity.MaterialRemark = this.txtMaterialRemark.Text; this._thisGoodsEntity.PrintCopies = (this.txtCopies.DataValue.HasValue ? Convert.ToInt32(this.txtCopies.DataValue) : 0); this._thisGoodsEntity.ProductDays = Convert.ToDecimal(this.txtproductDays.Text);//生产天数 this._thisGoodsEntity.DaygroutingNumber= Convert.ToDecimal(this.txtdaygroutingNumber.Text); this._thisGoodsEntity.Attendance = Convert.ToDecimal(this.txtattendance.Text); this._thisGoodsEntity.ProtectdaMrate = Convert.ToDecimal(this.txtprotectdaMrate.Text); this._sapInfo.AcceptChanges(); this._thisGoodsEntity.SAPInfo = this._sapInfo; this._thisGoodsEntity.LogoID = Convert.ToInt32(ftcLogo.SelectedValue); if (this.txtMouldWeight.DataValue != null) { this._thisGoodsEntity.MouldWeight = this.txtMouldWeight.DataValue; } if (this.txtMouldCost.DataValue != null) { this._thisGoodsEntity.MouldCost = this.txtMouldCost.DataValue; } if (this.txtSEATCOVERCODE.DataValue != null) { this._thisGoodsEntity.SeatCoverCode = Convert.ToInt32(this.txtSEATCOVERCODE.DataValue); } if (this.cbCeaseFlag.Checked) { this._thisGoodsEntity.CeaseFlag = Convert.ToInt32(Constant.ValueFlag.Effective); } else { this._thisGoodsEntity.CeaseFlag = Convert.ToInt32(Constant.ValueFlag.Invalid); } if (this.cbValueFlag.Checked) { this._thisGoodsEntity.ValueFlag = Convert.ToInt32(Constant.ValueFlag.Effective); } else { this._thisGoodsEntity.ValueFlag = Convert.ToInt32(Constant.ValueFlag.Invalid); } if (this.cbSecurityCodeBindFlag.Checked) { this._thisGoodsEntity.SecurityCodeBindFlag = Convert.ToInt32(Constant.ValueFlag.Effective); } else { this._thisGoodsEntity.SecurityCodeBindFlag = Convert.ToInt32(Constant.ValueFlag.Invalid); } if (this.cbSecurityCodeCheckFlag.Checked) { this._thisGoodsEntity.SecurityCodeCheckFlag = Convert.ToInt32(Constant.ValueFlag.Effective); } else { this._thisGoodsEntity.SecurityCodeCheckFlag = Convert.ToInt32(Constant.ValueFlag.Invalid); } this._thisGoodsEntity.ScrapSumFlag = (this.chkScrapSumFlag.Checked ? "1" : "0"); this._thisGoodsEntity.PlanFlag = (this.cbPlanFlag.Checked ? "1" : "0"); this._thisGoodsEntity.GoodsLineType = (this.chkGLT.Checked ? "1" : "0"); this._thisGoodsEntity.GoodsLineCode = this.chkGLT.Checked ? this.cbGLTDetail.SelectedValue.ToString() : "L"; this._thisGoodsEntity.Remarks = this.txtRemarks.Text; //首先将未修改的图片从集合中删除 for (int i = 0; i < _imgList.Count; i++) { this._picByteList.RemoveAt(Constant.INT_IS_ZERO); this._smallByteList.RemoveAt(Constant.INT_IS_ZERO); } this._imgList.Clear(); //循环插入图片 for (int i = 0; i < _picByteList.Count; i++) { GoodsImageEntity imgEntity = new GoodsImageEntity(); imgEntity.ValueFlag = Convert.ToInt32(Constant.ValueFlag.Effective); byte[] buffer = _picByteList[i]; imgEntity.Image = buffer; imgEntity.Thumbnail = _smallByteList[i]; this._imgList.Add(imgEntity); } //如果是编辑模式,有被删除的图片,那么要把这些图片也加入到集合中 if (this._updateImgList.Count != Constant.INT_IS_ZERO) { for (int i = 0; i < this._updateImgList.Count; i++) { GoodsImageEntity updateImgEntity = this._updateImgList[i]; this._imgList.Add(updateImgEntity); } } if (this._formGoodsId == Constant.INT_IS_ZERO) { int MyReturn = (int)DoAsync(new BaseAsyncMethod(() => { return SystemModuleProxy.Service.AddGoods(this._thisGoodsEntity, this._imgList, this._attList); })); if (MyReturn > Constant.INT_IS_ZERO) { MessageBox.Show(string.Format(Messages.MSG_CMN_I001, "产品档案", "保存"), this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); PageInitialization(); } else if (MyReturn == -10) { MessageBox.Show(string.Format(Messages.MSG_CMN_W006, "物料编码"), this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning); this.scbSAPCode1.Focus(); return; } else { MessageBox.Show(string.Format(Messages.MSG_CMN_W001, "产品档案", "保存"), this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning); } } else { int MyReturn = SystemModuleProxy.Service.UpdateGoods(_thisGoodsEntity, _imgList, _attList); if (MyReturn > Constant.INT_IS_ZERO) { MessageBox.Show(string.Format(Messages.MSG_CMN_I001, "产品档案", "保存"), this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); this.DialogResult = DialogResult.OK; } else if (MyReturn == -10) { MessageBox.Show(string.Format(Messages.MSG_CMN_W006, "物料编码"), this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning); this.scbSAPCode1.Focus(); return; } else if (MyReturn == -500) { MessageBox.Show(Messages.MSG_CMN_W012, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1); this.DialogResult = DialogResult.OK; } else { MessageBox.Show(string.Format(Messages.MSG_CMN_W001, "产品档案", "保存"), this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning); } } } catch (Exception ex) { // 对异常进行共通处理 ExceptionManager.HandleEventException(this.ToString(), System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex); } } /// /// 上传缩略图 /// private void btnUpload_Click(object sender, EventArgs e) { try { odlgFile.Filter = Constant.FILTER_PIC; odlgFile.FilterIndex = Constant.INT_IS_ZERO; odlgFile.RestoreDirectory = true; odlgFile.Title = "选择产品图片"; odlgFile.FileName = null; odlgFile.RestoreDirectory = true; if (odlgFile.ShowDialog() == DialogResult.OK) { FileInfo file = new FileInfo(odlgFile.FileName); if (Constant.UPLOAD_PIC_MAX_SIZE < file.Length) { MessageBox.Show(string.Format(Messages.MSG_CMN_W013, "产品图片", "大小", "1M"), this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); } else { Image PicImage = Image.FromStream(file.OpenRead()); this._picByteList.Add(ImageToByte(PicImage)); GetThumbnail(file); BindImg(); } } } catch (Exception ex) { // 对异常进行共通处理 ExceptionManager.HandleEventException(this.ToString(), System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex); } } /// /// 删除某缩略图 /// private void btnDelete_Click(object sender, EventArgs e) { try { foreach (ListViewItem lvSelect in lvPic.SelectedItems) { int index = lvSelect.Index; if (index < Constant.INT_IS_ZERO) { index = Constant.INT_IS_ZERO; } ilPic.Images.RemoveAt(index); this._picByteList.RemoveAt(index); this._smallByteList.RemoveAt(index); lvPic.Items.RemoveAt(index); if (index < this._imgList.Count) { if (this._imgList[index].GoodsImageID != Constant.INT_IS_ZERO) { GoodsImageEntity deleteImgEntity = this._imgList[index]; this._imgList[index].ValueFlag = Convert.ToInt32(Constant.ValueFlag.Invalid); this._updateImgList.Add(deleteImgEntity); this._imgList.RemoveAt(index); } } } BindImg(); } catch (Exception ex) { // 对异常进行共通处理 ExceptionManager.HandleEventException(this.ToString(), System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex); } } /// /// 关闭窗体 /// private void btnCancel_Click(object sender, EventArgs e) { this.DialogResult = DialogResult.OK; } /// /// 查看图片 /// private void lvPic_DoubleClick(object sender, EventArgs e) { try { foreach (ListViewItem lvSelect in lvPic.SelectedItems) { int index = lvSelect.Index; if (index < Constant.INT_IS_ZERO) { index = Constant.INT_IS_ZERO; } F_CMN_0102 addGoods = new F_CMN_0102(_picByteList[index]); DialogResult dialogresult = addGoods.ShowDialog(); } } catch (Exception ex) { // 对异常进行共通处理 ExceptionManager.HandleEventException(this.ToString(), System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex); } } /// /// SAP物料编码改变事件 /// /// /// private void txtSAPRemark_TextChanged(object sender, EventArgs e) { if (this.dgvGoodsSap.CurrentRow == null) { return; } try { DataRowView row = this.dgvGoodsSap.CurrentRow.DataBoundItem as DataRowView; if (row != null) { row["materialremark"] = txtSAPRemark.Text; row.EndEdit(); } } catch (Exception ex) { // 对异常进行共通处理 ExceptionManager.HandleEventException(this.ToString(), System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex); } } /// /// /// /// /// private void txtMouldOutputCount_TextChanged(object sender, EventArgs e) { try { int mouldOutputCount = (this.txtMouldOutputCount.DataValue.HasValue ? Convert.ToInt32(this.txtMouldOutputCount.DataValue) : 1); int standardGroutingNum = (this.txtStandardGroutingNum.DataValue.HasValue ? Convert.ToInt32(this.txtStandardGroutingNum.DataValue) : 0); this.txtStandardGroutingSum.DataValue = mouldOutputCount * standardGroutingNum; } catch (Exception ex) { // 对异常进行共通处理 ExceptionManager.HandleEventException(this.ToString(), System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex); } } /// /// /// /// /// private void chkGLT_Click(object sender, EventArgs e) { this.cbGLTDetail.Enabled = this.chkGLT.Checked; } #endregion #region 私有方法 /// /// 加载页面所需的数据源 /// private void LoadDataSource() { try { // 绑定釉料类别 DataTable dtGlazeType = SystemModuleProxy.Service.GetDataDictionaryByType(Constant.DictionaryType.TPC002, Constant.INT_IS_ONE); if (dtGlazeType != null) { ddlGlazeTypeID.DisplayMember = "DictionaryValue"; ddlGlazeTypeID.ValueMember = "DictionaryID"; ddlGlazeTypeID.DataSource = dtGlazeType; } // 绑定坯库类型 DataTable dtMudStoreType = SystemModuleProxy.Service.GetDataDictionaryByType(Constant.DictionaryType.TPC009, Constant.INT_IS_ONE); if (dtMudStoreType != null) { //cq MODIFY 20210826 产品档案坯库类型取汉字(这里是Remarks) //ddlMudStoreType.DisplayMember = "DictionaryValue"; //begin ddlMudStoreType.DisplayMember = "Remarks"; ddlMudStoreType.ValueMember = "DictionaryID"; ddlMudStoreType.DataSource = dtMudStoreType; } DataSet logos = SystemModuleProxy.Service.GetLogoInfo(); if (logos != null && logos.Tables.Count > 0) { ftcLogo.DisplayMember = "LogoNameCode"; ftcLogo.ValueMember = "LogoID"; ftcLogo.DataSource = logos.Tables[0]; } //L:立浇 G:高压 M:粘接高压(三水厂) Q:吊装线 DataTable dt = new DataTable(); dt.Columns.Add("key"); dt.Columns.Add("value"); dt.Rows.Add(new object[] { "L", "立浇【L】" }); dt.Rows.Add(new object[] { "G", "高压【G】" }); dt.Rows.Add(new object[] { "M", "粘接高压(三水厂)【M】" }); //dt.Rows.Add(new object[] { "Q", "吊装线" }); this.cbGLTDetail.DataSource = dt; this.cbGLTDetail.ValueMember = "key"; this.cbGLTDetail.DisplayMember = "value"; } catch (Exception ex) { throw ex; } } /// /// 绑定缩略图到控件中 /// private void BindImg() { try { //每次绑定要清空数据源 this.ilPic.Images.Clear(); //将缩略图二进制集合中的数据转换成图片文件 List LSImageList = new List(); foreach (byte[] smallby in _smallByteList) { LSImageList.Add(byteArrayToImage(smallby)); } //添加数据源 foreach (Image img in LSImageList) { ilPic.Images.Add(img); } this.ilPic.ImageSize = new Size(Constant.INT_IS_HUNDRED, Constant.INT_IS_HUNDRED); this.lvPic.LargeImageList = this.ilPic; this.lvPic.BeginUpdate(); //清空列表的数据源 lvPic.Items.Clear(); //添加列表的数据源 for (int i = 0; i < ilPic.Images.Count; i++) { ListViewItem lvi = new ListViewItem(); lvi.ImageIndex = i; this.lvPic.Items.Add(lvi); } this.lvPic.EndUpdate(); } catch (Exception ex) { throw ex; } } /// /// 重绘缩略图并把缩略图转为二进制储存在集合众 /// /// 图片实体 /// private void GetThumbnail(FileInfo sourceFile) { try { Image imgSource = Image.FromStream(sourceFile.OpenRead()); ImageFormat thisFormat = imgSource.RawFormat; int sW = Constant.INT_IS_ZERO, sH = Constant.INT_IS_ZERO; // 按比例缩放 int sWidth = imgSource.Width; int sHeight = imgSource.Height; int destWidth = Constant.INT_IS_HUNDRED; int destHeight = getSmallImageHeight(sWidth, sHeight, destWidth); if (sHeight > destHeight || sWidth > destWidth) { if ((sWidth * destHeight) > (sHeight * destWidth)) { sW = destWidth; sH = (destWidth * sHeight) / sWidth; } else { sH = destHeight; sW = (sWidth * destHeight) / sHeight; } } else { sW = sWidth; sH = sHeight; } Bitmap outBmp = new Bitmap(destWidth, destHeight); Graphics g = Graphics.FromImage(outBmp); g.Clear(Color.Black); // 设置画布的描绘质量 g.CompositingQuality = CompositingQuality.HighQuality; g.SmoothingMode = SmoothingMode.HighQuality; g.InterpolationMode = InterpolationMode.HighQualityBicubic; g.DrawImage(imgSource, new Rectangle((destWidth - sW) / Constant.INT_IS_TWO, (destHeight - sH) / Constant.INT_IS_TWO, sW, sH), Constant.INT_IS_ZERO, Constant.INT_IS_ZERO, imgSource.Width, imgSource.Height, GraphicsUnit.Pixel); g.Dispose(); //将重绘的图片转为二进制并保存 Image image = (Image)outBmp; byte[] smallbuffer = ImageToByte(image); this._smallByteList.Add(smallbuffer); imgSource.Dispose(); outBmp.Dispose(); } catch (Exception ex) { throw ex; } } /// /// 根据原图片宽高比获取缩略图的高(根据宽) /// /// 原图宽度 /// 原图高度 /// 缩略图宽度 /// 缩略图的高度 private int getSmallImageHeight(int BigWidth, int BigHeight, int SmallWidth) { try { decimal scale = Convert.ToDecimal(BigWidth) / Convert.ToDecimal(BigHeight); return Convert.ToInt32(SmallWidth / scale); } catch (Exception ex) { throw ex; } } /// /// 验证添加项 /// private int ValidationText() { int ErrorID = 0; if (this.ddlGlazeTypeID.SelectedValue.ToString() == string.Empty) { ErrorID = 7; } if (this.txtGoodsName.Text.Trim() == string.Empty) { ErrorID = 3; } if (scbGoodsType.SearchedItem == null) { ErrorID = 6; } if (this.txtGoodsCode.Text.Trim() == string.Empty) { ErrorID = 1; } return ErrorID; } /// /// 绑定缩略图到缩略图集合中 /// /// 图片集合 private void BindByteImage(DataSet ImageData) { try { foreach (DataRow dr in ImageData.Tables[0].Rows) { //将数据库中的缩略图取出 this._smallByteList.Add((byte[])dr[2]); this._picByteList.Add((byte[])dr[3]); //绑定实体到修改图片集合中 GoodsImageEntity imgEntity = new GoodsImageEntity(); imgEntity.GoodsImageID = Convert.ToDecimal(dr[0]); imgEntity.GoodsID = Convert.ToDecimal(dr[1]); imgEntity.Thumbnail = (byte[])dr[2]; imgEntity.Image = (byte[])dr[3]; imgEntity.AccountID = Convert.ToDecimal(dr[4]); imgEntity.ValueFlag = Convert.ToDecimal(dr[5]); imgEntity.CreateTime = Convert.ToDateTime(dr[6]); imgEntity.CreateUserID = Convert.ToDecimal(dr[7]); imgEntity.UpdateTime = Convert.ToDateTime(dr[8]); imgEntity.UpdateUserID = Convert.ToDecimal(dr[9]); imgEntity.OPTimeStamp = Convert.ToDateTime(dr[10]); this._imgList.Add(imgEntity); } //绑定缩略图 BindImg(); } catch (Exception ex) { throw ex; } } /// /// 将数据库中的二进制转换成图片 /// /// 需要转换成图片的二进制数据 /// 图片文件实体 private static Image byteArrayToImage(object data) { try { System.IO.MemoryStream ms = new System.IO.MemoryStream((byte[])data); System.Drawing.Image returnImage = System.Drawing.Image.FromStream(ms); return returnImage; } catch (Exception ex) { throw ex; } } /// /// 将图片文件转换成二进制 /// /// 需要转换的图片 /// 图片二进制数据 private static byte[] ImageToByte(Image img) { try { byte[] smallbuffer = null; using (MemoryStream ms = new MemoryStream()) { img.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg); ms.Position = Constant.INT_IS_ZERO; smallbuffer = new byte[ms.Length]; ms.Read(smallbuffer, Constant.INT_IS_ZERO, Convert.ToInt32(ms.Length)); ms.Flush(); } return smallbuffer; } catch (Exception ex) { throw ex; } } /// /// 验证产品编号唯一性 /// /// 产品编号 /// 是否重复,真为不重复,可插入 private bool ValidationCode(string goodsCode) { try { GoodsEntity vgoods = new GoodsEntity(); vgoods.GoodsCodeOnly = goodsCode; int i = ((DataSet)SystemModuleProxy.Service.SerachGoods(vgoods)).Tables[0].Rows.Count; if (i > Constant.INT_IS_ZERO) { return false; } else { return true; } } catch (Exception ex) { throw ex; } } /// ///编辑装板 禁用页面输入 /// private void DisableControl() { //页面控件初始化 this.txtGoodsCode.Enabled = false; this.scbGoodsType.Enabled = false; this.ddlGlazeTypeID.Enabled = false; this.dtpStartingDate.Enabled = false; this.txtWaterLabelCode.Enabled = false; this.txtCertificateCode.Enabled = false; this.ddlMudStoreType.Enabled = false; //this.ddlGlazeTypeID.SelectedValue = null; this.txtRemarks.Enabled = false; this.btnUpload.Enabled = false; this.btnDelete.Enabled = false; this.cbCeaseFlag.Enabled = false; this.cbValueFlag.Enabled = false; this.chkScrapSumFlag.Enabled = false; this.cbSecurityCodeBindFlag.Enabled = false; this.cbSecurityCodeCheckFlag.Enabled = false; this.cbPlanFlag.Enabled = false; this.chkGLT.Enabled = false; this.cbGLTDetail.Enabled = false; this.txtCopies.Enabled = false; this.txtGoodsName.Enabled = false; //成员变量初始化 this.txtGoodsModel.Enabled = false; this.txtGoodsSpecification.Enabled = false; this.txtUnitPrice.Enabled = false; this.txtProductionCycle.Enabled = false; this.txtGlazeWeight.Enabled = false; this.txtLusterwareWeight.Enabled = false; this.txtMudWeight.Enabled = false; this.txtSEATCOVERCODE.Enabled = false; this.txtSPM001.Enabled = false; this.txtSPM002.Enabled = false; this.txtReservedDays.Enabled = false; this.txtproductDays.Enabled = false; this.txtattendance.Enabled = false; this.txtdaygroutingNumber.Enabled = false; this.txtprotectdaMrate.Enabled = false; this.txtMouldMaterialCode.Enabled = false; this.txtMouldOutputCount.Enabled = false; this.txtStandardGroutingNum.Enabled = false; this.txtStandardGroutingSum.Enabled = false; this.txtstd_gnum_max.Enabled = false; this.txtMouldWeight.Enabled = false; this.txtMouldCost.Enabled = false; this.txtPackageNum.Enabled = false; this.scbSAPCode1.Enabled = false; this.txtOutletDistance.Enabled = false; this.txtMaterialRemark.Enabled = false; this.ftcLogo.Enabled = false; this.scbSAPCode2.Enabled = false; this.txtSAPWaterLabelCode.Enabled = false; this.txtSAPCertificateCode.Enabled = false; this.txtSAPRemark.Enabled = false; } /// /// 页面控件初始化 /// private void PageInitialization() { //页面控件初始化 this.txtGoodsCode.Text = ""; //this.gtsGoodaType.GoodsTypeCode = null; //this.gtsGoodaType.GoodsTypeID = null; //this.gtsGoodaType.GoodsTypeName = null; //this.gtsGoodaType.Text = ""; this.scbGoodsType.ClearValue(); this.txtGoodsName.Text = ""; this.txtGoodsModel.Text = ""; this.txtGoodsSpecification.Text = ""; this.txtMudWeight.Text = ""; this.txtGlazeWeight.Text = ""; //this.ddlGlazeTypeID.SelectedValue = null; this.txtProductionCycle.Text = ""; this.txtLusterwareWeight.Text = ""; this.txtRemarks.Text = ""; this.lvPic.Items.Clear(); this.cbCeaseFlag.Checked = true; this.cbValueFlag.Checked = true; this.chkGLT.Checked = false; this.txtSPM001.DataValue = 0; this.txtSPM002.DataValue = 0; this.txtMouldOutputCount.DataValue = 1; this.txtStandardGroutingNum.DataValue = 0; this.txtstd_gnum_max.DataValue = 0; this.dtpStartingDate.Value = DateTime.Now.Date; //成员变量初始化 this._thisGoodsEntity = new GoodsEntity(); this._picByteList = new List(); this._smallByteList = new List(); this._imgList = new List(); this._updateImgList = new List(); this.txtUnitPrice.DataValue = 0; this.txtPlateLimitNum1.DataValue = 0; this.txtPlateLimitNumNew1.DataValue = 0; this.txtReservedDays.DataValue = 0; this.txtPackageNum.Text = ""; this.txtOutletDistance.Text = ""; this.scbSAPCode1.Text = ""; this.txtMaterialRemark.Text = ""; this.txtMouldWeight.DataValue = null; this.txtMouldCost.DataValue = null; this.txtSEATCOVERCODE.DataValue = null; this.txtWaterLabelCode.Clear(); this.txtCertificateCode.Clear(); this.chkScrapSumFlag.Checked = true; this.txtMouldMaterialCode.Clear(); foreach (DataRow row in this._sapInfo.Rows) { row["materialcode"] = DBNull.Value; row["materialremark"] = DBNull.Value; row["WaterLabelCode"] = DBNull.Value; row["PlateLimitNum"] = DBNull.Value; row["PlateLimitNumNew"] = DBNull.Value; } this._sapInfo.AcceptChanges(); } #endregion #region SAP物料 private void dgvGoodsSap_SelectionChanged(object sender, EventArgs e) { if (this.dgvGoodsSap.CurrentRow == null) { //this.scbSAPCode2.Clear(); //this.txtSAPRemark.Clear(); return; } try { this.scbSAPCode2.Text = this.dgvGoodsSap.CurrentRow.Cells["colmaterialcode"].Value + ""; this.txtSAPRemark.Text = this.dgvGoodsSap.CurrentRow.Cells["colmaterialremark"].Value + ""; this.txtSAPWaterLabelCode.Text = this.dgvGoodsSap.CurrentRow.Cells["colWaterLabelCode"].Value + ""; this.txtSAPCertificateCode.Text = this.dgvGoodsSap.CurrentRow.Cells["colCertificateCode"].Value + ""; this.txtPlateLimitNum.Text = this.dgvGoodsSap.CurrentRow.Cells["colPlateLimitNum"].Value + ""; this.txtPlateLimitNumNew.Text = this.dgvGoodsSap.CurrentRow.Cells["colPlateLimitNumNew"].Value + ""; } catch (Exception ex) { // 对异常进行共通处理 ExceptionManager.HandleEventException(this.ToString(), System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex); } } private void txtSAPCode_Validated(object sender, EventArgs e) { //if (this.dgvGoodsSap.CurrentRow == null) //{ // return; //} //try //{ // DataRowView row = this.dgvGoodsSap.CurrentRow.DataBoundItem as DataRowView; // if (row != null) // { // row["materialcode"] = scbSAPCode2.Text; // row.EndEdit(); // } //} //catch (Exception ex) //{ // // 对异常进行共通处理 // ExceptionManager.HandleEventException(this.ToString(), // System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex); //} } private void txtSAPRemark_Validated(object sender, EventArgs e) { //if (this.dgvGoodsSap.CurrentRow == null) //{ // return; //} //try //{ // DataRowView row = this.dgvGoodsSap.CurrentRow.DataBoundItem as DataRowView; // if (row != null) // { // row["materialremark"] = txtSAPRemark.Text; // row.EndEdit(); // } //} //catch (Exception ex) //{ // // 对异常进行共通处理 // ExceptionManager.HandleEventException(this.ToString(), // System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex); //} } private void txtSAPWaterLabelCode_Validated(object sender, EventArgs e) { if (this.dgvGoodsSap.CurrentRow == null) { return; } try { DataRowView row = this.dgvGoodsSap.CurrentRow.DataBoundItem as DataRowView; if (row != null) { row["WaterLabelCode"] = txtSAPWaterLabelCode.Text; row.EndEdit(); } } catch (Exception ex) { // 对异常进行共通处理 ExceptionManager.HandleEventException(this.ToString(), System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex); } } private void txtSAPCertificateCode_Validated(object sender, EventArgs e) { if (this.dgvGoodsSap.CurrentRow == null) { return; } try { DataRowView row = this.dgvGoodsSap.CurrentRow.DataBoundItem as DataRowView; if (row != null) { row["CertificateCode"] = txtSAPCertificateCode.Text; row.EndEdit(); } } catch (Exception ex) { // 对异常进行共通处理 ExceptionManager.HandleEventException(this.ToString(), System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex); } } /// /// 物料编码改变事件 /// /// /// private void scbSAPCode2_TextValueChanged(object sender, WinForm.Controls.ScbSearchBox.TextChangeEventArgs e) { if (this.dgvGoodsSap.CurrentRow == null) { return; } try { DataRowView row = this.dgvGoodsSap.CurrentRow.DataBoundItem as DataRowView; if (row != null) { row["materialcode"] = scbSAPCode2.Text; row.EndEdit(); } } catch (Exception ex) { // 对异常进行共通处理 ExceptionManager.HandleEventException(this.ToString(), System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex); } } /// /// 装板限制数量改变事件 /// /// /// private void txtPlateLimitNum_Validated(object sender, EventArgs e) { if (this.dgvGoodsSap.CurrentRow == null) { return; } try { DataRowView row = this.dgvGoodsSap.CurrentRow.DataBoundItem as DataRowView; if (row != null) { if (txtPlateLimitNum.Text != "") { row["PlateLimitNum"] = txtPlateLimitNum.Text; } else { row["PlateLimitNum"] = DBNull.Value; } row.EndEdit(); } } catch (Exception ex) { // 对异常进行共通处理 ExceptionManager.HandleEventException(this.ToString(), System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex); } } /// /// 新板限制数量 /// /// /// private void txtPlateLimitNumNew_Validated(object sender, EventArgs e) { if (this.dgvGoodsSap.CurrentRow == null) { return; } try { DataRowView row = this.dgvGoodsSap.CurrentRow.DataBoundItem as DataRowView; if (row != null) { if (txtPlateLimitNumNew.Text != "") { row["PlateLimitNumNew"] = txtPlateLimitNumNew.Text; } else { row["PlateLimitNumNew"] = DBNull.Value; } row.EndEdit(); } } catch (Exception ex) { // 对异常进行共通处理 ExceptionManager.HandleEventException(this.ToString(), System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex); } } /// /// 防伪码绑定改变事件 /// /// /// private void cbSecurityCodeBindFlag_CheckedChanged(object sender, EventArgs e) { if (!this.cbSecurityCodeBindFlag.Checked) { this.cbSecurityCodeCheckFlag.Checked = false; } } /// /// 防伪码验证改变事件 /// /// /// private void cbSecurityCodeCheckFlag_CheckedChanged(object sender, EventArgs e) { if (this.cbSecurityCodeCheckFlag.Checked) { this.cbSecurityCodeBindFlag.Checked = true; } } #endregion /// /// 物料选择 /// /// /// private void scbSAPCode1_SearchedItemChanged(object sender, EventArgs e) { try { string matntCode = scbSAPCode1.SearchedValue.ToString(); // 异步处理,获取系统参数信息 ClientRequestEntity cre = new ClientRequestEntity(); cre.NameSpace = "F_SAPCode"; cre.Name = "GetSAPCode"; cre.Properties["matnr"] = matntCode; // 调用服务器端获取数据集 ServiceResultEntity sre = CommonModuleProxy.Service.DoRequest(cre); if (sre != null && sre.Data != null && sre.Data.Tables.Count > 0 && sre.Data.Tables[0].Rows.Count > 0) { this.txtMaterialRemark.Text = sre.Data.Tables[0].Rows[0]["materialname"].ToString(); } } catch (Exception ex) { throw ex; } } private void scbSAPCode2_SearchedItemChanged(object sender, EventArgs e) { try { string matntCode = scbSAPCode2.SearchedValue.ToString(); // 异步处理,获取系统参数信息 ClientRequestEntity cre = new ClientRequestEntity(); cre.NameSpace = "F_SAPCode"; cre.Name = "GetSAPCode"; cre.Properties["matnr"] = matntCode; // 调用服务器端获取数据集 ServiceResultEntity sre = CommonModuleProxy.Service.DoRequest(cre); if (sre != null && sre.Data != null && sre.Data.Tables.Count > 0 && sre.Data.Tables[0].Rows.Count >0) { this.txtSAPRemark.Text = sre.Data.Tables[0].Rows[0]["materialname"].ToString(); } } catch (Exception ex) { throw ex; } } } }