F_PM_1202.cs 178 KB

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