F_MST_0502.cs 52 KB

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