F_MST_0502.cs 48 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091
  1. /*******************************************************************************
  2. * Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential
  3. * 类的信息:
  4. * 1.程序名称:F_MST_0502.cs
  5. * 2.功能描述:新建或编辑产品档案信息
  6. * 编辑履历:
  7. * 作者 日期 版本 修改内容
  8. * 庄天威 2014/09/13 1.00 新建
  9. *******************************************************************************/
  10. using Dongke.IBOSS.PRD.Basics.BaseControls;
  11. using Dongke.IBOSS.PRD.Basics.BaseResources;
  12. using Dongke.IBOSS.PRD.Client.CommonModule;
  13. using Dongke.IBOSS.PRD.Client.CommonModule.FormCommon;
  14. using Dongke.IBOSS.PRD.WCF.DataModels;
  15. using Dongke.IBOSS.PRD.WCF.Proxys;
  16. using System;
  17. using System.Collections.Generic;
  18. using System.Data;
  19. using System.Drawing;
  20. using System.Drawing.Drawing2D;
  21. using System.Drawing.Imaging;
  22. using System.IO;
  23. using System.Windows.Forms;
  24. namespace Dongke.IBOSS.PRD.Client.SystemModule
  25. {
  26. /// <summary>
  27. /// 新建或编辑产品档案信息
  28. /// </summary>
  29. public partial class F_MST_0502 : FormBase
  30. {
  31. #region 成员变量
  32. //页面状态
  33. private Constant.FormMode _formStatus;
  34. // 产品ID
  35. private int _formGoodsId;
  36. // 产品图片二进制集合
  37. private List<byte[]> _picByteList = new List<byte[]>();
  38. // 产品图片缩略图二进制集合
  39. private List<byte[]> _smallByteList = new List<byte[]>();
  40. // 产品图片实体集合
  41. private List<GoodsImageEntity> _imgList = new List<GoodsImageEntity>();
  42. // 已存在的图片实体集合(修改)
  43. private List<GoodsImageEntity> _updateImgList = new List<GoodsImageEntity>();
  44. // 产品附件实体集合
  45. private List<GoodsAttachmentEntity> _attList = new List<GoodsAttachmentEntity>();
  46. // 当前编辑实体
  47. private GoodsEntity _thisGoodsEntity = new GoodsEntity();
  48. private DataTable _sapInfo = null;
  49. #endregion
  50. #region 构造函数
  51. /// <summary>
  52. /// 新建/编辑产品档案窗体构造
  53. /// </summary>
  54. /// <param name="modelId">窗体模式,0为新建,1为编辑</param>
  55. /// <param name="goodsId">编辑产品ID</param>
  56. public F_MST_0502(Constant.FormMode status, int goodsId)
  57. {
  58. InitializeComponent();
  59. this.dgvGoodsSap.AutoGenerateColumns = false;
  60. this._formStatus = status;
  61. this._formGoodsId = goodsId;
  62. if (this._formStatus == Constant.FormMode.Add)
  63. {
  64. this.Text = FormTitles.F_MST_0502_ADD;
  65. }
  66. else
  67. {
  68. this.Text = FormTitles.F_MST_0502_EDIT;
  69. }
  70. this.btnSave.Text = ButtonText.BTN_SAVE;
  71. this.btnCancel.Text = ButtonText.BTN_CLOSE;
  72. this.btnUpload.Text = ButtonText.BTN_UPLOAD;
  73. this.btnDelete.Text = ButtonText.BTN_DELETE;
  74. }
  75. #endregion
  76. #region 事件
  77. /// <summary>
  78. /// 窗体加载
  79. /// </summary>
  80. private void F_MST_0702_Load(object sender, EventArgs e)
  81. {
  82. try
  83. {
  84. this.scbGoodsType.IsOnlyDisplayEnd = true;
  85. LoadDataSource();
  86. if (this._formStatus == Constant.FormMode.Edit)
  87. {
  88. // 产品编码不能编辑 add by chenxy 2016-08-16 begin
  89. this.txtGoodsCode.ReadOnly = true;
  90. // 产品编码不能编辑 add by chenxy 2016-08-16 end
  91. //根据goodsId查询对应的产品信息
  92. this._thisGoodsEntity.GoodsID = this._formGoodsId;
  93. DataSet updateGoods = SystemModuleProxy.Service.SerachGoods(this._thisGoodsEntity);
  94. if (updateGoods.Tables[0].Rows.Count != Constant.INT_IS_ZERO)
  95. {
  96. //把值绑入实体
  97. DataRow drGoods = updateGoods.Tables[0].Rows[0];
  98. this._thisGoodsEntity.GoodsCode = drGoods["GoodsCode"].ToString();
  99. this._thisGoodsEntity.GoodsTypeID = Convert.ToInt32(drGoods["GOODSTYPEID"]);
  100. this._thisGoodsEntity.GlazeTypeID = Convert.ToInt32(drGoods["GLAZETYPEID"]);
  101. this._thisGoodsEntity.CeaseFlag = Convert.ToInt32(drGoods["CEASEFLAG"]);
  102. this._thisGoodsEntity.Remarks = drGoods["Remarks"].ToString();
  103. this._thisGoodsEntity.AccountID = Convert.ToInt32(drGoods["AccountID"]);
  104. this._thisGoodsEntity.ValueFlag = Convert.ToInt32(drGoods["ValueFlag"]);
  105. this._thisGoodsEntity.CreateTime = Convert.ToDateTime(drGoods["CreateTime"]);
  106. this._thisGoodsEntity.CreateUserID = Convert.ToInt32(drGoods["CreateUserID"]);
  107. this._thisGoodsEntity.UpdateTime = Convert.ToDateTime(drGoods["UpdateTime"]);
  108. this._thisGoodsEntity.UpdateUserID = Convert.ToInt32(drGoods["UpdateUserID"]);
  109. this._thisGoodsEntity.OPTimeStamp = Convert.ToDateTime(drGoods["OPTimeStamp"]);
  110. this._thisGoodsEntity.StartingDate = Convert.ToDateTime(drGoods["StartingDate"]);
  111. this._thisGoodsEntity.AutoLossCycle = Convert.ToInt32(drGoods["AutoLossCycle"]);
  112. this._thisGoodsEntity.DeliverLimitCycle = Convert.ToInt32(drGoods["DeliverLimitCycle"]);
  113. this._thisGoodsEntity.PlateLimitNum = Convert.ToInt32(drGoods["PlateLimitNum"]);
  114. this._thisGoodsEntity.UnitPrice = Convert.ToDecimal(drGoods["UnitPrice"]);
  115. this._thisGoodsEntity.ReservedDays = Convert.ToInt32(drGoods["ReservedDays"]);
  116. this._thisGoodsEntity.MouldOutputCount = Convert.ToInt32(drGoods["MouldOutputCount"]);
  117. this._thisGoodsEntity.StandardGroutingNum = Convert.ToInt32(drGoods["StandardGroutingNum"]);
  118. this._thisGoodsEntity.MouldMaterialCode = drGoods["MouldMaterialCode"] + "";
  119. this._thisGoodsEntity.WaterLabelCode = drGoods["WaterLabelCode"] + "";
  120. if (!string.IsNullOrEmpty(drGoods["MudStoreType"] + ""))
  121. {
  122. this._thisGoodsEntity.MudStoreType = Convert.ToInt32(drGoods["MudStoreType"]);
  123. }
  124. //将实体的值赋给各控件
  125. this.txtGoodsCode.Text = drGoods["GoodsCode"].ToString();
  126. this.txtGoodsName.Text = drGoods["GoodsName"].ToString();
  127. this.txtGoodsSpecification.Text = drGoods["GoodsSpecification"].ToString();
  128. this.txtGoodsModel.Text = drGoods["GoodsModel"].ToString();
  129. this.scbGoodsType.CheckedData = updateGoods.Tables[0];
  130. //this.scbGoodsType.InitValue(drGoods["GoodsTypeName"].ToString(), _thisGoodsEntity.GoodsTypeID);
  131. this.scbGoodsType.Text = drGoods["GoodsTypeName"].ToString();
  132. this.ddlGlazeTypeID.SelectedValue = _thisGoodsEntity.GlazeTypeID;
  133. if (_thisGoodsEntity.MudStoreType != null)
  134. {
  135. this.ddlMudStoreType.SelectedValue = _thisGoodsEntity.MudStoreType;
  136. }
  137. this.txtMudWeight.Text = drGoods["MudWeight"].ToString();
  138. this.txtGlazeWeight.Text = drGoods["GlazeWeight"].ToString();
  139. this.txtLusterwareWeight.Text = drGoods["LusterwareWeight"].ToString();
  140. this.txtProductionCycle.Text = drGoods["ProductionCycle"].ToString();
  141. this.cbCeaseFlag.Checked = (_thisGoodsEntity.CeaseFlag == Constant.INT_IS_ONE);
  142. this.cbValueFlag.Checked = (this._thisGoodsEntity.ValueFlag == Constant.INT_IS_ONE);
  143. this.txtRemarks.Text = this._thisGoodsEntity.Remarks;
  144. this.dtpStartingDate.Value = this._thisGoodsEntity.StartingDate;
  145. this.txtSPM001.DataValue = this._thisGoodsEntity.AutoLossCycle;
  146. this.txtSPM002.DataValue = this._thisGoodsEntity.DeliverLimitCycle;
  147. this.txtMouldOutputCount.DataValue = this._thisGoodsEntity.MouldOutputCount;
  148. this.txtStandardGroutingNum.DataValue = this._thisGoodsEntity.StandardGroutingNum;
  149. this.txtMouldMaterialCode.Text = this._thisGoodsEntity.MouldMaterialCode;
  150. this.txtWaterLabelCode.Text = this._thisGoodsEntity.WaterLabelCode;
  151. this.txtPlateLimitNum.DataValue = this._thisGoodsEntity.PlateLimitNum;
  152. this.txtUnitPrice.DataValue = this._thisGoodsEntity.UnitPrice;
  153. this.txtReservedDays.DataValue = this._thisGoodsEntity.ReservedDays;
  154. this.chkGLT.Checked = (drGoods["GOODS_LINE_TYPE"] + "" == "1");
  155. this.txtPackageNum.Text = drGoods["PackageNum"].ToString();
  156. this.txtOutletDistance.Text = drGoods["OutletDistance"].ToString();
  157. this.scbSAPCode1.Text = drGoods["MaterialCode"].ToString();
  158. this.txtMaterialRemark.Text = drGoods["MaterialRemark"].ToString();
  159. this.txtCopies.Text = drGoods["printcopies"].ToString();
  160. this.ftcLogo.InitValue(drGoods["logoname"] + "", drGoods["logoid"]);
  161. if (drGoods["MouldWeight"] != DBNull.Value)
  162. {
  163. this.txtMouldWeight.DataValue = Convert.ToDecimal(drGoods["MouldWeight"]);
  164. }
  165. if (drGoods["MouldCost"] != DBNull.Value)
  166. {
  167. this.txtMouldCost.DataValue = Convert.ToDecimal(drGoods["MouldCost"]);
  168. }
  169. this.chkScrapSumFlag.Checked = (drGoods["ScrapSumFlag"] + "" == "1");
  170. if (drGoods["SeatCoverCode"] != DBNull.Value)
  171. {
  172. this.txtSEATCOVERCODE.DataValue = Convert.ToInt32(drGoods["SeatCoverCode"]);
  173. }
  174. //查询对应的图片
  175. DataSet dsImg = SystemModuleProxy.Service.getImageByGoodsId(this._formGoodsId);
  176. BindByteImage(dsImg);
  177. }
  178. }
  179. // 产品物料信息
  180. ClientRequestEntity cre = new ClientRequestEntity();
  181. cre.NameSpace = "MST_Goods";
  182. cre.Name = "GetGoodsSAPByEdit";
  183. cre.Request = this._formGoodsId;
  184. // 调用服务器端获取数据集
  185. ServiceResultEntity sre = SystemModuleProxy.Service.DoRequest(cre);
  186. if (sre != null && sre.Data != null && sre.Data.Tables.Count > 0)
  187. {
  188. this._sapInfo = sre.Data.Tables[0];
  189. this.dgvGoodsSap.DataSource = this._sapInfo;
  190. }
  191. this.txtGoodsCode.Focus();
  192. }
  193. catch (Exception ex)
  194. {
  195. // 对异常进行共通处理
  196. ExceptionManager.HandleEventException(this.ToString(),
  197. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  198. }
  199. }
  200. /// <summary>
  201. /// 获取数据事件
  202. /// </summary>
  203. private void btnSave_Click(object sender, EventArgs e)
  204. {
  205. try
  206. {
  207. //基础数据验证
  208. int ErrorId = ValidationText();
  209. if (ErrorId != Constant.INT_IS_ZERO)
  210. {
  211. string errorAddress = "";
  212. switch (ErrorId)
  213. {
  214. case 1:
  215. this.txtGoodsCode.Focus();
  216. errorAddress = "产品编码";
  217. break;
  218. case 3:
  219. this.txtGoodsName.Focus();
  220. errorAddress = "产品名称";
  221. break;
  222. case 6:
  223. this.scbGoodsType.Focus();
  224. errorAddress = "产品类别";
  225. break;
  226. case 7:
  227. this.ddlGlazeTypeID.Focus();
  228. errorAddress = "釉料类别";
  229. break;
  230. default:
  231. break;
  232. };
  233. MessageBox.Show(string.Format(Messages.MSG_CMN_W005, errorAddress),
  234. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
  235. return;
  236. }
  237. if (string.IsNullOrEmpty(scbSAPCode1.Text))
  238. {
  239. this.scbSAPCode1.Focus();
  240. MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "物料编码"),
  241. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
  242. return;
  243. }
  244. //if (string.IsNullOrEmpty(txtGroutmaterialcode.Text))
  245. //{
  246. // this.txtGroutmaterialcode.Focus();
  247. // MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "注浆初始物料编码"),
  248. // this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
  249. // return;
  250. //}
  251. if (string.IsNullOrEmpty(txtMouldMaterialCode.Text))
  252. {
  253. this.txtMouldMaterialCode.Focus();
  254. MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "模具物料编码"),
  255. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
  256. return;
  257. }
  258. if (string.IsNullOrEmpty(ftcLogo.SelectedValue + ""))
  259. {
  260. this.ftcLogo.Focus();
  261. MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "注浆商标"),
  262. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
  263. return;
  264. }
  265. //查询产品编号唯一性
  266. if ((this.txtGoodsCode.Text.Trim() != this._thisGoodsEntity.GoodsCode && _formStatus == Constant.FormMode.Edit)
  267. || this._formStatus == Constant.FormMode.Add)
  268. {
  269. if (ValidationCode(this.txtGoodsCode.Text.Trim()) == false)
  270. {
  271. MessageBox.Show(string.Format(Messages.MSG_CMN_W006, "产品编码"), this.Text,
  272. MessageBoxButtons.OK, MessageBoxIcon.Warning);
  273. return;
  274. }
  275. }
  276. //实体赋值
  277. if (this._thisGoodsEntity == null)
  278. {
  279. this._thisGoodsEntity = new GoodsEntity();
  280. }
  281. this._thisGoodsEntity.GoodsCode = this.txtGoodsCode.Text.Trim();
  282. this._thisGoodsEntity.GoodsModel = this.txtGoodsModel.Text.Trim();
  283. this._thisGoodsEntity.GoodsName = this.txtGoodsName.Text.Trim();
  284. this._thisGoodsEntity.GoodsSpecification = this.txtGoodsSpecification.Text;
  285. this._thisGoodsEntity.GoodsTypeID = Convert.ToInt32(scbGoodsType.SearchedItem["GoodsTypeID"]);
  286. this._thisGoodsEntity.GlazeTypeID = this.ddlGlazeTypeID.SelectedValue.ToString() == "" ? null : (int?)Convert.ToInt32(this.ddlGlazeTypeID.SelectedValue);
  287. this._thisGoodsEntity.MudStoreType = this.ddlMudStoreType.SelectedValue.ToString() == "" ? null : (int?)Convert.ToInt32(this.ddlMudStoreType.SelectedValue);
  288. this._thisGoodsEntity.MudQuantity = this.txtMudWeight.Text == "" ? Constant.INT_IS_ZERO : Convert.ToDecimal(this.txtMudWeight.Text);
  289. this._thisGoodsEntity.GlazeQuantity = this.txtGlazeWeight.Text == "" ? Constant.INT_IS_ZERO : Convert.ToDecimal(this.txtGlazeWeight.Text);
  290. this._thisGoodsEntity.LusterwareWeight = this.txtLusterwareWeight.Text == "" ? Constant.INT_IS_ZERO : Convert.ToDecimal(this.txtLusterwareWeight.Text);
  291. this._thisGoodsEntity.ProductionCycle = this.txtProductionCycle.Text == "" ? Constant.INT_IS_ZERO : Convert.ToDecimal(this.txtProductionCycle.Text);
  292. this._thisGoodsEntity.StartingDate = this.dtpStartingDate.Value.Date;
  293. this._thisGoodsEntity.AutoLossCycle = (this.txtSPM001.DataValue.HasValue ? Convert.ToInt32(this.txtSPM001.DataValue) : 0);
  294. this._thisGoodsEntity.DeliverLimitCycle = (this.txtSPM002.DataValue.HasValue ? Convert.ToInt32(this.txtSPM002.DataValue) : 0);
  295. this._thisGoodsEntity.MouldOutputCount = (this.txtMouldOutputCount.DataValue.HasValue ? Convert.ToInt32(this.txtMouldOutputCount.DataValue) : 1);
  296. this._thisGoodsEntity.StandardGroutingNum = (this.txtStandardGroutingNum.DataValue.HasValue ? Convert.ToInt32(this.txtStandardGroutingNum.DataValue) : 0);
  297. this._thisGoodsEntity.MouldMaterialCode = this.txtMouldMaterialCode.Text.Trim();
  298. this._thisGoodsEntity.WaterLabelCode = this.txtWaterLabelCode.Text;
  299. this._thisGoodsEntity.PlateLimitNum = (this.txtPlateLimitNum.DataValue.HasValue ? Convert.ToInt32(this.txtPlateLimitNum.DataValue) : 0);
  300. this._thisGoodsEntity.UnitPrice = (this.txtUnitPrice.DataValue.HasValue ? this.txtUnitPrice.DataValue.Value : 0);
  301. this._thisGoodsEntity.ReservedDays = (this.txtReservedDays.DataValue.HasValue ? Convert.ToInt32(this.txtReservedDays.DataValue) : 0);
  302. this._thisGoodsEntity.PackageNum = this.txtPackageNum.Text.Trim();
  303. this._thisGoodsEntity.OutletDistance = this.txtOutletDistance.Text.Trim();
  304. this._thisGoodsEntity.MaterialCode = this.scbSAPCode1.Text.Trim();
  305. this._thisGoodsEntity.MaterialRemark = this.txtMaterialRemark.Text;
  306. this._thisGoodsEntity.PrintCopies = (this.txtCopies.DataValue.HasValue ? Convert.ToInt32(this.txtCopies.DataValue) : 0);
  307. this._sapInfo.AcceptChanges();
  308. this._thisGoodsEntity.SAPInfo = this._sapInfo;
  309. this._thisGoodsEntity.LogoID = Convert.ToInt32(ftcLogo.SelectedValue);
  310. if (this.txtMouldWeight.DataValue != null)
  311. {
  312. this._thisGoodsEntity.MouldWeight = this.txtMouldWeight.DataValue;
  313. }
  314. if (this.txtMouldCost.DataValue != null)
  315. {
  316. this._thisGoodsEntity.MouldCost = this.txtMouldCost.DataValue;
  317. }
  318. if (this.txtSEATCOVERCODE.DataValue != null)
  319. {
  320. this._thisGoodsEntity.SeatCoverCode = Convert.ToInt32(this.txtSEATCOVERCODE.DataValue);
  321. }
  322. if (this.cbCeaseFlag.Checked)
  323. {
  324. this._thisGoodsEntity.CeaseFlag = Convert.ToInt32(Constant.ValueFlag.Effective);
  325. }
  326. else
  327. {
  328. this._thisGoodsEntity.CeaseFlag = Convert.ToInt32(Constant.ValueFlag.Invalid);
  329. }
  330. if (this.cbValueFlag.Checked)
  331. {
  332. this._thisGoodsEntity.ValueFlag = Convert.ToInt32(Constant.ValueFlag.Effective);
  333. }
  334. else
  335. {
  336. this._thisGoodsEntity.ValueFlag = Convert.ToInt32(Constant.ValueFlag.Invalid);
  337. }
  338. this._thisGoodsEntity.ScrapSumFlag = (this.chkScrapSumFlag.Checked ? "1" : "0");
  339. this._thisGoodsEntity.GoodsLineType = (this.chkGLT.Checked ? "1" : "0");
  340. this._thisGoodsEntity.Remarks = this.txtRemarks.Text;
  341. //首先将未修改的图片从集合中删除
  342. for (int i = 0; i < _imgList.Count; i++)
  343. {
  344. this._picByteList.RemoveAt(Constant.INT_IS_ZERO);
  345. this._smallByteList.RemoveAt(Constant.INT_IS_ZERO);
  346. }
  347. this._imgList.Clear();
  348. //循环插入图片
  349. for (int i = 0; i < _picByteList.Count; i++)
  350. {
  351. GoodsImageEntity imgEntity = new GoodsImageEntity();
  352. imgEntity.ValueFlag = Convert.ToInt32(Constant.ValueFlag.Effective);
  353. byte[] buffer = _picByteList[i];
  354. imgEntity.Image = buffer;
  355. imgEntity.Thumbnail = _smallByteList[i];
  356. this._imgList.Add(imgEntity);
  357. }
  358. //如果是编辑模式,有被删除的图片,那么要把这些图片也加入到集合中
  359. if (this._updateImgList.Count != Constant.INT_IS_ZERO)
  360. {
  361. for (int i = 0; i < this._updateImgList.Count; i++)
  362. {
  363. GoodsImageEntity updateImgEntity = this._updateImgList[i];
  364. this._imgList.Add(updateImgEntity);
  365. }
  366. }
  367. if (this._formGoodsId == Constant.INT_IS_ZERO)
  368. {
  369. int MyReturn = (int)DoAsync(new BaseAsyncMethod(() =>
  370. {
  371. return SystemModuleProxy.Service.AddGoods(this._thisGoodsEntity, this._imgList, this._attList);
  372. }));
  373. if (MyReturn > Constant.INT_IS_ZERO)
  374. {
  375. MessageBox.Show(string.Format(Messages.MSG_CMN_I001, "产品档案", "保存"),
  376. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
  377. PageInitialization();
  378. }
  379. else if (MyReturn == -10)
  380. {
  381. MessageBox.Show(string.Format(Messages.MSG_CMN_W006, "物料编码"), this.Text,
  382. MessageBoxButtons.OK, MessageBoxIcon.Warning);
  383. this.scbSAPCode1.Focus();
  384. return;
  385. }
  386. else
  387. {
  388. MessageBox.Show(string.Format(Messages.MSG_CMN_W001, "产品档案", "保存"),
  389. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  390. }
  391. }
  392. else
  393. {
  394. int MyReturn = SystemModuleProxy.Service.UpdateGoods(_thisGoodsEntity, _imgList, _attList);
  395. if (MyReturn > Constant.INT_IS_ZERO)
  396. {
  397. MessageBox.Show(string.Format(Messages.MSG_CMN_I001, "产品档案", "保存"),
  398. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
  399. this.DialogResult = DialogResult.OK;
  400. }
  401. else if (MyReturn == -10)
  402. {
  403. MessageBox.Show(string.Format(Messages.MSG_CMN_W006, "物料编码"), this.Text,
  404. MessageBoxButtons.OK, MessageBoxIcon.Warning);
  405. this.scbSAPCode1.Focus();
  406. return;
  407. }
  408. else if (MyReturn == -500)
  409. {
  410. MessageBox.Show(Messages.MSG_CMN_W012, this.Text, MessageBoxButtons.OK,
  411. MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
  412. this.DialogResult = DialogResult.OK;
  413. }
  414. else
  415. {
  416. MessageBox.Show(string.Format(Messages.MSG_CMN_W001, "产品档案", "保存"),
  417. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  418. }
  419. }
  420. }
  421. catch (Exception ex)
  422. {
  423. // 对异常进行共通处理
  424. ExceptionManager.HandleEventException(this.ToString(),
  425. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  426. }
  427. }
  428. /// <summary>
  429. /// 上传缩略图
  430. /// </summary>
  431. private void btnUpload_Click(object sender, EventArgs e)
  432. {
  433. try
  434. {
  435. odlgFile.Filter = Constant.FILTER_PIC;
  436. odlgFile.FilterIndex = Constant.INT_IS_ZERO;
  437. odlgFile.RestoreDirectory = true;
  438. odlgFile.Title = "选择产品图片";
  439. odlgFile.FileName = null;
  440. odlgFile.RestoreDirectory = true;
  441. if (odlgFile.ShowDialog() == DialogResult.OK)
  442. {
  443. FileInfo file = new FileInfo(odlgFile.FileName);
  444. if (Constant.UPLOAD_PIC_MAX_SIZE < file.Length)
  445. {
  446. MessageBox.Show(string.Format(Messages.MSG_CMN_W013, "产品图片", "大小", "1M"),
  447. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
  448. }
  449. else
  450. {
  451. Image PicImage = Image.FromStream(file.OpenRead());
  452. this._picByteList.Add(ImageToByte(PicImage));
  453. GetThumbnail(file);
  454. BindImg();
  455. }
  456. }
  457. }
  458. catch (Exception ex)
  459. {
  460. // 对异常进行共通处理
  461. ExceptionManager.HandleEventException(this.ToString(),
  462. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  463. }
  464. }
  465. /// <summary>
  466. /// 删除某缩略图
  467. /// </summary>
  468. private void btnDelete_Click(object sender, EventArgs e)
  469. {
  470. try
  471. {
  472. foreach (ListViewItem lvSelect in lvPic.SelectedItems)
  473. {
  474. int index = lvSelect.Index;
  475. if (index < Constant.INT_IS_ZERO)
  476. {
  477. index = Constant.INT_IS_ZERO;
  478. }
  479. ilPic.Images.RemoveAt(index);
  480. this._picByteList.RemoveAt(index);
  481. this._smallByteList.RemoveAt(index);
  482. lvPic.Items.RemoveAt(index);
  483. if (index < this._imgList.Count)
  484. {
  485. if (this._imgList[index].GoodsImageID != Constant.INT_IS_ZERO)
  486. {
  487. GoodsImageEntity deleteImgEntity = this._imgList[index];
  488. this._imgList[index].ValueFlag = Convert.ToInt32(Constant.ValueFlag.Invalid);
  489. this._updateImgList.Add(deleteImgEntity);
  490. this._imgList.RemoveAt(index);
  491. }
  492. }
  493. }
  494. BindImg();
  495. }
  496. catch (Exception ex)
  497. {
  498. // 对异常进行共通处理
  499. ExceptionManager.HandleEventException(this.ToString(),
  500. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  501. }
  502. }
  503. /// <summary>
  504. /// 关闭窗体
  505. /// </summary>
  506. private void btnCancel_Click(object sender, EventArgs e)
  507. {
  508. this.DialogResult = DialogResult.OK;
  509. }
  510. /// <summary>
  511. /// 查看图片
  512. /// </summary>
  513. private void lvPic_DoubleClick(object sender, EventArgs e)
  514. {
  515. try
  516. {
  517. foreach (ListViewItem lvSelect in lvPic.SelectedItems)
  518. {
  519. int index = lvSelect.Index;
  520. if (index < Constant.INT_IS_ZERO)
  521. {
  522. index = Constant.INT_IS_ZERO;
  523. }
  524. F_CMN_0102 addGoods = new F_CMN_0102(_picByteList[index]);
  525. DialogResult dialogresult = addGoods.ShowDialog();
  526. }
  527. }
  528. catch (Exception ex)
  529. {
  530. // 对异常进行共通处理
  531. ExceptionManager.HandleEventException(this.ToString(),
  532. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  533. }
  534. }
  535. /// <summary>
  536. /// SAP物料编码改变事件
  537. /// </summary>
  538. /// <param name="sender"></param>
  539. /// <param name="e"></param>
  540. private void txtSAPRemark_TextChanged(object sender, EventArgs e)
  541. {
  542. if (this.dgvGoodsSap.CurrentRow == null)
  543. {
  544. return;
  545. }
  546. try
  547. {
  548. DataRowView row = this.dgvGoodsSap.CurrentRow.DataBoundItem as DataRowView;
  549. if (row != null)
  550. {
  551. row["materialremark"] = txtSAPRemark.Text;
  552. row.EndEdit();
  553. }
  554. }
  555. catch (Exception ex)
  556. {
  557. // 对异常进行共通处理
  558. ExceptionManager.HandleEventException(this.ToString(),
  559. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  560. }
  561. }
  562. #endregion
  563. #region 私有方法
  564. /// <summary>
  565. /// 加载页面所需的数据源
  566. /// </summary>
  567. private void LoadDataSource()
  568. {
  569. try
  570. {
  571. // 绑定釉料类别
  572. DataTable dtGlazeType = SystemModuleProxy.Service.GetDataDictionaryByType(Constant.DictionaryType.TPC002, Constant.INT_IS_ONE);
  573. if (dtGlazeType != null)
  574. {
  575. ddlGlazeTypeID.DisplayMember = "DictionaryValue";
  576. ddlGlazeTypeID.ValueMember = "DictionaryID";
  577. ddlGlazeTypeID.DataSource = dtGlazeType;
  578. }
  579. // 绑定坯库类型
  580. DataTable dtMudStoreType = SystemModuleProxy.Service.GetDataDictionaryByType(Constant.DictionaryType.TPC009, Constant.INT_IS_ONE);
  581. if (dtMudStoreType != null)
  582. {
  583. ddlMudStoreType.DisplayMember = "DictionaryValue";
  584. ddlMudStoreType.ValueMember = "DictionaryID";
  585. ddlMudStoreType.DataSource = dtMudStoreType;
  586. }
  587. DataSet logos = SystemModuleProxy.Service.GetLogoInfo();
  588. if (logos != null && logos.Tables.Count > 0)
  589. {
  590. ftcLogo.DisplayMember = "LogoNameCode";
  591. ftcLogo.ValueMember = "LogoID";
  592. ftcLogo.DataSource = logos.Tables[0];
  593. }
  594. }
  595. catch (Exception ex)
  596. {
  597. throw ex;
  598. }
  599. }
  600. /// <summary>
  601. /// 绑定缩略图到控件中
  602. /// </summary>
  603. private void BindImg()
  604. {
  605. try
  606. {
  607. //每次绑定要清空数据源
  608. this.ilPic.Images.Clear();
  609. //将缩略图二进制集合中的数据转换成图片文件
  610. List<Image> LSImageList = new List<Image>();
  611. foreach (byte[] smallby in _smallByteList)
  612. {
  613. LSImageList.Add(byteArrayToImage(smallby));
  614. }
  615. //添加数据源
  616. foreach (Image img in LSImageList)
  617. {
  618. ilPic.Images.Add(img);
  619. }
  620. this.ilPic.ImageSize = new Size(Constant.INT_IS_HUNDRED, Constant.INT_IS_HUNDRED);
  621. this.lvPic.LargeImageList = this.ilPic;
  622. this.lvPic.BeginUpdate();
  623. //清空列表的数据源
  624. lvPic.Items.Clear();
  625. //添加列表的数据源
  626. for (int i = 0; i < ilPic.Images.Count; i++)
  627. {
  628. ListViewItem lvi = new ListViewItem();
  629. lvi.ImageIndex = i;
  630. this.lvPic.Items.Add(lvi);
  631. }
  632. this.lvPic.EndUpdate();
  633. }
  634. catch (Exception ex)
  635. {
  636. throw ex;
  637. }
  638. }
  639. /// <summary>
  640. /// 重绘缩略图并把缩略图转为二进制储存在集合众
  641. /// </summary>
  642. /// <param name="sourceFile">图片实体</param>
  643. /// <returns></returns>
  644. private void GetThumbnail(FileInfo sourceFile)
  645. {
  646. try
  647. {
  648. Image imgSource = Image.FromStream(sourceFile.OpenRead());
  649. ImageFormat thisFormat = imgSource.RawFormat;
  650. int sW = Constant.INT_IS_ZERO, sH = Constant.INT_IS_ZERO;
  651. // 按比例缩放
  652. int sWidth = imgSource.Width;
  653. int sHeight = imgSource.Height;
  654. int destWidth = Constant.INT_IS_HUNDRED;
  655. int destHeight = getSmallImageHeight(sWidth, sHeight, destWidth);
  656. if (sHeight > destHeight || sWidth > destWidth)
  657. {
  658. if ((sWidth * destHeight) > (sHeight * destWidth))
  659. {
  660. sW = destWidth;
  661. sH = (destWidth * sHeight) / sWidth;
  662. }
  663. else
  664. {
  665. sH = destHeight;
  666. sW = (sWidth * destHeight) / sHeight;
  667. }
  668. }
  669. else
  670. {
  671. sW = sWidth;
  672. sH = sHeight;
  673. }
  674. Bitmap outBmp = new Bitmap(destWidth, destHeight);
  675. Graphics g = Graphics.FromImage(outBmp);
  676. g.Clear(Color.Black);
  677. // 设置画布的描绘质量
  678. g.CompositingQuality = CompositingQuality.HighQuality;
  679. g.SmoothingMode = SmoothingMode.HighQuality;
  680. g.InterpolationMode = InterpolationMode.HighQualityBicubic;
  681. g.DrawImage(imgSource, new Rectangle((destWidth - sW) / Constant.INT_IS_TWO, (destHeight - sH) /
  682. Constant.INT_IS_TWO, sW, sH), Constant.INT_IS_ZERO, Constant.INT_IS_ZERO,
  683. imgSource.Width, imgSource.Height, GraphicsUnit.Pixel);
  684. g.Dispose();
  685. //将重绘的图片转为二进制并保存
  686. Image image = (Image)outBmp;
  687. byte[] smallbuffer = ImageToByte(image);
  688. this._smallByteList.Add(smallbuffer);
  689. imgSource.Dispose();
  690. outBmp.Dispose();
  691. }
  692. catch (Exception ex)
  693. {
  694. throw ex;
  695. }
  696. }
  697. /// <summary>
  698. /// 根据原图片宽高比获取缩略图的高(根据宽)
  699. /// </summary>
  700. /// <param name="BigWidth">原图宽度</param>
  701. /// <param name="BigHeight">原图高度</param>
  702. /// <param name="SmallWidth">缩略图宽度</param>
  703. /// <returns>缩略图的高度</returns>
  704. private int getSmallImageHeight(int BigWidth, int BigHeight, int SmallWidth)
  705. {
  706. try
  707. {
  708. decimal scale = Convert.ToDecimal(BigWidth) / Convert.ToDecimal(BigHeight);
  709. return Convert.ToInt32(SmallWidth / scale);
  710. }
  711. catch (Exception ex)
  712. {
  713. throw ex;
  714. }
  715. }
  716. /// <summary>
  717. /// 验证添加项
  718. /// </summary>
  719. private int ValidationText()
  720. {
  721. int ErrorID = 0;
  722. if (this.ddlGlazeTypeID.SelectedValue.ToString() == string.Empty)
  723. {
  724. ErrorID = 7;
  725. }
  726. if (this.txtGoodsName.Text.Trim() == string.Empty)
  727. {
  728. ErrorID = 3;
  729. }
  730. if (scbGoodsType.SearchedItem == null)
  731. {
  732. ErrorID = 6;
  733. }
  734. if (this.txtGoodsCode.Text.Trim() == string.Empty)
  735. {
  736. ErrorID = 1;
  737. }
  738. return ErrorID;
  739. }
  740. /// <summary>
  741. /// 绑定缩略图到缩略图集合中
  742. /// </summary>
  743. /// <param name="ImageData">图片集合</param>
  744. private void BindByteImage(DataSet ImageData)
  745. {
  746. try
  747. {
  748. foreach (DataRow dr in ImageData.Tables[0].Rows)
  749. {
  750. //将数据库中的缩略图取出
  751. this._smallByteList.Add((byte[])dr[2]);
  752. this._picByteList.Add((byte[])dr[3]);
  753. //绑定实体到修改图片集合中
  754. GoodsImageEntity imgEntity = new GoodsImageEntity();
  755. imgEntity.GoodsImageID = Convert.ToDecimal(dr[0]);
  756. imgEntity.GoodsID = Convert.ToDecimal(dr[1]);
  757. imgEntity.Thumbnail = (byte[])dr[2];
  758. imgEntity.Image = (byte[])dr[3];
  759. imgEntity.AccountID = Convert.ToDecimal(dr[4]);
  760. imgEntity.ValueFlag = Convert.ToDecimal(dr[5]);
  761. imgEntity.CreateTime = Convert.ToDateTime(dr[6]);
  762. imgEntity.CreateUserID = Convert.ToDecimal(dr[7]);
  763. imgEntity.UpdateTime = Convert.ToDateTime(dr[8]);
  764. imgEntity.UpdateUserID = Convert.ToDecimal(dr[9]);
  765. imgEntity.OPTimeStamp = Convert.ToDateTime(dr[10]);
  766. this._imgList.Add(imgEntity);
  767. }
  768. //绑定缩略图
  769. BindImg();
  770. }
  771. catch (Exception ex)
  772. {
  773. throw ex;
  774. }
  775. }
  776. /// <summary>
  777. /// 将数据库中的二进制转换成图片
  778. /// </summary>
  779. /// <param name="data">需要转换成图片的二进制数据</param>
  780. /// <returns>图片文件实体</returns>
  781. private static Image byteArrayToImage(object data)
  782. {
  783. try
  784. {
  785. System.IO.MemoryStream ms = new System.IO.MemoryStream((byte[])data);
  786. System.Drawing.Image returnImage = System.Drawing.Image.FromStream(ms);
  787. return returnImage;
  788. }
  789. catch (Exception ex)
  790. {
  791. throw ex;
  792. }
  793. }
  794. /// <summary>
  795. /// 将图片文件转换成二进制
  796. /// </summary>
  797. /// <param name="img">需要转换的图片</param>
  798. /// <returns>图片二进制数据</returns>
  799. private static byte[] ImageToByte(Image img)
  800. {
  801. try
  802. {
  803. byte[] smallbuffer = null;
  804. using (MemoryStream ms = new MemoryStream())
  805. {
  806. img.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
  807. ms.Position = Constant.INT_IS_ZERO;
  808. smallbuffer = new byte[ms.Length];
  809. ms.Read(smallbuffer, Constant.INT_IS_ZERO, Convert.ToInt32(ms.Length));
  810. ms.Flush();
  811. }
  812. return smallbuffer;
  813. }
  814. catch (Exception ex)
  815. {
  816. throw ex;
  817. }
  818. }
  819. /// <summary>
  820. /// 验证产品编号唯一性
  821. /// </summary>
  822. /// <param name="goodsCode">产品编号</param>
  823. /// <returns>是否重复,真为不重复,可插入</returns>
  824. private bool ValidationCode(string goodsCode)
  825. {
  826. try
  827. {
  828. GoodsEntity vgoods = new GoodsEntity();
  829. vgoods.GoodsCodeOnly = goodsCode;
  830. int i = ((DataSet)SystemModuleProxy.Service.SerachGoods(vgoods)).Tables[0].Rows.Count;
  831. if (i > Constant.INT_IS_ZERO)
  832. {
  833. return false;
  834. }
  835. else
  836. {
  837. return true;
  838. }
  839. }
  840. catch (Exception ex)
  841. {
  842. throw ex;
  843. }
  844. }
  845. /// <summary>
  846. /// 页面控件初始化
  847. /// </summary>
  848. private void PageInitialization()
  849. {
  850. //页面控件初始化
  851. this.txtGoodsCode.Text = "";
  852. //this.gtsGoodaType.GoodsTypeCode = null;
  853. //this.gtsGoodaType.GoodsTypeID = null;
  854. //this.gtsGoodaType.GoodsTypeName = null;
  855. //this.gtsGoodaType.Text = "";
  856. this.scbGoodsType.ClearValue();
  857. this.txtGoodsName.Text = "";
  858. this.txtGoodsModel.Text = "";
  859. this.txtGoodsSpecification.Text = "";
  860. this.txtMudWeight.Text = "";
  861. this.txtGlazeWeight.Text = "";
  862. //this.ddlGlazeTypeID.SelectedValue = null;
  863. this.txtProductionCycle.Text = "";
  864. this.txtLusterwareWeight.Text = "";
  865. this.txtRemarks.Text = "";
  866. this.lvPic.Items.Clear();
  867. this.cbCeaseFlag.Checked = true;
  868. this.cbValueFlag.Checked = true;
  869. this.chkGLT.Checked = false;
  870. this.txtSPM001.DataValue = 0;
  871. this.txtSPM002.DataValue = 0;
  872. this.txtMouldOutputCount.DataValue = 1;
  873. this.txtStandardGroutingNum.DataValue = 0;
  874. this.dtpStartingDate.Value = DateTime.Now.Date;
  875. //成员变量初始化
  876. this._thisGoodsEntity = new GoodsEntity();
  877. this._picByteList = new List<byte[]>();
  878. this._smallByteList = new List<byte[]>();
  879. this._imgList = new List<GoodsImageEntity>();
  880. this._updateImgList = new List<GoodsImageEntity>();
  881. this.txtUnitPrice.DataValue = 0;
  882. this.txtPlateLimitNum.DataValue = 0;
  883. this.txtReservedDays.DataValue = 0;
  884. this.txtPackageNum.Text = "";
  885. this.txtOutletDistance.Text = "";
  886. this.scbSAPCode1.Text = "";
  887. this.txtMaterialRemark.Text = "";
  888. this.txtMouldWeight.DataValue = null;
  889. this.txtMouldCost.DataValue = null;
  890. this.txtSEATCOVERCODE.DataValue = null;
  891. this.txtWaterLabelCode.Clear();
  892. this.chkScrapSumFlag.Checked = true;
  893. this.txtMouldMaterialCode.Clear();
  894. foreach (DataRow row in this._sapInfo.Rows)
  895. {
  896. row["materialcode"] = DBNull.Value;
  897. row["materialremark"] = DBNull.Value;
  898. row["WaterLabelCode"] = DBNull.Value;
  899. }
  900. this._sapInfo.AcceptChanges();
  901. }
  902. #endregion
  903. #region SAP物料
  904. private void dgvGoodsSap_SelectionChanged(object sender, EventArgs e)
  905. {
  906. if (this.dgvGoodsSap.CurrentRow == null)
  907. {
  908. //this.scbSAPCode2.Clear();
  909. //this.txtSAPRemark.Clear();
  910. return;
  911. }
  912. try
  913. {
  914. this.scbSAPCode2.Text = this.dgvGoodsSap.CurrentRow.Cells["colmaterialcode"].Value + "";
  915. this.txtSAPRemark.Text = this.dgvGoodsSap.CurrentRow.Cells["colmaterialremark"].Value + "";
  916. this.txtSAPWaterLabelCode.Text = this.dgvGoodsSap.CurrentRow.Cells["colWaterLabelCode"].Value + "";
  917. }
  918. catch (Exception ex)
  919. {
  920. // 对异常进行共通处理
  921. ExceptionManager.HandleEventException(this.ToString(),
  922. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  923. }
  924. }
  925. private void txtSAPCode_Validated(object sender, EventArgs e)
  926. {
  927. //if (this.dgvGoodsSap.CurrentRow == null)
  928. //{
  929. // return;
  930. //}
  931. //try
  932. //{
  933. // DataRowView row = this.dgvGoodsSap.CurrentRow.DataBoundItem as DataRowView;
  934. // if (row != null)
  935. // {
  936. // row["materialcode"] = scbSAPCode2.Text;
  937. // row.EndEdit();
  938. // }
  939. //}
  940. //catch (Exception ex)
  941. //{
  942. // // 对异常进行共通处理
  943. // ExceptionManager.HandleEventException(this.ToString(),
  944. // System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  945. //}
  946. }
  947. private void txtSAPRemark_Validated(object sender, EventArgs e)
  948. {
  949. //if (this.dgvGoodsSap.CurrentRow == null)
  950. //{
  951. // return;
  952. //}
  953. //try
  954. //{
  955. // DataRowView row = this.dgvGoodsSap.CurrentRow.DataBoundItem as DataRowView;
  956. // if (row != null)
  957. // {
  958. // row["materialremark"] = txtSAPRemark.Text;
  959. // row.EndEdit();
  960. // }
  961. //}
  962. //catch (Exception ex)
  963. //{
  964. // // 对异常进行共通处理
  965. // ExceptionManager.HandleEventException(this.ToString(),
  966. // System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  967. //}
  968. }
  969. private void txtSAPWaterLabelCode_Validated(object sender, EventArgs e)
  970. {
  971. if (this.dgvGoodsSap.CurrentRow == null)
  972. {
  973. return;
  974. }
  975. try
  976. {
  977. DataRowView row = this.dgvGoodsSap.CurrentRow.DataBoundItem as DataRowView;
  978. if (row != null)
  979. {
  980. row["WaterLabelCode"] = txtSAPWaterLabelCode.Text;
  981. row.EndEdit();
  982. }
  983. }
  984. catch (Exception ex)
  985. {
  986. // 对异常进行共通处理
  987. ExceptionManager.HandleEventException(this.ToString(),
  988. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  989. }
  990. }
  991. /// <summary>
  992. /// 物料编码改变事件
  993. /// </summary>
  994. /// <param name="sender"></param>
  995. /// <param name="e"></param>
  996. private void scbSAPCode2_TextValueChanged(object sender, WinForm.Controls.ScbSearchBox.TextChangeEventArgs e)
  997. {
  998. if (this.dgvGoodsSap.CurrentRow == null)
  999. {
  1000. return;
  1001. }
  1002. try
  1003. {
  1004. DataRowView row = this.dgvGoodsSap.CurrentRow.DataBoundItem as DataRowView;
  1005. if (row != null)
  1006. {
  1007. row["materialcode"] = scbSAPCode2.Text;
  1008. row.EndEdit();
  1009. }
  1010. }
  1011. catch (Exception ex)
  1012. {
  1013. // 对异常进行共通处理
  1014. ExceptionManager.HandleEventException(this.ToString(),
  1015. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  1016. }
  1017. }
  1018. #endregion
  1019. private void txtMouldOutputCount_TextChanged(object sender, EventArgs e)
  1020. {
  1021. try
  1022. {
  1023. int mouldOutputCount = (this.txtMouldOutputCount.DataValue.HasValue ? Convert.ToInt32(this.txtMouldOutputCount.DataValue) : 1);
  1024. int standardGroutingNum = (this.txtStandardGroutingNum.DataValue.HasValue ? Convert.ToInt32(this.txtStandardGroutingNum.DataValue) : 0);
  1025. this.txtStandardGroutingSum.DataValue = mouldOutputCount * standardGroutingNum;
  1026. }
  1027. catch (Exception ex)
  1028. {
  1029. // 对异常进行共通处理
  1030. ExceptionManager.HandleEventException(this.ToString(),
  1031. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  1032. }
  1033. }
  1034. }
  1035. }