F_MST_0502.cs 39 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117
  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. }
  915. catch (Exception ex)
  916. {
  917. // 对异常进行共通处理
  918. ExceptionManager.HandleEventException(this.ToString(),
  919. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  920. }
  921. }
  922. private void txtSAPCode_Validated(object sender, EventArgs e)
  923. {
  924. //if (this.dgvGoodsSap.CurrentRow == null)
  925. //{
  926. // return;
  927. //}
  928. //try
  929. //{
  930. // DataRowView row = this.dgvGoodsSap.CurrentRow.DataBoundItem as DataRowView;
  931. // if (row != null)
  932. // {
  933. // row["materialcode"] = txtSAPCode.Text;
  934. // row.EndEdit();
  935. // }
  936. //}
  937. //catch (Exception ex)
  938. //{
  939. // // 对异常进行共通处理
  940. // ExceptionManager.HandleEventException(this.ToString(),
  941. // System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  942. //}
  943. }
  944. private void txtSAPRemark_Validated(object sender, EventArgs e)
  945. {
  946. //if (this.dgvGoodsSap.CurrentRow == null)
  947. //{
  948. // return;
  949. //}
  950. //try
  951. //{
  952. // DataRowView row = this.dgvGoodsSap.CurrentRow.DataBoundItem as DataRowView;
  953. // if (row != null)
  954. // {
  955. // row["materialremark"] = txtSAPRemark.Text;
  956. // row.EndEdit();
  957. // }
  958. //}
  959. //catch (Exception ex)
  960. //{
  961. // // 对异常进行共通处理
  962. // ExceptionManager.HandleEventException(this.ToString(),
  963. // System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  964. //}
  965. }
  966. private void txtSAPWaterLabelCode_Validated(object sender, EventArgs e)
  967. {
  968. if (this.dgvGoodsSap.CurrentRow == null)
  969. {
  970. return;
  971. }
  972. try
  973. {
  974. DataRowView row = this.dgvGoodsSap.CurrentRow.DataBoundItem as DataRowView;
  975. if (row != null)
  976. {
  977. row["WaterLabelCode"] = txtSAPWaterLabelCode.Text;
  978. row.EndEdit();
  979. }
  980. }
  981. catch (Exception ex)
  982. {
  983. // 对异常进行共通处理
  984. ExceptionManager.HandleEventException(this.ToString(),
  985. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  986. }
  987. }
  988. /// <summary>
  989. /// 物料编码改变事件
  990. /// </summary>
  991. /// <param name="sender"></param>
  992. /// <param name="e"></param>
  993. private void scbSAPCode2_TextValueChanged(object sender, WinForm.Controls.ScbSearchBox.TextChangeEventArgs e)
  994. {
  995. if (this.dgvGoodsSap.CurrentRow == null)
  996. {
  997. return;
  998. }
  999. try
  1000. {
  1001. DataRowView row = this.dgvGoodsSap.CurrentRow.DataBoundItem as DataRowView;
  1002. if (row != null)
  1003. {
  1004. row["materialcode"] = scbSAPCode2.Text;
  1005. row.EndEdit();
  1006. }
  1007. }
  1008. catch (Exception ex)
  1009. {
  1010. // 对异常进行共通处理
  1011. ExceptionManager.HandleEventException(this.ToString(),
  1012. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  1013. }
  1014. }
  1015. /// <summary>
  1016. /// 物料编码改变事件
  1017. /// </summary>
  1018. /// <param name="sender"></param>
  1019. /// <param name="e"></param>
  1020. //private void scbSAPCode2_VisibleChanged(object sender, EventArgs e)
  1021. //{
  1022. // if (this.dgvGoodsSap.CurrentRow == null)
  1023. // {
  1024. // return;
  1025. // }
  1026. // try
  1027. // {
  1028. // DataRowView row = this.dgvGoodsSap.CurrentRow.DataBoundItem as DataRowView;
  1029. // if (row != null)
  1030. // {
  1031. // row["materialcode"] = scbSAPCode2.Text;
  1032. // row.EndEdit();
  1033. // }
  1034. // }
  1035. // catch (Exception ex)
  1036. // {
  1037. // // 对异常进行共通处理
  1038. // ExceptionManager.HandleEventException(this.ToString(),
  1039. // System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  1040. // }
  1041. //}
  1042. #endregion
  1043. private void txtMouldOutputCount_TextChanged(object sender, EventArgs e)
  1044. {
  1045. try
  1046. {
  1047. int mouldOutputCount = (this.txtMouldOutputCount.DataValue.HasValue ? Convert.ToInt32(this.txtMouldOutputCount.DataValue) : 1);
  1048. int standardGroutingNum = (this.txtStandardGroutingNum.DataValue.HasValue ? Convert.ToInt32(this.txtStandardGroutingNum.DataValue) : 0);
  1049. this.txtStandardGroutingSum.DataValue = mouldOutputCount * standardGroutingNum;
  1050. }
  1051. catch (Exception ex)
  1052. {
  1053. // 对异常进行共通处理
  1054. ExceptionManager.HandleEventException(this.ToString(),
  1055. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  1056. }
  1057. }
  1058. private void chkGLT_Click(object sender, EventArgs e)
  1059. {
  1060. this.cbGLTDetail.Enabled = this.chkGLT.Checked;
  1061. }
  1062. }
  1063. }