Make_RepairOk.cs 76 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Text;
  7. using System.Windows.Forms;
  8. using UAS_MES_NEW.CustomControl.DataGrid_View;
  9. using UAS_MES_NEW.CustomControl.TextBoxWithIcon;
  10. using UAS_MES_NEW.DataOperate;
  11. using UAS_MES_NEW.Entity;
  12. using UAS_MES_NEW.PublicMethod;
  13. namespace UAS_MES_NEW.Make
  14. {
  15. public partial class Make_RepairOk : Form
  16. {
  17. string mb_id = "";
  18. string mbr_id = "";
  19. /// <summary>
  20. /// 存放父节点信息
  21. /// </summary>
  22. Dictionary<string, Dictionary<string, string>> BadInf_1 = new Dictionary<string, Dictionary<string, string>>();
  23. /// <summary>
  24. /// 存放子节点信息
  25. /// </summary>
  26. Dictionary<string, Dictionary<string, string>> BadInf_2 = new Dictionary<string, Dictionary<string, string>>();
  27. DataHelper dh = null;
  28. LogStringBuilder sql = new LogStringBuilder();
  29. List<string> sqls = new List<string>();
  30. DataTable dt = null;
  31. AutoSizeFormClass asc = new AutoSizeFormClass();
  32. string macode;
  33. string msid = "";
  34. string ifrework = "";
  35. string reworkstatus = "";
  36. string firstsn = "";
  37. string ms_stepcode = "";
  38. string ms_beforesn = "";
  39. DataTable Dbfind;
  40. public Make_RepairOk()
  41. {
  42. InitializeComponent();
  43. }
  44. private void Make_Repair_Load(object sender, EventArgs e)
  45. {
  46. //为DBFind配置Call和Form的名称
  47. cr_code.FormName = Name;
  48. cr_code.TableName = "craft";
  49. cr_code.SelectField = "cr_name # 工艺名称,cr_code # 工艺编号,cr_prodcode # 物料编号";
  50. cr_code.SetValueField = new string[] { "cr_code" };
  51. cr_code.DBTitle = "回流工艺";
  52. cr_code.DbChange += Cr_code_DbChange;
  53. cd_stepcode.FormName = Name;
  54. cd_stepcode.TableName = "craftdetail left join step on st_code=cd_stepcode left join craft on cd_crid=cr_id";
  55. cd_stepcode.SetValueField = new string[] { "cd_stepcode" };
  56. cd_stepcode.SelectField = "cd_stepname # 工序名称 ,cd_stepcode # 工序编号,cd_stepno # 执行顺序";
  57. cd_stepcode.DBTitle = "回流工序";
  58. cd_stepcode.DbChange += Cd_stepcode_DbChange;
  59. cd_stepcode.Condition = "ST_STATUSCODE='AUDITED' and cr_code='" + cr_code.Text + "' and cr_prodcode='" + ms_prodcode.Text + "' and ST_IFOFFLINE = -1 order by cd_stepno";
  60. bd_soncode.FormName = Name;
  61. bd_soncode.TableName = "bom left join bomdetail on bd_bomid=bo_id left join product on bd_soncode=pr_code";
  62. bd_soncode.SetValueField = new string[] { "bd_soncode" };
  63. bd_soncode.SelectField = "bd_soncode # 子件编号,pr_detail # 物料名称,pr_spec # 物料规格,bd_location # 位号";
  64. bd_soncode.DBTitle = "不良零件";
  65. bd_soncode.DbChange += Prodcode_DbChange;
  66. //nrg_name.BringToFront();
  67. nrg_name.TableName = "(select nrg_name,nrg_code from QUA_NGREASONGROUP left join DATAINPUTRECORD ON NRG_NAME = DIR_COMMENT AND DIR_GROUP = '不良原因组' and DIR_SOURCECODE = '" + User.UserSourceCode + "' ORDER BY NVL(DIR_NUMBER,0) DESC)";
  68. nrg_name.Field = "nrg_name";
  69. nrg_name.ValueField = "nrg_code";
  70. nrg_name.Condition = " 1=1 ORDER BY ROWNUM asc";
  71. nr_name.TableName = "QUA_NGREASONGROUPDET left join QUA_NGREASONGROUP on nrgd_nrgid=nrg_id left join QUA_NGReason on nrgd_nrcode=nr_code left join DATAINPUTRECORD ON nr_name = DIR_COMMENT AND DIR_GROUP = '不良原因' and DIR_SOURCECODE = '" + User.UserSourceCode + "' ";
  72. nr_name.Field = "nr_name";
  73. nr_name.ValueField = "nr_code";
  74. mbr_dutyname.TableName = "(select nd_name,nd_code from ngduty left join DATAINPUTRECORD ON nd_name = DIR_COMMENT AND DIR_GROUP = '责任别' and DIR_SOURCECODE = '" + User.UserSourceCode + "' ORDER BY NVL(DIR_NUMBER,0) DESC) ";
  75. mbr_dutyname.Field = "nd_name";
  76. mbr_dutyname.ValueField = "nd_code";
  77. mbr_dutyname.Condition = " 1=1 ORDER BY ROWNUM asc";
  78. so_name.TableName = "(select so_name,so_code from solution left join DATAINPUTRECORD ON so_name = DIR_COMMENT AND DIR_GROUP = '解决方案' and DIR_SOURCECODE = '" + User.UserSourceCode + "' ORDER BY NVL(DIR_NUMBER,0) DESC)";
  79. so_name.Field = "so_name";
  80. so_name.ValueField = "so_code";
  81. so_name.Condition = " 1=1 ORDER BY ROWNUM asc";
  82. if (User.UserAccountType != "admin")
  83. {
  84. retsnlabel.Visible = false;
  85. retsn.Visible = false;
  86. }
  87. asc.controllInitializeSize(this);
  88. mbc_component.SendToBack();
  89. so_name.SendToBack();
  90. mbl_loc.SendToBack();
  91. bd_soncode.SendToBack();
  92. mbp_partdgv.SendToBack();
  93. mbp_part_label.SendToBack();
  94. dh = SystemInf.dh;
  95. GetSNCode.Focus();
  96. }
  97. private void LoadBadcodeGroup()
  98. {
  99. sql.Clear();
  100. sql.Append("select ri_id,ri_name from RepairItem where ri_statuscode='AUDITED' ");
  101. dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
  102. badgroup.DataSource = dt;
  103. badgroup.DisplayMember = "ri_name";
  104. badgroup.ValueMember = "ri_id";
  105. LoadBadCodeListView();
  106. }
  107. private void LoadBadCodeListView()
  108. {
  109. string ri_id = badgroup.SelectedValue.ToString();
  110. sql.Clear();
  111. sql.Append("select rid_code from RepairItemdetail where rid_riid='" + ri_id + "' ");
  112. dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
  113. BadInfo.DataSource = dt;
  114. //往listview中添加数据
  115. WaitRejectList.Items.Clear();
  116. WaitRejectList.BeginUpdate();
  117. for (int i = 0; i < dt.Rows.Count; i++)
  118. {
  119. ListViewItem lvi = new ListViewItem();
  120. //第一列是勾选列,设置列头文本为空
  121. lvi.Text = "";
  122. for (int j = 0; j < dt.Columns.Count; j++)
  123. lvi.SubItems.Add(dt.Rows[i][j].ToString());
  124. WaitRejectList.Items.Add(lvi);
  125. }
  126. WaitRejectList.EndUpdate();
  127. }
  128. private void Prodcode_DbChange(object sender, EventArgs e)
  129. {
  130. Dbfind = bd_soncode.ReturnData;
  131. BaseUtil.SetFormValue(this.Controls, Dbfind);
  132. if (bd_soncode.Text != "")
  133. {
  134. if (mbr_id != "")
  135. {
  136. if (!dh.CheckExist("makebadrspart", "mbp_sncode='" + GetSNCode.Text + "' and mbp_part='" + bd_soncode.Text + "' and mbp_badcode='" + bc_code.Text + "'"))
  137. {
  138. sql.Clear();
  139. sql.Append("insert into makebadrspart(mbp_id,mbp_mbrid,mbp_part,mbp_badcode,");
  140. sql.Append("mbp_brcode,mbp_sncode,mbp_makecode,mbp_indate,mbp_inman)");
  141. sql.Append("select makebadrspart_seq.nextval," + mbr_id + ",'" + bd_soncode.Text + "',");
  142. sql.Append("'" + bc_code.Text + "','" + nr_code.Text + "','" + GetSNCode.Text + "','" + macode + "',");
  143. sql.Append("sysdate,'" + User.UserCode + "' from dual");
  144. dh.ExecuteSql(sql.GetString(), "insert");
  145. DataTable dt = (DataTable)dh.ExecuteSql("select mbp_id,mbp_part from makebadrspart where mbp_mbrid=" + mbr_id, "select");
  146. BaseUtil.FillDgvWithDataTable(mbp_partdgv, dt);
  147. }
  148. }
  149. else OperatResult.AppendText(">>请先选择不良原因\n", Color.Red);
  150. }
  151. else OperatResult.AppendText(">>不良零件不能为空\n", Color.Red);
  152. }
  153. private void Cd_stepcode_DbChange(object sender, EventArgs e)
  154. {
  155. Dbfind = cd_stepcode.ReturnData;
  156. BaseUtil.SetFormValue(this.Controls, Dbfind);
  157. }
  158. private void Cr_code_DbChange(object sender, EventArgs e)
  159. {
  160. Dbfind = cr_code.ReturnData;
  161. BaseUtil.SetFormValue(this.Controls, Dbfind);
  162. }
  163. private void GetSNCode_KeyDown(object sender, KeyEventArgs e)
  164. {
  165. if (e.KeyCode == Keys.Enter)
  166. {
  167. if (GetSNCode.Text == "")
  168. {
  169. OperatResult.AppendText(">>序列号不允许为空\n", Color.Red);
  170. string cdstepcode = cd_stepcode.Text;
  171. //cd_stepcode.Enabled = true;
  172. BaseUtil.CleanForm(this);
  173. cd_stepcode.Text = cdstepcode;
  174. BadCodeTree.Nodes.Clear();
  175. return;
  176. }
  177. sql.Clear();
  178. sql.Append("select ms_status,ms_outboxcode,ms_paststep,ms_reworkstatus,nvl(ms_ifrework,0)ms_ifrework,ms_sncode from makeserial left join make ");
  179. sql.Append("on ms_makecode=ma_code where ms_sncode = '" + GetSNCode.Text + "' or ms_firstsn = '" + GetSNCode.Text + "' order by ms_id desc");
  180. dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
  181. string ms_paststep = "";
  182. if (dt.Rows.Count > 0)
  183. {
  184. string ms_status = dt.Rows[0]["ms_status"].ToString();
  185. ms_paststep = dt.Rows[0]["ms_paststep"].ToString();
  186. ifrework = dt.Rows[0]["ms_ifrework"].ToString();
  187. reworkstatus = dt.Rows[0]["ms_reworkstatus"].ToString();
  188. GetSNCode.Text = dt.Rows[0]["ms_sncode"].ToString();
  189. //if (dt.Rows[0]["ms_outboxcode"].ToString() != "")
  190. //{
  191. // OperatResult.AppendText(">>序列号:" + GetSNCode.Text + "已装箱,请先进行拆箱\n", Color.Red);
  192. // BaseUtil.CleanForm(this);
  193. // BadCodeTree.Nodes.Clear();
  194. // return;
  195. //}
  196. //如果不是返修序列号执行原来的步骤
  197. if (ifrework == "0")
  198. {
  199. if (ms_status == "4")
  200. {
  201. OperatResult.AppendText(">>序列号:" + GetSNCode.Text + "已处于报废状态\n", Color.Red);
  202. string cdstepcode = cd_stepcode.Text;
  203. //cd_stepcode.Enabled = true;
  204. BaseUtil.CleanForm(this);
  205. cd_stepcode.Text = cdstepcode;
  206. BadCodeTree.Nodes.Clear();
  207. return;
  208. }
  209. if (ms_status != "3")
  210. {
  211. OperatResult.AppendText(">>序列号:" + GetSNCode.Text + "不处于维修状态\n", Color.Red);
  212. string cdstepcode = cd_stepcode.Text;
  213. //cd_stepcode.Enabled = true;
  214. BaseUtil.CleanForm(this);
  215. cd_stepcode.Text = cdstepcode;
  216. BadCodeTree.Nodes.Clear();
  217. return;
  218. }
  219. }
  220. else
  221. {
  222. if (reworkstatus == "4")
  223. {
  224. OperatResult.AppendText(">>序列号:" + GetSNCode.Text + "已处于报废状态\n", Color.Red);
  225. string cdstepcode = cd_stepcode.Text;
  226. //cd_stepcode.Enabled = true;
  227. BaseUtil.CleanForm(this);
  228. cd_stepcode.Text = cdstepcode;
  229. BadCodeTree.Nodes.Clear();
  230. return;
  231. }
  232. if (reworkstatus != "0" && reworkstatus != "3")
  233. {
  234. OperatResult.AppendText(">>序列号:" + GetSNCode.Text + "不处于维修状态\n", Color.Red);
  235. string cdstepcode = cd_stepcode.Text;
  236. //cd_stepcode.Enabled = true;
  237. BaseUtil.CleanForm(this);
  238. cd_stepcode.Text = cdstepcode;
  239. BadCodeTree.Nodes.Clear();
  240. return;
  241. }
  242. }
  243. }
  244. else
  245. {
  246. OperatResult.AppendText(">>序列号:" + GetSNCode.Text + "不存在\n", Color.Red);
  247. string cdstepcode = cd_stepcode.Text;
  248. //cd_stepcode.Enabled = true;
  249. BaseUtil.CleanForm(this);
  250. cd_stepcode.Text = cdstepcode;
  251. BadCodeTree.Nodes.Clear();
  252. return;
  253. }
  254. //dt = (DataTable)dh.ExecuteSql("select mb_stepcode from makebad where mb_sncode='" + GetSNCode.Text + "' and mb_status=0 order by mb_id desc", "select");
  255. ////打不良的资源和当前资源相等可以快速维修,无须登录维修资源
  256. //bool QuickRepair = false;
  257. //if (dt.Rows.Count > 0)
  258. //{
  259. // if (dt.Rows[0]["mb_stepcode"].ToString() == User.CurrentStepCode)
  260. // {
  261. // QuickRepair = true;
  262. // }
  263. //}
  264. string ErrorMessage = "";
  265. //验证工序是否正确
  266. if (LogicHandler.CheckStepAttribute(Tag.ToString(), User.UserSourceCode, out ErrorMessage))
  267. {
  268. BadInf_1.Clear();
  269. string oStatus = "";
  270. if (LogicHandler.GetMakeInfo(GetSNCode.Text, out macode, out oStatus, out ErrorMessage))
  271. {
  272. //验证makeserial或者ms_firstsn表序列号是否存在
  273. sql.Clear();
  274. sql.Append("select nvl(ms_badtimes,0)ms_badtimes,max(ms_id) ms_id,ms_makecode,ma_craftcode,ms_stepcode,ms_firstsn,ms_prodcode,ms_sncode,ma_bomversion,pr_detail,ms_craftcode,ms_checkno,ms_ifrework,ms_reworkcheckno,ms_beforesn ");
  275. sql.Append("from makeserial left join make on ms_makecode=ma_code left join product on pr_code=ms_prodcode where ms_makecode ='" + macode + "' and ms_sncode in(");
  276. sql.Append("select '" + GetSNCode.Text + "' from dual union select firstsn from makesnrelation where ");
  277. sql.Append("sn='" + GetSNCode.Text + "') group by ms_makecode,ms_stepcode,ms_prodcode,ma_craftcode,ms_sncode,ma_bomversion,pr_detail,ms_firstsn,ms_craftcode,ms_checkno,ms_ifrework,ms_reworkcheckno,ms_badtimes,ms_beforesn");
  278. dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
  279. if (dt.Rows.Count > 0)
  280. {
  281. msid = dt.Rows[0]["ms_id"].ToString();
  282. ms_beforesn = dt.Rows[0]["ms_beforesn"].ToString();
  283. ms_stepcode = dt.Rows[0]["ms_stepcode"].ToString();
  284. BaseUtil.SetFormValue(this.Controls, dt);
  285. //判断是否当前工单途程的上料记录
  286. firstsn = dt.Rows[0]["ms_firstsn"].ToString();
  287. string ma_bomversion = dt.Rows[0]["ma_bomversion"].ToString();
  288. int ms_badtimes = int.Parse(dt.Rows[0]["ms_badtimes"].ToString());
  289. string cdstepcode = "";
  290. //sql.Clear();
  291. //sql.Append("select cm_craftcode,cm_stepcode,cm_soncode,min(cm_indate)cm_indate,sum(case when cm_status=-1 ");
  292. //sql.Append("then 0 else 1 end)qty from craftmaterial left join product on pr_code=cm_soncode where(cm_sncode ");
  293. //sql.Append("in (select sn from makesnrelation where firstsn='" + firstsn + "' union select '" + firstsn + "' from dual)) ");
  294. //sql.Append("and cm_craftcode='" + cr_code.Text + "'and nvl(cm_lastdeco,0)<>0 group by cm_craftcode,cm_stepcode,cm_soncode having ");
  295. //sql.Append("sum(case when cm_status=-1 then 0 else 1 end)=0 order by cm_indate");
  296. sql.Clear();
  297. sql.Append("select sp_stepcode cm_stepcode,sp_craftcode cm_craftcode from stepproduct left join product on pr_code=sp_fsoncode where sp_bomversion='" + ma_bomversion + "' and ");
  298. sql.Append("sp_craftcode='" + cr_code.Text + "' And sp_mothercode ='" + ms_prodcode.Text + "' and sp_tracekind=1 ");
  299. //sql.Append("sp_craftcode=v_v_mscraftcode and sp_stepcode='' And sp_mothercode ='"+ms_prodcode.Text+"' and sp_tracekind=1");
  300. sql.Append("and not exists(select 1 from craftmaterial where cm_sncode in (select '" + firstsn + "' from dual union ");
  301. sql.Append("select sn from makesnrelation where firstsn='" + firstsn + "') and cm_makecode='" + macode + "' and ");
  302. sql.Append("cm_fsoncode=sp_fsoncode and cm_status=0) and instr((select ms_paststep from makeserial where ms_firstsn='" + firstsn + "'),sp_stepcode)>0 order by SP_DETNO asc");
  303. dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
  304. if (dt.Rows.Count < 0)
  305. {
  306. cdstepcode = dt.Rows[0]["cm_stepcode"].ToString();
  307. //如果本工序包含老化则默认选择本工序,否则选择上料的后一道工序
  308. if (dh.getFieldDataByCondition("craft left join craftdetail on cr_id=cd_crid", "nvl(cd_ifburnin,0)", "cr_code='" + cr_code.Text + "' and cr_prodcode='" + ms_prodcode.Text + "' and cd_stepcode='" + dt.Rows[0]["cm_stepcode"].ToString() + "'").ToString() != "0")
  309. cdstepcode = dt.Rows[0]["cm_stepcode"].ToString();
  310. else
  311. {
  312. string nextstep = LogicHandler.GetNextStep(dt.Rows[0]["cm_craftcode"].ToString(), dt.Rows[0]["cm_stepcode"].ToString(), ms_prodcode.Text);
  313. if (ms_paststep.Contains(nextstep))
  314. {
  315. cdstepcode = nextstep;
  316. }
  317. else
  318. {
  319. cdstepcode = dt.Rows[0]["cm_stepcode"].ToString();
  320. }
  321. }
  322. }
  323. else
  324. {
  325. sql.Clear();
  326. sql.Append("select cm_craftcode,cm_stepcode,cm_soncode,min(cm_indate)cm_indate,sum(case when cm_status=-1 ");
  327. sql.Append("then 0 else 1 end)qty from craftmaterial left join product on pr_code=cm_soncode where(cm_sncode ");
  328. sql.Append("in (select sn from makesnrelation where firstsn='" + firstsn + "' union select '" + firstsn + "' from dual)) ");
  329. sql.Append("and cm_craftcode='" + cr_code.Text + "' group by cm_craftcode,cm_stepcode,cm_soncode having ");
  330. sql.Append("sum(case when cm_status=-1 then 0 else 1 end)=0 order by cm_indate");
  331. dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
  332. if (dt.Rows.Count > 0)
  333. {
  334. cdstepcode = dt.Rows[0]["cm_stepcode"].ToString();
  335. }
  336. }
  337. if (cdstepcode == "")
  338. {
  339. //序号小于等于当前不良的序号
  340. string currentdetno = dh.getFieldDataByCondition("craft left join craftdetail on cr_id=cd_crid", "cd_detno", "cr_code='" + cr_code.Text + "' and cr_prodcode='" + ms_prodcode.Text + "' and cd_stepcode='" + ms_stepcode + "'").ToString();
  341. sql.Clear();
  342. sql.Append("select cd_stepcode from craft left join craftdetail on cr_id =cd_crid where ");
  343. sql.Append("cr_code='" + cr_code.Text + "' and cr_prodcode='" + ms_prodcode.Text + "' and ");
  344. sql.Append("nvl(cd_ifburnin,0)<>0 and cd_detno <='" + currentdetno + "'");
  345. dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
  346. if (dt.Rows.Count > 0)
  347. {
  348. cdstepcode = dt.Rows[0][0].ToString();
  349. }
  350. }
  351. //如果ms_stepcode和扣料工序均没有查到返修的工序
  352. if (cdstepcode == "")
  353. {
  354. string flowback = dh.getFieldDataByCondition("craftdetail left JOIN craft on cr_id = cd_crid", "cd_stepcode", "cr_code= '" + cr_code.Text + "' and cr_prodcode = '" + ms_prodcode.Text + "' and nvl(cd_ifflowback,0)=-1").ToString();
  355. if (flowback != "")
  356. {
  357. cdstepcode = flowback;
  358. }
  359. else
  360. {
  361. cdstepcode = ms_stepcode;
  362. }
  363. }
  364. //cd_stepcode.Text = cdstepcode;
  365. //if (dh.getFieldDataByCondition("craftdetail left JOIN craft on cr_id = cd_crid", "nvl(cd_ifinput,0)cd_ifinput", "cr_code= '" + cr_code.Text + "' and cr_prodcode = '" + ms_prodcode.Text + "' and cd_stepcode = '" + cd_stepcode.Text + "'").ToString() == "-1")
  366. // cd_stepcode.Enabled = false;
  367. //else
  368. // cd_stepcode.Enabled = true;
  369. LoadBadInfTree(sender, e);
  370. if (ms_badtimes > 3)
  371. {
  372. OperatResult.AppendText(">>SN:" + ms_sncode.Text + "累计维修次数超过3次,提示\n", Color.Red);
  373. }
  374. if (autoin.Checked)
  375. {
  376. RepairComplete_Click(sender, e);
  377. }
  378. }
  379. else OperatResult.AppendText(">>" + ErrorMessage + "\n", Color.Red);
  380. }
  381. else OperatResult.AppendText(">>" + ErrorMessage + "\n", Color.Red);
  382. }
  383. else OperatResult.AppendText(">>" + ErrorMessage + "\n", Color.Red);
  384. }
  385. }
  386. private void Make_Repair_SizeChanged(object sender, EventArgs e)
  387. {
  388. mbc_component.BringToFront();
  389. so_name.BringToFront();
  390. mbl_loc.BringToFront();
  391. bd_soncode.BringToFront();
  392. mbp_partdgv.BringToFront();
  393. mbp_part_label.BringToFront();
  394. asc.controlAutoSize(this);
  395. mbc_component.SendToBack();
  396. so_name.SendToBack();
  397. mbl_loc.SendToBack();
  398. bd_soncode.SendToBack();
  399. mbp_partdgv.SendToBack();
  400. mbp_part_label.SendToBack();
  401. }
  402. private void BadCodeTree_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
  403. {
  404. if (e.Node.Level == 0)
  405. {
  406. mb_id = e.Node.Tag.ToString();
  407. BaseUtil.CleanControlsText(bc_name, bc_code, bg_name, bg_code, mb_badremark, nrg_name, nrg_code, nr_name, nr_code, so_name, so_code, mbr_dutyname, mbr_dutycode, mbc_component);
  408. mbl_locdgv.DataSource = null;
  409. mbp_partdgv.DataSource = null;
  410. bc_name.Text = BadInf_1[mb_id]["bc_name"];
  411. bc_code.Text = BadInf_1[mb_id]["mb_badcode"];
  412. bg_name.Text = BadInf_1[mb_id]["bg_name"];
  413. bg_code.Text = BadInf_1[mb_id]["mb_bgcode"];
  414. //mb_badremark.Text = BadInf_1[mb_id]["mb_badremark"];
  415. mbr_id = "";
  416. SaveRepairInf.Enabled = true;
  417. }
  418. if (e.Node.Level == 1)
  419. {
  420. //展示父节点信息
  421. mb_id = e.Node.Parent.Tag.ToString();
  422. bc_code.Text = BadInf_1[mb_id]["mb_badcode"];
  423. bc_name.Text = BadInf_1[mb_id]["bc_name"];
  424. bg_code.Text = BadInf_1[mb_id]["mb_bgcode"];
  425. bg_name.Text = BadInf_1[mb_id]["bg_name"];
  426. //展示子节点信息
  427. mbr_id = e.Node.Tag.ToString();
  428. nrg_code.Text = BadInf_2[mbr_id]["nrg_code"];
  429. nrg_name.Text = BadInf_2[mbr_id]["nrg_name"];
  430. nr_code.Text = BadInf_2[mbr_id]["nr_code"];
  431. nr_name.Text = BadInf_2[mbr_id]["nr_name"];
  432. so_code.Text = BadInf_2[mbr_id]["so_code"];
  433. so_name.Text = BadInf_2[mbr_id]["so_name"];
  434. mbr_dutycode.Text = BadInf_2[mbr_id]["mbr_dutycode"];
  435. mbr_dutyname.Text = BadInf_2[mbr_id]["mbr_dutyname"];//mbr_remark
  436. mb_badremark.Text = BadInf_2[mbr_id]["mbr_remark"];
  437. mbc_component.Text = dh.getFieldDataByCondition("makebadrscom", "mbc_component", "mbc_mbrid=" + mbr_id).ToString();
  438. //加载两个Grid的数据源
  439. DataTable dt = (DataTable)dh.ExecuteSql("select mbp_id,mbp_part from makebadrspart where mbp_mbrid=" + mbr_id, "select");
  440. BaseUtil.FillDgvWithDataTable(mbp_partdgv, dt);
  441. dt = (DataTable)dh.ExecuteSql("select mbl_id,mbl_loc,mbl_orispeccode from makebadrsloc where mbl_mbrid=" + mbr_id, "select");
  442. BaseUtil.FillDgvWithDataTable(mbl_locdgv, dt);
  443. SaveRepairInf.Enabled = false;
  444. }
  445. }
  446. private void LoadBadInfTree(object sender, EventArgs e)
  447. {
  448. BadCodeTree.Nodes.Clear();
  449. sql.Clear();
  450. //不是返工工单时的取当前工单
  451. sql.Append("select mb_id,mb_sncode,mb_badcode,mb_bgcode,nvl(bc_name,mb_badcode) bc_name,nvl(bg_name,mb_bgcode) bg_name,");
  452. sql.Append("mb_badremark from makebad left join badcode on bc_code=mb_badcode left join badgroup ");
  453. sql.Append("on bg_code=mb_bgcode where mb_sncode='" + (GetSNCode.Text == "" ? ms_sncode.Text : GetSNCode.Text) + "' and mb_makecode='" + macode + "' and mb_status=0");
  454. dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
  455. if (dt.Rows.Count == 0)
  456. {
  457. sql.Clear();
  458. sql.Append("select mb_id,mb_sncode,mb_badcode,mb_bgcode,nvl(bc_name,mb_badcode) bc_name,nvl(bg_name,mb_bgcode) bg_name, ");
  459. sql.Append("mb_badremark from makebad left join badcode on bc_code=mb_badcode left join badgroup on bg_code=mb_bgcode ");
  460. sql.Append("left join make on ma_code=mb_makecode where mb_sncode='" + (GetSNCode.Text == "" ? ms_sncode.Text : GetSNCode.Text) + "' and mb_makecode<>'" + macode + "' and mb_status=0");
  461. dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
  462. }
  463. for (int i = 0; i < dt.Rows.Count; i++)
  464. {
  465. //添加根节点
  466. TreeNode tnode_0 = new TreeNode();
  467. string bg_name = dt.Rows[i]["bg_name"].ToString();
  468. string bc_name = dt.Rows[i]["bc_name"].ToString();
  469. string mb_badcode = dt.Rows[i]["mb_badcode"].ToString();
  470. string mb_bgcode = dt.Rows[i]["mb_bgcode"].ToString();
  471. tnode_0.Text = (bg_name == "" ? mb_bgcode : bg_name) + ":" + (bc_name == "" ? mb_bgcode : bc_name);
  472. tnode_0.Name = dt.Rows[i]["mb_bgcode"].ToString();
  473. //作为Dictionary的主标识
  474. string mb_id = dt.Rows[i]["mb_id"].ToString();
  475. tnode_0.Tag = mb_id;
  476. Dictionary<string, string> dic = new Dictionary<string, string>();
  477. dic.Add("mb_id", mb_id);
  478. dic.Add("mb_sncode", dt.Rows[i]["mb_sncode"].ToString());
  479. dic.Add("mb_badcode", dt.Rows[i]["mb_badcode"].ToString());
  480. dic.Add("mb_bgcode", dt.Rows[i]["mb_bgcode"].ToString());
  481. dic.Add("bc_name", dt.Rows[i]["bc_name"].ToString());
  482. dic.Add("bg_name", dt.Rows[i]["bg_name"].ToString());
  483. //dic.Add("mb_badremark", dt.Rows[i]["mb_badremark"].ToString());
  484. if (!BadInf_1.ContainsKey(tnode_0.Tag.ToString()))
  485. BadInf_1.Add(tnode_0.Tag.ToString(), dic);
  486. BadCodeTree.Nodes.Add(tnode_0);
  487. BadCodeTree.SelectedNode = BadCodeTree.Nodes[0];
  488. //添加子节点
  489. sql.Clear();
  490. sql.Append("select mbr_id,mbr_brcode,mbr_brgcode,mbr_solutioncode,so_code,so_name,mbr_dutycode,mbr_dutyname,nd_name,nrg_name");
  491. sql.Append(",nr_name,nr_code,nrg_code,mbr_remark from makebadreason left join QUA_NGReason on nr_code=mbr_brcode left join ");
  492. sql.Append("QUA_NGREASONGROUPdet on nrgd_nrcode=nr_code left join QUA_NGREASONGROUP on nrg_id=nrgd_nrgid and ");
  493. sql.Append("mbr_brgcode=nrg_code left join solution on so_code=mbr_solutioncode left join ngduty on nd_code=mbr_dutycode ");
  494. sql.Append("where mbr_mbid=" + mb_id);
  495. DataTable dt1 = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
  496. for (int j = 0; j < dt1.Rows.Count; j++)
  497. {
  498. TreeNode tnode_1 = new TreeNode();
  499. //存放子节点的信息
  500. Dictionary<string, string> dic1 = new Dictionary<string, string>();
  501. string mbr_id = dt1.Rows[j]["mbr_id"].ToString();
  502. tnode_1.Tag = mbr_id;
  503. dic1.Add("mbr_id", mbr_id);
  504. dic1.Add("mbr_brcode", dt1.Rows[j]["mbr_id"].ToString());
  505. dic1.Add("mbr_brgcode", dt1.Rows[j]["mbr_brcode"].ToString());
  506. dic1.Add("mbr_solutioncode", dt1.Rows[j]["mbr_solutioncode"].ToString());
  507. dic1.Add("mbr_dutycode", dt1.Rows[j]["mbr_dutycode"].ToString());
  508. dic1.Add("mbr_dutyname", dt1.Rows[j]["mbr_dutyname"].ToString());
  509. dic1.Add("mbr_remark", dt1.Rows[j]["mbr_remark"].ToString());
  510. dic1.Add("nd_name", dt1.Rows[j]["nd_name"].ToString());
  511. dic1.Add("so_name", dt1.Rows[j]["so_name"].ToString());
  512. dic1.Add("so_code", dt1.Rows[j]["so_code"].ToString());
  513. dic1.Add("nrg_name", dt1.Rows[j]["nrg_name"].ToString());
  514. dic1.Add("nrg_code", dt1.Rows[j]["nrg_code"].ToString());
  515. dic1.Add("nr_name", dt1.Rows[j]["nr_name"].ToString());
  516. dic1.Add("nr_code", dt1.Rows[j]["nr_code"].ToString());
  517. tnode_1.Text = dt1.Rows[j]["nr_name"].ToString();
  518. if (!BadInf_2.ContainsKey(mbr_id))
  519. BadInf_2.Add(mbr_id, dic1);
  520. tnode_0.Nodes.Add(tnode_1);
  521. }
  522. }
  523. try
  524. {
  525. if (bg_code.Text != "")
  526. BadCodeTree.Nodes[bg_code.Text].Expand();
  527. LoadBadcodeGroup();
  528. }
  529. catch (Exception) { }
  530. }
  531. private void RefreshTreeView_Click(object sender, EventArgs e)
  532. {
  533. LoadBadInfTree(sender, e);
  534. }
  535. private void RepairComplete_Click(object sender, EventArgs e)
  536. {
  537. if (ms_sncode.Text == "")
  538. {
  539. OperatResult.AppendText(">>序列号不允许为空\n", Color.Red);
  540. return;
  541. }
  542. if (ifrework != "0" && reworkstatus == "0")
  543. {
  544. if (dh.getRowCount("Makebad", "mb_sncode='" + ms_sncode.Text + "' and mb_makecode='" + ms_makecode.Text + "' and mb_status=0") == 0)
  545. {
  546. OperatResult.AppendText(">>维修必须维护不良代码\n", Color.Red);
  547. return;
  548. }
  549. }
  550. //判断是否所有的不良信息都有维护不良原因
  551. DataTable dt = (DataTable)dh.ExecuteSql("select mb_id,bc_name,mbr_mbid from makebad left join makebadreason on mbr_mbid=mb_id left join badcode on mb_badcode=bc_code where mb_sncode='" + ms_sncode.Text + "' and mb_makecode='" + ms_makecode.Text + "' and mb_status=0", "select");
  552. string ErrorMessage = "";
  553. for (int i = 0; i < dt.Rows.Count; i++)
  554. {
  555. if (dt.Rows[i]["mb_id"].ToString() != dt.Rows[i]["mbr_mbid"].ToString())
  556. ErrorMessage += "【" + dt.Rows[i]["bc_name"].ToString() + "】";
  557. }
  558. if (ErrorMessage != "")
  559. {
  560. OperatResult.AppendText(">>" + ErrorMessage + "未维护不良原因\n", Color.Red);
  561. return;
  562. }
  563. //如果岗位资源对应工序的版面不为空的时候
  564. if (dh.getFieldDataByCondition("makeserial left join step on ms_stepcode=st_code", "st_table", "ms_id='" + msid + "'").ToString() != "")
  565. {
  566. if (!dh.CheckExist("makebadrsloc", "mbl_mbrid='" + mbr_id + "' and mbl_makecode='" + ms_makecode.Text + "' and mbl_sncode='" + GetSNCode.Text + "' "))
  567. {
  568. OperatResult.AppendText(">>工序存在版面必须维护不良位置\n", Color.Red);
  569. return;
  570. }
  571. }
  572. if (dh.getFieldDataByCondition("product", "nvl(pr_isreturn,0)", "pr_code='" + ms_prodcode.Text + "'").ToString() == "-1")
  573. {
  574. OperatResult.AppendText(">>产品" + ms_prodcode.Text + "不允许回流\n", Color.Red);
  575. return;
  576. }
  577. ////查询拆解的物料
  578. //sql.Clear();
  579. //sql.Append("select distinct cm_soncode from craftmaterial where cm_sncode in (select '" + firstsn + "' from dual union ");
  580. //sql.Append("select sn from makesnrelation where firstsn='" + firstsn + "') and cm_craftcode<>'" + cr_code.Text + "' and cm_makecode<>'" + ms_makecode.Text + "' and cm_status=-1 ");
  581. //dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
  582. ////如果含有序列号物料有被拆解过
  583. //if (dt.Rows.Count > 0)
  584. //{
  585. // string soncode = "";
  586. // for (int i = 0; i < dt.Rows.Count; i++)
  587. // {
  588. // soncode += "'" + dt.Rows[i][0].ToString() + "',";
  589. // }
  590. // //查询对应的上料记录
  591. // sql.Clear();
  592. // sql.Append("select cm_soncode from craftmaterial where cm_sncode in (select '" + firstsn + "' from dual union select sn from ");
  593. // sql.Append(" makesnrelation where firstsn='" + firstsn + "') and cm_status=0 and cm_soncode in (" + soncode.Substring(0, soncode.Length - 1) + ")");
  594. // DataTable LoadSoncode = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
  595. // //查询的结果不相等表示未完成上料
  596. // if (dt.Rows.Count != LoadSoncode.Rows.Count)
  597. // {
  598. // for (int i = 0; i < LoadSoncode.Rows.Count; i++)
  599. // {
  600. // if (soncode.Contains(LoadSoncode.Rows[i][0].ToString()))
  601. // {
  602. // soncode = soncode.Replace(LoadSoncode.Rows[i][0].ToString(), "");
  603. // }
  604. // }
  605. // OperatResult.AppendText(">>" + soncode.Replace("'", "") + "物料尚未备料,不允许回流\n", Color.Red);
  606. // return;
  607. // }
  608. //}
  609. dt = (DataTable)dh.ExecuteSql("select cr_id from craft where cr_statuscode='AUDITED' and cr_code='" + cr_code.Text + "'", "select");
  610. if (dt.Rows.Count == 0)
  611. OperatResult.AppendText(">>回流工序不存在\n", Color.Red);
  612. else
  613. {
  614. string cr_id = dt.Rows[0]["cr_id"].ToString();
  615. dt = (DataTable)dh.ExecuteSql("select cd_ifinput from craftdetail left join step on st_code=cd_stepcode where cd_crid='" + cr_id + "' and cd_stepcode='" + cd_stepcode.Text + "' and st_statuscode='AUDITED'", "select");
  616. if (dt.Rows.Count == 0)
  617. OperatResult.AppendText(">>回流工序不在回流工艺中\n", Color.Red);
  618. else
  619. {
  620. dt = dh.getFieldsDataByCondition("makeserial", new string[] { "nvl(ms_ifrework,0) ms_ifrework", "ms_paststep" }, "ms_sncode='" + ms_sncode.Text + "' and ms_makecode='" + macode + "'");
  621. List<string> SQLS = new List<string>();
  622. if (dt.Rows.Count > 0)
  623. {
  624. string ms_ifrework = dt.Rows[0]["ms_ifrework"].ToString();
  625. string ms_paststep = dt.Rows[0]["ms_paststep"].ToString();
  626. //如果回流的执行过的工序为空
  627. //if (!ms_paststep.Contains(cd_stepcode.Text) && ms_paststep != "")
  628. //{
  629. // OperatResult.AppendText(">>不允许回流到未执行的工序\n", Color.Red);
  630. // return;
  631. //}
  632. if (ms_ifrework == "0")
  633. SQLS.Add("update makeserial set ms_checkno='',ms_paststep = ms_paststep || case when instr(','||ms_paststep||',','" + User.CurrentStepCode + "')=0 then ','||'" + User.CurrentStepCode + "' end , ms_nextstepcode ='" + cd_stepcode.Text + "',ms_craftcode='" + cr_code.Text + "',ms_stepcode='" + User.CurrentStepCode + "',ms_status=1 where ms_id='" + msid + "'");
  634. else
  635. SQLS.Add("update makeserial set ms_checkno='',ms_paststep = ms_paststep || case when instr(','||ms_paststep||',','" + User.CurrentStepCode + "')=0 then ','||'" + User.CurrentStepCode + "' end , ms_nextstepcode ='" + cd_stepcode.Text + "',ms_craftcode='" + cr_code.Text + "',ms_stepcode='" + User.CurrentStepCode + "',ms_reworkstatus=1 where ms_id='" + msid + "'");
  636. }
  637. SQLS.Add("update makebad set mb_status=-1,mb_okman ='" + User.UserName + "',MB_OKTIME = sysdate where mb_sncode='" + ms_sncode.Text + "' and mb_makecode='" + ms_makecode.Text + "' and mb_status = 0");
  638. //取消最近拆解部件
  639. SQLS.Add("update craftmaterial set cm_status=-1 where cm_sncode='" + ms_sncode.Text + "' and cm_makecode='" + ms_makecode.Text + "' and CM_MATERIALTYPE = 1 ");
  640. if (ms_beforesn != "")
  641. {
  642. SQLS.Add("update makeserial set ms_sncode = ms_firstsn,ms_beforesn = '' where ms_id='" + msid + "'");
  643. SQLS.Add("update makebad set mb_sncode = mb_mscode where mb_sncode='" + ms_sncode.Text + "' and mb_makecode='" + ms_makecode.Text + "' ");
  644. SQLS.Add("update MAKEBADREASON set mbr_sncode = '" + ms_beforesn + "' where mbr_sncode='" + ms_sncode.Text + "' and mbr_makecode='" + ms_makecode.Text + "' ");
  645. SQLS.Add("delete MAKESNRELATION where beforesn = '" + ms_beforesn + "'");
  646. }
  647. //if (checkBox1.Checked)
  648. //{
  649. // if (dh.CheckExist("makeserial", "ms_sncode = '" + ms_sncode.Text + "' and ms_makecode = '" + ms_makecode.Text + "' and ms_key is not null"))
  650. // {
  651. // SQLS.Add("update makeserial set ms_bs = '',MS_IFCCLEAN ='Y',ms_key='',ms_keyid='',MS_HARDWREID='',MS_KEYSTATEID='',MS_BIOS='',ms_ec='',ms_uuid='',MS_KEYPARTNUMBER='',ms_bt='',ms_mac='',ms_imei='',ms_imei1='' where ms_sncode = '" + ms_sncode.Text + "' and ms_makecode = '" + ms_makecode.Text + "'");
  652. // LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, macode, User.UserLineCode, User.UserSourceCode, "需要清空写入信息", "需要清空写入信息", ms_sncode.Text, ms_checkno.Text);
  653. // }
  654. // else {
  655. // SQLS.Add("update makeserial set ms_bs = '',ms_key='',ms_keyid='',MS_HARDWREID='',MS_KEYSTATEID='',MS_BIOS='',ms_ec='',ms_uuid='',MS_KEYPARTNUMBER='',ms_bt='',ms_mac='',ms_imei='',ms_imei1='' where ms_sncode = '" + ms_sncode.Text + "' and ms_makecode = '" + ms_makecode.Text + "'");
  656. // }
  657. // }
  658. //SQLS.Add("update MakeBadCount set mbc_status=-1 where mbc_sncode='" + ms_sncode.Text + "'");
  659. dh.ExecuteSQLTran(SQLS.ToArray());
  660. LogicHandler.InsertMakeProcess(ms_sncode.Text, ms_makecode.Text, User.UserSourceCode, "回流工序", "完成维修回流", User.UserCode);
  661. LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, macode, User.UserLineCode, User.UserSourceCode, "回流工序", "完成维修回流", ms_sncode.Text, ms_checkno.Text);
  662. OperatResult.AppendText(">>序列号" + ms_sncode.Text + "回流成功\n", Color.Green);
  663. string cdstepcode = cd_stepcode.Text;
  664. cd_stepcode.Enabled = true;
  665. BaseUtil.CleanForm(this);
  666. cd_stepcode.Text = cdstepcode;
  667. BadCodeTree.Nodes.Clear();
  668. GetSNCode.Clear();
  669. GetSNCode.Focus();
  670. i = 0;
  671. }
  672. }
  673. }
  674. private void Scrap_Click(object sender, EventArgs e)
  675. {
  676. if (ms_sncode.Text != "")
  677. {
  678. //判断是否有无法维修的记录
  679. int ScrapNum = int.Parse(dh.getFieldDataByCondition("makebadreason left join makebad on mb_id=mbr_mbid", "count(0) cn", "mb_sncode='" + ms_sncode.Text + "' and mb_status=0").ToString());
  680. if (ScrapNum == 0)
  681. OperatResult.AppendText(">>" + ms_sncode.Text + "报废必须维护不良原因\n", Color.Red);
  682. else
  683. {
  684. string confirm = MessageBox.Show(this.ParentForm, "此操作不可撤销,是否确认报废", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Asterisk).ToString();
  685. if (confirm == "Yes")
  686. {
  687. DataTable dt = dh.getFieldsDataByCondition("makeserial", new string[] { "nvl(ms_ifrework,0)ms_ifrework", "ms_reworkcode", "ms_code" }, "ms_sncode='" + ms_sncode.Text + "' and ms_makecode='" + macode + "'");
  688. if (dt.Rows.Count > 0)
  689. {
  690. string ms_ifrework = dt.Rows[0]["ms_ifrework"].ToString();
  691. string reworkcode = dt.Rows[0]["ms_reworkcode"].ToString();
  692. string ms_code = dt.Rows[0]["ms_code"].ToString();
  693. if (ms_ifrework == "0")
  694. {
  695. dh.UpdateByCondition("makeserial", "ms_paststep = ms_paststep ||'," + User.CurrentStepCode + "',ms_status=4,ms_nextstepcode=''", "ms_sncode='" + ms_sncode.Text + "' and ms_makecode='" + macode + "'");
  696. }
  697. else
  698. {
  699. sqls.Clear();
  700. sqls.Add("update makeserial set ms_paststep = ms_paststep ||'," + User.CurrentStepCode + "',ms_status=4,ms_reworkstatus= 4,ms_nextstepcode='' where ms_sncode='" + ms_sncode.Text + "' and ms_makecode='" + macode + "'");
  701. sqls.Add("update oqcbatch set ob_nowcheckqty=ob_nowcheckqty-1 where ob_checkno='" + ms_reworkcheckno.Text + "'");
  702. sqls.Add("delete from oqcbatchdetail where obd_sncode='" + ms_sncode.Text + "' and obd_checkno='" + ms_reworkcheckno.Text + "'");
  703. sqls.Add("update ReworkDetail set rd_rwstatus='报废' where rd_reid=(select re_id from rework where re_code='" + reworkcode + "') and rd_sncode='" + reworkcode + "'");
  704. dh.ExecuteSQLTran(sqls.ToArray());
  705. }
  706. dh.ExecuteSql("update MAKESOURCESTOCK set mss_remain = mss_remain + MSS_BASEQTY,MSS_INVALIDTIME = null,mss_useqty = mss_useqty-MSS_BASEQTY where mss_barcode in (select cm_barcode from CRAFTMATERIAL where cm_mscode = '" + ms_code + "' and cm_makecode = '" + macode + "' and cm_status = 0) and mss_makecode = '" + macode + "' ", "update");
  707. dh.ExecuteSql(" merge into barcode using (select cm_barcode,cm_inqty from CRAFTMATERIAL where cm_mscode = '" + ms_code + "' and cm_makecode = '" + macode + "' and cm_status = 0) A on (barcode.bar_code = A.cm_barcode) when matched then update set bar_remain = bar_remain + cm_inqty ", "update");
  708. }
  709. dh.ExecuteSql("update makebad set mb_status=-2,mb_okman ='" + User.UserName + "' where mb_sncode='" + ms_sncode.Text + "' and mb_makecode='" + ms_makecode.Text + "' and mb_status = 0", "update");
  710. dh.UpdateByCondition("makecraftdetail", "mcd_inqty=mcd_inqty-1,mcd_outqty=mcd_outqty-1", "mcd_macode='" + ms_makecode.Text + "' and mcd_stepcode='" + ms_stepcode + "'");
  711. dh.UpdateByCondition("make", "MA_NGMADEQTY=nvl(MA_NGMADEQTY,0)+1,ma_qty = ma_qty+1", "ma_code='" + macode + "'");
  712. LogicHandler.InsertMakeProcess(ms_sncode.Text, ms_makecode.Text, User.UserSourceCode, "报废", "序列号报废", User.UserCode);
  713. LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, macode, User.UserLineCode, User.UserSourceCode, "报废", "序列号报废", ms_sncode.Text, ms_checkno.Text);
  714. OperatResult.AppendText(">>报废成功\n", Color.Green);
  715. GetSNCode.Clear();
  716. GetSNCode.Focus();
  717. BaseUtil.CleanForm(this);
  718. BadCodeTree.Nodes.Clear();
  719. }
  720. }
  721. }
  722. else OperatResult.AppendText(">>序列号不允许为空\n", Color.Red);
  723. }
  724. private void NewBadCode_Click(object sender, EventArgs e)
  725. {
  726. if (GetSNCode.Text == "" || macode == null || macode == "")
  727. {
  728. OperatResult.AppendText(">>序列号和工单号不允许为空\n", Color.Red);
  729. }
  730. else
  731. {
  732. Make_NewBadCode badcode = new Make_NewBadCode(GetSNCode.Text, macode);
  733. badcode.FormClosed += LoadBadInfTree;
  734. BaseUtil.SetFormCenter(badcode);
  735. badcode.ShowDialog();
  736. }
  737. }
  738. private void NewRepairInf_Click(object sender, EventArgs e)
  739. {
  740. if (bg_name.Text == "" && bc_name.Text == "")
  741. {
  742. OperatResult.AppendText(">>不良代码组和不良代码不能为空\n", Color.Red);
  743. }
  744. else
  745. {
  746. Make_NewMatainInf mataininf = new Make_NewMatainInf(bg_name.Text, bg_code.Text, bc_name.Text, bc_code.Text, GetSNCode.Text, msid, mb_id);
  747. mataininf.FormClosed += LoadBadInfTree;
  748. BaseUtil.SetFormCenter(mataininf);
  749. mataininf.ShowDialog();
  750. }
  751. }
  752. private void SaveRepairInf_Click(object sender, EventArgs e)
  753. {
  754. string ErrorMessage = "";
  755. if (bg_name.Text == "" || bc_name.Text == "")
  756. {
  757. OperatResult.AppendText(">>不良代码组和不良代码不能为空\n", Color.Red);
  758. return;
  759. }
  760. if (nrg_name.Text == "")
  761. ErrorMessage += " 不良原因组 ";
  762. if (nr_name.Text == "")
  763. ErrorMessage += " 不良原因 ";
  764. if (mbr_dutyname.Text == "")
  765. ErrorMessage += " 责任别 ";
  766. //if (mbr_dutyname.Text == "物料问题" && mbc_component.Text == "")
  767. // ErrorMessage += "责任别为物料问题时必须选择不良零件";
  768. if (ErrorMessage != "")
  769. {
  770. ErrorMessage += "不能为空";
  771. OperatResult.AppendText(">>" + ErrorMessage + "\n", Color.Red);
  772. return;
  773. }
  774. string mbr_id = dh.GetSEQ("makebadreason_seq");
  775. //存在不良组件进行提示
  776. if (dh.CheckExist("makebadreason left join makebad on mbr_mbid=mb_id and mbr_sncode=mb_sncode", "mbr_badcode='" + bc_code.Text + "' and mbr_sncode='" + ms_sncode.Text + "' and mbr_brcode='" + nr_code.Text + "' and mb_status=0"))
  777. {
  778. OperatResult.AppendText(">>不良代码【" + bc_name.Text + "】已存在不良原因【" + nr_name.Text + "】\n", Color.Red);
  779. return;
  780. }
  781. if (!dh.CheckExist("QUA_NGREASONGROUP", "nrg_name='" + nrg_name.Text + "'"))
  782. {
  783. OperatResult.AppendText(">>不良原因组不存在\n", Color.Red);
  784. return;
  785. }
  786. if (!dh.CheckExist("QUA_NGReason", "nr_name='" + nr_name.Text + "'"))
  787. {
  788. OperatResult.AppendText(">>不良原因不存在\n", Color.Red);
  789. return;
  790. }
  791. if (!dh.CheckExist("ngduty", "nd_name='" + mbr_dutyname.Text + "'"))
  792. {
  793. OperatResult.AppendText(">>责任别不存在\n", Color.Red);
  794. return;
  795. }
  796. if (!dh.CheckExist("solution", "so_name='" + so_name.Text + "'"))
  797. {
  798. OperatResult.AppendText(">>解决方案不存在\n", Color.Red);
  799. return;
  800. }
  801. //保存选择记录至后台,根据岗位资源代码记录
  802. dh.ExecuteSql("merge into DATAINPUTRECORD using (select NRG_NAME from QUA_NGREASONGROUP where NRG_NAME = '" + nrg_name.Text + "') ON (NRG_NAME = DIR_COMMENT AND DIR_GROUP = '不良原因组' and DIR_SOURCECODE = '" + User.UserSourceCode + "') when matched then update set DIR_NUMBER = DIR_NUMBER +1 when not matched then insert (DIR_COMMENT,DIR_NUMBER,DIR_SOURCECODE,DIR_GROUP) VALUES (NRG_NAME,1,'" + User.UserSourceCode + "','不良原因组')", "select");
  803. dh.ExecuteSql("merge into DATAINPUTRECORD using (select nr_name from QUA_NGReason left join QUA_NGREASONGROUPDET on nrgd_nrcode=nr_code left join QUA_NGREASONGROUP on nrgd_nrgid=nrg_id where nr_name = '" + nr_name.Text + "' and NRG_NAME = '" + nrg_name.Text + "') ON (nr_name = DIR_COMMENT AND DIR_GROUP = '不良原因' and DIR_SOURCECODE = '" + User.UserSourceCode + "') when matched then update set DIR_NUMBER = DIR_NUMBER +1 when not matched then insert (DIR_COMMENT,DIR_NUMBER,DIR_SOURCECODE,DIR_GROUP) VALUES (nr_name,1,'" + User.UserSourceCode + "','不良原因')", "select");
  804. dh.ExecuteSql("merge into DATAINPUTRECORD using (select nd_name from ngduty where nd_name = '" + mbr_dutyname.Text + "') ON (nd_name = DIR_COMMENT AND DIR_GROUP = '责任别' and DIR_SOURCECODE = '" + User.UserSourceCode + "') when matched then update set DIR_NUMBER = DIR_NUMBER +1 when not matched then insert (DIR_COMMENT,DIR_NUMBER,DIR_SOURCECODE,DIR_GROUP) VALUES (nd_name,1,'" + User.UserSourceCode + "','责任别')", "select");
  805. dh.ExecuteSql("merge into DATAINPUTRECORD using (select so_name from solution where so_name = '" + so_name.Text + "') ON (so_name = DIR_COMMENT AND DIR_GROUP = '解决方案' and DIR_SOURCECODE = '" + User.UserSourceCode + "') when matched then update set DIR_NUMBER = DIR_NUMBER +1 when not matched then insert (DIR_COMMENT,DIR_NUMBER,DIR_SOURCECODE,DIR_GROUP) VALUES (so_name,1,'" + User.UserSourceCode + "','解决方案')", "select");
  806. //保存不良原因
  807. sql.Clear();
  808. sql.Append("insert into makebadreason (mbr_mbid,mbr_id,mbr_brcode,mbr_solutioncode,");
  809. sql.Append("mbr_dutycode,mbr_brgcode,mbr_badcode,mbr_sncode,mbr_makecode,mbr_indate,");
  810. sql.Append("mbr_inman,mbr_brname,mbr_solutionname,mbr_badname,mbr_brgname,mbr_dutyname,mbr_remark) select '" + mb_id + "','" + mbr_id + "','" + nr_code.Text + "',");
  811. sql.Append("'" + so_code.Text + "','" + mbr_dutyname.Text + "','" + nrg_code.Text + "','" + bc_code.Text + "',");
  812. sql.Append("'" + ms_sncode.Text + "','" + ms_makecode.Text + "',sysdate,'" + User.UserCode + "','" + nr_name.Text + "','" + so_name.Text + "','" + bc_name.Text + "','" + nrg_name.Text + "','" + mbr_dutyname.Text + "','" + mb_badremark.Text + "' from dual");
  813. dh.ExecuteSql(sql.GetString(), "insert");
  814. if (mbc_component.Text != "")
  815. {
  816. sql.Clear();
  817. sql.Append("insert into makebadrscom (mbc_id,mbc_mbrid,mbc_component,mbc_badcode,");
  818. sql.Append("mbc_brcode,mbc_sncode,mbc_makecode,mbc_indate,mbc_inman ) values ");
  819. sql.Append("(makebadrscom_seq.nextval,'" + mbr_id + "' ,'" + mbc_component.Text + "',");
  820. sql.Append("'" + bc_code.Text + "','" + nr_code.Text + "','" + ms_sncode.Text + "','" + ms_makecode.Text + "',sysdate,'" + User.UserCode + "')");
  821. dh.ExecuteSql(sql.GetString(), "insert");
  822. }
  823. OperatResult.AppendText(">>不良原因保存成功\n", Color.Green);
  824. SaveRepairInf.Enabled = false;
  825. LoadBadInfTree(sender, e);
  826. }
  827. private void DeleteRepairInf_Click(object sender, EventArgs e)
  828. {
  829. DataTable dt = (DataTable)dh.ExecuteSql("select ms_makecode from makeserial where ms_id='" + msid + "' and ms_sncode='" + GetSNCode.Text + "' and ms_status=3", "select");
  830. if (dt.Rows.Count > 0)
  831. {
  832. if (mbr_id != "")
  833. {
  834. string delete1 = "delete from makebadrsloc where mbl_mbrid='" + mbr_id + "'";
  835. string delete2 = "delete from makebadrspart where mbp_mbrid='" + mbr_id + "'";
  836. string delete3 = "delete from makebadrscom where mbc_mbrid='" + mbr_id + "'";
  837. string delete4 = "delete from makebadreason where mbr_id='" + mbr_id + "'";
  838. dh.ExecuteSQLTran(delete1, delete2, delete3, delete4);
  839. OperatResult.AppendText(">>删除成功\n", Color.Green);
  840. BaseUtil.CleanControlsText(bc_name, bc_code, bg_name, bg_code, mb_badremark, nrg_name, nrg_code, nr_name, nr_code, so_name, so_code, mbr_dutyname, mbr_dutycode, mbc_component);
  841. mbp_partdgv.DataSource = null;
  842. mbl_locdgv.DataSource = null;
  843. mbr_id = "";
  844. //删除后重新加载Tree的信息
  845. LoadBadInfTree(sender, e);
  846. }
  847. else OperatResult.AppendText(">>必须选择不良原因\n", Color.Red);
  848. }
  849. else OperatResult.AppendText(">>" + GetSNCode.Text + "序列号错误,不存在或者不处于维修状态\n", Color.Red);
  850. }
  851. private void SaveBadLocation_Click(object sender, EventArgs e)
  852. {
  853. DataTable dt = (DataTable)dh.ExecuteSql("select ms_makecode from makeserial where ms_id='" + msid + "' and ms_sncode='" + GetSNCode.Text + "' and ms_status=3", "select");
  854. if (dt.Rows.Count > 0)
  855. {
  856. if (mbl_loc.Text != "")
  857. {
  858. if (mbr_id != "")
  859. {
  860. if (!dh.CheckExist("makebadrsloc", "mbl_mbrid='" + mbr_id + "' and mbl_sncode='" + GetSNCode.Text + "' and mbl_loc='" + mbl_loc.Text + "'"))
  861. {
  862. if (dh.CheckExist("barcode", "bar_code = '" + mbl_loc.Text + "'"))
  863. {
  864. string MBL_PRODCODE = dh.getFieldDataByCondition("barcode", "bar_prodcode", "bar_code = '" + mbl_loc.Text + "'").ToString();
  865. string orpspeccode = dh.getFieldDataByCondition("product", "pr_orispeccode", "pr_code = '" + MBL_PRODCODE + "'").ToString();
  866. string items = "";
  867. for (int i = 0; i < WaitRejectList.Items.Count; i++)
  868. {
  869. if (WaitRejectList.Items[i].Checked)
  870. {
  871. items += WaitRejectList.Items[i].SubItems[1].Text.ToString() + ",";
  872. }
  873. }
  874. if (dh.CheckExist("MAKEMATERIAL", "mm_code = '" + macode + "' and mm_prodcode||mm_repprodcode like '%" + MBL_PRODCODE + "%'"))
  875. {
  876. sql.Clear();
  877. sql.Append("insert into makebadrsloc(mbl_id,mbl_mbrid,mbl_loc,mbl_badcode,mbl_brcode,");
  878. sql.Append("mbl_sncode,mbl_makecode,mbl_indate ,mbl_inman,MBL_PRODCODE,MBL_ORISPECCODE,mbl_compents) select makebadrsloc_seq.nextval," + mbr_id);
  879. sql.Append(",'" + mbl_loc.Text + "','" + bc_code.Text + "','" + nr_code.Text + "','" + GetSNCode.Text + "','" + macode + "',");
  880. sql.Append("sysdate,'" + User.UserCode + "','" + MBL_PRODCODE + "','" + orpspeccode + "','" + items + "' from dual");
  881. dh.ExecuteSql(sql.GetString(), "insert");
  882. dt = (DataTable)dh.ExecuteSql("select mbl_id,mbl_loc,mbl_orispeccode from makebadrsloc where mbl_mbrid=" + mbr_id, "select");
  883. BaseUtil.FillDgvWithDataTable(mbl_locdgv, dt);
  884. }
  885. else
  886. OperatResult.AppendText(">>该维修条码对应物料" + MBL_PRODCODE + "不属于此工单可用物料\n", Color.Red, mbl_loc);
  887. }
  888. else
  889. OperatResult.AppendText(">>该维修条码" + mbl_loc.Text + "系统不存在\n", Color.Red, mbl_loc);
  890. }
  891. else OperatResult.AppendText(">>已存在该维修条码\n", Color.Red, mbl_loc);
  892. }
  893. else OperatResult.AppendText(">>请先选择不良原因\n", Color.Red);
  894. }
  895. else OperatResult.AppendText(">>维修条码不能为空\n", Color.Red);
  896. }
  897. else OperatResult.AppendText(">>" + GetSNCode.Text + "序列号错误,不存在或者不处于维修状态\n", Color.Red);
  898. }
  899. private void nr_name_TextChanged(object sender, EventArgs e)
  900. {
  901. if (nr_name.Text == "")
  902. SaveBadLocation.Enabled = false;
  903. else
  904. SaveBadLocation.Enabled = true;
  905. }
  906. private void mbl_loc_KeyDown(object sender, KeyEventArgs e)
  907. {
  908. if (e.KeyCode == Keys.Enter)
  909. SaveBadLocation_Click(sender, e);
  910. }
  911. private void prodcode_TextKeyDown(object sender, KeyEventArgs e)
  912. {
  913. if (e.KeyCode == Keys.Enter)
  914. {
  915. if (bd_soncode.Text != "")
  916. {
  917. if (mbr_id != "")
  918. {
  919. sql.Clear();
  920. sql.Append("insert into makebadrspart(mbp_id,mbp_mbrid,mbp_part,mbp_badcode,");
  921. sql.Append("mbp_brcode,mbp_sncode,mbp_makecode,mbp_indate,mbp_inman)");
  922. sql.Append("select makebadrspart_seq.nextval," + mbr_id + ",'" + bd_soncode.Text + "',");
  923. sql.Append("'" + bc_code.Text + "','" + nr_code.Text + "','" + GetSNCode.Text + "','" + macode + "',");
  924. sql.Append("sysdate,'" + User.UserCode + "' from dual");
  925. dh.ExecuteSql(sql.GetString(), "insert");
  926. DataTable dt = (DataTable)dh.ExecuteSql("select mbp_id,mbp_part from makebadrspart where mbp_mbrid=" + mbr_id, "select");
  927. BaseUtil.FillDgvWithDataTable(mbp_partdgv, dt);
  928. }
  929. else OperatResult.AppendText(">>请先选择不良原因\n", Color.Red);
  930. }
  931. else OperatResult.AppendText(">>不良零件不能为空\n", Color.Red);
  932. }
  933. }
  934. private void cr_code_UserControlTextChanged(object sender, EventArgs e)
  935. {
  936. //cd_stepcode.Condition = "ST_STATUSCODE='AUDITED' and cr_code='" + cr_code.Text + "' and cr_prodcode='" + ms_prodcode.Text + "' and ( cd_ifburnout <>0) order by cd_stepno";
  937. cd_stepcode.Condition = "ST_STATUSCODE='AUDITED' and cr_code='" + cr_code.Text + "' and cr_prodcode='" + ms_prodcode.Text + "' and ST_IFOFFLINE = -1 order by cd_stepno";
  938. }
  939. private void Clean_Click(object sender, EventArgs e)
  940. {
  941. OperatResult.Clear();
  942. }
  943. private void mbl_locdgv_CellContentClick(object sender, DataGridViewCellEventArgs e)
  944. {
  945. if (e.RowIndex >= 0)
  946. {
  947. if (mbl_locdgv.Columns[e.ColumnIndex].Name == "DeletePos")
  948. {
  949. dh.ExecuteSql("delete from makebadrsloc where mbl_id='" + mbl_locdgv.Rows[e.RowIndex].Cells["mbl_id"].Value.ToString() + "'", "insert");
  950. dt = (DataTable)dh.ExecuteSql("select mbl_id,mbl_loc,mbl_orispeccode from makebadrsloc where mbl_mbrid=" + mbr_id, "select");
  951. BaseUtil.FillDgvWithDataTable(mbl_locdgv, dt);
  952. }
  953. }
  954. }
  955. private void mbp_partdgv_CellContentClick(object sender, DataGridViewCellEventArgs e)
  956. {
  957. if (e.RowIndex >= 0)
  958. {
  959. if (mbp_partdgv.Columns[e.ColumnIndex].Name == "DeleteCom")
  960. {
  961. dh.ExecuteSql("delete from makebadrspart where mbp_id='" + mbp_partdgv.Rows[e.RowIndex].Cells["mbp_id"].Value.ToString() + "'", "insert");
  962. DataTable dt = (DataTable)dh.ExecuteSql("select mbp_id,mbp_part from makebadrspart where mbp_mbrid=" + mbr_id, "select");
  963. BaseUtil.FillDgvWithDataTable(mbp_partdgv, dt);
  964. }
  965. }
  966. }
  967. private void Make_Repair_FormClosing(object sender, FormClosingEventArgs e)
  968. {
  969. dh.Dispose();
  970. }
  971. private void ms_prodcode_TextChanged(object sender, EventArgs e)
  972. {
  973. if (ms_prodcode.Text != "")
  974. cr_code.Condition = "cr_prodcode='" + ms_prodcode.Text + "'";
  975. else
  976. cr_code.Condition = "";
  977. bd_soncode.Condition = "bd_mothercode='" + ms_prodcode.Text + "' and NVL(bd_usestatus,' ')<>'DISABLE'";
  978. //设置工序的条件
  979. //cd_stepcode.Condition = "ST_STATUSCODE='AUDITED' and cr_code='" + cr_code.Text + "' and cr_prodcode='" + ms_prodcode.Text + "' and ( cd_ifburnout <>0) order by cd_stepno";
  980. cd_stepcode.Condition = "ST_STATUSCODE='AUDITED' and cr_code='" + cr_code.Text + "' and cr_prodcode='" + ms_prodcode.Text + "' and ST_IFOFFLINE = -1 order by cd_stepno";
  981. }
  982. public void RefreshData()
  983. {
  984. GetSNCode_KeyDown(new object(), new KeyEventArgs(Keys.Enter));
  985. }
  986. private void nr_name_UserControlTextChanged(object sender, EventArgs e)
  987. {
  988. if (nr_name.Text != "")
  989. {
  990. SaveBadLocation.Enabled = true;
  991. if (nrg_name.Text == "")
  992. {
  993. OperatResult.AppendText(">>请先填写不良代码组\n", Color.Red);
  994. nr_name.Text = "";
  995. }
  996. else
  997. {
  998. if (nr_code.Text == "" || (nr_code.Text != "" && nr_code.Text != nr_name.Value))
  999. nr_code.Text = nr_name.Value;
  1000. }
  1001. }
  1002. else SaveBadLocation.Enabled = false;
  1003. }
  1004. private void nrg_name_UserControlTextChanged(object sender, EventArgs e)
  1005. {
  1006. if (nrg_code.Text == "" || (nrg_code.Text != "" && nrg_code.Text != nrg_name.Value))
  1007. nrg_code.Text = nrg_name.Value;
  1008. nr_name.Condition = "nrg_code in('" + (nrg_code.Text == "" ? "''" : nrg_code.Text) + "')";
  1009. }
  1010. private void mbr_dutyname_UserControlTextChanged(object sender, EventArgs e)
  1011. {
  1012. if (mbr_dutycode.Text == "" || (mbr_dutycode.Text != "" && mbr_dutycode.Text != mbr_dutyname.Value))
  1013. mbr_dutycode.Text = mbr_dutyname.Value;
  1014. }
  1015. private void mbc_component_UserControlTextChanged(object sender, EventArgs e)
  1016. {
  1017. }
  1018. private void so_name_UserControlTextChanged(object sender, EventArgs e)
  1019. {
  1020. if (so_code.Text == "" || (so_code.Text != "" && so_code.Text != so_name.Value))
  1021. so_code.Text = so_name.Value;
  1022. }
  1023. private void BadCodeTree_AfterSelect(object sender, TreeViewEventArgs e)
  1024. {
  1025. if (e.Node.Level == 0)
  1026. {
  1027. mb_id = e.Node.Tag.ToString();
  1028. BaseUtil.CleanControlsText(bc_name, bc_code, bg_name, bg_code, mb_badremark, nrg_name, nrg_code, nr_name, nr_code, so_name, so_code, mbr_dutyname, mbr_dutycode, mbc_component);
  1029. mbl_locdgv.DataSource = null;
  1030. mbp_partdgv.DataSource = null;
  1031. bc_name.Text = BadInf_1[mb_id]["bc_name"];
  1032. bc_code.Text = BadInf_1[mb_id]["mb_badcode"];
  1033. bg_name.Text = BadInf_1[mb_id]["bg_name"];
  1034. bg_code.Text = BadInf_1[mb_id]["mb_bgcode"];
  1035. // mb_badremark.Text = BadInf_1[mb_id]["mb_badremark"];
  1036. mbr_id = "";
  1037. SaveRepairInf.Enabled = true;
  1038. }
  1039. if (e.Node.Level == 1)
  1040. {
  1041. //展示父节点信息
  1042. mb_id = e.Node.Parent.Tag.ToString();
  1043. bc_code.Text = BadInf_1[mb_id]["mb_badcode"];
  1044. bc_name.Text = BadInf_1[mb_id]["bc_name"];
  1045. bg_code.Text = BadInf_1[mb_id]["mb_bgcode"];
  1046. bg_name.Text = BadInf_1[mb_id]["bg_name"];
  1047. //展示子节点信息
  1048. mbr_id = e.Node.Tag.ToString();
  1049. nrg_code.Text = BadInf_2[mbr_id]["nrg_code"];
  1050. nrg_name.Text = BadInf_2[mbr_id]["nrg_name"];
  1051. nr_code.Text = BadInf_2[mbr_id]["nr_code"];
  1052. nr_name.Text = BadInf_2[mbr_id]["nr_name"];
  1053. so_code.Text = BadInf_2[mbr_id]["so_code"];
  1054. so_name.Text = BadInf_2[mbr_id]["so_name"];
  1055. mbr_dutycode.Text = BadInf_2[mbr_id]["mbr_dutycode"];
  1056. mbr_dutyname.Text = BadInf_2[mbr_id]["mbr_dutyname"];
  1057. mb_badremark.Text = BadInf_2[mbr_id]["mbr_remark"];
  1058. mbc_component.Text = dh.getFieldDataByCondition("makebadrscom", "mbc_component", "mbc_mbrid=" + mbr_id).ToString();
  1059. //加载两个Grid的数据源
  1060. DataTable dt = (DataTable)dh.ExecuteSql("select mbp_id,mbp_part from makebadrspart where mbp_mbrid=" + mbr_id, "select");
  1061. BaseUtil.FillDgvWithDataTable(mbp_partdgv, dt);
  1062. dt = (DataTable)dh.ExecuteSql("select mbl_id,mbl_loc,mbl_orispeccode from makebadrsloc where mbl_mbrid=" + mbr_id, "select");
  1063. BaseUtil.FillDgvWithDataTable(mbl_locdgv, dt);
  1064. SaveRepairInf.Enabled = false;
  1065. }
  1066. }
  1067. private void normalButton1_Click(object sender, EventArgs e)
  1068. {
  1069. DataTable dt = (DataTable)dh.ExecuteSql("select ms_makecode from makeserial where ms_id='" + msid + "' and ms_sncode='" + GetSNCode.Text + "' and ms_status=3", "select");
  1070. if (dt.Rows.Count > 0)
  1071. {
  1072. if (mb_id != "")
  1073. {
  1074. string delete1 = "delete from makebadrsloc where mbl_mbrid in (select mbr_id from makebadreason where mbr_mbid = '" + mb_id + "' )";
  1075. string delete2 = "delete from makebadrspart where mbp_mbrid in (select mbr_id from makebadreason where mbr_mbid = '" + mb_id + "' )";
  1076. string delete3 = "delete from makebadrscom where mbc_mbrid in (select mbr_id from makebadreason where mbr_mbid = '" + mb_id + "' )";
  1077. string delete4 = "delete from makebadreason where mbr_mbid='" + mb_id + "'";
  1078. string delete = "delete from makebad where mb_id = '" + mb_id + "'";
  1079. dh.ExecuteSQLTran(delete1, delete2, delete3, delete4, delete);
  1080. OperatResult.AppendText(">>删除成功\n", Color.Green);
  1081. BaseUtil.CleanControlsText(bc_name, bc_code, bg_name, bg_code, mb_badremark, nrg_name, nrg_code, nr_name, nr_code, so_name, so_code, mbr_dutyname, mbr_dutycode, mbc_component);
  1082. mbp_partdgv.DataSource = null;
  1083. mbl_locdgv.DataSource = null;
  1084. mb_id = "";
  1085. //删除后重新加载Tree的信息
  1086. LoadBadInfTree(sender, e);
  1087. }
  1088. else OperatResult.AppendText(">>必须选择不良现象\n", Color.Red);
  1089. }
  1090. else OperatResult.AppendText(">>" + GetSNCode.Text + "序列号错误,不存在或者不处于维修状态\n", Color.Red);
  1091. }
  1092. private void snCollectionBox1_KeyDown(object sender, KeyEventArgs e)
  1093. {
  1094. if (e.KeyCode == Keys.Enter)
  1095. {
  1096. if (retsn.Text != "")
  1097. {
  1098. if (dh.CheckExist("makeserial", "ms_sncode = '" + retsn.Text + "' and MS_IFCCLEAN is not null"))
  1099. {
  1100. dh.ExecuteSql("update makeserial set MS_IFCCLEAN ='' where ms_sncode = '" + retsn.Text + "'", "select");
  1101. LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, macode, User.UserLineCode, User.UserSourceCode, "完成清空写入信息", "完成清空写入信息", retsn.Text, "");
  1102. OperatResult.AppendText(">>" + retsn.Text + "序列号清空写入信息完成\n", Color.Green, retsn);
  1103. }
  1104. else OperatResult.AppendText(">>" + retsn.Text + "序列号不存在或不需要录入\n", Color.Red, retsn);
  1105. }
  1106. else OperatResult.AppendText(">>" + retsn.Text + "录入不可为空\n", Color.Red, retsn);
  1107. }
  1108. }
  1109. int i = 0;
  1110. private void timer1_Tick(object sender, EventArgs e)
  1111. {
  1112. if (GetSNCode.Text == "" && cd_stepcode.Text != "")
  1113. {
  1114. i = i + 1;
  1115. }
  1116. if (i > 300 && GetSNCode.Text == "" && cd_stepcode.Text != "")
  1117. {
  1118. i = 0;
  1119. cd_stepcode.Text = "";
  1120. OperatResult.AppendText(">>清空回流工序\n", Color.Black);
  1121. }
  1122. }
  1123. private void normalButton2_Click(object sender, EventArgs e)
  1124. {
  1125. if (ms_sncode.Text != "")
  1126. {
  1127. //判断是否有无法维修的记录
  1128. int ScrapNum = int.Parse(dh.getFieldDataByCondition("makebadreason left join makebad on mb_id=mbr_mbid", "count(0) cn", "mb_sncode='" + ms_sncode.Text + "' and mb_status=0").ToString());
  1129. if (ScrapNum == 0)
  1130. OperatResult.AppendText(">>" + ms_sncode.Text + "退料必须维护不良原因\n", Color.Red);
  1131. else
  1132. {
  1133. string confirm = MessageBox.Show(this.ParentForm, "此操作不可撤销,是否确认退料", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Asterisk).ToString();
  1134. if (confirm == "Yes")
  1135. {
  1136. DataTable dt = dh.getFieldsDataByCondition("makeserial", new string[] { "nvl(ms_ifrework,0)ms_ifrework", "ms_reworkcode", "ms_code" }, "ms_sncode='" + ms_sncode.Text + "' and ms_makecode='" + macode + "'");
  1137. if (dt.Rows.Count > 0)
  1138. {
  1139. string ms_ifrework = dt.Rows[0]["ms_ifrework"].ToString();
  1140. string reworkcode = dt.Rows[0]["ms_reworkcode"].ToString();
  1141. string ms_code = dt.Rows[0]["ms_code"].ToString();
  1142. if (ms_ifrework == "0")
  1143. {
  1144. dh.UpdateByCondition("makeserial", "ms_paststep = ms_paststep ||'," + User.CurrentStepCode + "',ms_status=5,ms_nextstepcode=''", "ms_sncode='" + ms_sncode.Text + "' and ms_makecode='" + macode + "'");
  1145. }
  1146. else
  1147. {
  1148. sqls.Clear();
  1149. sqls.Add("update makeserial set ms_paststep = ms_paststep ||'," + User.CurrentStepCode + "',ms_status=5,ms_reworkstatus= 5,ms_nextstepcode='' where ms_sncode='" + ms_sncode.Text + "' and ms_makecode='" + macode + "'");
  1150. sqls.Add("update oqcbatch set ob_nowcheckqty=ob_nowcheckqty-1 where ob_checkno='" + ms_reworkcheckno.Text + "'");
  1151. sqls.Add("delete from oqcbatchdetail where obd_sncode='" + ms_sncode.Text + "' and obd_checkno='" + ms_reworkcheckno.Text + "'");
  1152. sqls.Add("update ReworkDetail set rd_rwstatus='退料' where rd_reid=(select re_id from rework where re_code='" + reworkcode + "') and rd_sncode='" + reworkcode + "'");
  1153. dh.ExecuteSQLTran(sqls.ToArray());
  1154. }
  1155. dh.ExecuteSql("update MAKESOURCESTOCK set mss_remain = mss_remain + MSS_BASEQTY,MSS_INVALIDTIME = null,mss_useqty = mss_useqty-MSS_BASEQTY where mss_barcode in (select cm_barcode from CRAFTMATERIAL where cm_mscode = '" + ms_code + "' and cm_makecode = '" + macode + "' and cm_status = 0) and mss_makecode = '" + macode + "' ", "update");
  1156. dh.ExecuteSql(" merge into barcode using (select cm_barcode,cm_inqty from CRAFTMATERIAL where cm_mscode = '" + ms_code + "' and cm_makecode = '" + macode + "' and cm_status = 0) A on (barcode.bar_code = A.cm_barcode) when matched then update set bar_remain = bar_remain + cm_inqty ", "update");
  1157. }
  1158. dh.ExecuteSql("update makebad set mb_status=-2,mb_okman ='" + User.UserName + "' where mb_sncode='" + ms_sncode.Text + "' and mb_makecode='" + ms_makecode.Text + "' and mb_status = 0", "update");
  1159. dh.UpdateByCondition("makecraftdetail", "mcd_inqty=mcd_inqty-1,mcd_outqty=mcd_outqty-1", "mcd_macode='" + ms_makecode.Text + "' and mcd_stepcode='" + ms_stepcode + "'");
  1160. dh.UpdateByCondition("make", "MA_NGMADEQTY=nvl(MA_NGMADEQTY,0)+1,ma_qty = ma_qty+1", "ma_code='" + macode + "'");
  1161. LogicHandler.InsertMakeProcess(ms_sncode.Text, ms_makecode.Text, User.UserSourceCode, "退料", "序列号退料", User.UserCode);
  1162. LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, macode, User.UserLineCode, User.UserSourceCode, "退料", "序列号退料", ms_sncode.Text, ms_checkno.Text);
  1163. OperatResult.AppendText(">>退料成功\n", Color.Green);
  1164. GetSNCode.Clear();
  1165. GetSNCode.Focus();
  1166. BaseUtil.CleanForm(this);
  1167. BadCodeTree.Nodes.Clear();
  1168. }
  1169. }
  1170. }
  1171. else OperatResult.AppendText(">>序列号不允许为空\n", Color.Red);
  1172. }
  1173. }
  1174. }