F_MST_0502.cs 61 KB

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