F_MST_0502.cs 39 KB

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