F_MST_0502.cs 58 KB

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