F_MST_0502.cs 52 KB

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