F_PM_3402.cs 179 KB

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