OQC_BatchResultJudge.cs 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363
  1. using System;
  2. using System.Data;
  3. using System.Windows.Forms;
  4. using System.Drawing;
  5. using UAS_MES.PublicMethod;
  6. using UAS_MES.DataOperate;
  7. using System.Text;
  8. using UAS_MES.Entity;
  9. using System.Collections.Generic;
  10. namespace UAS_MES.OQC
  11. {
  12. public partial class OQC_BatchResultJudge : Form
  13. {
  14. AutoSizeFormClass asc = new AutoSizeFormClass();
  15. DataHelper dh;
  16. LogStringBuilder sql = new LogStringBuilder();
  17. DataTable dt;
  18. string ErrorMessage = "";
  19. /// <summary>
  20. /// 是否通过资源验证
  21. /// </summary>
  22. bool PassCheckStep = false;
  23. public OQC_BatchResultJudge()
  24. {
  25. InitializeComponent();
  26. }
  27. private void 抽检批维护_Load(object sender, EventArgs e)
  28. {
  29. dh = SystemInf.dh;
  30. ob_checkno.Focus();
  31. asc.controllInitializeSize(this);
  32. }
  33. private void GetBatch_Click(object sender, EventArgs e)
  34. {
  35. if (CheckStep())
  36. {
  37. DataTable temp = dh.getFieldsDatasByCondition("makeserial", new string[] { "nvl(ms_ifrework,0)ms_ifrework", "ms_reworkcheckno" }, "ms_sncode='" + ms_sncode.Text.ToUpper() + "' order by ms_id desc");
  38. if (temp.Rows.Count > 0)
  39. {
  40. if (temp.Rows[0]["ms_ifrework"].ToString() != "0")
  41. {
  42. ob_checkno.Text = temp.Rows[0]["ms_reworkcheckno"].ToString();
  43. }
  44. }
  45. PassCheckStep = true;
  46. string ErrorMessage = "";
  47. DataTable[] dt = LogicHandler.GetOQCBatch(ms_sncode.Text, obd_outboxcode.Text, ob_checkno.Text, "OQCResultDetermine", out ErrorMessage);
  48. if (ErrorMessage == "")
  49. {
  50. BaseUtil.SetFormValue(Controls, dt[0]);
  51. switch (ob_result.Text)
  52. {
  53. case "OK":
  54. BatchPass.Enabled = false;
  55. BatchRejection.Enabled = false;
  56. ForcePass.Enabled = false;
  57. ForceRejection.Enabled = false;
  58. WithdrawPass.Enabled = true;
  59. WithdrawRejection.Enabled = false;
  60. break;
  61. case "FOK":
  62. BatchPass.Enabled = false;
  63. BatchRejection.Enabled = false;
  64. ForcePass.Enabled = false;
  65. ForceRejection.Enabled = false;
  66. WithdrawPass.Enabled = true;
  67. WithdrawRejection.Enabled = false;
  68. break;
  69. case "NG":
  70. BatchPass.Enabled = false;
  71. BatchRejection.Enabled = false;
  72. ForcePass.Enabled = false;
  73. ForceRejection.Enabled = false;
  74. WithdrawPass.Enabled = false;
  75. WithdrawRejection.Enabled = true;
  76. break;
  77. case "FNG":
  78. BatchPass.Enabled = false;
  79. BatchRejection.Enabled = false;
  80. ForcePass.Enabled = false;
  81. ForceRejection.Enabled = false;
  82. WithdrawPass.Enabled = false;
  83. WithdrawRejection.Enabled = true;
  84. break;
  85. case "":
  86. if (ob_checkno.Text != "")
  87. {
  88. BatchPass.Enabled = true;
  89. BatchRejection.Enabled = true;
  90. ForcePass.Enabled = true;
  91. ForceRejection.Enabled = true;
  92. WithdrawPass.Enabled = true;
  93. WithdrawRejection.Enabled = true;
  94. }
  95. break;
  96. default:
  97. break;
  98. }
  99. }
  100. else
  101. {
  102. BaseUtil.CleanForm(this);
  103. BatchPass.Enabled = false;
  104. BatchRejection.Enabled = false;
  105. ForcePass.Enabled = false;
  106. ForceRejection.Enabled = false;
  107. WithdrawPass.Enabled = false;
  108. WithdrawRejection.Enabled = false;
  109. OperateResult.AppendText(">>" + ErrorMessage + "\n", Color.Red);
  110. }
  111. }
  112. else
  113. {
  114. PassCheckStep = false;
  115. }
  116. }
  117. private void BatchPass_Click(object sender, EventArgs e)
  118. {
  119. string ReworkCode = "";
  120. if (CheckBefore() && PassCheckStep)
  121. {
  122. if (int.Parse(ob_crqty.Text) > int.Parse(ob_cracceptqty.Text))
  123. {
  124. OperateResult.AppendText(">>当前批次CR不合格数为" + ob_ngqty.Text + ",大于最大CR通过数" + ob_cracceptqty.Text + "\n", Color.Red);
  125. return;
  126. }
  127. if (int.Parse(ob_maqty.Text) > int.Parse(ob_maacceptqty.Text))
  128. {
  129. OperateResult.AppendText(">>当前批次MA不合格数为" + ob_maqty.Text + ",大于最大MA通过数" + ob_maacceptqty.Text + "\n", Color.Red);
  130. return;
  131. }
  132. if (int.Parse(ob_miqty.Text) > int.Parse(ob_miacceptqty.Text))
  133. {
  134. OperateResult.AppendText(">>当前批次MI不合格数为" + ob_miqty.Text + ",大于最大MI通过数" + ob_miacceptqty.Text + "\n", Color.Red);
  135. return;
  136. }
  137. if (LogicHandler.OQCBatchJudge(ob_checkno.Text, User.UserSourceCode, "OK", "", User.UserCode, Remark.Text, out ReworkCode, out ErrorMessage))
  138. {
  139. LogicHandler.DoCommandLog(Tag.ToString(),User.UserCode,"",User.UserLineCode,User.UserSourceCode,"通过批", "抽检批: "+ ob_checkno.Text+"通过","",ob_checkno.Text);
  140. OperateResult.AppendText(">>通过批成功\n", Color.Green);
  141. GetBatch.PerformClick();
  142. }
  143. else OperateResult.AppendText(">>" + ErrorMessage + "\n", Color.Red);
  144. }
  145. }
  146. private void BatchRejection_Click(object sender, EventArgs e)
  147. {
  148. string ReworkCode = "";
  149. if (CheckBefore() && PassCheckStep)
  150. {
  151. if (LogicHandler.OQCBatchJudge(ob_checkno.Text, User.UserSourceCode, "NG", ReworkRequire.Checked ? "Y" : "N", User.UserCode, Remark.Text, out ReworkCode, out ErrorMessage))
  152. {
  153. OperateResult.AppendText(">>判退批成功\n", Color.Green);
  154. LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, "", User.UserLineCode, User.UserSourceCode, "判退批", "抽检批: " + ob_checkno.Text + "判退", "", ob_checkno.Text);
  155. if (ReworkRequire.Checked)
  156. {
  157. dh.UpdateByCondition("oqcbatch", "ob_reworkcode='" + ReworkCode + "'", "ob_checkno='" + ob_checkno.Text + "'");
  158. OperateResult.AppendText(">>生成返工需求单" + ReworkCode + "\n", Color.Green);
  159. }
  160. GetBatch.PerformClick();
  161. }
  162. else OperateResult.AppendText(">>" + ErrorMessage + "\n", Color.Red);
  163. }
  164. }
  165. private void ForcePass_Click(object sender, EventArgs e)
  166. {
  167. string ReworkCode = "";
  168. if (PassCheckStep)
  169. {
  170. if (LogicHandler.OQCBatchJudge(ob_checkno.Text, User.UserSourceCode, "FOK", "", User.UserCode, Remark.Text, out ReworkCode, out ErrorMessage))
  171. {
  172. LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, "", User.UserLineCode, User.UserSourceCode, "强制通过批", "抽检批: " + ob_checkno.Text + "强制通过", "", ob_checkno.Text);
  173. OperateResult.AppendText(">>强制通过批" + ob_checkno.Text + "成功\n", Color.Green);
  174. GetBatch.PerformClick();
  175. }
  176. else OperateResult.AppendText(">>" + ErrorMessage + "\n", Color.Red);
  177. }
  178. }
  179. private void ForceRejection_Click(object sender, EventArgs e)
  180. {
  181. string ReworkCode = "";
  182. if (PassCheckStep)
  183. {
  184. if (LogicHandler.OQCBatchJudge(ob_checkno.Text, User.UserSourceCode, "FNG", ReworkRequire.Checked ? "Y" : "N", User.UserCode, Remark.Text, out ReworkCode, out ErrorMessage))
  185. {
  186. OperateResult.AppendText(">>强制退批" + ob_checkno.Text + "成功\n", Color.Green);
  187. LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, "", User.UserLineCode, User.UserSourceCode, "强制退批", "抽检批: " + ob_checkno.Text + "强制退批", "", ob_checkno.Text);
  188. if (ReworkRequire.Checked)
  189. {
  190. dh.UpdateByCondition("oqcbatch", "ob_reworkcode='" + ReworkCode + "'", "ob_checkno='" + ob_checkno.Text + "'");
  191. OperateResult.AppendText(">>生成返工需求单" + ReworkCode + "\n", Color.Green);
  192. }
  193. GetBatch.PerformClick();
  194. }
  195. else OperateResult.AppendText(">>" + ErrorMessage + "\n", Color.Red);
  196. }
  197. }
  198. private void WithdrawPass_Click(object sender, EventArgs e)
  199. {
  200. string ReworkCode = "";
  201. if (PassCheckStep)
  202. {
  203. if (ob_result.Text == "OK" || ob_result.Text == "FOK")
  204. {
  205. if (LogicHandler.OQCBatchJudge(ob_checkno.Text, User.UserSourceCode, "REOK", "", User.UserCode, Remark.Text, out ReworkCode, out ErrorMessage))
  206. {
  207. LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, "", User.UserLineCode, User.UserSourceCode, "撤销通过批", "抽检批: " + ob_checkno.Text + "撤销通过", "", ob_checkno.Text);
  208. OperateResult.AppendText(">>撤销通过批" + ob_checkno.Text + "成功\n", Color.Green);
  209. GetBatch.PerformClick();
  210. }
  211. else OperateResult.AppendText(">>" + ErrorMessage + "\n", Color.Red);
  212. }
  213. else OperateResult.AppendText(">>该抽检批次未通过,无需撤销通过\n", Color.Red);
  214. }
  215. }
  216. private void WithdrawRejection_Click(object sender, EventArgs e)
  217. {
  218. string ReworkCode = "";
  219. if (PassCheckStep)
  220. {
  221. if (ob_result.Text == "NG" || ob_result.Text == "FNG")
  222. {
  223. dt = (DataTable)dh.ExecuteSql("select re_statuscode from rework where re_checkno='" + ob_checkno.Text + "'", "select");
  224. if (dt.Rows.Count > 0)
  225. {
  226. if (dt.Rows[0]["re_statuscode"].ToString() == "AUDITED")
  227. {
  228. OperateResult.AppendText(">>该批次存在已审核的返修工单,不允许撤销\n", Color.Red);
  229. return;
  230. }
  231. else
  232. {
  233. string logout_confirm = MessageBox.Show("已存在返修工单,撤销会删除该工单,是否继续", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question).ToString();
  234. if (logout_confirm == "Yes")
  235. {
  236. if (LogicHandler.OQCBatchJudge(ob_checkno.Text, User.UserSourceCode, "RENG", "", User.UserCode, Remark.Text, out ReworkCode, out ErrorMessage))
  237. {
  238. LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, "", User.UserLineCode, User.UserSourceCode, "撤销判退", "抽检批: " + ob_checkno.Text + "撤销判退", "", ob_checkno.Text);
  239. OperateResult.AppendText(">>撤销判退成功\n", Color.Green);
  240. ob_result.Text = "";
  241. GetBatch.PerformClick();
  242. }
  243. else OperateResult.AppendText(">>" + ErrorMessage + "\n", Color.Red);
  244. }
  245. else return;
  246. }
  247. }
  248. else
  249. {
  250. if (LogicHandler.OQCBatchJudge(ob_checkno.Text, User.UserSourceCode, "RENG", "", User.UserCode, Remark.Text, out ReworkCode, out ErrorMessage))
  251. {
  252. OperateResult.AppendText(">>撤销判退成功\n", Color.Green);
  253. ob_result.Text = "";
  254. GetBatch.PerformClick();
  255. }
  256. else OperateResult.AppendText(">>" + ErrorMessage + "\n", Color.Red);
  257. }
  258. }
  259. else OperateResult.AppendText(">>该抽检批次未判退,无需撤销判退\n", Color.Red);
  260. }
  261. }
  262. private void Clean_Click(object sender, EventArgs e)
  263. {
  264. OperateResult.Clear();
  265. }
  266. /// <summary>
  267. /// 操作之前通用的验证逻辑
  268. /// </summary>
  269. /// <returns></returns>
  270. private bool CheckBefore()
  271. {
  272. //if (ob_status.Text == "检验中")
  273. //{
  274. // if (ob_maxngacceptqty.Text == "")
  275. // {
  276. // if (ob_aqlcode.Text == "")
  277. // OperateResult.AppendText(">>AQL标准为空的时候必须填写最大不合格允许通过数\n", Color.Red);
  278. // else
  279. // {
  280. // sql.Clear();
  281. // sql.Append("select nvl(ad_minqty,0)ad_minqty,nvl(ad_maxqty,0)ad_maxqty,nvl(ad_maxngacceptqty,0) ");
  282. // sql.Append("ad_maxngacceptqty from QUA_Aql left join qua_aqldetail on ad_alid=al_id where ");
  283. // sql.Append("al_code='" + ob_aqlcode.Text + "' and ad_minqty<='" + ob_nowcheckqty.Text + "' and ad_maxqty>='" + ob_nowcheckqty.Text + "'");
  284. // dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
  285. // if (dt.Rows.Count > 0)
  286. // {
  287. // ob_maxngacceptqty.Text = dt.Rows[0]["ad_maxngacceptqty"].ToString();
  288. // return true;
  289. // }
  290. // }
  291. // }
  292. // else
  293. // {
  294. // return true;
  295. // }
  296. //}
  297. //else OperateResult.AppendText(">>状态未在检验中的批次不允许进行判断\n", Color.Red);
  298. //return false;
  299. return true;
  300. }
  301. private bool CheckStep()
  302. {
  303. if (LogicHandler.CheckStepAttribute(Tag.ToString(), User.UserSourceCode, out ErrorMessage))
  304. {
  305. return true;
  306. }
  307. else
  308. {
  309. OperateResult.AppendText(">>" + ErrorMessage + "\n", Color.Red);
  310. return false;
  311. }
  312. }
  313. private void 抽检批维护_SizeChanged(object sender, EventArgs e)
  314. {
  315. asc.controlAutoSize(this);
  316. }
  317. private void ob_checkno_KeyDown(object sender, KeyEventArgs e)
  318. {
  319. if (e.KeyCode == Keys.Enter)
  320. GetBatch.PerformClick();
  321. }
  322. private void ms_sncode_KeyDown(object sender, KeyEventArgs e)
  323. {
  324. if (e.KeyCode == Keys.Enter)
  325. {
  326. //因为通过序列号获取的时候会带出送检批次,获取数据的方法根据送检批次为主
  327. //所以在通过序列号获取的时候要清除界面数据
  328. string sncode = ms_sncode.Text;
  329. BaseUtil.CleanForm(this);
  330. ms_sncode.Text = sncode;
  331. GetBatch.PerformClick();
  332. }
  333. }
  334. private void obd_outboxcode_KeyDown(object sender, KeyEventArgs e)
  335. {
  336. if (e.KeyCode == Keys.Enter)
  337. GetBatch.PerformClick();
  338. }
  339. private void OQC_BatchResultJudge_FormClosing(object sender, FormClosingEventArgs e)
  340. {
  341. dh.Dispose();
  342. }
  343. }
  344. }