F_PM_3402.cs 180 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486
  1. /*******************************************************************************
  2. * Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential
  3. * 类的信息:
  4. * 1.程序名称:F_PM_3402.cs
  5. * 2.功能描述:成品检验
  6. * 编辑履历:
  7. * 作者 日期 版本 修改内容
  8. * 秦祺 2021/11/1 1.00 新建
  9. *******************************************************************************/
  10. using System;
  11. using System.Collections.Generic;
  12. using System.Data;
  13. using System.Drawing;
  14. using System.Drawing.Drawing2D;
  15. using System.Drawing.Imaging;
  16. using System.IO;
  17. using System.Windows.Forms;
  18. using Dongke.IBOSS.PRD.Basics.BaseControls;
  19. using Dongke.IBOSS.PRD.Basics.BaseResources;
  20. using Dongke.IBOSS.PRD.Basics.Library;
  21. using Dongke.IBOSS.PRD.Client.CommonModule;
  22. using Dongke.IBOSS.PRD.Client.Controls;
  23. using Dongke.IBOSS.PRD.Client.Controls.FormCommon;
  24. using Dongke.IBOSS.PRD.WCF.DataModels;
  25. using Dongke.IBOSS.PRD.WCF.DataModels.PMModule;
  26. using Dongke.IBOSS.PRD.WCF.Proxys;
  27. using Dongke.IBOSS.PRD.WCF.Proxys.PMModuleService;
  28. using Dongke.IBOSS.PRD.WCF.Proxys.SystemModuleService;
  29. namespace Dongke.IBOSS.PRD.Client.PMModule
  30. {
  31. /// <summary>
  32. /// 成品检验
  33. /// </summary>
  34. public partial class F_PM_3402 : DKDockPanelBase
  35. {
  36. #region 成员变量
  37. // 工序ID
  38. private int _procedureID;
  39. // 生产工号
  40. private int _userID = -1;
  41. // 生产编号
  42. private string _userCode;
  43. // 生产名称
  44. private string _userName;
  45. // 工序实体类
  46. //ProcedureEntity _procedureDataEntity;
  47. DataTable _procedureDataTable = null;
  48. // 产品数据表
  49. DataTable _dtProductionData = null;
  50. // 产品缺陷数据表
  51. DataTable _dtProductionDefectData = null;
  52. // 当前选择的行
  53. private int _selectedRowIndex;
  54. // ComBoxEditingControl
  55. private DataGridViewComboBoxEditingControl _dataGridViewComboBox = null;
  56. // 当前产品条码的产品ID,用来查询缺陷位置
  57. private int _currentGoodsID = 0;
  58. // 当前产品条码,用来切换筛选列表数据
  59. private string _currentBarCode = "";
  60. // 当前产品缺陷
  61. private int _currentDefectFlag = 0;
  62. // 返工工序搜索列表对象
  63. C_DGV_Cell_ListBoxComboBox _C_DGV_Cell_ListBoxComboBox = null;
  64. // 过滤结果集
  65. private DataSet _ds = null;
  66. // 过滤员工结果集
  67. private DataSet _dsStaff = null;
  68. // 过滤缺陷图片
  69. private DataSet _dsImage = null;
  70. // 过滤漏检员工结果集
  71. private DataSet _dsMissdeStaff = null;
  72. // 临时数,用来过滤责任员工数据源标识
  73. private int _tempCount = 0;
  74. // 当前临时标记
  75. private string _currentTempSign = "";
  76. // 图片字节集
  77. private List<byte[]> _PicByte = new List<byte[]>();
  78. // 缩略图片字节集
  79. private List<byte[]> _smallByte = new List<byte[]>();
  80. // 当前产品缺陷
  81. private int _currentDefaultDefectFlag = 0;
  82. // 当前默认产品分级ID
  83. private int _currentGoodsLevelTypeID = 0;
  84. // 返工工序数据源
  85. private DataSet _dsRework = null;
  86. // 产品等级数据源
  87. private DataSet _dsGoodsLevel = null;
  88. //编辑生产数据ID
  89. private int _productiondataid = 0;
  90. // 是否查看
  91. private bool _isView = false;
  92. // 允许编辑
  93. private int _AllowEdit = 0;
  94. // 是否只读
  95. private int _ReadOnly = 0;// 1为只读
  96. // 时间戳
  97. private DateTime _optimestamp;
  98. // 成检登记改判限制天数
  99. private int _settingvaluedays = 0;
  100. private int _finishedCheckProcedureID;
  101. private DataTable scrapReasonDataSource;
  102. #endregion
  103. #region 属性
  104. /// <summary>
  105. /// 条码返工工序数据源
  106. /// </summary>
  107. public DataSet DSREWORK
  108. {
  109. set
  110. {
  111. _dsRework = value;
  112. }
  113. get
  114. {
  115. if (_dsRework == null)
  116. {
  117. return _dsRework = new DataSet();
  118. }
  119. return _dsRework;
  120. }
  121. }
  122. /// <summary>
  123. /// 生产工号
  124. /// </summary>
  125. public int UserID
  126. {
  127. set
  128. {
  129. _userID = value;
  130. }
  131. get
  132. {
  133. return _userID;
  134. }
  135. }
  136. /// <summary>
  137. /// 生产编号
  138. /// </summary>
  139. public string UserCode
  140. {
  141. set
  142. {
  143. _userCode = value;
  144. }
  145. get
  146. {
  147. return _userCode;
  148. }
  149. }
  150. /// <summary>
  151. /// 用户名称
  152. /// </summary>
  153. public string UserName
  154. {
  155. set
  156. {
  157. _userName = value;
  158. }
  159. get
  160. {
  161. return _userName;
  162. }
  163. }
  164. /// <summary>
  165. /// 时间戳
  166. /// </summary>
  167. public DateTime PTimeStamp
  168. {
  169. get
  170. {
  171. return _optimestamp;
  172. }
  173. set
  174. {
  175. _optimestamp = value;
  176. }
  177. }
  178. /// <summary>
  179. /// 产品数据表
  180. /// </summary>
  181. public DataTable TableProductionData
  182. {
  183. set
  184. {
  185. _dtProductionData = value;
  186. }
  187. get
  188. {
  189. if (_dtProductionData == null)
  190. {
  191. _dtProductionData = new DataTable("ProductionData");
  192. _dtProductionData.Columns.Add("ProductionDataID");
  193. _dtProductionData.Columns.Add("BarCode");
  194. _dtProductionData.Columns.Add("GoodsID");
  195. _dtProductionData.Columns.Add("GoodsCode");
  196. _dtProductionData.Columns.Add("GoodsName");
  197. _dtProductionData.Columns.Add("DefectFlagID", typeof(decimal));
  198. _dtProductionData.Columns.Add("ReworkProcedureID", typeof(decimal));
  199. _dtProductionData.Columns.Add("Remarks");
  200. _dtProductionData.Columns.Add("UserID");
  201. _dtProductionData.Columns.Add("UserCode");
  202. _dtProductionData.Columns.Add("UserName");
  203. _dtProductionData.Columns.Add("GoodsLevelTypeID");
  204. _dtProductionData.Columns.Add("OrgGoodsLevelTypeID");//原产品分级ID
  205. _dtProductionData.Columns.Add("ReFine");//重烧标识
  206. _dtProductionData.Columns.Add("LengBu");//冷补标识
  207. _dtProductionData.Columns.Add("SpecialRepairflag");//干补标识
  208. _dtProductionData.Columns.Add("ReadOnly");//1 为 只读
  209. _dtProductionData.Columns.Add("KilnCarCode");
  210. _dtProductionData.Columns.Add("KilnCode");
  211. _dtProductionData.Columns.Add("Dictionaryvalue");
  212. _dtProductionData.Columns.Add("MouldCode");//模具编号
  213. _dtProductionData.Columns.Add("GroutingDate", typeof(DateTime));//注浆日期
  214. _dtProductionData.Columns.Add("GroutingUserCode");//成型工号
  215. _dtProductionData.Columns.Add("IsPublicBody");//公坯标识
  216. _dtProductionData.Columns.Add("GroutingNum");//注浆次数
  217. _dtProductionData.Columns.Add("OPTimeStamp", typeof(DateTime));//时间戳 记录在产记录的时间戳
  218. _dtProductionData.Columns.Add("LogoCodeName");//
  219. _dtProductionData.Columns.Add("LogoID");//
  220. _dtProductionData.Columns.Add("CheckTime");//
  221. return _dtProductionData;
  222. }
  223. else
  224. {
  225. return _dtProductionData;
  226. }
  227. }
  228. }
  229. /// <summary>
  230. /// 缺陷数据集
  231. /// </summary>
  232. public DataSet DSTable
  233. {
  234. set
  235. {
  236. _ds = value;
  237. }
  238. get
  239. {
  240. if (_ds == null)
  241. {
  242. _ds = new DataSet();
  243. return _ds;
  244. }
  245. else
  246. {
  247. return _ds;
  248. }
  249. }
  250. }
  251. /// <summary>
  252. /// 员工数据集
  253. /// </summary>
  254. public DataSet DSTableStaff
  255. {
  256. set
  257. {
  258. _dsStaff = value;
  259. }
  260. get
  261. {
  262. if (_dsStaff == null)
  263. {
  264. _dsStaff = new DataSet();
  265. return _dsStaff;
  266. }
  267. else
  268. {
  269. return _dsStaff;
  270. }
  271. }
  272. }
  273. /// <summary>
  274. /// 漏检员工数据集
  275. /// </summary>
  276. public DataSet DSTableMissedStaff
  277. {
  278. set
  279. {
  280. _dsMissdeStaff = value;
  281. }
  282. get
  283. {
  284. if (_dsMissdeStaff == null)
  285. {
  286. _dsMissdeStaff = new DataSet();
  287. return _dsMissdeStaff;
  288. }
  289. else
  290. {
  291. return _dsMissdeStaff;
  292. }
  293. }
  294. }
  295. /// <summary>
  296. /// 缺陷图片
  297. /// </summary>
  298. public DataSet DSTableImage
  299. {
  300. set
  301. {
  302. _dsImage = value;
  303. }
  304. get
  305. {
  306. if (_dsImage == null)
  307. {
  308. _dsImage = new DataSet();
  309. return _dsImage;
  310. }
  311. else
  312. {
  313. return _dsImage;
  314. }
  315. }
  316. }
  317. #endregion
  318. #region 构造函数
  319. public F_PM_3402()
  320. {
  321. InitializeComponent();
  322. }
  323. public F_PM_3402(int procedureID, string fromTitle)
  324. {
  325. InitializeComponent();
  326. //this._procedureID = procedureID;
  327. this.Text = fromTitle;
  328. this.tsbtnAdd.Text = ButtonText.TSBTN_ADD;
  329. this.tsbtnEdit.Text = ButtonText.TSBTN_EDIT;
  330. this.btnSave.Text = ButtonText.BTN_SAVE;
  331. this.btnCancel.Text = ButtonText.BTN_CLOSE;
  332. this.tsbtnClose.Text = ButtonText.TSBTN_TOOL_CLOSE;
  333. this.btnUpload.Text = ButtonText.BTN_UPLOAD;
  334. this.btnDelete.Text = ButtonText.BTN_DELETE;
  335. }
  336. public F_PM_3402(int procedureID, string fromTitle, int productiondataID, bool isView)
  337. {
  338. InitializeComponent();
  339. this._AllowEdit = 1;//允许编辑
  340. this._productiondataid = productiondataID;
  341. //this._procedureID = procedureID;
  342. this.Text = fromTitle;
  343. this._isView = isView;
  344. this.tsbtnAdd.Text = ButtonText.TSBTN_ADD;
  345. this.tsbtnEdit.Text = ButtonText.TSBTN_EDIT;
  346. this.btnSave.Text = ButtonText.BTN_SAVE;
  347. this.btnCancel.Text = ButtonText.BTN_CLOSE;
  348. this.tsbtnClose.Text = ButtonText.TSBTN_TOOL_CLOSE;
  349. this.btnUpload.Text = ButtonText.BTN_UPLOAD;
  350. this.btnDelete.Text = ButtonText.BTN_DELETE;
  351. }
  352. #endregion
  353. #region 事件
  354. /// <summary>
  355. /// 窗体加载事件
  356. /// </summary>
  357. /// <param name="sender"></param>
  358. /// <param name="e"></param>
  359. private void F_PM_1202_Load(object sender, System.EventArgs e)
  360. {
  361. try
  362. {
  363. this.dgvProductionData.AutoGenerateColumns = false;
  364. this.dgvProductionData.DataSource = null;
  365. this.dgvProductionData.DataSource = TableProductionData;
  366. this.dgvDefect.AutoGenerateColumns = false;
  367. this.dgvDefectStaff.AutoGenerateColumns = false;
  368. // 加载权限
  369. FormPermissionManager.FormPermissionControl(this.Name, this,
  370. Dongke.IBOSS.PRD.Client.DataModels.LogInUserInfo.CurrentUser.CurrentUserEntity.UserRightData,
  371. Dongke.IBOSS.PRD.Client.DataModels.LogInUserInfo.CurrentUser.CurrentUserEntity.FunctionData);
  372. // 获取工序明细数据
  373. //ClientRequestEntity cre = new ClientRequestEntity();
  374. //cre.NameSpace = "F_PM_3402";
  375. //cre.Name = "GetProcedureDataEntityByID";
  376. //cre.Properties["ProcedureID"] = this._procedureID;
  377. //ServiceResultEntity sre = DoAsync<ServiceResultEntity>(() =>
  378. //{
  379. // return PCModuleProxyNew.Service.HandleRequest(cre);
  380. //});
  381. //this._procedureDataTable = sre.Data.Tables[0];
  382. //ProcedureEntity procedureDataEntity = (ProcedureEntity)DoAsync(new BaseAsyncMethod(() =>
  383. //{
  384. // return PMModuleProxy.Service.GetProcedureDataEntityByID(this._procedureID);
  385. //}));
  386. //this._procedureDataEntity = procedureDataEntity;
  387. // 产品分级数据源
  388. ClientRequestEntity cre = new ClientRequestEntity();
  389. cre.NameSpace = "F_PM_3402";
  390. cre.Name = "GetGoodsLevel"; //半成品检验
  391. ServiceResultEntity sre = DoAsync<ServiceResultEntity>(() =>
  392. {
  393. return PCModuleProxyNew.Service.HandleRequest(cre);
  394. });
  395. DataSet dsGoodsLevel = sre.Data;
  396. //DataSet dsGoodsLevel = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  397. //{
  398. // return SystemModuleProxy.Service.GetGoodsLevel(2);//半成品检验
  399. //}));
  400. // 产品分级数据源
  401. if (dsGoodsLevel != null && dsGoodsLevel.Tables[0].Rows.Count > Constant.INT_IS_ZERO)
  402. {
  403. this.DefectFlag.DisplayMember = "DefectFlagName";
  404. this.DefectFlag.ValueMember = "DefectFlagID";
  405. this.DefectFlag.DataSource = dsGoodsLevel.Tables[0];
  406. this._currentDefaultDefectFlag = Convert.ToInt32(dsGoodsLevel.Tables[0].Rows[0]["DefectFlagID"]);
  407. this._currentGoodsLevelTypeID = Convert.ToInt32(dsGoodsLevel.Tables[0].Rows[0]["GoodsLevelTypeID"]);
  408. this._dsGoodsLevel = dsGoodsLevel;
  409. }
  410. // 报损原因数据源
  411. cre = new ClientRequestEntity();
  412. cre.NameSpace = "F_PM_3402";
  413. cre.Name = "GetDictionaryData";
  414. cre.Properties["dicType"] = "TPC016";
  415. cre.Properties["isLeaf"] = "1";
  416. sre = DoAsync<ServiceResultEntity>(() =>
  417. {
  418. return PCModuleProxyNew.Service.HandleRequest(cre);
  419. });
  420. DataSet scrapReason = sre.Data;
  421. // 报损原因数据源
  422. if (scrapReason != null && scrapReason.Tables[0].Rows.Count > Constant.INT_IS_ZERO)
  423. {
  424. this.SCRAPREASON.DisplayMember = "DICTIONARYVALUE";
  425. this.SCRAPREASON.ValueMember = "DICTIONARYID";
  426. this.SCRAPREASON.DataSource = scrapReason.Tables[0];
  427. scrapReasonDataSource = scrapReason.Tables[0];
  428. }
  429. if (this.DSREWORK == null)
  430. {
  431. this.DSREWORK = new DataSet();
  432. }
  433. this.ReworkProcedureID.DisplayMember = "ReworkProcedureName";
  434. this.ReworkProcedureID.ValueMember = "ReworkProcedureID";
  435. // 2016-10-10 是否启用成检登记改判限制天数 wangx
  436. cre = new ClientRequestEntity();
  437. cre.NameSpace = "F_PM_3402";
  438. cre.Name = "GetSystemSettingDataByCode";
  439. cre.Properties["SettingType"] = Constant.SettingType.S_PM_009.ToString();
  440. sre = DoAsync<ServiceResultEntity>(() =>
  441. {
  442. return PCModuleProxyNew.Service.HandleRequest(cre);
  443. });
  444. DataSet dsSetting = sre.Data;
  445. //DataSet dsSetting = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  446. //{
  447. // return SystemModuleProxy.Service.GetSystemSettingDataByCode(Constant.SettingType.S_PM_009.ToString());
  448. //}));
  449. if (dsSetting != null && dsSetting.Tables[0].Rows.Count > 0)
  450. {
  451. _settingvaluedays = Convert.ToInt32(dsSetting.Tables[0].Rows[0]["SettingValue"]);
  452. }
  453. // end
  454. // 设置控件禁用或启用
  455. SetControlEnable(); //判断此生产工号是否能成检
  456. if (this._productiondataid > Constant.INT_IS_ZERO)
  457. {
  458. SetEditDataSource();
  459. if (this._isView)
  460. {
  461. SetSubstandard();
  462. }
  463. }
  464. }
  465. catch (Exception ex)
  466. {
  467. // 对异常进行共通处理
  468. ExceptionManager.HandleEventException(this.ToString(),
  469. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  470. }
  471. }
  472. /// <summary>
  473. /// 设置控件禁用或启用
  474. /// </summary>
  475. private void SetControlEnable()
  476. {
  477. //if (this._procedureDataTable != null)
  478. //{
  479. // if (Convert.ToInt32(this._procedureDataTable.Rows[0]["CollectType"]) == (int)Constant.ProcedureCollectType.Togather)
  480. // {
  481. // this.txtUserCode.Enabled = true;
  482. // this.btnSave.Visible = true;
  483. // }
  484. // else
  485. {
  486. this.txtUserCode.Enabled = true;
  487. this.txtUserCode.ReadOnly = true;
  488. // 此工号是否能生产工序
  489. ClientRequestEntity cre = new ClientRequestEntity();
  490. cre.NameSpace = "F_PM_3402";
  491. cre.Name = "CheckProcedureUser";
  492. cre.Properties["UserCode"] = DataModels.LogInUserInfo.CurrentUser.CurrentUserEntity.UserCode;
  493. ServiceResultEntity sre = DoAsync<ServiceResultEntity>(() =>
  494. {
  495. return PCModuleProxyNew.Service.HandleRequest(cre);
  496. });
  497. DataTable checkProcedureUser = sre.Data.Tables[0];
  498. //CheckProcedureUserResult checkProcedureUser = (CheckProcedureUserResult)DoAsync(new BaseAsyncMethod(() =>
  499. //{
  500. // return PMModuleProxy.Service.CheckProcedureUser(this._procedureID,
  501. // DataModels.LogInUserInfo.CurrentUser.CurrentUserEntity.UserCode);
  502. //}));
  503. //if (checkProcedureUser != null)
  504. //{
  505. // if (!string.IsNullOrEmpty(checkProcedureUser.Rows[0]["ErrMsg"] + ""))
  506. // {
  507. // // 此工号不允许生产工序
  508. // MessageBox.Show(checkProcedureUser.Rows[0]["ErrMsg"] + "",
  509. // this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  510. // this.Close();
  511. // return;
  512. // }
  513. //}
  514. UserID = Convert.ToInt32(checkProcedureUser.Rows[0]["UserID"]);
  515. UserCode = checkProcedureUser.Rows[0]["UserCode"] + "";
  516. UserName = checkProcedureUser.Rows[0]["UserName"] + "";
  517. }
  518. this.txtUserCode.Text = UserCode;
  519. //}
  520. }
  521. /// <summary>
  522. /// 条形码按键事件
  523. /// </summary>
  524. /// <param name="sender"></param>
  525. /// <param name="e"></param>
  526. private void txtBarCode_KeyPress(object sender, KeyPressEventArgs e)
  527. {
  528. try
  529. {
  530. this._ReadOnly = 0;//防止输入前一个条码为只读时,在输入另一个条码永远是只读
  531. if (this.txtBarCode.ReadOnly)
  532. {
  533. return;
  534. }
  535. if ((int)e.KeyChar == 13) // 按了回车键
  536. {
  537. if (this.txtUserCode.Text.Trim() == string.Empty)
  538. {
  539. this.txtUserCode.Focus();
  540. this.txtBarCode.Text = string.Empty;
  541. return;
  542. }
  543. if (this.txtBarCode.Text.Trim() == string.Empty)
  544. {
  545. this.txtBarCode.Focus();
  546. return;
  547. }
  548. //根据barcode取工序ID,procedureID
  549. ClientRequestEntity cre = new ClientRequestEntity();
  550. cre.NameSpace = "F_PM_3402";
  551. cre.Name = "GetProductionID";
  552. cre.Properties["BarCode"] = this.txtBarCode.Text.Trim();
  553. ServiceResultEntity sre = DoAsync<ServiceResultEntity>(() =>
  554. {
  555. return PCModuleProxyNew.Service.HandleRequest(cre);
  556. });
  557. if (sre.Data != null &&sre.Data.Tables.Count > 0 && sre.Data.Tables[0].Rows.Count > 0 )
  558. {
  559. DataSet ds = sre.Data;
  560. this._finishedCheckProcedureID = Convert.ToInt32(ds.Tables[0].Rows[0]["finishedcheckprocedureid"]);
  561. cre = new ClientRequestEntity();
  562. cre.NameSpace = "F_PM_3402";
  563. cre.Name = "GetReworkProcedureByProcedureID";
  564. cre.Properties["ProcedureID"] = this._finishedCheckProcedureID;
  565. sre = DoAsync<ServiceResultEntity>(() =>
  566. {
  567. return PCModuleProxyNew.Service.HandleRequest(cre);
  568. });
  569. DataSet ds1 = sre.Data;
  570. // 分离出重烧和冷补
  571. DataTable dtReworkProcedure = ds1.Tables[0].Copy();
  572. dtReworkProcedure.DefaultView.RowFilter = "ReworkProcedureName like '%重烧%'";
  573. DataTable dtRefire = dtReworkProcedure.DefaultView.ToTable();
  574. dtRefire.TableName = "Refire";
  575. dtReworkProcedure = ds1.Tables[0].Copy();
  576. dtReworkProcedure.DefaultView.RowFilter = "ReworkProcedureName like '%冷补%'";
  577. DataTable dtLengBu = dtReworkProcedure.DefaultView.ToTable();
  578. dtLengBu.TableName = "LengBu";
  579. if (this.DSREWORK == null)
  580. {
  581. this.DSREWORK = new DataSet();
  582. }
  583. if (this.DSREWORK.Tables.Count == 0)
  584. {
  585. this.DSREWORK.Tables.Add(dtRefire);
  586. this.DSREWORK.Tables.Add(dtLengBu);
  587. }
  588. // 返工工序数据源
  589. //C_DGV_Cell_ListBoxComboBox C_DGV_Cell_ListBoxComboBox = dgvProductionData.Rows[_selectedRowIndex].Cells[4] as C_DGV_Cell_ListBoxComboBox;
  590. //C_DGV_Cell_ListBoxComboBox.DataSource = ds1.Tables[0];
  591. //C_DGV_Cell_ListBoxComboBox.DisplayMember = "ReworkProcedureName";
  592. //C_DGV_Cell_ListBoxComboBox.ValueMember = "ReworkProcedureID";
  593. this.ReworkProcedureID.DisplayMember = "ReworkProcedureName";
  594. this.ReworkProcedureID.ValueMember = "ReworkProcedureID";
  595. ReworkProcedureID.DataSource = DSREWORK.Tables["Refire"];
  596. cre = new ClientRequestEntity();
  597. cre.NameSpace = "F_PM_3402";
  598. cre.Name = "CheckBarcode";
  599. cre.Properties["ProcedureID"] = this._finishedCheckProcedureID;
  600. cre.Properties["BarCode"] = this.txtBarCode.Text.Trim();
  601. sre = DoAsync<ServiceResultEntity>(() =>
  602. {
  603. return PCModuleProxyNew.Service.HandleRequest(cre);
  604. });
  605. DataSet dsCheckBarcode = sre.Data;
  606. // 校验条码 获取校验条码信
  607. //DataSet dsCheckBarcode = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  608. //{
  609. // return PMModuleProxy.Service.CheckBarcode(this._procedureID, this.txtBarCode.Text.Trim());
  610. //}));
  611. if (dsCheckBarcode != null && dsCheckBarcode.Tables.Count > Constant.INT_IS_ZERO)
  612. {
  613. if (dsCheckBarcode.Tables[0].Rows.Count > Constant.INT_IS_ZERO)
  614. {
  615. this.txtProcedureName.Text = dsCheckBarcode.Tables[0].Rows[0]["ProcedureName"] + "";
  616. if (dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_errMsg.ToString()].ToString() != string.Empty)
  617. {
  618. if (dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_missFlag.ToString()].ToString() == "0")
  619. {
  620. // 表示有错误
  621. MessageBox.Show(string.Format(dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_errMsg.ToString()].ToString(), this.txtBarCode.Text.Trim(), "产品条码"),
  622. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  623. }
  624. //else
  625. //{
  626. // S_CMN_020 frmscmn020 = new S_CMN_020(Convert.ToInt32(dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_missFlag.ToString()])
  627. // , dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_errMsg.ToString()].ToString());
  628. // frmscmn020.ShowDialog();
  629. //}
  630. this.txtBarCode.Focus();
  631. this.txtBarCode.SelectAll();
  632. return;
  633. }
  634. else
  635. {
  636. this._procedureID = Convert.ToInt32(ds.Tables[0].Rows[0]["procedureid"]);
  637. //this._finishedCheckProcedureID = Convert.ToInt32(dsCheckBarcode.Tables[0].Rows[0]["FinishedCheckProcedureid"]);
  638. BindProductionData(dsCheckBarcode);//从来未走过此工序
  639. this._currentBarCode = txtBarCode.Text.Trim();
  640. //this.txtBarCode.Text = string.Empty;
  641. }
  642. if (dsCheckBarcode.Tables[1].Rows.Count > Constant.INT_IS_ZERO)
  643. {
  644. this.dgvPackingBomDetail.DataSource = dsCheckBarcode.Tables[1];
  645. }
  646. if (dsCheckBarcode.Tables.Count > 2 && dsCheckBarcode.Tables[2].Rows.Count > Constant.INT_IS_ZERO)
  647. {
  648. this.dgvDefect.DataSource = dsCheckBarcode.Tables[2];
  649. for (int i = 0; i < dsCheckBarcode.Tables[2].Rows.Count; i++)
  650. {
  651. DataRow dr = DSTable.Tables[this.txtBarCode.Text.Trim() + ""].NewRow();
  652. dr["BarCode"] = this.txtBarCode.Text.Trim() + "";
  653. dr["DefectID"] = dsCheckBarcode.Tables[2].Rows[i]["DefectID"];
  654. dr["DefectName"] = dsCheckBarcode.Tables[2].Rows[i]["DefectName"];
  655. dr["DefectCode"] = dsCheckBarcode.Tables[2].Rows[i]["DefectCode"];
  656. dr["DefectPositionID"] = dsCheckBarcode.Tables[2].Rows[i]["DefectPositionID"];
  657. dr["DefectPositionName"] = dsCheckBarcode.Tables[2].Rows[i]["DefectPositionName"];
  658. dr["DefectPositionCode"] = dsCheckBarcode.Tables[2].Rows[i]["DefectPositionCode"];
  659. dr["DefectProcedureID"] = dsCheckBarcode.Tables[2].Rows[i]["DefectProcedureID"];
  660. dr["DefectProcedureName"] = dsCheckBarcode.Tables[2].Rows[i]["DefectProcedureName"];
  661. dr["DefectProcedureCode"] = dsCheckBarcode.Tables[2].Rows[i]["DefectProcedureCode"];
  662. dr["DefectUserID"] = dsCheckBarcode.Tables[2].Rows[i]["DefectUserID"];
  663. dr["DefectUserName"] = dsCheckBarcode.Tables[2].Rows[i]["DefectUserName"];
  664. dr["DefectUserCode"] = dsCheckBarcode.Tables[2].Rows[i]["DefectUserCode"];
  665. dr["Jobs"] = dsCheckBarcode.Tables[2].Rows[i]["Jobs"];
  666. dr["JobsText"] = dsCheckBarcode.Tables[2].Rows[i]["JobsText"];
  667. dr["DefectRemarks"] = dsCheckBarcode.Tables[2].Rows[i]["DefectRemarks"];
  668. dr["TempCount"] = this._tempCount;
  669. if (string.IsNullOrEmpty(dsCheckBarcode.Tables[2].Rows[i]["DefectProductionDataID"]+""))
  670. {
  671. dr["ProductionDataID"] = 0;
  672. }
  673. else
  674. {
  675. dr["ProductionDataID"] = dsCheckBarcode.Tables[2].Rows[i]["DefectProductionDataID"];// dsCheckBarcode.Tables[2].Rows[i]["ProductionDataID"];
  676. }
  677. dr["DefectFineID"] = dsCheckBarcode.Tables[2].Rows[i]["DefectFineID"];
  678. dr["DefectFineValue"] = dsCheckBarcode.Tables[2].Rows[i]["DefectFineValue"];
  679. dr["MissedUserID"] = dsCheckBarcode.Tables[2].Rows[i]["MissedUserID"];
  680. dr["MissedUserCode"] = dsCheckBarcode.Tables[2].Rows[i]["MissedUserCode"];
  681. dr["MissedUserName"] = dsCheckBarcode.Tables[2].Rows[i]["MissedUserName"];
  682. dr["IsAllowEdit"] = this._AllowEdit;
  683. dr["DefectDeductionNum"] = dsCheckBarcode.Tables[2].Rows[i]["DefectDeductionNum"];
  684. dr["IsOtherDefect"] = dsCheckBarcode.Tables[2].Rows[i]["SpecialDefect"];
  685. dr["CheckTime"] = dsCheckBarcode.Tables[2].Rows[i]["CheckTime"];
  686. DSTable.Tables[this.txtBarCode.Text.Trim()+""].Rows.Add(dr);
  687. #region 获取责任员工
  688. if (!this.DSTableStaff.Tables.Contains(string.Format("TempTable{0}", this._tempCount)))
  689. {
  690. DataTable dtStaff = new DataTable(string.Format("TempTable{0}", this._tempCount));
  691. dtStaff.Columns.Add("IsSelected");
  692. dtStaff.Columns.Add("StaffID");
  693. dtStaff.Columns.Add("StaffCode");
  694. dtStaff.Columns.Add("StaffName");
  695. dtStaff.Columns.Add("StaffTempCount");
  696. dtStaff.Columns.Add("StaffStatus");
  697. this.DSTableStaff.Tables.Add(dtStaff);
  698. }
  699. cre = new ClientRequestEntity();
  700. cre.NameSpace = "F_PM_3402";
  701. cre.Name = "GetDutyStaffByUserJobsID";
  702. cre.Properties["Jobs"] = Convert.ToInt32(dr["Jobs"]);
  703. cre.Properties["UserID"] = Convert.ToInt32(dr["DefectUserID"]);
  704. sre = DoAsync<ServiceResultEntity>(() =>
  705. {
  706. return PCModuleProxyNew.Service.HandleRequest(cre);
  707. });
  708. DataSet dsDutyStaff = sre.Data;
  709. if (dsDutyStaff != null && dsDutyStaff.Tables.Count > Constant.INT_IS_ZERO
  710. && dsDutyStaff.Tables[0].Rows.Count > Constant.INT_IS_ZERO)
  711. {
  712. foreach (DataRow dstaff in dsDutyStaff.Tables[0].Rows)
  713. {
  714. DataRow addDr = DSTableStaff.Tables[string.Format("TempTable{0}", this._tempCount)].NewRow();
  715. addDr["IsSelected"] = 1;
  716. addDr["StaffID"] = dstaff["StaffID"];
  717. addDr["StaffCode"] = dstaff["StaffCode"];
  718. addDr["StaffName"] = dstaff["StaffName"];
  719. addDr["StaffTempCount"] = StaffTempCount;
  720. addDr["StaffStatus"] = dstaff["StaffStatus"];
  721. DSTableStaff.Tables[string.Format("TempTable{0}", this._tempCount)].Rows.Add(addDr);
  722. }
  723. this.dgvDefectStaff.DataSource = DSTableStaff.Tables[string.Format("TempTable{0}", this._tempCount)];
  724. }
  725. #endregion
  726. #region 获取漏检责任员工
  727. if (!this.DSTableMissedStaff.Tables.Contains(string.Format("TempTable{0}", this._tempCount)))
  728. {
  729. DataTable dtMissedStaff = new DataTable(string.Format("TempTable{0}", this._tempCount));
  730. dtMissedStaff.Columns.Add("IsSelected");
  731. dtMissedStaff.Columns.Add("StaffID");
  732. dtMissedStaff.Columns.Add("StaffCode");
  733. dtMissedStaff.Columns.Add("StaffName");
  734. dtMissedStaff.Columns.Add("StaffTempCount");
  735. dtMissedStaff.Columns.Add("StaffStatus");
  736. dtMissedStaff.Columns.Add("UJobsID");
  737. dtMissedStaff.Columns.Add("SJobsID");
  738. this.DSTableMissedStaff.Tables.Add(dtMissedStaff);
  739. }
  740. if (!string.IsNullOrEmpty(dr["MissedUserID"]+"") && Convert.ToInt32(dr["MissedUserID"]) > 0)
  741. {
  742. cre = new ClientRequestEntity();
  743. cre.NameSpace = "F_PM_3402";
  744. cre.Name = "GetMissedStaffByUserID";
  745. cre.Properties["UserID"] = Convert.ToInt32(dr["MissedUserID"]);
  746. sre = DoAsync<ServiceResultEntity>(() =>
  747. {
  748. return PCModuleProxyNew.Service.HandleRequest(cre);
  749. });
  750. DataSet dsMissedDutyStaff = sre.Data;
  751. if (dsMissedDutyStaff != null && dsMissedDutyStaff.Tables.Count > Constant.INT_IS_ZERO
  752. && dsMissedDutyStaff.Tables[0].Rows.Count > Constant.INT_IS_ZERO)
  753. {
  754. foreach (DataRow dmiss in dsMissedDutyStaff.Tables[0].Rows)
  755. {
  756. DataRow addDr = DSTableMissedStaff.Tables[string.Format("TempTable{0}", this._tempCount)].NewRow();
  757. addDr["IsSelected"] = 1;
  758. addDr["StaffID"] = dmiss["StaffID"];
  759. addDr["StaffCode"] = dmiss["StaffCode"];
  760. addDr["StaffName"] = dmiss["StaffName"];
  761. addDr["StaffTempCount"] = StaffTempCount;
  762. addDr["StaffStatus"] = dmiss["StaffStatus"];
  763. addDr["UJobsID"] = dmiss["UJobsID"];
  764. addDr["SJobsID"] = dmiss["SJobsID"];
  765. DSTableMissedStaff.Tables[string.Format("TempTable{0}", this._tempCount)].Rows.Add(addDr);
  766. }
  767. this.dgvMissStaff.DataSource = DSTableMissedStaff.Tables[string.Format("TempTable{0}", this._tempCount)];
  768. }
  769. }
  770. #endregion
  771. this._tempCount = this._tempCount + 1;
  772. }
  773. }
  774. }
  775. }
  776. }
  777. else
  778. {
  779. MessageBox.Show("该条码为无效条码", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  780. }
  781. }
  782. }
  783. catch (Exception ex)
  784. {
  785. // 对异常进行共通处理
  786. ExceptionManager.HandleEventException(this.ToString(),
  787. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  788. }
  789. }
  790. /// <summary>
  791. /// 生产数据编辑控件显示事件
  792. /// </summary>
  793. /// <param name="sender"></param>
  794. /// <param name="e"></param>
  795. private void dgvProductionData_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e)
  796. {
  797. if (e.Control is DataGridViewComboBoxEditingControl
  798. && this.dgvProductionData.CurrentCell.ColumnIndex == Constant.INT_IS_THREE
  799. && this.dgvProductionData.CurrentCell.RowIndex != -Constant.INT_IS_ONE)
  800. {
  801. this._dataGridViewComboBox = (DataGridViewComboBoxEditingControl)e.Control;
  802. //增加委托处理
  803. this._dataGridViewComboBox.SelectionChangeCommitted += new EventHandler(this.dataGridViewComboBox_SelectionChangeCommitted);
  804. }
  805. if (e.Control is DKListBoxComboBox
  806. && this.dgvProductionData.CurrentCell.ColumnIndex == Constant.INT_IS_FOUR
  807. && this.dgvProductionData.CurrentCell.RowIndex != -Constant.INT_IS_ONE)
  808. {
  809. //_selectedRowIndex = TableProductionData.Rows.Count - 1;
  810. _selectedRowIndex = this.dgvProductionData.CurrentCell.RowIndex;
  811. DKListBoxComboBox dkListBoxComboBox = (DKListBoxComboBox)e.Control;
  812. _currentGoodsID = Convert.ToInt32(this.dgvProductionData.Rows[_selectedRowIndex].Cells["GoodsID"].Value);
  813. _currentBarCode = this.dgvProductionData.Rows[_selectedRowIndex].Cells["BarCode"].Value.ToString();
  814. dkListBoxComboBox.DisplayMember = "ReworkProcedureName";
  815. dkListBoxComboBox.ValueMember = "ReworkProcedureID";
  816. int goodsLevelTypeID = Convert.ToInt32(dgvProductionData.CurrentRow.Cells["GoodsLevelTypeID"].Value);
  817. if (goodsLevelTypeID == 6)
  818. {
  819. ReworkProcedureID.DataSource = DSREWORK.Tables["Refire"];
  820. dkListBoxComboBox.DataSource = DSREWORK.Tables["Refire"];
  821. }
  822. else if (goodsLevelTypeID == 16)
  823. {
  824. ReworkProcedureID.DataSource = DSREWORK.Tables["LengBu"];
  825. dkListBoxComboBox.DataSource = DSREWORK.Tables["LengBu"];
  826. }
  827. //dkListBoxComboBox.DataSource = DSREWORK.Tables[0];// DSREWORK.Tables[_currentBarCode];
  828. }
  829. }
  830. /// <summary>
  831. /// 生产数据下拉列表改变事件
  832. /// </summary>
  833. /// <param name="sender"></param>
  834. /// <param name="e"></param>
  835. private void dataGridViewComboBox_SelectionChangeCommitted(object sender, EventArgs e)
  836. {
  837. //this._currentDefectFlag = Convert.ToInt32(((ComboBox)sender).SelectedValue.ToString());//当前缺陷类型
  838. //SetGridView(this._currentDefectFlag);
  839. }
  840. /// <summary>
  841. /// 产品数据选定项改变事件
  842. /// </summary>
  843. /// <param name="sender"></param>
  844. /// <param name="e"></param>
  845. private void dgvProductionData_SelectionChanged(object sender, EventArgs e)
  846. {
  847. try
  848. {
  849. if (this.dgvProductionData.CurrentCell != null)
  850. {
  851. this._selectedRowIndex = this.dgvProductionData.CurrentCell.RowIndex;
  852. // 有无缺陷 0无缺陷 1有缺陷
  853. this._currentDefectFlag = Convert.ToInt32(this.dgvProductionData.Rows[_selectedRowIndex].Cells["GoodsLevelTypeID"].Value.ToString());
  854. this._currentGoodsID = Convert.ToInt32(this.dgvProductionData.Rows[_selectedRowIndex].Cells["GoodsID"].Value);
  855. this._currentBarCode = this.dgvProductionData.Rows[_selectedRowIndex].Cells["BarCode"].Value.ToString();
  856. this.dgvDefect.DataSource = DSTable.Tables[this._currentBarCode];
  857. this.dgvDefectStaff.CurrentCell = null;
  858. this.dgvDefectStaff.DataSource = null;
  859. this._smallByte.Clear();//防止重复绑定图片
  860. this.lvPic.Clear();//
  861. //设置只读数据,交不显示数据
  862. string readonlyFlag = this.dgvProductionData.Rows[_selectedRowIndex].Cells["ReadOnly"].Value.ToString();
  863. if (readonlyFlag == "1")
  864. {
  865. tsbtnAdd.Enabled = false;
  866. tsbtnEdit.Enabled = false;
  867. }
  868. else
  869. {
  870. tsbtnAdd.Enabled = true;
  871. tsbtnEdit.Enabled = true;
  872. }
  873. }
  874. }
  875. catch (Exception ex)
  876. {
  877. // 对异常进行共通处理
  878. ExceptionManager.HandleEventException(this.ToString(),
  879. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  880. }
  881. }
  882. /// <summary>
  883. /// 缺陷数据源选定项改变事件
  884. /// </summary>
  885. /// <param name="sender"></param>
  886. /// <param name="e"></param>
  887. private void dgvDefect_SelectionChanged(object sender, EventArgs e)
  888. {
  889. try
  890. {
  891. if (this.dgvDefect.CurrentCell != null)
  892. {
  893. DataRow[] dr = this.TableProductionData.Select("barcode='" + this._currentBarCode + "'");
  894. if (dr.Length > 0)
  895. {
  896. if (dr[0]["ReadOnly"].ToString() == "1")
  897. {
  898. this.tsbtnEdit.Enabled = false;
  899. this.tsbtnAdd.Enabled = false;
  900. this.btnDelete.Enabled = false;
  901. this.btnUpload.Enabled = false;
  902. }
  903. else
  904. {
  905. this.tsbtnEdit.Enabled = true;
  906. this.tsbtnAdd.Enabled = true;
  907. this.btnDelete.Enabled = true;
  908. this.btnUpload.Enabled = true;
  909. }
  910. }
  911. else
  912. {
  913. //if (this._productiondataid > Constant.INT_IS_ZERO)
  914. //{
  915. if (this.btnSave.Enabled)
  916. {
  917. this.tsbtnEdit.Enabled = true;
  918. this.tsbtnAdd.Enabled = true;
  919. this.btnDelete.Enabled = true;
  920. this.btnUpload.Enabled = true;
  921. }
  922. }
  923. // }
  924. if (this.dgvDefect.Rows[this.dgvDefect.CurrentCell.RowIndex].Cells["TempCount"].Value.ToString() != string.Empty)
  925. {
  926. int staffTempCount = Convert.ToInt32(this.dgvDefect.Rows[this.dgvDefect.CurrentCell.RowIndex].Cells["TempCount"].Value.ToString());
  927. this.dgvDefectStaff.DataSource = DSTableStaff.Tables[string.Format("TempTable{0}", staffTempCount.ToString())];
  928. this.dgvMissStaff.DataSource = DSTableMissedStaff.Tables[string.Format("TempTable{0}", staffTempCount.ToString())];
  929. this._currentTempSign = this.dgvDefect.Rows[this.dgvDefect.CurrentCell.RowIndex].Cells["TempCount"].Value.ToString(); //当前临时标记
  930. this._smallByte.Clear();//防止重复绑定图片
  931. BindByteImage(DSTableImage.Tables[string.Format("TempTable{0}", staffTempCount.ToString())]);
  932. }
  933. else
  934. {
  935. this.dgvDefectStaff.DataSource = null;
  936. this.dgvMissStaff.DataSource = null;
  937. this._smallByte.Clear();//防止重复绑定图片
  938. this.lvPic.Clear();//
  939. }
  940. }
  941. }
  942. catch (Exception ex)
  943. {
  944. // 对异常进行共通处理
  945. ExceptionManager.HandleEventException(this.ToString(),
  946. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  947. }
  948. }
  949. /// <summary>
  950. /// 上传图片按钮事件
  951. /// </summary>
  952. /// <param name="sender"></param>
  953. /// <param name="e"></param>
  954. private void btnUpload_Click(object sender, EventArgs e)
  955. {
  956. try
  957. {
  958. this.odlgFile.Filter = Constant.FILTER_PIC;
  959. this.odlgFile.FilterIndex = Constant.INT_IS_ZERO;
  960. this.odlgFile.RestoreDirectory = true;
  961. this.odlgFile.Title = "选择缺陷图片";
  962. this.odlgFile.FileName = null;
  963. this.odlgFile.RestoreDirectory = true;
  964. if (this.odlgFile.ShowDialog() == DialogResult.OK)
  965. {
  966. FileInfo file = new FileInfo(odlgFile.FileName);
  967. if (Constant.UPLOAD_PIC_MAX_SIZE < file.Length)
  968. {
  969. MessageBox.Show(string.Format(Messages.MSG_CMN_W013, "缺陷图片", "大小", "1M"),
  970. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
  971. }
  972. else
  973. {
  974. Image PicImage = Image.FromStream(file.OpenRead());
  975. byte[] orgImageByte = ImageToByte(PicImage);
  976. this._PicByte.Add(orgImageByte);
  977. GetThumbnail(file, orgImageByte);
  978. BindImg();
  979. }
  980. }
  981. }
  982. catch (Exception ex)
  983. {
  984. // 对异常进行共通处理
  985. ExceptionManager.HandleEventException(this.ToString(),
  986. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  987. }
  988. }
  989. /// <summary>
  990. /// 删除图片按钮事件
  991. /// </summary>
  992. /// <param name="sender"></param>
  993. /// <param name="e"></param>
  994. private void btnDelete_Click(object sender, EventArgs e)
  995. {
  996. foreach (ListViewItem lvSelect in lvPic.SelectedItems)
  997. {
  998. int index = lvSelect.Index;
  999. if (index < Constant.INT_IS_ZERO)
  1000. {
  1001. index = Constant.INT_IS_ZERO;
  1002. }
  1003. if (this._currentTempSign != string.Empty)
  1004. {
  1005. DSTableImage.Tables[string.Format("TempTable{0}", this._currentTempSign)].Rows.RemoveAt(lvSelect.Index);
  1006. DSTableImage.Tables[string.Format("TempTable{0}", this._currentTempSign)].AcceptChanges();
  1007. }
  1008. BindByteImage(DSTableImage.Tables[string.Format("TempTable{0}", this._currentTempSign)]);
  1009. }
  1010. }
  1011. /// <summary>
  1012. /// 关闭按钮事件
  1013. /// </summary>
  1014. /// <param name="sender"></param>
  1015. /// <param name="e"></param>
  1016. private void tsbtnClose_Click(object sender, EventArgs e)
  1017. {
  1018. this.Close();
  1019. }
  1020. /// <summary>
  1021. /// 产品条码列表删除事件
  1022. /// </summary>
  1023. /// <param name="sender"></param>
  1024. /// <param name="e"></param>
  1025. private void dgvProductionData_UserDeletingRow(object sender, DataGridViewRowCancelEventArgs e)
  1026. {
  1027. try
  1028. {
  1029. string BarCode = this.dgvProductionData.Rows[e.Row.Index].Cells["BarCode"].Value.ToString();
  1030. DSTable.Tables[BarCode].Rows.Clear();//清空行
  1031. this.dgvDefectStaff.DataSource = null;//责任员工数据源
  1032. this.dgvMissStaff.DataSource = null; //漏检员工数据源
  1033. this.lvPic.Clear();
  1034. }
  1035. catch (Exception ex)
  1036. {
  1037. throw ex;
  1038. }
  1039. }
  1040. /// <summary>
  1041. /// 产品缺陷删除行事件
  1042. /// </summary>
  1043. /// <param name="sender"></param>
  1044. /// <param name="e"></param>
  1045. private void dgvDefect_UserDeletingRow(object sender, DataGridViewRowCancelEventArgs e)
  1046. {
  1047. try
  1048. {
  1049. if (e.Row.Index != -1)
  1050. {
  1051. //ProductionDataID
  1052. if (this.dgvDefect.CurrentCell != null)
  1053. {
  1054. //是新增进来,加载条码是不允许删除的,只是编辑权限才能可以删除
  1055. //if (this.dgvDefect.Rows[e.Row.Index].Cells["ProductionDataID"].Value.ToString() != "" && Convert.ToInt32(this.dgvDefect.Rows[e.Row.Index].Cells["ProductionDataID"].Value) > 0 && this.dgvDefect.Rows[e.Row.Index].Cells["IsAllowEdit"].Value.ToString() == "0")
  1056. //{
  1057. // e.Cancel = true;
  1058. // return;
  1059. //}
  1060. string TempCount = this.dgvDefect.Rows[e.Row.Index].Cells["TempCount"].Value.ToString();
  1061. DSTableStaff.Tables[string.Format("TempTable{0}", TempCount.ToString())].Rows.Clear();//清空行
  1062. this.dgvDefectStaff.DataSource = null;
  1063. DSTableMissedStaff.Tables[string.Format("TempTable{0}", TempCount.ToString())].Rows.Clear();//清空行
  1064. this.dgvMissStaff.DataSource = null;
  1065. this.lvPic.Clear();
  1066. if (Convert.ToInt32(TempCount) > 0)
  1067. {
  1068. if (this.dgvDefect.CurrentCell != null)
  1069. {
  1070. DataRow[] dr = this.TableProductionData.Select("barcode='" + this._currentBarCode + "'");
  1071. if (dr.Length > 0)
  1072. {
  1073. if (dr[0]["ReadOnly"].ToString() == "1")
  1074. {
  1075. this.tsbtnEdit.Enabled = false;
  1076. this.tsbtnAdd.Enabled = false;
  1077. this.btnDelete.Enabled = false;
  1078. this.btnUpload.Enabled = false;
  1079. }
  1080. else
  1081. {
  1082. this.tsbtnEdit.Enabled = true;
  1083. this.tsbtnAdd.Enabled = true;
  1084. this.btnDelete.Enabled = true;
  1085. this.btnUpload.Enabled = true;
  1086. }
  1087. }
  1088. else
  1089. {
  1090. //if (this._productiondataid > Constant.INT_IS_ZERO)
  1091. //{
  1092. if (this.btnSave.Enabled)
  1093. {
  1094. this.tsbtnEdit.Enabled = true;
  1095. this.tsbtnAdd.Enabled = true;
  1096. this.btnDelete.Enabled = true;
  1097. this.btnUpload.Enabled = true;
  1098. }
  1099. }
  1100. // }
  1101. if (this.dgvDefect.Rows[0].Cells["TempCount"].Value.ToString() != string.Empty)
  1102. {
  1103. int staffTempCount = Convert.ToInt32(this.dgvDefect.Rows[0].Cells["TempCount"].Value.ToString());
  1104. this.dgvDefectStaff.DataSource = DSTableStaff.Tables[string.Format("TempTable{0}", staffTempCount.ToString())];
  1105. this.dgvMissStaff.DataSource = DSTableMissedStaff.Tables[string.Format("TempTable{0}", staffTempCount.ToString())];
  1106. this._currentTempSign = this.dgvDefect.Rows[0].Cells["TempCount"].Value.ToString(); //当前临时标记
  1107. this._smallByte.Clear();//防止重复绑定图片
  1108. BindByteImage(DSTableImage.Tables[string.Format("TempTable{0}", staffTempCount.ToString())]);
  1109. }
  1110. else
  1111. {
  1112. this.dgvDefectStaff.DataSource = null;
  1113. this.dgvMissStaff.DataSource = null;
  1114. this._smallByte.Clear();//防止重复绑定图片
  1115. this.lvPic.Clear();//
  1116. }
  1117. }
  1118. }
  1119. }
  1120. }
  1121. }
  1122. catch (Exception ex)
  1123. {
  1124. throw ex;
  1125. }
  1126. }
  1127. /// <summary>
  1128. /// 新建按钮事件
  1129. /// </summary>
  1130. /// <param name="sender"></param>
  1131. /// <param name="e"></param>
  1132. private void tsbtnAdd_Click(object sender, EventArgs e)
  1133. {
  1134. if (this.dgvProductionData.CurrentCell != null)
  1135. {
  1136. int allow = Convert.ToInt32(this.dgvProductionData.Rows[_selectedRowIndex].Cells["GoodsLevelTypeID"].Value.ToString());
  1137. if (allow != Constant.INT_IS_FOUR) // 有缺陷才能新建
  1138. {
  1139. F_PM_3403 frm3403 = new F_PM_3403(
  1140. DSTable.Tables[this._currentBarCode], this._currentBarCode,
  1141. this._currentGoodsID, this._tempCount, this._procedureID, this.Text, false, this, this.DSTableStaff, this.DSTableMissedStaff, this.DSTableImage, this._PicByte, this._smallByte, -1);
  1142. frm3403.ShowDialog();
  1143. }
  1144. }
  1145. }
  1146. /// <summary>
  1147. /// 编辑按钮事件
  1148. /// </summary>
  1149. /// <param name="sender"></param>
  1150. /// <param name="e"></param>
  1151. private void tsbtnEdit_Click(object sender, EventArgs e)
  1152. {
  1153. if (this.dgvDefect.CurrentCell != null)
  1154. {
  1155. //int isallowedit = Convert.ToInt32(this.dgvDefect.Rows[this.dgvDefect.CurrentCell.RowIndex].Cells["IsAllowEdit"].Value.ToString());
  1156. if (Convert.ToInt32(this.dgvDefect.Rows[this.dgvDefect.CurrentCell.RowIndex].Cells["IsAllowEdit"].Value.ToString()) == 1) //如果_AllowEdit=1,则是编辑状态,肯定允许编辑,因为分权限的时候就定义了
  1157. {
  1158. string barcode = this.dgvDefect.Rows[this.dgvDefect.CurrentCell.RowIndex].Cells["ProductionBarCode"].Value.ToString();
  1159. int tempcount = Convert.ToInt32(this.dgvDefect.Rows[this.dgvDefect.CurrentCell.RowIndex].Cells["TempCount"].Value.ToString());
  1160. int goodsID = 0;
  1161. DataRow[] dr = this.TableProductionData.Select("BarCode='" + barcode + "'");
  1162. if (dr.Length > Constant.INT_IS_ZERO)
  1163. {
  1164. goodsID = Convert.ToInt32(dr[0]["GoodsID"]);
  1165. }
  1166. F_PM_3403 frm3403 = new F_PM_3403(
  1167. DSTable.Tables[barcode], barcode,
  1168. goodsID, tempcount, this._procedureID, this.Text, true, this, this.DSTableStaff, this.DSTableMissedStaff, this.DSTableImage, this._PicByte, this._smallByte, this.dgvDefect.CurrentCell.RowIndex);
  1169. frm3403.ShowDialog();
  1170. }
  1171. }
  1172. }
  1173. /// <summary>
  1174. /// 产品数据源值改变后
  1175. /// </summary>
  1176. /// <param name="sender"></param>
  1177. /// <param name="e"></param>
  1178. private void dgvProductionData_CellValueChanged(object sender, DataGridViewCellEventArgs e)
  1179. {
  1180. if (this.dgvProductionData.CurrentRow == null
  1181. || this.dgvProductionData.Rows.Count < 1)
  1182. {
  1183. return;
  1184. }
  1185. DataGridViewRow rowItem = this.dgvProductionData.Rows[e.RowIndex];
  1186. DataGridViewColumn columnItem = this.dgvProductionData.Columns[e.ColumnIndex];
  1187. if ("DefectFlag".Equals(columnItem.Name))
  1188. {
  1189. SetGridView(Convert.ToInt32(rowItem.Cells["DefectFlag"].Value));
  1190. if (Convert.ToInt32(rowItem.Cells["DefectFlag"].Value) == 7)
  1191. {
  1192. dgvPackingBomDetail.Columns["NewCheck"].ReadOnly = true;
  1193. dgvPackingBomDetail.Columns["NEWIDNRKONLYCODE"].ReadOnly = true;
  1194. dgvPackingBomDetail.Columns["FrmLossCheck"].ReadOnly = false;
  1195. dgvPackingBomDetail.Columns["RecoverCheck"].ReadOnly = false;
  1196. foreach (DataGridViewRow itemRow in dgvPackingBomDetail.Rows)
  1197. {
  1198. itemRow.Cells["NewCheck"].Value = 0;
  1199. itemRow.Cells["NEWIDNRKONLYCODE"].Value = "";
  1200. }
  1201. }
  1202. else
  1203. {
  1204. dgvPackingBomDetail.Columns["FrmLossCheck"].ReadOnly = true;
  1205. dgvPackingBomDetail.Columns["RecoverCheck"].ReadOnly = true;
  1206. dgvPackingBomDetail.Columns["NewCheck"].ReadOnly = false;
  1207. dgvPackingBomDetail.Columns["NEWIDNRKONLYCODE"].ReadOnly = false;
  1208. foreach (DataGridViewRow itemRow in dgvPackingBomDetail.Rows)
  1209. {
  1210. itemRow.Cells["FrmLossCheck"].Value = 0;
  1211. itemRow.Cells["RecoverCheck"].Value = 0;
  1212. }
  1213. }
  1214. }
  1215. }
  1216. /// <summary>
  1217. /// 保存按钮事件
  1218. /// </summary>
  1219. /// <param name="sender"></param>
  1220. /// <param name="e"></param>
  1221. private void btnSave_Click(object sender, EventArgs e)
  1222. {
  1223. try
  1224. {
  1225. //ProductionDataEntity[] productionDataEntitys = new ProductionDataEntity[this.TableProductionData.Rows.Count];
  1226. if (this.TableProductionData.Select("ReadOnly<>1").Length > 0)
  1227. {
  1228. this.TableProductionData = this.TableProductionData.Select("ReadOnly<>1").CopyToDataTable();
  1229. }
  1230. ProductionDataEntity[] productionDataEntitys = new ProductionDataEntity[this.TableProductionData.Rows.Count];
  1231. bool isError = false; // 是否存在缺陷员工
  1232. int ErrorCount = -1;
  1233. int CurrentRowIndex = -1;
  1234. for (int i = 0; i < this.TableProductionData.Rows.Count; i++)
  1235. {
  1236. if (this.TableProductionData.Rows[i]["ReadOnly"].ToString() == "1") //只读数据不进行保存
  1237. {
  1238. continue;
  1239. }
  1240. ProductionDataEntity productionDataEntity = new ProductionDataEntity();
  1241. //if (this._productiondataid > 0)
  1242. //{
  1243. // productionDataEntity.ProductionDataID = this._productiondataid;
  1244. //}
  1245. if (this.TableProductionData.Rows[i]["ProductionDataID"].ToString() != "")
  1246. {
  1247. productionDataEntity.ProductionDataID = Convert.ToInt32(this.TableProductionData.Rows[i]["ProductionDataID"]);
  1248. }
  1249. productionDataEntity.Barcode = this.TableProductionData.Rows[i]["BarCode"].ToString();
  1250. productionDataEntity.UserID = UserID;// Convert.ToInt32(this.TableProductionData.Rows[i]["UserID"]);
  1251. productionDataEntity.UserCode = UserCode;// this.TableProductionData.Rows[i]["UserCode"].ToString();
  1252. productionDataEntity.UserName = UserName;// this.TableProductionData.Rows[i]["UserName"].ToString(); ;
  1253. productionDataEntity.DefectFlag = Convert.ToInt32(this.TableProductionData.Rows[i]["GoodsLevelTypeID"]) == 4 ? 1 : 2;
  1254. productionDataEntity.GoodsLevelID = Convert.ToInt32(this.TableProductionData.Rows[i]["DefectFlagID"]);
  1255. productionDataEntity.GoodsLevelTypeID = Convert.ToInt32(this.TableProductionData.Rows[i]["GoodsLevelTypeID"]);
  1256. productionDataEntity.Remarks = this.TableProductionData.Rows[i]["Remarks"].ToString();
  1257. if (this.TableProductionData.Rows[i]["LogoID"].ToString() != "")
  1258. {
  1259. productionDataEntity.LogoID = Convert.ToInt32(this.TableProductionData.Rows[i]["LogoID"]);
  1260. }
  1261. if (this.TableProductionData.Rows[i]["OPTimeStamp"].ToString() != "")
  1262. {
  1263. productionDataEntity.OPTimeStamp = Convert.ToDateTime(this.TableProductionData.Rows[i]["OPTimeStamp"]);
  1264. }
  1265. if (this.TableProductionData.Rows[i]["CheckTime"].ToString() != "")
  1266. {
  1267. productionDataEntity.CheckTime = Convert.ToDateTime(this.TableProductionData.Rows[i]["CheckTime"]);
  1268. }
  1269. if (this.TableProductionData.Rows[i]["OrgGoodsLevelTypeID"].ToString() != "-1")
  1270. {
  1271. productionDataEntity.OrgGoodsLevelTypeID = Convert.ToInt32(this.TableProductionData.Rows[i]["OrgGoodsLevelTypeID"]);
  1272. }
  1273. if (!string.IsNullOrEmpty(this.TableProductionData.Rows[i]["ReworkProcedureID"].ToString()))
  1274. {
  1275. productionDataEntity.ReworkProcedureID = int.Parse(this.TableProductionData.Rows[i]["ReworkProcedureID"].ToString());
  1276. productionDataEntity.IsReworked = 1;
  1277. }
  1278. productionDataEntitys[i] = productionDataEntity;
  1279. if (Convert.ToInt32(this.TableProductionData.Rows[i]["GoodsLevelTypeID"]) == (int)Constant.GoodsLevelType.ReFire) //重烧
  1280. {
  1281. if (this.TableProductionData.Rows[i]["ReworkProcedureID"].ToString() == "" ||
  1282. Convert.ToInt32(this.TableProductionData.Rows[i]["ReworkProcedureID"].ToString()) == -Constant.INT_IS_ONE)
  1283. {
  1284. isError = true;
  1285. ErrorCount = 1;
  1286. CurrentRowIndex = i;
  1287. this.dgvProductionData.Rows[i].Selected = true;
  1288. break;
  1289. }
  1290. }
  1291. if (Convert.ToInt32(this.TableProductionData.Rows[i]["GoodsLevelTypeID"]) != (int)Constant.GoodsLevelType.Quality) //正品
  1292. {
  1293. // 不是正品
  1294. if (this.DSTable.Tables[productionDataEntity.Barcode].Rows.Count == Constant.INT_IS_ZERO)
  1295. {
  1296. isError = true;
  1297. ErrorCount = -2;
  1298. CurrentRowIndex = i;
  1299. this.dgvProductionData.Rows[i].Selected = true;
  1300. break;
  1301. }
  1302. }
  1303. if (dgvPackingBomDetail.DataSource != null )
  1304. {
  1305. DataTable packingBomDetailTable = dgvPackingBomDetail.DataSource as DataTable;
  1306. for (int j = 0; j < packingBomDetailTable.Rows.Count; j++)
  1307. {
  1308. if (!string.IsNullOrWhiteSpace(packingBomDetailTable.Rows[j]["IDNRKONLYCODE"] + ""))
  1309. {
  1310. if (packingBomDetailTable.Rows[j]["NewCheck"] + "" == "1" && string.IsNullOrWhiteSpace(packingBomDetailTable.Rows[j]["NEWIDNRKONLYCODE"] + ""))
  1311. {
  1312. isError = true;
  1313. ErrorCount = -3;
  1314. break;
  1315. }
  1316. }
  1317. //报损必须选择报损原因
  1318. if (packingBomDetailTable.Rows[j]["FrmLossCheck"] + "" == "1" || packingBomDetailTable.Rows[j]["RecoverCheck"] + "" == "1" || packingBomDetailTable.Rows[j]["NewCheck"] + "" == "1")
  1319. {
  1320. if (string.IsNullOrWhiteSpace(packingBomDetailTable.Rows[j]["DICTIONARYID"] +""))
  1321. {
  1322. isError = true;
  1323. ErrorCount = -4;
  1324. break;
  1325. }
  1326. else
  1327. {
  1328. int dictionaryID = Convert.ToInt32(packingBomDetailTable.Rows[j]["DICTIONARYID"]);
  1329. for (int index = 0; index < scrapReasonDataSource.Rows.Count; index++)
  1330. {
  1331. if (Convert.ToInt32(scrapReasonDataSource.Rows[index]["DICTIONARYID"]) == dictionaryID)
  1332. {
  1333. packingBomDetailTable.Rows[j]["SCRAPREASON"] = scrapReasonDataSource.Rows[index]["DICTIONARYVALUE"];
  1334. }
  1335. }
  1336. }
  1337. }
  1338. else
  1339. {
  1340. packingBomDetailTable.Rows[j]["DICTIONARYID"] = 0;
  1341. }
  1342. }
  1343. }
  1344. List<ProductionDefectEntity> productionDefectEntitys = new List<ProductionDefectEntity>();
  1345. ProductionDefectEntity productionDefectEntity = null;
  1346. for (int j = 0; j < this.DSTable.Tables[productionDataEntity.Barcode].Rows.Count; j++) //缺陷列表
  1347. {
  1348. productionDefectEntity = new ProductionDefectEntity();
  1349. productionDefectEntity.SpecialDefect = this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["IsOtherDefect"].ToString();
  1350. //if (this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["DefectDeductionID"].ToString() != "-1"
  1351. // && this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["DefectDeductionID"].ToString() != string.Empty)
  1352. //{
  1353. // productionDefectEntity.DefectDeductionNum = Convert.ToDecimal(this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["DefectDeductionNum"]);
  1354. //}
  1355. if (!string.IsNullOrEmpty(this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["DefectDeductionNum"] + ""))
  1356. {
  1357. productionDefectEntity.DefectDeductionNum = Convert.ToDecimal(this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["DefectDeductionNum"]);
  1358. }
  1359. productionDefectEntity.ScrapResponFlag = "0";
  1360. productionDefectEntity.DefectID =
  1361. Convert.ToInt32(this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["DefectID"]);
  1362. productionDefectEntity.DefectCode =
  1363. this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["DefectCode"].ToString();
  1364. productionDefectEntity.DefectName =
  1365. this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["DefectName"].ToString().Replace(productionDefectEntity.DefectCode + "->", "");
  1366. productionDefectEntity.DefectPositionID =
  1367. Convert.ToInt32(this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["DefectPositionID"]);
  1368. productionDefectEntity.DefectPositionCode =
  1369. this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["DefectPositionCode"].ToString();
  1370. productionDefectEntity.DefectPositionName =
  1371. this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["DefectPositionName"].ToString().Replace(productionDefectEntity.DefectPositionCode + "->", "");
  1372. productionDefectEntity.DefectProductionDataID =
  1373. Convert.ToInt32(this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["ProductionDataID"] + "");
  1374. if (productionDefectEntity.DefectProductionDataID == 0)
  1375. {
  1376. productionDefectEntity.DefectProductionDataID = null;
  1377. }
  1378. if (this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["DefectProcedureID"].ToString() != string.Empty &&
  1379. Convert.ToInt32(this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["DefectProcedureID"] + "") > Constant.INT_IS_ZERO)
  1380. {
  1381. productionDefectEntity.DefectProcedureID =
  1382. Convert.ToInt32(this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["DefectProcedureID"]);
  1383. }
  1384. productionDefectEntity.DefectProcedureCode =
  1385. this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["DefectProcedureCode"].ToString();
  1386. productionDefectEntity.DefectProcedureName =
  1387. this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["DefectProcedureName"].ToString();
  1388. productionDefectEntity.DefectUserID =
  1389. Convert.ToInt32(this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["DefectUserID"]);
  1390. productionDefectEntity.DefectUserCode =
  1391. this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["DefectUserCode"].ToString();
  1392. productionDefectEntity.DefectUserName =
  1393. this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["DefectUserName"].ToString();
  1394. productionDefectEntity.DefectJobs =
  1395. Convert.ToInt32(this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["Jobs"].ToString());
  1396. productionDefectEntity.Remarks =
  1397. this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["DefectRemarks"].ToString();
  1398. productionDefectEntity.Remarks =
  1399. this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["DefectRemarks"].ToString();
  1400. if (this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["DefectFineID"].ToString() != "-1"
  1401. && this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["DefectFineID"].ToString() != string.Empty)
  1402. {
  1403. productionDefectEntity.DefectFine = Convert.ToInt32(this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["DefectFineID"]);
  1404. }
  1405. if (this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["CheckTime"].ToString() != string.Empty)
  1406. {
  1407. //if (Convert.ToInt32(this.TableProductionData.Rows[i]["OrgGoodsLevelTypeID"]) == Convert.ToInt32(this.TableProductionData.Rows[i]["GoodsLevelTypeID"]))
  1408. //{
  1409. productionDefectEntity.CheckTime = Convert.ToDateTime(this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["CheckTime"]);
  1410. //}
  1411. }
  1412. if (this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["MissedUserID"].ToString() != "-1"
  1413. && this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["MissedUserID"].ToString() != string.Empty)
  1414. {
  1415. productionDefectEntity.MissedUserID = Convert.ToInt32(this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["MissedUserID"]);
  1416. productionDefectEntity.MissedUserCode = this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["MissedUserCode"].ToString();
  1417. productionDefectEntity.MissedUserName = this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["MissedUserName"].ToString();
  1418. }
  1419. // 遍历责任员工
  1420. List<DefectResponsibleEntity> DefectResponsibles = new List<DefectResponsibleEntity>();
  1421. if (this.DSTableStaff.Tables.Contains(string.Format("TempTable{0}",
  1422. this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["TempCount"].ToString())))
  1423. {
  1424. DefectResponsibleEntity defectResponsibleEntity = null;
  1425. DataTable dtTemp = this.DSTableStaff.Tables[string.Format("TempTable{0}",
  1426. this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["TempCount"].ToString())];
  1427. foreach (DataRow drStaff in dtTemp.Rows)
  1428. {
  1429. if (Convert.ToInt32(drStaff["IsSelected"]) == Constant.INT_IS_ONE)
  1430. {
  1431. defectResponsibleEntity = new DefectResponsibleEntity();
  1432. defectResponsibleEntity.StaffID = Convert.ToInt32(drStaff["StaffID"]);
  1433. defectResponsibleEntity.UserID = Convert.ToInt32(productionDefectEntity.DefectUserID);
  1434. defectResponsibleEntity.UserCode = productionDefectEntity.DefectUserCode;
  1435. defectResponsibleEntity.UJobsID =
  1436. Convert.ToInt32(this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["Jobs"].ToString());
  1437. defectResponsibleEntity.SJobsID =
  1438. Convert.ToInt32(this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["Jobs"].ToString());
  1439. defectResponsibleEntity.StaffStatus = Convert.ToInt32(drStaff["StaffStatus"]);
  1440. DefectResponsibles.Add(defectResponsibleEntity);
  1441. }
  1442. }
  1443. //productionDefectEntity.DefectResponsibles = DefectResponsibles.ToArray();//每个缺陷对应的责任员工
  1444. productionDefectEntity.DefectResponsibles = DefectResponsibles;//每个缺陷对应的责任员工
  1445. }
  1446. if (DefectResponsibles.Count == Constant.INT_IS_ZERO) // 并没有责任员工
  1447. {
  1448. isError = true;
  1449. this.dgvDefect.DataSource = this.DSTable.Tables[productionDataEntity.Barcode];
  1450. this.dgvDefect.CurrentCell = null;
  1451. this.dgvDefect.Rows[j].Selected = true;
  1452. if (this.DSTableStaff.Tables.Contains(string.Format("TempTable{0}",
  1453. this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["TempCount"].ToString())))
  1454. {
  1455. this.dgvDefectStaff.DataSource = this.DSTableStaff.Tables[string.Format("TempTable{0}",
  1456. this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["TempCount"].ToString())];
  1457. }
  1458. else
  1459. {
  1460. this.dgvDefectStaff.DataSource = null;
  1461. }
  1462. break;
  1463. }
  1464. // 遍历漏检责任员工
  1465. List<DefectMissedResponsibleEntity> DefectMissedResponsibles = new List<DefectMissedResponsibleEntity>();
  1466. if (this.DSTableMissedStaff.Tables.Contains(string.Format("TempTable{0}",
  1467. this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["TempCount"].ToString())))
  1468. {
  1469. DefectMissedResponsibleEntity defectMissedResponsibleEntity = null;
  1470. DataTable dtTemp = this.DSTableMissedStaff.Tables[string.Format("TempTable{0}",
  1471. this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["TempCount"].ToString())];
  1472. foreach (DataRow drStaff in dtTemp.Rows)
  1473. {
  1474. if (Convert.ToInt32(drStaff["IsSelected"]) == Constant.INT_IS_ONE)
  1475. {
  1476. defectMissedResponsibleEntity = new DefectMissedResponsibleEntity();
  1477. defectMissedResponsibleEntity.StaffID = Convert.ToInt32(drStaff["StaffID"]);
  1478. defectMissedResponsibleEntity.UserID = Convert.ToInt32(productionDefectEntity.DefectUserID);
  1479. defectMissedResponsibleEntity.UserCode = productionDefectEntity.DefectUserCode;
  1480. defectMissedResponsibleEntity.UJobsID = Convert.ToInt32(drStaff["UJobsID"]);
  1481. defectMissedResponsibleEntity.SJobsID = Convert.ToInt32(drStaff["SJobsID"]);
  1482. defectMissedResponsibleEntity.StaffStatus = Convert.ToInt32(drStaff["StaffStatus"]);
  1483. DefectMissedResponsibles.Add(defectMissedResponsibleEntity);
  1484. }
  1485. }
  1486. //productionDefectEntity.DefectMissedResponsibles = DefectMissedResponsibles.ToArray();
  1487. productionDefectEntity.DefectMissedResponsibles = DefectMissedResponsibles;
  1488. }
  1489. // 遍历缺陷图片
  1490. if (this.DSTableImage.Tables.Contains(string.Format("TempTable{0}",
  1491. this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["TempCount"].ToString())))
  1492. {
  1493. List<DefectImageEntity> defectImageEntitys = new List<DefectImageEntity>();
  1494. DefectImageEntity defectImageEntity = null;
  1495. DataTable dtTemp = this.DSTableImage.Tables[string.Format("TempTable{0}",
  1496. this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["TempCount"].ToString())];
  1497. foreach (DataRow drImage in dtTemp.Rows)
  1498. {
  1499. defectImageEntity = new DefectImageEntity();
  1500. defectImageEntity.Thumbnail = (byte[])drImage["ImageByte"];
  1501. defectImageEntity.Image = (byte[])drImage["orgImageByte"];
  1502. defectImageEntitys.Add(defectImageEntity);
  1503. }
  1504. //productionDefectEntity.DefectImages = defectImageEntitys.ToArray();
  1505. productionDefectEntity.DefectImages = defectImageEntitys;
  1506. }
  1507. productionDefectEntitys.Add(productionDefectEntity);
  1508. }
  1509. if (isError)
  1510. {
  1511. break;
  1512. }
  1513. //productionDataEntitys[i].ProductionDefects = productionDefectEntitys.ToArray();
  1514. productionDataEntitys[i].ProductionDefects = productionDefectEntitys;
  1515. }
  1516. // 有错误
  1517. if (isError)
  1518. {
  1519. if (CurrentRowIndex != -Constant.INT_IS_ONE)
  1520. {
  1521. this._currentDefectFlag = Convert.ToInt32(this.TableProductionData.Rows[CurrentRowIndex]["DefectFlagID"].ToString());
  1522. }
  1523. if (ErrorCount == -Constant.INT_IS_ONE)
  1524. {
  1525. // 提示信息
  1526. MessageBox.Show(Messages.MSG_PM_W002,
  1527. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  1528. return;
  1529. }
  1530. else if (ErrorCount == -Constant.INT_IS_TWO)
  1531. {
  1532. // 提示信息
  1533. MessageBox.Show(Messages.MSG_PM_W004,
  1534. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  1535. return;
  1536. }
  1537. else if (ErrorCount == -Constant.INT_IS_THREE)
  1538. {
  1539. // 提示信息
  1540. MessageBox.Show("报损并换新必须输入新组件唯一编码",
  1541. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  1542. return;
  1543. }
  1544. else if (ErrorCount == -Constant.INT_IS_FOUR)
  1545. {
  1546. // 提示信息
  1547. MessageBox.Show("报损必须选择报损原因",
  1548. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  1549. return;
  1550. }
  1551. else
  1552. {
  1553. this.dgvProductionData.DataSource = TableProductionData;
  1554. // 提示信息
  1555. MessageBox.Show(Messages.MSG_PM_W003,
  1556. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  1557. return;
  1558. }
  1559. }
  1560. // 最外层For循环结束
  1561. if (productionDataEntitys.Length > Constant.INT_IS_ZERO)
  1562. {
  1563. ClientRequestEntity cre = new ClientRequestEntity();
  1564. cre.NameSpace = "F_PM_3402";
  1565. cre.Name = "AddCheckBarcode";
  1566. cre.Properties["ProcedureID"] = this._finishedCheckProcedureID;
  1567. cre.Properties.Add("productionDataEntitys", JsonHelper.ToJson(productionDataEntitys));
  1568. if (this.dgvPackingBomDetail.DataSource != null )
  1569. {
  1570. DataTable bomDetailTable = (DataTable)this.dgvPackingBomDetail.DataSource;
  1571. bomDetailTable.TableName = "bomDetailTable";
  1572. cre.Data = new DataSet();
  1573. cre.Data.Tables.Add(bomDetailTable.Copy());
  1574. }
  1575. ServiceResultEntity sre = DoAsync<ServiceResultEntity>(() =>
  1576. {
  1577. return PCModuleProxyNew.Service.HandleRequest(cre);
  1578. });
  1579. if (sre.Status == Constant.ServiceResultStatus.Success)
  1580. {
  1581. // 提示信息
  1582. MessageBox.Show(string.Format(Messages.MSG_CMN_I001, "新建" + this.Text, "保存"),
  1583. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
  1584. // 保存成功后,清空相应数据源
  1585. this.TableProductionData.Rows.Clear();
  1586. this.dgvProductionData.DataSource = TableProductionData;
  1587. this.DSTable.Tables.Clear();
  1588. this.dgvDefect.DataSource = null;
  1589. this.DSTableStaff.Tables.Clear();
  1590. this.dgvDefectStaff.DataSource = null;
  1591. this.DSTableMissedStaff.Tables.Clear();
  1592. this.dgvMissStaff.DataSource = null;
  1593. this.DSTableImage.Tables.Clear();
  1594. this.lvPic.Clear();
  1595. this._PicByte.Clear();
  1596. this._smallByte.Clear();
  1597. this.txtBarCode.Text = string.Empty;
  1598. this.dgvPackingBomDetail.DataSource = null;
  1599. this.txtProcedureName.Text = string.Empty;
  1600. //if (Convert.ToInt32( this._procedureDataTable.Rows[0]["CollectType"]) == (int)Constant.ProcedureCollectType.Togather)
  1601. //{
  1602. // this.txtUserCode.Text = string.Empty;
  1603. // this.txtUserCode.ReadOnly = false;
  1604. //}
  1605. //this.DSREWORK.Tables.Clear();
  1606. }
  1607. // string returnValue = (string)DoAsync(new BaseAsyncMethod(() =>
  1608. //{
  1609. // return PMModuleProxy.Service.AddCheckBarcode(this._procedureID, productionDataEntitys);
  1610. //}));
  1611. //if (string.IsNullOrEmpty(returnValue))//成功
  1612. // {
  1613. // // 提示信息
  1614. // MessageBox.Show(string.Format(Messages.MSG_CMN_I001, "新建" + this.Text, "保存"),
  1615. // this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
  1616. // ////保存成功后,并且为编辑时候,把上次编辑的数据禁用
  1617. // //if (this._productiondataid > Constant.INT_IS_ZERO)
  1618. // //{
  1619. // // int deleteRow = (int)DoAsync(new BaseAsyncMethod(() =>
  1620. // // {
  1621. // // return PMModuleProxy.Service.DeleteProductionDataByID(this._productiondataid);
  1622. // // }));
  1623. // //}
  1624. // // 保存成功后,清空相应数据源
  1625. // this.TableProductionData.Rows.Clear();
  1626. // this.dgvProductionData.DataSource = TableProductionData;
  1627. // this.DSTable.Tables.Clear();
  1628. // this.dgvDefect.DataSource = null;
  1629. // this.DSTableStaff.Tables.Clear();
  1630. // this.dgvDefectStaff.DataSource = null;
  1631. // this.DSTableMissedStaff.Tables.Clear();
  1632. // this.dgvMissStaff.DataSource = null;
  1633. // this.DSTableImage.Tables.Clear();
  1634. // this.lvPic.Clear();
  1635. // this._PicByte.Clear();
  1636. // this._smallByte.Clear();
  1637. // this.txtBarCode.Text = string.Empty;
  1638. // if (this._procedureDataEntity.CollectType == (int)Constant.ProcedureCollectType.Togather)
  1639. // {
  1640. // this.txtUserCode.Text = string.Empty;
  1641. // this.txtUserCode.ReadOnly = false;
  1642. // }
  1643. // //this.DSREWORK.Tables.Clear();
  1644. // }
  1645. // else
  1646. // {
  1647. // // 提示信息
  1648. // MessageBox.Show(returnValue,
  1649. // this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  1650. // }
  1651. }
  1652. }
  1653. catch (Exception ex)
  1654. {
  1655. // 对异常进行共通处理
  1656. ExceptionManager.HandleEventException(this.ToString(),
  1657. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  1658. }
  1659. }
  1660. /// <summary>
  1661. /// 单元格编辑开始时事件
  1662. /// </summary>
  1663. /// <param name="sender"></param>
  1664. /// <param name="e"></param>
  1665. private void dgvProductionData_CellBeginEdit(object sender, DataGridViewCellCancelEventArgs e)
  1666. {
  1667. //if (e.ColumnIndex == Constant.INT_IS_FOUR && e.RowIndex != -Constant.INT_IS_ONE)
  1668. //{
  1669. // DataGridView dgv = (DataGridView)sender;
  1670. // string value = this.dgvProductionData.Rows[this.dgvProductionData.CurrentCell.RowIndex].Cells["GoodsLevelTypeID"].Value.ToString();
  1671. // if (value != Constant.GoodsLevelType.ReFire.GetHashCode().ToString())
  1672. // {
  1673. // e.Cancel = true;
  1674. // }
  1675. //}
  1676. //if (e.ColumnIndex == Constant.INT_IS_THREE && e.RowIndex != -Constant.INT_IS_ONE)
  1677. //{
  1678. // if (this.dgvProductionData.Rows[this.dgvProductionData.CurrentCell.RowIndex].Cells["ReadOnly"].Value.ToString() == "1")
  1679. // {
  1680. // e.Cancel = true;
  1681. // }
  1682. //}
  1683. if (e.ColumnIndex == Constant.INT_IS_FOUR && e.RowIndex != -Constant.INT_IS_ONE)
  1684. {
  1685. DataGridView dgv = (DataGridView)sender;
  1686. string value = this.dgvProductionData.Rows[this.dgvProductionData.CurrentCell.RowIndex].Cells["GoodsLevelTypeID"].Value.ToString();
  1687. if (value != Constant.GoodsLevelType.ReFire.GetHashCode().ToString() && value != Constant.GoodsLevelType.LengBu.GetHashCode().ToString())
  1688. {
  1689. e.Cancel = true;
  1690. }
  1691. }
  1692. if (e.ColumnIndex == Constant.INT_IS_THREE && e.RowIndex != -Constant.INT_IS_ONE)
  1693. {
  1694. if (this.dgvProductionData.Rows[this.dgvProductionData.CurrentCell.RowIndex].Cells["ReadOnly"].Value.ToString() == "1")
  1695. {
  1696. e.Cancel = true;
  1697. }
  1698. }
  1699. }
  1700. /// <summary>
  1701. /// 用户编码验证事件
  1702. /// </summary>
  1703. /// <param name="sender"></param>
  1704. /// <param name="e"></param>
  1705. private void txtUserCode_Validating(object sender, System.ComponentModel.CancelEventArgs e)
  1706. {
  1707. try
  1708. {
  1709. if (txtUserCode.Text.Trim() == string.Empty) // 如果未添加数据,则此项获取焦点
  1710. {
  1711. this.txtUserCode.IsMustInput = true;
  1712. this.txtUserCode.SelectAll();
  1713. e.Cancel = true;
  1714. return;
  1715. }
  1716. else if (!this.txtUserCode.ReadOnly)
  1717. {
  1718. SUserEntity userEntity = new SUserEntity();
  1719. userEntity.UserCode = this.txtUserCode.Text.Trim();
  1720. // 此工号是否能生产工序
  1721. ClientRequestEntity cre = new ClientRequestEntity();
  1722. cre.NameSpace = "F_PM_3402";
  1723. cre.Name = "CheckProcedureUser";
  1724. cre.Properties["ProcedureID"] = this._procedureID;
  1725. cre.Properties["UserCode"] = DataModels.LogInUserInfo.CurrentUser.CurrentUserEntity.UserCode;
  1726. ServiceResultEntity sre = DoAsync<ServiceResultEntity>(() =>
  1727. {
  1728. return PCModuleProxyNew.Service.HandleRequest(cre);
  1729. });
  1730. DataTable MsgCheckProcedureUser = sre.Data.Tables[0];
  1731. //CheckProcedureUserResult MsgCheckProcedureUser = (CheckProcedureUserResult)DoAsync(new BaseAsyncMethod(() =>
  1732. //{
  1733. // return PMModuleProxy.Service.CheckProcedureUser(this._procedureID, this.txtUserCode.Text.Trim());
  1734. //}));
  1735. if (MsgCheckProcedureUser != null)
  1736. {
  1737. if (MsgCheckProcedureUser.Rows[0]["ErrMsg"] != null)
  1738. {
  1739. MessageBox.Show(MsgCheckProcedureUser.Rows[0]["ErrMsg"] + "",
  1740. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  1741. this.txtUserCode.SelectAll();
  1742. e.Cancel = true;
  1743. return;
  1744. }
  1745. UserID = Convert.ToInt32(MsgCheckProcedureUser.Rows[0]["UserID"]);
  1746. UserCode = MsgCheckProcedureUser.Rows[0]["UserCode"] + "";
  1747. UserName = MsgCheckProcedureUser.Rows[0]["UserName"] + "";
  1748. this.txtUserCode.ReadOnly = true;
  1749. }
  1750. }
  1751. }
  1752. catch (Exception ex)
  1753. {
  1754. // 对异常进行共通处理
  1755. ExceptionManager.HandleEventException(this.ToString(),
  1756. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  1757. }
  1758. }
  1759. /// <summary>
  1760. /// 鼠标单击事件
  1761. /// </summary>
  1762. /// <param name="sender"></param>
  1763. /// <param name="e"></param>
  1764. private void txtUserCode_MouseClick(object sender, MouseEventArgs e)
  1765. {
  1766. if (this.txtUserCode.Text.Trim() != string.Empty)
  1767. {
  1768. this.txtUserCode.SelectAll();
  1769. }
  1770. }
  1771. /// <summary>
  1772. /// 责任员工
  1773. /// </summary>
  1774. /// <param name="sender"></param>
  1775. /// <param name="e"></param>
  1776. private void dgvDefectStaff_UserDeletingRow(object sender, DataGridViewRowCancelEventArgs e)
  1777. {
  1778. try
  1779. {
  1780. if (e.Row.Index != -1)
  1781. {
  1782. if (this.dgvDefect.CurrentCell != null)
  1783. {
  1784. //是新增进来,加载条码是不允许删除的,只是编辑权限才能可以删除
  1785. if (this.dgvDefect.Rows[e.Row.Index].Cells["ProductionDataID"].Value.ToString() != "" && Convert.ToInt32(this.dgvDefect.Rows[e.Row.Index].Cells["ProductionDataID"].Value) > 0 && this.dgvDefect.Rows[e.Row.Index].Cells["IsAllowEdit"].Value.ToString() == "0")
  1786. {
  1787. e.Cancel = true;
  1788. return;
  1789. }
  1790. }
  1791. }
  1792. }
  1793. catch (Exception ex)
  1794. {
  1795. throw ex;
  1796. }
  1797. }
  1798. /// <summary>
  1799. /// 漏扫责任员工
  1800. /// </summary>
  1801. /// <param name="sender"></param>
  1802. /// <param name="e"></param>
  1803. private void dgvMissStaff_UserDeletingRow(object sender, DataGridViewRowCancelEventArgs e)
  1804. {
  1805. try
  1806. {
  1807. if (e.Row.Index != -1)
  1808. {
  1809. if (this.dgvDefect.CurrentCell != null)
  1810. {
  1811. //是新增进来,加载条码是不允许删除的,只是编辑权限才能可以删除
  1812. if (this.dgvDefect.Rows[e.Row.Index].Cells["ProductionDataID"].Value.ToString() != "" && Convert.ToInt32(this.dgvDefect.Rows[e.Row.Index].Cells["ProductionDataID"].Value) > 0 && this.dgvDefect.Rows[e.Row.Index].Cells["IsAllowEdit"].Value.ToString() == "0")
  1813. {
  1814. e.Cancel = true;
  1815. return;
  1816. }
  1817. }
  1818. }
  1819. }
  1820. catch (Exception ex)
  1821. {
  1822. throw ex;
  1823. }
  1824. }
  1825. /// <summary>
  1826. /// 报损值改变事件
  1827. /// </summary>
  1828. /// <param name="sender"></param>
  1829. /// <param name="e"></param>
  1830. private void dgvPackingBomDetail_CurrentCellDirtyStateChanged(object sender, EventArgs e)
  1831. {
  1832. try
  1833. {
  1834. if (this.dgvPackingBomDetail.CurrentRow == null
  1835. || this.dgvPackingBomDetail.Rows.Count < 1)
  1836. {
  1837. return;
  1838. }
  1839. this.dgvPackingBomDetail.CommitEdit(DataGridViewDataErrorContexts.Commit);
  1840. DataGridViewRow rowItem = this.dgvPackingBomDetail.CurrentRow;
  1841. //DataGridViewColumn columnItem = this.dgvPackingBomDetail.Columns[e.ColumnIndex];
  1842. //次品,则可以选“单报损”和“回收”两项。其它等级时,只能选择“报损并换新、空”两项。
  1843. //单报损
  1844. if ("FrmLossCheck".Equals(this.dgvPackingBomDetail.Columns[this.dgvPackingBomDetail.CurrentCell.ColumnIndex].Name))
  1845. {
  1846. if (rowItem.Cells["FrmLossCheck"].Value.ToString() == "1")
  1847. {
  1848. rowItem.Cells["RecoverCheck"].Value = 0;
  1849. }
  1850. }
  1851. //回收
  1852. else if ("RecoverCheck".Equals(this.dgvPackingBomDetail.Columns[this.dgvPackingBomDetail.CurrentCell.ColumnIndex].Name))
  1853. {
  1854. if (rowItem.Cells["RecoverCheck"].Value.ToString() == "1")
  1855. {
  1856. rowItem.Cells["FrmLossCheck"].Value = 0;
  1857. }
  1858. }
  1859. //换新
  1860. else if ("NewCheck".Equals(this.dgvPackingBomDetail.Columns[this.dgvPackingBomDetail.CurrentCell.ColumnIndex].Name))
  1861. {
  1862. if (rowItem.Cells["NewCheck"].Value.ToString() == "1")
  1863. {
  1864. rowItem.Cells["FrmLossCheck"].Value = 0;
  1865. rowItem.Cells["RecoverCheck"].Value = 0;
  1866. }
  1867. }
  1868. }
  1869. catch (Exception ex)
  1870. {
  1871. throw ex;
  1872. }
  1873. }
  1874. #endregion
  1875. #region 私有方法
  1876. /// <summary>
  1877. /// 设置数据源
  1878. /// </summary>
  1879. /// <param name="tempCount"></param>
  1880. public void SetDataSource(int tempCount)
  1881. {
  1882. this.dgvDefect.DataSource = DSTable.Tables[this._currentBarCode];
  1883. this.dgvDefectStaff.DataSource = DSTableStaff.Tables[string.Format("TempTable{0}", this._tempCount.ToString())];
  1884. this.dgvMissStaff.DataSource = DSTableMissedStaff.Tables[string.Format("TempTable{0}", this._tempCount.ToString())];
  1885. this._tempCount = tempCount;
  1886. }
  1887. /// <summary>
  1888. /// 设置编辑产品为时设置只读
  1889. /// </summary>
  1890. private void SetSubstandard()
  1891. {
  1892. this.btnSave.Enabled = false;
  1893. this.dgvProductionData.ReadOnly = true;
  1894. this.tsbtnAdd.Enabled = false;
  1895. this.tsbtnEdit.Enabled = false;
  1896. this.dgvDefect.ReadOnly = true;
  1897. this.dgvDefectStaff.ReadOnly = true;
  1898. this.dgvMissStaff.ReadOnly = true;
  1899. this.btnDelete.Enabled = false;
  1900. this.btnUpload.Enabled = false;
  1901. }
  1902. /// <summary>
  1903. /// 编辑后设置数据源
  1904. /// </summary>
  1905. private void SetEditDataSource()
  1906. {
  1907. try
  1908. {
  1909. this.txtUserCode.Enabled = false;
  1910. this.txtBarCode.Enabled = false;
  1911. ClientRequestEntity cre = new ClientRequestEntity();
  1912. cre.NameSpace = "F_PM_3402";
  1913. cre.Name = "GetProductionDataByID";
  1914. cre.Properties["ProcedureID"] = this._productiondataid;
  1915. ServiceResultEntity sre = DoAsync<ServiceResultEntity>(() =>
  1916. {
  1917. return PCModuleProxyNew.Service.HandleRequest(cre);
  1918. });
  1919. DataSet dsProductionDataByID = sre.Data;
  1920. //DataSet dsProductionDataByID = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  1921. //{
  1922. // return PMModuleProxy.Service.GetProductionDataByID(this._productiondataid);
  1923. //}));
  1924. if (dsProductionDataByID != null && dsProductionDataByID.Tables[0].Rows.Count > Constant.INT_IS_ZERO)
  1925. {
  1926. #region wangx 2016-10-10 校验是否可以成检登记改判
  1927. if (_settingvaluedays > 0)
  1928. {
  1929. cre = new ClientRequestEntity();
  1930. cre.NameSpace = "F_PM_3402";
  1931. cre.Name = "BarcodeAllowCancel";
  1932. cre.Properties["Createtime"] = Convert.ToDateTime(dsProductionDataByID.Tables[0].Rows[0]["createtime"]);
  1933. cre.Properties["Settingvaluedays"] = _settingvaluedays;
  1934. cre.Properties["SettingCode"] = Constant.SettingType.S_PM_009.ToString();
  1935. sre = DoAsync<ServiceResultEntity>(() =>
  1936. {
  1937. return PCModuleProxyNew.Service.HandleRequest(cre);
  1938. });
  1939. ServiceResultEntity resultEntity = sre;
  1940. //ServiceResultEntity resultEntity = (ServiceResultEntity)DoAsync(new BaseAsyncMethod(() =>
  1941. //{
  1942. // return PMModuleProxy.Service.BarcodeAllowCancel(
  1943. // Convert.ToDateTime(dsProductionDataByID.Tables[0].Rows[0]["createtime"]),
  1944. // _settingvaluedays, Constant.SettingType.S_PM_009.ToString());
  1945. //}));
  1946. if (Convert.ToInt32(resultEntity.Result) < 0)
  1947. {
  1948. MessageBox.Show(resultEntity.Message,
  1949. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  1950. this.txtBarCode.Text = "";
  1951. this.btnSave.Visible = false;
  1952. }
  1953. }
  1954. #endregion wangx 2016-10-10 end
  1955. #region 如果是次品,回收后不允许编辑
  1956. if (Convert.ToInt32(dsProductionDataByID.Tables[0].Rows[0]["GoodsLevelTypeID"]) == 7)//次品
  1957. {
  1958. cre = new ClientRequestEntity();
  1959. cre.NameSpace = "F_PM_3402";
  1960. cre.Name = "GetRecyclingflagByBarcode";
  1961. cre.Properties["BarCode"] = dsProductionDataByID.Tables[0].Rows[0]["BarCode"].ToString();
  1962. sre = DoAsync<ServiceResultEntity>(() =>
  1963. {
  1964. return PCModuleProxyNew.Service.HandleRequest(cre);
  1965. });
  1966. int recyclingflag = 0;
  1967. if (sre.Data != null && sre.Data.Tables[0].Rows.Count > 0)
  1968. {
  1969. recyclingflag = Convert.ToInt32(sre.Data.Tables[0].Rows[0]["recyclingflag"]);
  1970. }
  1971. //int recyclingflag = (int)DoAsync(new BaseAsyncMethod(() =>
  1972. //{
  1973. // return PMModuleProxy.Service.GetRecyclingflagByBarcode(dsProductionDataByID.Tables[0].Rows[0]["BarCode"].ToString());
  1974. //}));
  1975. if (recyclingflag > 0)
  1976. {
  1977. MessageBox.Show("条码【" + dsProductionDataByID.Tables[0].Rows[0]["BarCode"].ToString() + "】已经回收,不允许改判", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  1978. this.txtBarCode.Enabled = true;
  1979. this.txtBarCode.Focus();
  1980. return;
  1981. }
  1982. }
  1983. #endregion
  1984. cre = new ClientRequestEntity();
  1985. cre.NameSpace = "F_PM_3402";
  1986. cre.Name = "GetSpecialRepairflagByBarcode";
  1987. cre.Properties["BarCode"] = dsProductionDataByID.Tables[0].Rows[0]["BarCode"].ToString();
  1988. sre = DoAsync<ServiceResultEntity>(() =>
  1989. {
  1990. return PCModuleProxyNew.Service.HandleRequest(cre);
  1991. });
  1992. int SpecialRepairflag = 0;
  1993. if (sre.Data != null && sre.Data.Tables[0].Rows.Count > 0)
  1994. {
  1995. SpecialRepairflag = Convert.ToInt32(sre.Data.Tables[0].Rows[0]["SpecialRepairflag"]);
  1996. }
  1997. //int SpecialRepairflag = (int)DoAsync(new BaseAsyncMethod(() =>
  1998. //{
  1999. // return PMModuleProxy.Service.GetSpecialRepairflagByBarcode(dsProductionDataByID.Tables[0].Rows[0]["BarCode"].ToString());
  2000. //}));
  2001. // 产品数据
  2002. DataRow drNew = TableProductionData.NewRow();
  2003. drNew["ProductionDataID"] = this._productiondataid;
  2004. drNew["BarCode"] = dsProductionDataByID.Tables[0].Rows[0]["BarCode"];
  2005. drNew["GoodsID"] = dsProductionDataByID.Tables[0].Rows[0]["GoodsID"];
  2006. drNew["GoodsCode"] = dsProductionDataByID.Tables[0].Rows[0]["GoodsCode"];
  2007. drNew["GoodsName"] = dsProductionDataByID.Tables[0].Rows[0]["GoodsName"];
  2008. drNew["DefectFlagID"] = dsProductionDataByID.Tables[0].Rows[0]["DefectFlagID"];
  2009. drNew["ReworkProcedureID"] = dsProductionDataByID.Tables[0].Rows[0]["ReworkProcedureID"];
  2010. drNew["Remarks"] = dsProductionDataByID.Tables[0].Rows[0]["Remarks"];
  2011. drNew["UserID"] = dsProductionDataByID.Tables[0].Rows[0]["UserID"];
  2012. drNew["GoodsLevelTypeID"] = dsProductionDataByID.Tables[0].Rows[0]["GoodsLevelTypeID"];
  2013. drNew["UserCode"] = dsProductionDataByID.Tables[0].Rows[0]["UserCode"];
  2014. drNew["UserName"] = dsProductionDataByID.Tables[0].Rows[0]["UserName"];
  2015. UserID = Convert.ToInt32(dsProductionDataByID.Tables[0].Rows[0]["UserID"]);
  2016. UserCode = dsProductionDataByID.Tables[0].Rows[0]["UserCode"].ToString();
  2017. UserName = dsProductionDataByID.Tables[0].Rows[0]["UserName"].ToString();
  2018. drNew["OrgGoodsLevelTypeID"] = dsProductionDataByID.Tables[0].Rows[0]["GoodsLevelTypeID"];
  2019. drNew["ReadOnly"] = this._ReadOnly;
  2020. drNew["KilnCarCode"] = dsProductionDataByID.Tables[0].Rows[0]["KilnCarCode"];
  2021. drNew["KilnCode"] = dsProductionDataByID.Tables[0].Rows[0]["KilnCode"];
  2022. drNew["Dictionaryvalue"] = dsProductionDataByID.Tables[0].Rows[0]["GLAZEName"];
  2023. drNew["UserCode"] = dsProductionDataByID.Tables[0].Rows[0]["UserCode"];
  2024. drNew["MouldCode"] = dsProductionDataByID.Tables[0].Rows[0]["MouldCode"];
  2025. drNew["GroutingUserCode"] = dsProductionDataByID.Tables[0].Rows[0]["GroutingUserCode"];
  2026. drNew["GroutingNum"] = dsProductionDataByID.Tables[0].Rows[0]["GroutingNum"];
  2027. drNew["IsPublicBody"] = dsProductionDataByID.Tables[0].Rows[0]["IsPublicBody"].ToString() != "1" ? 0 : 1;
  2028. drNew["GroutingDate"] = Convert.ToDateTime(dsProductionDataByID.Tables[0].Rows[0]["GroutingDate"]);
  2029. drNew["LogoCodeName"] = dsProductionDataByID.Tables[0].Rows[0]["LogoName"] + "[" + dsProductionDataByID.Tables[0].Rows[0]["LogoCode"] + "]";
  2030. drNew["LogoId"] = dsProductionDataByID.Tables[0].Rows[0]["LogoId"];
  2031. drNew["CheckTime"] = dsProductionDataByID.Tables[0].Rows[0]["CheckTime"];
  2032. cre = new ClientRequestEntity();
  2033. cre.NameSpace = "F_PM_3402";
  2034. cre.Name = "GetCompleteProcedureIDPDA";
  2035. cre.Properties["BarCode"] = dsProductionDataByID.Tables[0].Rows[0]["BarCode"] +"";
  2036. sre = DoAsync<ServiceResultEntity>(() =>
  2037. {
  2038. return PCModuleProxyNew.Service.HandleRequest(cre);
  2039. });
  2040. DataSet dsOPTimeStamp = sre.Data;
  2041. //DataSet dsOPTimeStamp = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  2042. //{
  2043. // return PMModuleProxy.Service.GetCompleteProcedureIDPDA(dsProductionDataByID.Tables[0].Rows[0]["BarCode"].ToString());
  2044. //}));
  2045. if (dsOPTimeStamp != null && dsOPTimeStamp.Tables[0].Rows.Count > 0)
  2046. {
  2047. drNew["OPTimeStamp"] = Convert.ToDateTime(dsOPTimeStamp.Tables[0].Rows[0]["OPTimeStamp"]);
  2048. }
  2049. //drNew["OPTimeStamp"]
  2050. // 校验条码是否重烧过,这个地方必须重新读取,因为防止编辑重烧以前的成检数据,如果直接取表里的就不准了
  2051. cre = new ClientRequestEntity();
  2052. cre.NameSpace = "F_PM_3402";
  2053. cre.Name = "GetReFine";
  2054. cre.Properties["BarCode"] = dsProductionDataByID.Tables[0].Rows[0]["BarCode"] + "";
  2055. sre = DoAsync<ServiceResultEntity>(() =>
  2056. {
  2057. return PCModuleProxyNew.Service.HandleRequest(cre);
  2058. });
  2059. DataSet dsReFine = sre.Data;
  2060. //DataSet dsReFine = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  2061. //{
  2062. // return PMModuleProxy.Service.GetReFine(dsProductionDataByID.Tables[0].Rows[0]["BarCode"].ToString());
  2063. //}));
  2064. if (dsReFine != null && dsReFine.Tables[0].Rows.Count > 0 && dsReFine.Tables[0].Rows[0]["IsReFire"].ToString() == "6")
  2065. {
  2066. drNew["ReFine"] = 1;
  2067. }
  2068. else
  2069. {
  2070. drNew["ReFine"] = 0;
  2071. }
  2072. drNew["SpecialRepairflag"] = SpecialRepairflag.ToString() == "1" ? 1 : 0;
  2073. //原产品类别
  2074. //UserID = Convert.ToInt32(dsProductionDataByID.Tables[0].Rows[0]["UserID"]);
  2075. //UserCode = dsProductionDataByID.Tables[0].Rows[0]["UserCode"].ToString();
  2076. //UserName = dsProductionDataByID.Tables[0].Rows[0]["UserName"].ToString();
  2077. TableProductionData.Rows.Add(drNew);
  2078. this.dgvProductionData.Rows[TableProductionData.Rows.Count - 1].Selected = true;
  2079. this._selectedRowIndex = TableProductionData.Rows.Count - 1;
  2080. this._currentBarCode = dsProductionDataByID.Tables[0].Rows[0]["BarCode"].ToString();
  2081. this._currentGoodsID = Convert.ToInt32(dsProductionDataByID.Tables[0].Rows[0]["GoodsID"]);
  2082. if (dsProductionDataByID.Tables[0].Rows[0]["GoodsLevelTypeID"].ToString() == Constant.INT_IS_SEVEN.ToString())
  2083. {
  2084. //次品设置只读的时候,原来默认不允许修改,目前注释掉
  2085. //SetSubstandard();
  2086. cre = new ClientRequestEntity();
  2087. cre.NameSpace = "F_PM_3402";
  2088. cre.Name = "GetSubstandardInfo";
  2089. cre.Properties["BarCode"] = dsProductionDataByID.Tables[0].Rows[0]["BarCode"] + "";
  2090. sre = DoAsync<ServiceResultEntity>(() =>
  2091. {
  2092. return PCModuleProxyNew.Service.HandleRequest(cre);
  2093. });
  2094. DataSet dsReturn = sre.Data;
  2095. //DataSet dsReturn = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  2096. //{
  2097. // return PMModuleProxy.Service.GetSubstandardInfo(dsProductionDataByID.Tables[0].Rows[0]["BarCode"].ToString());
  2098. //}));
  2099. if (dsReturn != null && dsReturn.Tables[0].Rows.Count == 0) //防止回收站里没有此条码
  2100. {
  2101. // 提示信息
  2102. MessageBox.Show("次品条码:" + dsProductionDataByID.Tables[0].Rows[0]["BarCode"].ToString() + "不允许修改",
  2103. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  2104. return;
  2105. }
  2106. this.tsbtnAdd.Enabled = true;
  2107. }
  2108. else
  2109. {
  2110. this.tsbtnAdd.Enabled = true;
  2111. if (dsProductionDataByID != null && dsProductionDataByID.Tables[1].Rows.Count > Constant.INT_IS_ZERO)
  2112. {
  2113. this.tsbtnEdit.Enabled = true;
  2114. }
  2115. }
  2116. }
  2117. if (dsProductionDataByID != null && dsProductionDataByID.Tables[0].Rows.Count > 0 &&
  2118. DSTable.Tables.IndexOf(dsProductionDataByID.Tables[0].Rows[0]["BarCode"].ToString()) == -Constant.INT_IS_ONE)
  2119. {
  2120. DataTable dtProductionDefectData = new DataTable(dsProductionDataByID.Tables[0].Rows[0]["BarCode"].ToString());
  2121. dtProductionDefectData.Columns.Add("BarCode");
  2122. dtProductionDefectData.Columns.Add("DefectID", typeof(decimal));
  2123. dtProductionDefectData.Columns.Add("DefectName");
  2124. dtProductionDefectData.Columns.Add("DefectCode");
  2125. dtProductionDefectData.Columns.Add("DefectPositionID", typeof(decimal));
  2126. dtProductionDefectData.Columns.Add("DefectPositionName");
  2127. dtProductionDefectData.Columns.Add("DefectPositionCode");
  2128. dtProductionDefectData.Columns.Add("DefectProcedureID", typeof(decimal));
  2129. dtProductionDefectData.Columns.Add("DefectProcedureName");
  2130. dtProductionDefectData.Columns.Add("DefectProcedureCode");
  2131. dtProductionDefectData.Columns.Add("DefectUserID", typeof(decimal));//责任员工
  2132. dtProductionDefectData.Columns.Add("DefectUserName");//责任员工
  2133. dtProductionDefectData.Columns.Add("DefectUserCode");//
  2134. dtProductionDefectData.Columns.Add("Jobs", typeof(decimal));//工种
  2135. dtProductionDefectData.Columns.Add("JobsText");//工种
  2136. dtProductionDefectData.Columns.Add("DefectRemarks");
  2137. dtProductionDefectData.Columns.Add("TempCount");
  2138. dtProductionDefectData.Columns.Add("ProductionDataID"); //生产数据ID
  2139. dtProductionDefectData.Columns.Add("DefectFineID"); //缺陷扣罚ID
  2140. dtProductionDefectData.Columns.Add("DefectFineValue"); //缺陷扣罚
  2141. dtProductionDefectData.Columns.Add("MissedUserID"); //漏检工号ID
  2142. dtProductionDefectData.Columns.Add("MissedUserCode"); //漏检工号编码
  2143. dtProductionDefectData.Columns.Add("MissedUserName"); //漏检工号名称
  2144. dtProductionDefectData.Columns.Add("IsAllowEdit"); //是否允许编辑 0 不允许,1允许
  2145. //新添加的 wangx 2016/1/6
  2146. dtProductionDefectData.Columns.Add("DefectDeductionID"); //缺陷扣除数ID
  2147. dtProductionDefectData.Columns.Add("DefectDeductionNum"); //缺陷扣除数
  2148. dtProductionDefectData.Columns.Add("IsOtherDefect"); //特殊缺陷
  2149. dtProductionDefectData.Columns.Add("CheckTime"); //缺陷检验时间
  2150. //新添加的 wangx 2016/1/6 end
  2151. DSTable.Tables.Add(dtProductionDefectData);
  2152. }
  2153. if (dsProductionDataByID != null && dsProductionDataByID.Tables[1].Rows.Count > Constant.INT_IS_ZERO)
  2154. {
  2155. // 产品缺陷
  2156. if (DSTable.Tables.IndexOf(dsProductionDataByID.Tables[0].Rows[0]["BarCode"].ToString()) == -Constant.INT_IS_ONE)
  2157. {
  2158. DataTable dtProductionDefectData = new DataTable(dsProductionDataByID.Tables[0].Rows[0]["BarCode"].ToString());
  2159. dtProductionDefectData.Columns.Add("BarCode");
  2160. dtProductionDefectData.Columns.Add("DefectID", typeof(decimal));
  2161. dtProductionDefectData.Columns.Add("DefectName");
  2162. dtProductionDefectData.Columns.Add("DefectCode");
  2163. dtProductionDefectData.Columns.Add("DefectPositionID", typeof(decimal));
  2164. dtProductionDefectData.Columns.Add("DefectPositionName");
  2165. dtProductionDefectData.Columns.Add("DefectPositionCode");
  2166. dtProductionDefectData.Columns.Add("DefectProcedureID", typeof(decimal));
  2167. dtProductionDefectData.Columns.Add("DefectProcedureName");
  2168. dtProductionDefectData.Columns.Add("DefectProcedureCode");
  2169. dtProductionDefectData.Columns.Add("DefectUserID", typeof(decimal));//责任员工
  2170. dtProductionDefectData.Columns.Add("DefectUserName");//责任员工
  2171. dtProductionDefectData.Columns.Add("DefectUserCode");//
  2172. dtProductionDefectData.Columns.Add("Jobs", typeof(decimal));//工种
  2173. dtProductionDefectData.Columns.Add("JobsText");//工种
  2174. dtProductionDefectData.Columns.Add("DefectRemarks");
  2175. dtProductionDefectData.Columns.Add("TempCount");
  2176. dtProductionDefectData.Columns.Add("ProductionDataID"); //生产数据ID
  2177. dtProductionDefectData.Columns.Add("DefectFineID"); //缺席扣罚ID
  2178. dtProductionDefectData.Columns.Add("DefectFineValue"); //缺席扣罚
  2179. dtProductionDefectData.Columns.Add("MissedUserID"); //漏检工号ID
  2180. dtProductionDefectData.Columns.Add("MissedUserCode"); //漏检工号编码
  2181. dtProductionDefectData.Columns.Add("MissedUserName"); //漏检工号名称
  2182. dtProductionDefectData.Columns.Add("IsAllowEdit"); //是否允许编辑 0 不允许,1允许
  2183. //新添加的 wangx 2016/1/6
  2184. dtProductionDefectData.Columns.Add("DefectDeductionID"); //缺陷扣除数ID
  2185. dtProductionDefectData.Columns.Add("DefectDeductionNum"); //缺陷扣除数
  2186. dtProductionDefectData.Columns.Add("IsOtherDefect"); //特殊缺陷
  2187. dtProductionDefectData.Columns.Add("CheckTime"); //缺陷检验时间
  2188. //新添加的 wangx 2016/1/6 end
  2189. DSTable.Tables.Add(dtProductionDefectData);
  2190. }
  2191. this.dgvProductionData.Rows[TableProductionData.Rows.Count - 1].Selected = true;
  2192. this._selectedRowIndex = TableProductionData.Rows.Count - 1;
  2193. this._currentDefectFlag = Convert.ToInt32(this.dgvProductionData.Rows[_selectedRowIndex].Cells["GoodsLevelTypeID"].Value.ToString());
  2194. this._currentGoodsID = Convert.ToInt32(this.dgvProductionData.Rows[_selectedRowIndex].Cells["GoodsID"].Value);
  2195. this._currentBarCode = this.dgvProductionData.Rows[_selectedRowIndex].Cells["BarCode"].Value.ToString();
  2196. //-----------------------
  2197. //DataSet ds = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  2198. //{
  2199. // return PMModuleProxy.Service.GetReworkProcedureByProcedureID(this._procedureID);
  2200. //}));
  2201. //ds.Tables[0].TableName = dsProductionDataByID.Tables[0].Rows[0]["BarCode"].ToString();
  2202. //if (this.DSREWORK == null)
  2203. //{
  2204. // this.DSREWORK = new DataSet();
  2205. //}
  2206. //this.DSREWORK.Tables.Add(ds.Tables[0].Copy());
  2207. //C_DGV_Cell_ListBoxComboBox C_DGV_Cell_ListBoxComboBox = dgvProductionData.Rows[_selectedRowIndex].Cells[4] as C_DGV_Cell_ListBoxComboBox;
  2208. //C_DGV_Cell_ListBoxComboBox.DataSource = ds.Tables[0];
  2209. //C_DGV_Cell_ListBoxComboBox.DisplayMember = "ReworkProcedureName";
  2210. //C_DGV_Cell_ListBoxComboBox.ValueMember = "ReworkProcedureID";
  2211. for (int i = 0; i < dsProductionDataByID.Tables[1].Rows.Count; i++)
  2212. {
  2213. DataRow dr = DSTable.Tables[dsProductionDataByID.Tables[0].Rows[0]["BarCode"].ToString()].NewRow();
  2214. dr["BarCode"] = dsProductionDataByID.Tables[1].Rows[i]["BarCode"];
  2215. dr["DefectID"] = dsProductionDataByID.Tables[1].Rows[i]["DefectID"];
  2216. dr["DefectName"] = dsProductionDataByID.Tables[1].Rows[i]["DefectName"];
  2217. dr["DefectCode"] = dsProductionDataByID.Tables[1].Rows[i]["DefectCode"];
  2218. dr["DefectPositionID"] = dsProductionDataByID.Tables[1].Rows[i]["DefectPositionID"];
  2219. dr["DefectPositionName"] = dsProductionDataByID.Tables[1].Rows[i]["DefectPositionName"];
  2220. dr["DefectPositionCode"] = dsProductionDataByID.Tables[1].Rows[i]["DefectPositionCode"];
  2221. dr["DefectProcedureID"] = dsProductionDataByID.Tables[1].Rows[i]["DefectProcedureID"];
  2222. dr["DefectProcedureName"] = dsProductionDataByID.Tables[1].Rows[i]["DefectProcedureName"];
  2223. dr["DefectProcedureCode"] = dsProductionDataByID.Tables[1].Rows[i]["DefectProcedureCode"];
  2224. dr["DefectUserID"] = dsProductionDataByID.Tables[1].Rows[i]["DefectUserID"];
  2225. dr["DefectUserName"] = dsProductionDataByID.Tables[1].Rows[i]["DefectUserName"];
  2226. dr["DefectUserCode"] = dsProductionDataByID.Tables[1].Rows[i]["DefectUserCode"];
  2227. dr["Jobs"] = dsProductionDataByID.Tables[1].Rows[i]["Jobs"];
  2228. dr["JobsText"] = dsProductionDataByID.Tables[1].Rows[i]["JobsText"];
  2229. dr["DefectRemarks"] = dsProductionDataByID.Tables[1].Rows[i]["DefectRemarks"];
  2230. dr["TempCount"] = this._tempCount;
  2231. dr["ProductionDataID"] = dsProductionDataByID.Tables[1].Rows[i]["DefectProductionDataID"];// dsProductionDataByID.Tables[1].Rows[i]["ProductionDataID"];
  2232. dr["DefectFineID"] = dsProductionDataByID.Tables[1].Rows[i]["DefectFineID"];
  2233. dr["DefectFineValue"] = dsProductionDataByID.Tables[1].Rows[i]["DefectFineValue"];
  2234. dr["MissedUserID"] = dsProductionDataByID.Tables[1].Rows[i]["MissedUserID"];
  2235. dr["MissedUserCode"] = dsProductionDataByID.Tables[1].Rows[i]["MissedUserCode"];
  2236. dr["MissedUserName"] = dsProductionDataByID.Tables[1].Rows[i]["MissedUserName"];
  2237. dr["IsAllowEdit"] = this._AllowEdit;
  2238. //dr["DefectDeductionID"] = dsProductionDataByID.Tables[1].Rows[i]["DefectDeductionID"];
  2239. dr["DefectDeductionNum"] = dsProductionDataByID.Tables[1].Rows[i]["DefectDeductionNum"];
  2240. dr["IsOtherDefect"] = dsProductionDataByID.Tables[1].Rows[i]["SpecialDefect"];
  2241. dr["CheckTime"] = dsProductionDataByID.Tables[1].Rows[i]["CheckTime"];
  2242. DSTable.Tables[dsProductionDataByID.Tables[0].Rows[0]["BarCode"].ToString()].Rows.Add(dr);
  2243. // 防止工种不选择的话,直接New一个
  2244. if (!this.DSTableStaff.Tables.Contains(string.Format("TempTable{0}", this._tempCount)))
  2245. {
  2246. DataTable dtStaff = new DataTable(string.Format("TempTable{0}", this._tempCount));
  2247. dtStaff.Columns.Add("IsSelected");
  2248. dtStaff.Columns.Add("StaffID");
  2249. dtStaff.Columns.Add("StaffCode");
  2250. dtStaff.Columns.Add("StaffName");
  2251. dtStaff.Columns.Add("StaffTempCount");
  2252. dtStaff.Columns.Add("StaffStatus");
  2253. this.DSTableStaff.Tables.Add(dtStaff);
  2254. }
  2255. // 责任员工
  2256. DataRow[] drRow = dsProductionDataByID.Tables[2].Select("ProductionDefectID=" + dsProductionDataByID.Tables[1].Rows[i]["ProductionDefectID"]);
  2257. if (drRow.Length > Constant.INT_IS_ZERO)
  2258. {
  2259. foreach (DataRow r in drRow)
  2260. {
  2261. DataRow drStaff = this.DSTableStaff.Tables[string.Format("TempTable{0}", this._tempCount)].NewRow();
  2262. drStaff["IsSelected"] = 1;
  2263. drStaff["StaffID"] = r["StaffID"];
  2264. drStaff["StaffCode"] = r["StaffCode"];
  2265. drStaff["StaffName"] = r["StaffName"];
  2266. drStaff["StaffTempCount"] = this._tempCount;
  2267. drStaff["StaffStatus"] = r["StaffStatus"];
  2268. this.DSTableStaff.Tables[string.Format("TempTable{0}", this._tempCount)].Rows.Add(drStaff);
  2269. }
  2270. }
  2271. // 漏检员工临时表
  2272. if (!this.DSTableMissedStaff.Tables.Contains(string.Format("TempTable{0}", this._tempCount)))
  2273. {
  2274. DataTable dtMissedStaff = new DataTable(string.Format("TempTable{0}", this._tempCount));
  2275. dtMissedStaff.Columns.Add("IsSelected");
  2276. dtMissedStaff.Columns.Add("StaffID");
  2277. dtMissedStaff.Columns.Add("StaffCode");
  2278. dtMissedStaff.Columns.Add("StaffName");
  2279. dtMissedStaff.Columns.Add("StaffTempCount");
  2280. dtMissedStaff.Columns.Add("StaffStatus");
  2281. dtMissedStaff.Columns.Add("UJobsID");
  2282. dtMissedStaff.Columns.Add("SJobsID");
  2283. this.DSTableMissedStaff.Tables.Add(dtMissedStaff);
  2284. }
  2285. //漏检员工临时表数据
  2286. DataRow[] drMissedRow = dsProductionDataByID.Tables[4].Select("ProductionDefectID=" + dsProductionDataByID.Tables[1].Rows[i]["ProductionDefectID"]);
  2287. if (drMissedRow.Length > Constant.INT_IS_ZERO)
  2288. {
  2289. foreach (DataRow r in drMissedRow)
  2290. {
  2291. DataRow drMissedStaff = this.DSTableMissedStaff.Tables[string.Format("TempTable{0}", this._tempCount)].NewRow();
  2292. drMissedStaff["IsSelected"] = 1;
  2293. drMissedStaff["StaffID"] = r["StaffID"];
  2294. drMissedStaff["StaffCode"] = r["StaffCode"];
  2295. drMissedStaff["StaffName"] = r["StaffName"];
  2296. drMissedStaff["StaffTempCount"] = this._tempCount;
  2297. drMissedStaff["StaffStatus"] = r["StaffStatus"];
  2298. drMissedStaff["UJobsID"] = r["UJobsID"];
  2299. drMissedStaff["SJobsID"] = r["SJobsID"];
  2300. this.DSTableMissedStaff.Tables[string.Format("TempTable{0}", this._tempCount)].Rows.Add(drMissedStaff);
  2301. }
  2302. }
  2303. if (!this.DSTableImage.Tables.Contains(string.Format("TempTable{0}", this._tempCount.ToString())))
  2304. {
  2305. DataTable dtImage = new DataTable(string.Format("TempTable{0}", this._tempCount.ToString()));
  2306. dtImage.Columns.Add("StaffTempCount");
  2307. dtImage.Columns.Add("ImageByte", typeof(byte[]));
  2308. dtImage.Columns.Add("OrgImageByte", typeof(byte[]));
  2309. this.DSTableImage.Tables.Add(dtImage);
  2310. }
  2311. this._currentTempSign = i.ToString();
  2312. // 缺陷图片
  2313. DataRow[] drImageRow = dsProductionDataByID.Tables[3].Select("ProductionDefectID=" + dsProductionDataByID.Tables[1].Rows[i]["ProductionDefectID"]);
  2314. if (drImageRow.Length > Constant.INT_IS_ZERO)
  2315. {
  2316. foreach (DataRow r in drImageRow)
  2317. {
  2318. if (r["SourcePathByte"] != DBNull.Value)
  2319. {
  2320. byte[] orgImageByte = (byte[])r["SourcePathByte"];
  2321. this._PicByte.Add(orgImageByte);
  2322. //this._smallByte.Add(orgImageByte);
  2323. if (!this.DSTableImage.Tables.Contains(string.Format("TempTable{0}", this._currentTempSign.ToString())))
  2324. {
  2325. DataTable dtImage = new DataTable(string.Format("TempTable{0}", this._currentTempSign.ToString()));
  2326. dtImage.Columns.Add("StaffTempCount");
  2327. dtImage.Columns.Add("ImageByte", typeof(byte[]));
  2328. dtImage.Columns.Add("OrgImageByte", typeof(byte[]));
  2329. this.DSTableImage.Tables.Add(dtImage);
  2330. }
  2331. DataRow drrow = DSTableImage.Tables[string.Format("TempTable{0}", this._currentTempSign)].NewRow();
  2332. drrow["StaffTempCount"] = this._currentTempSign;
  2333. drrow["ImageByte"] = orgImageByte;
  2334. drrow["OrgImageByte"] = orgImageByte;
  2335. DSTableImage.Tables[string.Format("TempTable{0}", this._currentTempSign)].Rows.Add(drrow);
  2336. BindImg();
  2337. }
  2338. }
  2339. }
  2340. this._tempCount = this._tempCount + 1;
  2341. }
  2342. this.dgvDefect.DataSource = DSTable.Tables[dsProductionDataByID.Tables[0].Rows[0]["BarCode"].ToString()];//根据条码产生不同数据源
  2343. //控制产品等级,只有编辑权限的人才能随便改
  2344. if (this._AllowEdit == 0) //
  2345. {
  2346. for (int i = 0; i < this.dgvProductionData.Rows.Count; i++)
  2347. {
  2348. int goodsLevelTypeID = Convert.ToInt32(this.TableProductionData.Rows[i]["GoodsLevelTypeID"]);
  2349. if (this._dsGoodsLevel != null)
  2350. {
  2351. DataTable dt = this._dsGoodsLevel.Tables[0].Copy();
  2352. DataView dv = dt.DefaultView;
  2353. dv.RowFilter = "GoodsLevelTypeID>=" + goodsLevelTypeID;
  2354. DataGridViewComboBoxCell dgcbc = (DataGridViewComboBoxCell)dgvProductionData.Rows[i].Cells[3];
  2355. dgcbc.DisplayMember = "DefectFlagName";
  2356. dgcbc.ValueMember = "DefectFlagID";
  2357. dgcbc.DataSource = dv.ToTable();
  2358. }
  2359. }
  2360. }
  2361. }
  2362. if (!this.btnSave.Visible)
  2363. {
  2364. this.tsbtnAdd.Enabled = false;
  2365. this.tsbtnEdit.Enabled = false;
  2366. }
  2367. }
  2368. catch (Exception ex)
  2369. {
  2370. throw ex;
  2371. }
  2372. }
  2373. /// <summary>
  2374. /// 绑定到第一个DataGriwView数据源
  2375. /// </summary>
  2376. private void BindProductionDataReFine(DataSet dsCheckBarcode)
  2377. {
  2378. try
  2379. {
  2380. DataRow[] dr = TableProductionData.Select("BarCode='" + this.txtBarCode.Text.Trim() + "'");
  2381. if (dr.Length > Constant.INT_IS_ZERO)
  2382. {
  2383. // 不允许重复添加
  2384. return;
  2385. }
  2386. ClientRequestEntity cre = new ClientRequestEntity();
  2387. cre.NameSpace = "F_PM_3402";
  2388. cre.Name = "GetSpecialRepairflagByBarcode";
  2389. cre.Properties["BarCode"] = this.txtBarCode.Text.Trim();
  2390. ServiceResultEntity sre = DoAsync<ServiceResultEntity>(() =>
  2391. {
  2392. return PCModuleProxyNew.Service.HandleRequest(cre);
  2393. });
  2394. int SpecialRepairflag = 0;
  2395. if (sre.Data != null && sre.Data.Tables[0].Rows.Count > 0)
  2396. {
  2397. SpecialRepairflag = Convert.ToInt32(sre.Data.Tables[0].Rows[0]["SpecialRepairflag"]);
  2398. }
  2399. //int SpecialRepairflag = (int)DoAsync(new BaseAsyncMethod(() =>
  2400. //{
  2401. // return PMModuleProxy.Service.GetSpecialRepairflagByBarcode(this.txtBarCode.Text.Trim());
  2402. //}));
  2403. string KilnCarCode = string.Empty;
  2404. string KilnCode = string.Empty;
  2405. string Dictionaryvalue = string.Empty;
  2406. cre = new ClientRequestEntity();
  2407. cre.NameSpace = "F_PM_3402";
  2408. cre.Name = "GetKilnCarByBarCode";
  2409. cre.Properties["BarCode"] = this.txtBarCode.Text.Trim();
  2410. sre = DoAsync<ServiceResultEntity>(() =>
  2411. {
  2412. return PCModuleProxyNew.Service.HandleRequest(cre);
  2413. });
  2414. DataSet dsKilnCar = sre.Data;
  2415. //DataSet dsKilnCar = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  2416. //{
  2417. // return PMModuleProxy.Service.GetKilnCarByBarCode(txtBarCode.Text.Trim());
  2418. //}));
  2419. if (dsKilnCar != null && dsKilnCar.Tables[0].Rows.Count > Constant.INT_IS_ZERO)
  2420. {
  2421. KilnCarCode = dsKilnCar.Tables[0].Rows[0]["KilnCarCode"].ToString();
  2422. KilnCode = dsKilnCar.Tables[0].Rows[0]["KilnCode"].ToString();
  2423. Dictionaryvalue = dsKilnCar.Tables[0].Rows[0]["Dictionaryvalue"].ToString();
  2424. }
  2425. DataRow drNew = TableProductionData.NewRow();
  2426. drNew["BarCode"] = this.txtBarCode.Text.Trim();
  2427. drNew["ProductionDataID"] = this._productiondataid;
  2428. drNew["GoodsID"] = dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_goodsID.ToString()];
  2429. drNew["GoodsCode"] = dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_goodsCode.ToString()];
  2430. drNew["GoodsName"] = dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_goodsName.ToString()];
  2431. drNew["DefectFlagID"] = _dsGoodsLevel.Tables[0].Rows[0]["DefectFlagID"];
  2432. drNew["ReworkProcedureID"] = DBNull.Value;
  2433. drNew["Remarks"] = "";
  2434. drNew["UserID"] = UserID;
  2435. drNew["UserCode"] = UserCode;
  2436. drNew["UserName"] = UserName;
  2437. drNew["GoodsLevelTypeID"] = _dsGoodsLevel.Tables[0].Rows[0]["GoodsLevelTypeID"];
  2438. drNew["OrgGoodsLevelTypeID"] = -1;
  2439. drNew["SpecialRepairflag"] = SpecialRepairflag == 1 ? 1 : 0;
  2440. drNew["KilnCarCode"] = KilnCarCode;
  2441. drNew["KilnCode"] = KilnCode;
  2442. drNew["Dictionaryvalue"] = Dictionaryvalue;
  2443. // 校验条码是否重烧过
  2444. cre = new ClientRequestEntity();
  2445. cre.NameSpace = "F_PM_3402";
  2446. cre.Name = "GetReFine";
  2447. cre.Properties["BarCode"] = this.txtBarCode.Text.Trim();
  2448. sre = DoAsync<ServiceResultEntity>(() =>
  2449. {
  2450. return PCModuleProxyNew.Service.HandleRequest(cre);
  2451. });
  2452. DataSet dsReFine = sre.Data;
  2453. //DataSet dsReFine = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  2454. //{
  2455. // return PMModuleProxy.Service.GetReFine(this.txtBarCode.Text.Trim());
  2456. //}));
  2457. if (dsReFine != null && dsReFine.Tables[0].Rows.Count > 0 && dsReFine.Tables[0].Rows[0]["IsReFire"].ToString() == "6")
  2458. {
  2459. drNew["ReFine"] = 1;
  2460. }
  2461. else
  2462. {
  2463. drNew["ReFine"] = 0;
  2464. }
  2465. if (dsReFine != null && dsReFine.Tables[0].Rows.Count > 0 && dsReFine.Tables[0].Rows[0]["IsLengBu"].ToString() == "1")
  2466. {
  2467. drNew["LengBu"] = 1;
  2468. }
  2469. else
  2470. {
  2471. drNew["LengBu"] = 0;
  2472. }
  2473. drNew["UserCode"] = this.txtUserCode.Text.Trim();
  2474. // 由产品条码获取注浆信息
  2475. cre = new ClientRequestEntity();
  2476. cre.NameSpace = "F_PM_3402";
  2477. cre.Name = "GetGroutingProducttByBarCode";
  2478. cre.Properties["BarCode"] = this.txtBarCode.Text.Trim();
  2479. sre = DoAsync<ServiceResultEntity>(() =>
  2480. {
  2481. return PCModuleProxyNew.Service.HandleRequest(cre);
  2482. });
  2483. DataSet dsGroutingProduct = sre.Data;
  2484. //DataSet dsGroutingProduct = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  2485. //{
  2486. // return PMModuleProxy.Service.GetGroutingProducttByBarCode(txtBarCode.Text.Trim());
  2487. //}));
  2488. drNew["MouldCode"] = dsGroutingProduct.Tables[0].Rows[0]["MouldCode"];
  2489. drNew["GroutingUserCode"] = dsGroutingProduct.Tables[0].Rows[0]["GroutingUserCode"];
  2490. drNew["GroutingNum"] = dsGroutingProduct.Tables[0].Rows[0]["GroutingNum"];
  2491. drNew["IsPublicBody"] = dsGroutingProduct.Tables[0].Rows[0]["IsPublicBody"].ToString() != "1" ? 0 : 1;
  2492. drNew["GroutingDate"] = Convert.ToDateTime(dsGroutingProduct.Tables[0].Rows[0]["GroutingDate"]);
  2493. drNew["LogoCodeName"] = dsGroutingProduct.Tables[0].Rows[0]["LogoName"] + "[" + dsGroutingProduct.Tables[0].Rows[0]["LogoCode"] + "]";
  2494. drNew["LogoID"] = dsGroutingProduct.Tables[0].Rows[0]["LogoID"];
  2495. TableProductionData.Rows.Add(drNew);
  2496. if (DSTable.Tables.IndexOf(this.txtBarCode.Text.Trim()) == -Constant.INT_IS_ONE)
  2497. {
  2498. DataTable dtProductionDefectData = new DataTable(this.txtBarCode.Text.Trim());
  2499. dtProductionDefectData.Columns.Add("BarCode");
  2500. dtProductionDefectData.Columns.Add("DefectID", typeof(decimal));
  2501. dtProductionDefectData.Columns.Add("DefectName");
  2502. dtProductionDefectData.Columns.Add("DefectCode");
  2503. dtProductionDefectData.Columns.Add("DefectPositionID", typeof(decimal));
  2504. dtProductionDefectData.Columns.Add("DefectPositionName");
  2505. dtProductionDefectData.Columns.Add("DefectPositionCode");
  2506. dtProductionDefectData.Columns.Add("DefectProcedureID", typeof(decimal));
  2507. dtProductionDefectData.Columns.Add("DefectProcedureName");
  2508. dtProductionDefectData.Columns.Add("DefectProcedureCode");
  2509. dtProductionDefectData.Columns.Add("DefectUserID", typeof(decimal));//责任员工
  2510. dtProductionDefectData.Columns.Add("DefectUserName");//责任员工
  2511. dtProductionDefectData.Columns.Add("DefectUserCode");//
  2512. dtProductionDefectData.Columns.Add("Jobs", typeof(decimal));//工种
  2513. dtProductionDefectData.Columns.Add("JobsText");//工种
  2514. dtProductionDefectData.Columns.Add("DefectRemarks");
  2515. dtProductionDefectData.Columns.Add("TempCount");
  2516. dtProductionDefectData.Columns.Add("ProductionDataID"); //生产数据ID
  2517. dtProductionDefectData.Columns.Add("DefectFineID"); //缺席扣罚ID
  2518. dtProductionDefectData.Columns.Add("DefectFineValue"); //缺席扣罚
  2519. dtProductionDefectData.Columns.Add("MissedUserID"); //漏检工号ID
  2520. dtProductionDefectData.Columns.Add("MissedUserCode"); //漏检工号编码
  2521. dtProductionDefectData.Columns.Add("MissedUserName"); //漏检工号名称
  2522. dtProductionDefectData.Columns.Add("IsAllowEdit"); //漏检工号名称
  2523. //新添加的 wangx 2016/1/6
  2524. dtProductionDefectData.Columns.Add("DefectDeductionID"); //缺陷扣除数ID
  2525. dtProductionDefectData.Columns.Add("DefectDeductionNum"); //缺陷扣除数
  2526. dtProductionDefectData.Columns.Add("IsOtherDefect"); //特殊缺陷
  2527. dtProductionDefectData.Columns.Add("CheckTime"); //缺陷检验时间
  2528. DSTable.Tables.Add(dtProductionDefectData);
  2529. }
  2530. this.dgvDefect.DataSource = DSTable.Tables[this.txtBarCode.Text.Trim()];//根据条码产生不同数据源
  2531. this.dgvProductionData.Rows[TableProductionData.Rows.Count - 1].Selected = true;
  2532. this.dgvDefect.DataSource = null;
  2533. this.dgvDefectStaff.DataSource = null;
  2534. this.lvPic.Clear();
  2535. // 添加一个产品条码时除了第一个显示在数据表中,其它的全部清空
  2536. this.tsbtnAdd.Enabled = true;//添加完条码后,可以新建其它信息
  2537. // 添加一个产品条码时除了第一个显示在数据表中,其它的全部清空
  2538. this.tsbtnAdd.Enabled = true;//添加完条码后,可以新建其它信息
  2539. // 添加一个产品条码时除了第一个显示在数据表中,其它的全部清空
  2540. this.tsbtnAdd.Enabled = true;//添加完条码后,可以新建其它信息
  2541. this._selectedRowIndex = TableProductionData.Rows.Count - 1;
  2542. //DataSet ds = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  2543. //{
  2544. // return PMModuleProxy.Service.GetReworkProcedureByProcedureID(this._procedureID);
  2545. //}));
  2546. //ds.Tables[0].TableName = this.txtBarCode.Text.Trim();
  2547. //if (this.DSREWORK == null)
  2548. //{
  2549. // this.DSREWORK = new DataSet();
  2550. //}
  2551. //this.DSREWORK.Tables.Add(ds.Tables[0].Copy());
  2552. //// 返工工序数据源
  2553. //C_DGV_Cell_ListBoxComboBox C_DGV_Cell_ListBoxComboBox = dgvProductionData.Rows[_selectedRowIndex].Cells[4] as C_DGV_Cell_ListBoxComboBox;
  2554. //C_DGV_Cell_ListBoxComboBox.DataSource = ds.Tables[0];
  2555. //C_DGV_Cell_ListBoxComboBox.DisplayMember = "ReworkProcedureName";
  2556. //C_DGV_Cell_ListBoxComboBox.ValueMember = "ReworkProcedureID";
  2557. }
  2558. catch (Exception ex)
  2559. {
  2560. throw ex;
  2561. }
  2562. }
  2563. /// <summary>
  2564. /// 绑定到第一个DataGriwView数据源
  2565. /// </summary>
  2566. private void BindProductionDataEdit(DataSet dsCheckBarcode)
  2567. {
  2568. try
  2569. {
  2570. DataRow[] dr = TableProductionData.Select("BarCode='" + this.txtBarCode.Text.Trim() + "'");
  2571. if (dr.Length > Constant.INT_IS_ZERO)
  2572. {
  2573. // 不允许重复添加
  2574. return;
  2575. }
  2576. ClientRequestEntity cre = new ClientRequestEntity();
  2577. cre.NameSpace = "F_PM_3402";
  2578. cre.Name = "GetSpecialRepairflagByBarcode";
  2579. cre.Properties["BarCode"] = this.txtBarCode.Text.Trim();
  2580. ServiceResultEntity sre = DoAsync<ServiceResultEntity>(() =>
  2581. {
  2582. return PCModuleProxyNew.Service.HandleRequest(cre);
  2583. });
  2584. int SpecialRepairflag = 0;
  2585. if (sre.Data != null && sre.Data.Tables[0].Rows.Count > 0)
  2586. {
  2587. SpecialRepairflag = Convert.ToInt32(sre.Data.Tables[0].Rows[0]["SpecialRepairflag"]);
  2588. }
  2589. //int SpecialRepairflag = (int)DoAsync(new BaseAsyncMethod(() =>
  2590. //{
  2591. // return PMModuleProxy.Service.GetSpecialRepairflagByBarcode(this.txtBarCode.Text.Trim());
  2592. //}));
  2593. string KilnCarCode = string.Empty;
  2594. string KilnCode = string.Empty;
  2595. string Dictionaryvalue = string.Empty;
  2596. cre = new ClientRequestEntity();
  2597. cre.NameSpace = "F_PM_3402";
  2598. cre.Name = "GetKilnCarByBarCode";
  2599. cre.Properties["BarCode"] = this.txtBarCode.Text.Trim();
  2600. sre = DoAsync<ServiceResultEntity>(() =>
  2601. {
  2602. return PCModuleProxyNew.Service.HandleRequest(cre);
  2603. });
  2604. DataSet dsKilnCar = sre.Data;
  2605. //DataSet dsKilnCar = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  2606. //{
  2607. // return PMModuleProxy.Service.GetKilnCarByBarCode(txtBarCode.Text.Trim());
  2608. //}));
  2609. if (dsKilnCar != null && dsKilnCar.Tables[0].Rows.Count > Constant.INT_IS_ZERO)
  2610. {
  2611. KilnCarCode = dsKilnCar.Tables[0].Rows[0]["KilnCarCode"].ToString();
  2612. KilnCode = dsKilnCar.Tables[0].Rows[0]["KilnCode"].ToString();
  2613. Dictionaryvalue = dsKilnCar.Tables[0].Rows[0]["Dictionaryvalue"].ToString();
  2614. }
  2615. DataRow drNew = TableProductionData.NewRow();
  2616. drNew["ProductionDataID"] = this._productiondataid;
  2617. drNew["BarCode"] = this.txtBarCode.Text.Trim();
  2618. cre = new ClientRequestEntity();
  2619. cre.NameSpace = "F_PM_3402";
  2620. cre.Name = "GetGoodsInfoBybarcode";
  2621. cre.Properties["BarCode"] = this.txtBarCode.Text.Trim();
  2622. sre = DoAsync<ServiceResultEntity>(() =>
  2623. {
  2624. return PCModuleProxyNew.Service.HandleRequest(cre);
  2625. });
  2626. DataSet ds = sre.Data;
  2627. //DataSet ds = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  2628. //{
  2629. // return PMModuleProxy.Service.GetGoodsInfoBybarcode(this.txtBarCode.Text.Trim());
  2630. //}));
  2631. if (ds != null && ds.Tables[0].Rows.Count > 0)
  2632. {
  2633. drNew["GoodsID"] = ds.Tables[0].Rows[0]["GoodsID"];
  2634. drNew["GoodsCode"] = ds.Tables[0].Rows[0]["GoodsCode"];
  2635. drNew["GoodsName"] = ds.Tables[0].Rows[0]["GoodsName"];
  2636. }
  2637. drNew["DefectFlagID"] = _dsGoodsLevel.Tables[0].Rows[0]["DefectFlagID"];
  2638. drNew["ReworkProcedureID"] = DBNull.Value;
  2639. drNew["Remarks"] = "";
  2640. drNew["UserID"] = UserID;
  2641. drNew["UserCode"] = UserCode;
  2642. drNew["UserName"] = UserName;
  2643. drNew["GoodsLevelTypeID"] = _dsGoodsLevel.Tables[0].Rows[0]["GoodsLevelTypeID"];
  2644. drNew["OrgGoodsLevelTypeID"] = -1;
  2645. drNew["SpecialRepairflag"] = SpecialRepairflag == 1 ? 1 : 0;
  2646. drNew["KilnCarCode"] = KilnCarCode;
  2647. drNew["KilnCode"] = KilnCode;
  2648. drNew["Dictionaryvalue"] = Dictionaryvalue;
  2649. // 校验条码是否重烧过
  2650. cre = new ClientRequestEntity();
  2651. cre.NameSpace = "F_PM_3402";
  2652. cre.Name = "GetReFine";
  2653. cre.Properties["BarCode"] = this.txtBarCode.Text.Trim();
  2654. sre = DoAsync<ServiceResultEntity>(() =>
  2655. {
  2656. return PCModuleProxyNew.Service.HandleRequest(cre);
  2657. });
  2658. DataSet dsReFine = sre.Data;
  2659. //DataSet dsReFine = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  2660. //{
  2661. // return PMModuleProxy.Service.GetReFine(this.txtBarCode.Text.Trim());
  2662. //}));
  2663. if (dsReFine != null && dsReFine.Tables[0].Rows.Count > 0 && dsReFine.Tables[0].Rows[0]["IsReFire"].ToString() == "6")
  2664. {
  2665. drNew["ReFine"] = 1;
  2666. }
  2667. else
  2668. {
  2669. drNew["ReFine"] = 0;
  2670. }
  2671. if (dsReFine != null && dsReFine.Tables[0].Rows.Count > 0 && dsReFine.Tables[0].Rows[0]["IsLengBu"].ToString() == "1")
  2672. {
  2673. drNew["LengBu"] = 1;
  2674. }
  2675. else
  2676. {
  2677. drNew["LengBu"] = 0;
  2678. }
  2679. drNew["UserCode"] = this.txtUserCode.Text.Trim();
  2680. // 由产品条码获取注浆信息
  2681. cre = new ClientRequestEntity();
  2682. cre.NameSpace = "F_PM_3402";
  2683. cre.Name = "GetGroutingProducttByBarCode";
  2684. cre.Properties["BarCode"] = this.txtBarCode.Text.Trim();
  2685. sre = DoAsync<ServiceResultEntity>(() =>
  2686. {
  2687. return PCModuleProxyNew.Service.HandleRequest(cre);
  2688. });
  2689. DataSet dsGroutingProduct = sre.Data;
  2690. //DataSet dsGroutingProduct = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  2691. //{
  2692. // return PMModuleProxy.Service.GetGroutingProducttByBarCode(txtBarCode.Text.Trim());
  2693. //}));
  2694. drNew["MouldCode"] = dsGroutingProduct.Tables[0].Rows[0]["MouldCode"];
  2695. drNew["GroutingUserCode"] = dsGroutingProduct.Tables[0].Rows[0]["GroutingUserCode"];
  2696. drNew["GroutingNum"] = dsGroutingProduct.Tables[0].Rows[0]["GroutingNum"];
  2697. drNew["IsPublicBody"] = dsGroutingProduct.Tables[0].Rows[0]["IsPublicBody"].ToString() != "1" ? 0 : 1;
  2698. drNew["GroutingDate"] = Convert.ToDateTime(dsGroutingProduct.Tables[0].Rows[0]["GroutingDate"]);
  2699. drNew["LogoCodeName"] = dsGroutingProduct.Tables[0].Rows[0]["LogoName"] + "[" + dsGroutingProduct.Tables[0].Rows[0]["LogoCode"] + "]";
  2700. drNew["LogoId"] = dsGroutingProduct.Tables[0].Rows[0]["LogoId"];
  2701. TableProductionData.Rows.Add(drNew);
  2702. if (DSTable.Tables.IndexOf(this.txtBarCode.Text.Trim()) == -Constant.INT_IS_ONE)
  2703. {
  2704. DataTable dtProductionDefectData = new DataTable(this.txtBarCode.Text.Trim());
  2705. dtProductionDefectData.Columns.Add("BarCode");
  2706. dtProductionDefectData.Columns.Add("DefectID", typeof(decimal));
  2707. dtProductionDefectData.Columns.Add("DefectName");
  2708. dtProductionDefectData.Columns.Add("DefectCode");
  2709. dtProductionDefectData.Columns.Add("DefectPositionID", typeof(decimal));
  2710. dtProductionDefectData.Columns.Add("DefectPositionName");
  2711. dtProductionDefectData.Columns.Add("DefectPositionCode");
  2712. dtProductionDefectData.Columns.Add("DefectProcedureID", typeof(decimal));
  2713. dtProductionDefectData.Columns.Add("DefectProcedureName");
  2714. dtProductionDefectData.Columns.Add("DefectProcedureCode");
  2715. dtProductionDefectData.Columns.Add("DefectUserID", typeof(decimal));//责任员工
  2716. dtProductionDefectData.Columns.Add("DefectUserName");//责任员工
  2717. dtProductionDefectData.Columns.Add("DefectUserCode");//
  2718. dtProductionDefectData.Columns.Add("Jobs", typeof(decimal));//工种
  2719. dtProductionDefectData.Columns.Add("JobsText");//工种
  2720. dtProductionDefectData.Columns.Add("DefectRemarks");
  2721. dtProductionDefectData.Columns.Add("TempCount");
  2722. dtProductionDefectData.Columns.Add("ProductionDataID"); //生产数据ID
  2723. dtProductionDefectData.Columns.Add("DefectFineID"); //缺席扣罚ID
  2724. dtProductionDefectData.Columns.Add("DefectFineValue"); //缺席扣罚
  2725. dtProductionDefectData.Columns.Add("MissedUserID"); //漏检工号ID
  2726. dtProductionDefectData.Columns.Add("MissedUserCode"); //漏检工号编码
  2727. dtProductionDefectData.Columns.Add("MissedUserName"); //漏检工号名称
  2728. dtProductionDefectData.Columns.Add("IsAllowEdit"); //允许编辑
  2729. //新添加的 wangx 2016/1/6
  2730. dtProductionDefectData.Columns.Add("DefectDeductionID"); //缺陷扣除数ID
  2731. dtProductionDefectData.Columns.Add("DefectDeductionNum"); //缺陷扣除数
  2732. dtProductionDefectData.Columns.Add("IsOtherDefect"); //特殊缺陷
  2733. dtProductionDefectData.Columns.Add("CheckTime"); //缺陷检验时间
  2734. DSTable.Tables.Add(dtProductionDefectData);
  2735. }
  2736. this.dgvDefect.DataSource = DSTable.Tables[this.txtBarCode.Text.Trim()];//根据条码产生不同数据源
  2737. this.dgvProductionData.Rows[TableProductionData.Rows.Count - 1].Selected = true;
  2738. this.dgvDefect.DataSource = null;
  2739. this.dgvDefectStaff.DataSource = null;
  2740. this.lvPic.Clear();
  2741. // 添加一个产品条码时除了第一个显示在数据表中,其它的全部清空
  2742. this.tsbtnAdd.Enabled = true;//添加完条码后,可以新建其它信息
  2743. // 添加一个产品条码时除了第一个显示在数据表中,其它的全部清空
  2744. this.tsbtnAdd.Enabled = true;//添加完条码后,可以新建其它信息
  2745. // 添加一个产品条码时除了第一个显示在数据表中,其它的全部清空
  2746. this.tsbtnAdd.Enabled = true;//添加完条码后,可以新建其它信息
  2747. this._selectedRowIndex = TableProductionData.Rows.Count - 1;
  2748. }
  2749. catch (Exception ex)
  2750. {
  2751. throw ex;
  2752. }
  2753. }
  2754. /// <summary>
  2755. /// 绑定到第一个DataGriwView数据源
  2756. /// </summary>
  2757. private void BindProductionData(DataSet dsCheckBarcode)
  2758. {
  2759. try
  2760. {
  2761. DataRow[] dr = TableProductionData.Select("BarCode='" + this.txtBarCode.Text.Trim() + "'");
  2762. if (dr.Length > Constant.INT_IS_ZERO)
  2763. {
  2764. // 不允许重复添加
  2765. return;
  2766. }
  2767. int SpecialRepairflag = 0;
  2768. if (dsCheckBarcode == null || dsCheckBarcode.Tables[0].Rows.Count == 0)
  2769. {
  2770. ClientRequestEntity cre1 = new ClientRequestEntity();
  2771. cre1.NameSpace = "F_PM_3402";
  2772. cre1.Name = "GetSpecialRepairflagByBarcode";
  2773. cre1.Properties["BarCode"] = this.txtBarCode.Text.Trim();
  2774. ServiceResultEntity sre1 = DoAsync<ServiceResultEntity>(() =>
  2775. {
  2776. return PCModuleProxyNew.Service.HandleRequest(cre1);
  2777. });
  2778. if (sre1.Data != null && sre1.Data.Tables[0].Rows.Count > 0)
  2779. {
  2780. SpecialRepairflag = Convert.ToInt32(sre1.Data.Tables[0].Rows[0]["SpecialRepairflag"]);
  2781. }
  2782. //SpecialRepairflag = (int)DoAsync(new BaseAsyncMethod(() =>
  2783. //{
  2784. // return PMModuleProxy.Service.GetSpecialRepairflagByBarcode(this.txtBarCode.Text.Trim());
  2785. //}));
  2786. }
  2787. else
  2788. {
  2789. SpecialRepairflag = Convert.ToInt32(dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_specialRepairFlag.ToString()]);
  2790. }
  2791. string KilnCarCode = string.Empty;
  2792. string KilnCode = string.Empty;
  2793. string Dictionaryvalue = string.Empty;
  2794. ClientRequestEntity cre = new ClientRequestEntity();
  2795. cre.NameSpace = "F_PM_3402";
  2796. cre.Name = "GetKilnCarByBarCode";
  2797. cre.Properties["BarCode"] = this.txtBarCode.Text.Trim();
  2798. ServiceResultEntity sre = DoAsync<ServiceResultEntity>(() =>
  2799. {
  2800. return PCModuleProxyNew.Service.HandleRequest(cre);
  2801. });
  2802. DataSet dsKilnCar = sre.Data;
  2803. //DataSet dsKilnCar = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  2804. //{
  2805. // return PMModuleProxy.Service.GetKilnCarByBarCode(txtBarCode.Text.Trim());
  2806. //}));
  2807. if (dsKilnCar != null && dsKilnCar.Tables[0].Rows.Count > Constant.INT_IS_ZERO)
  2808. {
  2809. KilnCarCode = dsKilnCar.Tables[0].Rows[0]["KilnCarCode"].ToString();
  2810. KilnCode = dsKilnCar.Tables[0].Rows[0]["KilnCode"].ToString();
  2811. Dictionaryvalue = dsKilnCar.Tables[0].Rows[0]["Dictionaryvalue"].ToString();
  2812. }
  2813. DataRow drNew = TableProductionData.NewRow();
  2814. drNew["BarCode"] = this.txtBarCode.Text.Trim();
  2815. if (dsCheckBarcode != null)
  2816. {
  2817. drNew["GoodsID"] = dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_goodsID.ToString()];
  2818. drNew["GoodsCode"] = dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_goodsCode.ToString()];
  2819. drNew["GoodsName"] = dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_goodsName.ToString()];
  2820. }
  2821. else
  2822. {
  2823. ClientRequestEntity cre1 = new ClientRequestEntity();
  2824. cre1.NameSpace = "F_PM_3402";
  2825. cre1.Name = "GetGoodsInfoBybarcode";
  2826. cre1.Properties["BarCode"] = this.txtBarCode.Text.Trim();
  2827. ServiceResultEntity sre1 = DoAsync<ServiceResultEntity>(() =>
  2828. {
  2829. return PCModuleProxyNew.Service.HandleRequest(cre1);
  2830. });
  2831. DataSet ds = sre1.Data;
  2832. //DataSet ds = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  2833. //{
  2834. // return PMModuleProxy.Service.GetGoodsInfoBybarcode(this.txtBarCode.Text.Trim());
  2835. //}));
  2836. if (ds != null && ds.Tables[0].Rows.Count > 0)
  2837. {
  2838. drNew["GoodsID"] = ds.Tables[0].Rows[0]["GoodsID"];
  2839. drNew["GoodsCode"] = ds.Tables[0].Rows[0]["GoodsCode"];
  2840. drNew["GoodsName"] = ds.Tables[0].Rows[0]["GoodsName"];
  2841. }
  2842. }
  2843. drNew["UserID"] = UserID;
  2844. drNew["KilnCarCode"] = KilnCarCode;
  2845. drNew["KilnCode"] = KilnCode;
  2846. drNew["Dictionaryvalue"] = Dictionaryvalue;
  2847. if (dsCheckBarcode.Tables[0].Columns.Contains("DefectFlagID") && !string.IsNullOrWhiteSpace(dsCheckBarcode.Tables[0].Rows[0]["DefectFlagID"] + ""))
  2848. {
  2849. drNew["DefectFlagID"] = dsCheckBarcode.Tables[0].Rows[0]["DefectFlagID"];
  2850. drNew["GoodsLevelTypeID"] = dsCheckBarcode.Tables[0].Rows[0]["DefectFlagID"];
  2851. //控制报损
  2852. if (!string.IsNullOrWhiteSpace(dsCheckBarcode.Tables[0].Rows[0]["DefectFlagID"]+"") && Convert.ToInt32(drNew["GoodsLevelTypeID"]) == 7)
  2853. {
  2854. dgvPackingBomDetail.Columns["NewCheck"].ReadOnly = true;
  2855. dgvPackingBomDetail.Columns["NEWIDNRKONLYCODE"].ReadOnly = true;
  2856. dgvPackingBomDetail.Columns["FrmLossCheck"].ReadOnly = false;
  2857. dgvPackingBomDetail.Columns["RecoverCheck"].ReadOnly = false;
  2858. }
  2859. else
  2860. {
  2861. dgvPackingBomDetail.Columns["FrmLossCheck"].ReadOnly = true;
  2862. dgvPackingBomDetail.Columns["RecoverCheck"].ReadOnly = true;
  2863. dgvPackingBomDetail.Columns["NewCheck"].ReadOnly = false;
  2864. dgvPackingBomDetail.Columns["NEWIDNRKONLYCODE"].ReadOnly = false;
  2865. }
  2866. }
  2867. else
  2868. {
  2869. drNew["DefectFlagID"] = _dsGoodsLevel.Tables[0].Rows[0]["DefectFlagID"];
  2870. drNew["GoodsLevelTypeID"] = _dsGoodsLevel.Tables[0].Rows[0]["GoodsLevelTypeID"];
  2871. }
  2872. drNew["ReworkProcedureID"] = DBNull.Value;
  2873. drNew["Remarks"] = "";
  2874. drNew["UserID"] = UserID;
  2875. drNew["UserCode"] = UserCode;
  2876. drNew["UserName"] = UserName;
  2877. drNew["OrgGoodsLevelTypeID"] = -1;
  2878. drNew["SpecialRepairflag"] = SpecialRepairflag == 1 ? 1 : 0;
  2879. drNew["LogoCodeName"] = dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_logoName.ToString()]
  2880. + "[" + dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_logoCode.ToString()] + "]";
  2881. drNew["LogoID"] = dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_logoID.ToString()];
  2882. // 校验条码是否重烧过
  2883. cre = new ClientRequestEntity();
  2884. cre.NameSpace = "F_PM_3402";
  2885. cre.Name = "GetReFine";
  2886. cre.Properties["BarCode"] = this.txtBarCode.Text.Trim();
  2887. sre = DoAsync<ServiceResultEntity>(() =>
  2888. {
  2889. return PCModuleProxyNew.Service.HandleRequest(cre);
  2890. });
  2891. DataSet dsReFine = sre.Data;
  2892. //DataSet dsReFine = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  2893. //{
  2894. // return PMModuleProxy.Service.GetReFine(this.txtBarCode.Text.Trim());
  2895. //}));
  2896. if (dsReFine != null && dsReFine.Tables[0].Rows.Count > 0 && dsReFine.Tables[0].Rows[0]["IsReFire"].ToString() == "6")
  2897. {
  2898. drNew["ReFine"] = 1;
  2899. }
  2900. else
  2901. {
  2902. drNew["ReFine"] = 0;
  2903. }
  2904. if (dsReFine != null && dsReFine.Tables[0].Rows.Count > 0 && dsReFine.Tables[0].Rows[0]["IsLengBu"].ToString() == "1")
  2905. {
  2906. drNew["LengBu"] = 1;
  2907. }
  2908. else
  2909. {
  2910. drNew["LengBu"] = 0;
  2911. }
  2912. if (dsCheckBarcode == null || dsCheckBarcode.Tables[0].Rows.Count == 0)
  2913. {
  2914. // 由产品条码获取注浆信息
  2915. cre = new ClientRequestEntity();
  2916. cre.NameSpace = "F_PM_3402";
  2917. cre.Name = "GetGroutingProducttByBarCode";
  2918. cre.Properties["BarCode"] = this.txtBarCode.Text.Trim();
  2919. sre = DoAsync<ServiceResultEntity>(() =>
  2920. {
  2921. return PCModuleProxyNew.Service.HandleRequest(cre);
  2922. });
  2923. DataSet dsGroutingProduct = sre.Data;
  2924. //DataSet dsGroutingProduct = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  2925. //{
  2926. // return PMModuleProxy.Service.GetGroutingProducttByBarCode(txtBarCode.Text.Trim());
  2927. //}));
  2928. drNew["UserCode"] = this.txtUserCode.Text.Trim();
  2929. drNew["MouldCode"] = dsGroutingProduct.Tables[0].Rows[0]["MouldCode"];
  2930. drNew["GroutingUserCode"] = dsGroutingProduct.Tables[0].Rows[0]["GroutingUserCode"];
  2931. drNew["GroutingNum"] = dsGroutingProduct.Tables[0].Rows[0]["GroutingNum"];
  2932. drNew["IsPublicBody"] = dsGroutingProduct.Tables[0].Rows[0]["IsPublicBody"].ToString() != "1" ? 0 : 1;
  2933. drNew["GroutingDate"] = Convert.ToDateTime(dsGroutingProduct.Tables[0].Rows[0]["GroutingDate"]);
  2934. }
  2935. else
  2936. {
  2937. drNew["UserCode"] = this.txtUserCode.Text.Trim();
  2938. drNew["MouldCode"] = dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_mouldCode.ToString()];
  2939. drNew["GroutingUserCode"] = dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_groutingUserCode.ToString()];
  2940. drNew["GroutingNum"] = dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_groutingNum.ToString()];
  2941. drNew["IsPublicBody"] = dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_ispublicbody.ToString()].ToString() != "1" ? 0 : 1;
  2942. drNew["GroutingDate"] = Convert.ToDateTime(dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_groutingdate.ToString()]);
  2943. }
  2944. TableProductionData.Rows.Add(drNew);
  2945. if (DSTable.Tables.IndexOf(this.txtBarCode.Text.Trim()) == -Constant.INT_IS_ONE)
  2946. {
  2947. DataTable dtProductionDefectData = new DataTable(this.txtBarCode.Text.Trim());
  2948. dtProductionDefectData.Columns.Add("BarCode");
  2949. dtProductionDefectData.Columns.Add("DefectID", typeof(decimal));
  2950. dtProductionDefectData.Columns.Add("DefectName");
  2951. dtProductionDefectData.Columns.Add("DefectCode");
  2952. dtProductionDefectData.Columns.Add("DefectPositionID", typeof(decimal));
  2953. dtProductionDefectData.Columns.Add("DefectPositionName");
  2954. dtProductionDefectData.Columns.Add("DefectPositionCode");
  2955. dtProductionDefectData.Columns.Add("DefectProcedureID", typeof(decimal));
  2956. dtProductionDefectData.Columns.Add("DefectProcedureName");
  2957. dtProductionDefectData.Columns.Add("DefectProcedureCode");
  2958. dtProductionDefectData.Columns.Add("DefectUserID", typeof(decimal));//责任员工
  2959. dtProductionDefectData.Columns.Add("DefectUserName");//责任员工
  2960. dtProductionDefectData.Columns.Add("DefectUserCode");//
  2961. dtProductionDefectData.Columns.Add("Jobs", typeof(decimal));//工种
  2962. dtProductionDefectData.Columns.Add("JobsText");//工种
  2963. dtProductionDefectData.Columns.Add("DefectRemarks");
  2964. dtProductionDefectData.Columns.Add("TempCount");
  2965. dtProductionDefectData.Columns.Add("ProductionDataID"); //生产数据ID
  2966. dtProductionDefectData.Columns.Add("DefectFineID"); //缺席扣罚ID
  2967. dtProductionDefectData.Columns.Add("DefectFineValue"); //缺席扣罚
  2968. dtProductionDefectData.Columns.Add("MissedUserID"); //漏检工号ID
  2969. dtProductionDefectData.Columns.Add("MissedUserCode"); //漏检工号编码
  2970. dtProductionDefectData.Columns.Add("MissedUserName"); //漏检工号名称
  2971. dtProductionDefectData.Columns.Add("IsAllowEdit"); //允许编辑
  2972. //新添加的 wangx 2016/1/6
  2973. dtProductionDefectData.Columns.Add("DefectDeductionID"); //缺陷扣除数ID
  2974. dtProductionDefectData.Columns.Add("DefectDeductionNum"); //缺陷扣除数
  2975. dtProductionDefectData.Columns.Add("IsOtherDefect"); //特殊缺陷
  2976. dtProductionDefectData.Columns.Add("CheckTime"); //缺陷检验时间
  2977. DSTable.Tables.Add(dtProductionDefectData);
  2978. }
  2979. this.dgvDefect.DataSource = DSTable.Tables[this.txtBarCode.Text.Trim()];//根据条码产生不同数据源
  2980. this.dgvProductionData.Rows[TableProductionData.Rows.Count - 1].Selected = true;
  2981. this.dgvDefect.DataSource = null;
  2982. this.dgvDefectStaff.DataSource = null;
  2983. this.dgvPackingBomDetail.DataSource = null;
  2984. this.lvPic.Clear();
  2985. // 添加一个产品条码时除了第一个显示在数据表中,其它的全部清空
  2986. this.tsbtnAdd.Enabled = true;//添加完条码后,可以新建其它信息
  2987. // 添加一个产品条码时除了第一个显示在数据表中,其它的全部清空
  2988. this.tsbtnAdd.Enabled = true;//添加完条码后,可以新建其它信息
  2989. // 添加一个产品条码时除了第一个显示在数据表中,其它的全部清空
  2990. this.tsbtnAdd.Enabled = true;//添加完条码后,可以新建其它信息
  2991. this._selectedRowIndex = TableProductionData.Rows.Count - 1;
  2992. //DataTable dt = this._dsGoodsLevel.Tables[0];
  2993. //DataView dv = dt.DefaultView;
  2994. //dv.RowFilter = "GoodsLevelTypeID>=" + goodsLevelTypeID;
  2995. //DataSet ds = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  2996. //{
  2997. // return PMModuleProxy.Service.GetReworkProcedureByProcedureID(this._procedureID);
  2998. //}));
  2999. //ds.Tables[0].TableName = this.txtBarCode.Text.Trim();
  3000. //if (this.DSREWORK == null)
  3001. //{
  3002. // this.DSREWORK = new DataSet();
  3003. //}
  3004. //this.DSREWORK.Tables.Add(ds.Tables[0].Copy());
  3005. //// 返工工序数据源
  3006. //C_DGV_Cell_ListBoxComboBox C_DGV_Cell_ListBoxComboBox = dgvProductionData.Rows[_selectedRowIndex].Cells[4] as C_DGV_Cell_ListBoxComboBox;
  3007. //C_DGV_Cell_ListBoxComboBox.DataSource = ds.Tables[0];
  3008. //C_DGV_Cell_ListBoxComboBox.DisplayMember = "ReworkProcedureName";
  3009. //C_DGV_Cell_ListBoxComboBox.ValueMember = "ReworkProcedureID";
  3010. }
  3011. catch (Exception ex)
  3012. {
  3013. throw ex;
  3014. }
  3015. }
  3016. /// <summary>
  3017. /// 通过是否有缺陷来启用或禁用
  3018. /// </summary>
  3019. /// <param name="DefectFlag"></param>
  3020. private void SetGridView(int GoodsLevelID)
  3021. {
  3022. DataTable dtDefectFlag = this.DefectFlag.DataSource as DataTable;//获取缺陷数据源
  3023. int GoodsLevelTypeID = -1;
  3024. DataRow[] dr = dtDefectFlag.Select("DefectFlagID=" + GoodsLevelID);
  3025. if (dr.Length > Constant.INT_IS_ZERO)
  3026. {
  3027. GoodsLevelTypeID = Convert.ToInt32(dr[0]["GoodsLevelTypeID"]);
  3028. this.dgvProductionData.Rows[this.dgvProductionData.CurrentCell.RowIndex].Cells["GoodsLevelTypeID"].Value = GoodsLevelTypeID;
  3029. }
  3030. if (GoodsLevelTypeID != -Constant.INT_IS_ONE)
  3031. {
  3032. this.dgvProductionData.Rows[this.dgvProductionData.CurrentCell.RowIndex].Cells["ReworkProcedureID"].Value = DBNull.Value;
  3033. this.dgvProductionData.Rows[this.dgvProductionData.CurrentCell.RowIndex].Cells["ReworkProcedureCode"].Value = string.Empty;
  3034. this.dgvProductionData.Rows[this.dgvProductionData.CurrentCell.RowIndex].Cells["ReworkProcedureName"].Value = string.Empty;
  3035. if (GoodsLevelTypeID == (int)Constant.GoodsLevelType.Quality) //正品
  3036. {
  3037. this.dgvProductionData.Rows[this.dgvProductionData.CurrentCell.RowIndex].Cells["ReworkProcedureID"].ReadOnly = true;
  3038. try
  3039. {
  3040. string BarCode = this.dgvProductionData.Rows[this.dgvProductionData.CurrentCell.RowIndex].Cells["BarCode"].Value.ToString();
  3041. if (DSTable.Tables.Contains(BarCode))
  3042. {
  3043. DSTable.Tables[BarCode].Rows.Clear();//清空行
  3044. }
  3045. this.dgvDefectStaff.DataSource = null;
  3046. this.lvPic.Clear();
  3047. }
  3048. catch (Exception ex)
  3049. {
  3050. throw ex;
  3051. }
  3052. }
  3053. else if (GoodsLevelTypeID == (int)Constant.GoodsLevelType.Quality) //次品 或者正品
  3054. {
  3055. this.dgvProductionData.Rows[this.dgvProductionData.CurrentCell.RowIndex].Cells["ReworkProcedureID"].ReadOnly = true;
  3056. }
  3057. else if (GoodsLevelTypeID == (int)Constant.GoodsLevelType.ReFire)//重烧
  3058. {
  3059. this.dgvProductionData.Rows[this.dgvProductionData.CurrentCell.RowIndex].Cells["ReworkProcedureID"].ReadOnly = false;
  3060. }
  3061. else if (GoodsLevelTypeID == (int)Constant.GoodsLevelType.Substandard)//副品
  3062. {
  3063. // this.dgvProductionData.Rows[this.dgvProductionData.CurrentCell.RowIndex].Cells["GoodsLevelTypeID"].Value = GoodsLevelTypeID;
  3064. this.dgvProductionData.Rows[this.dgvProductionData.CurrentCell.RowIndex].Cells["ReworkProcedureID"].ReadOnly = false;
  3065. }
  3066. else if (GoodsLevelTypeID == (int)Constant.GoodsLevelType.LengBu)//冷补
  3067. {
  3068. this.dgvProductionData.Rows[this.dgvProductionData.CurrentCell.RowIndex].Cells["ReworkProcedureID"].ReadOnly = false;
  3069. }
  3070. }
  3071. }
  3072. /// <summary>
  3073. /// 清空以前所选中的缺陷
  3074. /// </summary>
  3075. /// <param name="checkValue"></param>
  3076. private void SetCheckBoxSelected(int checkValue, int rowIndex)
  3077. {
  3078. DataTable dtOrgDataSource = this.dgvDefect.DataSource as DataTable;
  3079. for (int i = 0; i < DSTable.Tables[dtOrgDataSource.TableName].Rows.Count; i++)
  3080. {
  3081. if (i == rowIndex)
  3082. {
  3083. dtOrgDataSource.Rows[i]["discarde"] = 1;
  3084. }
  3085. else
  3086. {
  3087. dtOrgDataSource.Rows[i]["discarde"] = 0;
  3088. }
  3089. }
  3090. }
  3091. /// <summary>
  3092. /// 绑定并显示图片
  3093. /// </summary>
  3094. /// <param name="ImageData"></param>
  3095. public void BindByteImage(DataTable ImageData)
  3096. {
  3097. this._smallByte.Clear();
  3098. if (ImageData != null && ImageData.Rows.Count > 0)
  3099. {
  3100. foreach (DataRow dr in ImageData.Rows)
  3101. {
  3102. //将数据库中的缩略图取出
  3103. this._smallByte.Add((byte[])dr[1]);
  3104. }
  3105. //绑定缩略图
  3106. BindImg();
  3107. }
  3108. }
  3109. /// <summary>
  3110. /// 将图片文件转换成二进制
  3111. /// </summary>
  3112. /// <param name="img"></param>
  3113. /// <returns></returns>
  3114. public static byte[] ImageToByte(Image img)
  3115. {
  3116. byte[] smallbuffer = null;
  3117. using (MemoryStream ms = new MemoryStream())
  3118. {
  3119. img.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
  3120. ms.Position = Constant.INT_IS_ZERO;
  3121. smallbuffer = new byte[ms.Length];
  3122. ms.Read(smallbuffer, Constant.INT_IS_ZERO, Convert.ToInt32(ms.Length));
  3123. ms.Flush();
  3124. }
  3125. return smallbuffer;
  3126. }
  3127. /// <SUMMARY>
  3128. /// 重绘缩略图并把缩略图转为二进制储存
  3129. /// </SUMMARY>
  3130. /// <PARAM name="sourceFile">图片源路径</PARAM>
  3131. /// <PARAM name="destHeight">缩放后图片高度</PARAM>
  3132. /// <PARAM name="destWidth">缩放后图片宽度</PARAM>
  3133. /// <RETURNS></RETURNS>
  3134. public void GetThumbnail(FileInfo sourceFile, byte[] orgImageByte)
  3135. {
  3136. Image imgSource = Image.FromStream(sourceFile.OpenRead());
  3137. ImageFormat thisFormat = imgSource.RawFormat;
  3138. int sW = 0, sH = 0;
  3139. // 按比例缩放
  3140. int sWidth = imgSource.Width;
  3141. int sHeight = imgSource.Height;
  3142. int destWidth = 100;
  3143. int destHeight = getSmallImageHeight(sWidth, sHeight, destWidth);
  3144. if (sHeight > destHeight || sWidth > destWidth)
  3145. {
  3146. if ((sWidth * destHeight) > (sHeight * destWidth))
  3147. {
  3148. sW = destWidth;
  3149. sH = (destWidth * sHeight) / sWidth;
  3150. }
  3151. else
  3152. {
  3153. sH = destHeight;
  3154. sW = (sWidth * destHeight) / sHeight;
  3155. }
  3156. }
  3157. else
  3158. {
  3159. sW = sWidth;
  3160. sH = sHeight;
  3161. }
  3162. Bitmap outBmp = new Bitmap(destWidth, destHeight);
  3163. Graphics g = Graphics.FromImage(outBmp);
  3164. g.Clear(Color.Black);
  3165. // 设置画布的描绘质量
  3166. g.CompositingQuality = CompositingQuality.HighQuality;
  3167. g.SmoothingMode = SmoothingMode.HighQuality;
  3168. g.InterpolationMode = InterpolationMode.HighQualityBicubic;
  3169. g.DrawImage(imgSource, new Rectangle((destWidth - sW) / 2, (destHeight - sH) / 2, sW, sH), 0, 0, imgSource.Width, imgSource.Height, GraphicsUnit.Pixel);
  3170. g.Dispose();
  3171. //将重绘的图片转为二进制并保存
  3172. Image image = (Image)outBmp;
  3173. byte[] smallbuffer = ImageToByte(image);
  3174. if (this._currentTempSign != string.Empty)
  3175. {
  3176. if (!this.DSTableImage.Tables.Contains(string.Format("TempTable{0}", this._currentTempSign.ToString())))
  3177. {
  3178. DataTable dtImage = new DataTable(string.Format("TempTable{0}", this._currentTempSign.ToString()));
  3179. dtImage.Columns.Add("StaffTempCount");
  3180. dtImage.Columns.Add("ImageByte", typeof(byte[]));
  3181. dtImage.Columns.Add("OrgImageByte", typeof(byte[]));
  3182. this.DSTableImage.Tables.Add(dtImage);
  3183. }
  3184. DataRow dr = DSTableImage.Tables[string.Format("TempTable{0}", this._currentTempSign)].NewRow();
  3185. dr["StaffTempCount"] = this._currentTempSign;
  3186. dr["ImageByte"] = smallbuffer;
  3187. dr["OrgImageByte"] = orgImageByte;
  3188. DSTableImage.Tables[string.Format("TempTable{0}", this._currentTempSign)].Rows.Add(dr);
  3189. }
  3190. this._smallByte.Add(smallbuffer);
  3191. imgSource.Dispose();
  3192. outBmp.Dispose();
  3193. }
  3194. /// <summary>
  3195. /// 根据原图片宽高比获取缩略图的高(根据宽)
  3196. /// </summary>
  3197. /// <param name="BigWidth"></param>
  3198. /// <param name="BigHeight"></param>
  3199. /// <param name="SmallWidth"></param>
  3200. /// <returns></returns>
  3201. protected int getSmallImageHeight(int BigWidth, int BigHeight, int SmallWidth)
  3202. {
  3203. decimal scale = Convert.ToDecimal(BigWidth) / Convert.ToDecimal(BigHeight);
  3204. return Convert.ToInt32(SmallWidth / scale);
  3205. }
  3206. /// <summary>
  3207. /// 绑定缩略图到控件中
  3208. /// </summary>
  3209. protected void BindImg()
  3210. {
  3211. ImageList ilPic = new ImageList();
  3212. //每次绑定要清空数据源
  3213. ilPic.Images.Clear();
  3214. //将缩略图二进制集合中的数据转换成图片文件
  3215. List<Image> LSImageList = new List<Image>();
  3216. foreach (byte[] smallby in _smallByte)
  3217. {
  3218. LSImageList.Add(byteArrayToImage(smallby));
  3219. }
  3220. //添加数据源
  3221. foreach (Image img in LSImageList)
  3222. {
  3223. ilPic.Images.Add(img);
  3224. }
  3225. ilPic.ImageSize = new Size(100, 100);
  3226. this.lvPic.LargeImageList = ilPic;
  3227. this.lvPic.BeginUpdate();
  3228. //清空列表的数据源
  3229. lvPic.Items.Clear();
  3230. //添加列表的数据源
  3231. for (int i = 0; i < ilPic.Images.Count; i++)
  3232. {
  3233. ListViewItem lvi = new ListViewItem();
  3234. lvi.ImageIndex = i;
  3235. this.lvPic.Items.Add(lvi);
  3236. }
  3237. this.lvPic.EndUpdate();
  3238. }
  3239. /// <summary>
  3240. /// 将数据库中的二进制转换成图片
  3241. /// </summary>
  3242. /// <param name="data"></param>
  3243. /// <returns></returns>
  3244. public static Image byteArrayToImage(object data)
  3245. {
  3246. System.IO.MemoryStream ms = new System.IO.MemoryStream((byte[])data);
  3247. System.Drawing.Image returnImage = System.Drawing.Image.FromStream(ms);
  3248. return returnImage;
  3249. }
  3250. #endregion
  3251. }
  3252. }