OQC_SamplingDataCollection.cs 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Data;
  4. using System.Drawing;
  5. using System.Text;
  6. using System.Windows.Forms;
  7. using UAS_MES.CustomControl.DataGrid_View;
  8. using UAS_MES.DataOperate;
  9. using UAS_MES.Entity;
  10. using UAS_MES.PublicMethod;
  11. namespace UAS_MES.OQC
  12. {
  13. public partial class OQC_SamplingDataCollection : Form
  14. {
  15. AutoSizeFormClass asc = new AutoSizeFormClass();
  16. DataHelper dh;
  17. DataTable dt;
  18. DataTable BadCode;
  19. List<DataGridViewRow> dgvr = new List<DataGridViewRow>();
  20. LogStringBuilder sql = new LogStringBuilder();
  21. string[] LevelDefect = new string[] { "A#A", "B#B", "C#C", "D#D" };
  22. string ErrorMessage = "";
  23. DataTable TempForCheckType = new DataTable();
  24. public OQC_SamplingDataCollection()
  25. {
  26. InitializeComponent();
  27. }
  28. private void 抽样数据采集_Load(object sender, EventArgs e)
  29. {
  30. asc.controllInitializeSize(this);
  31. BaseUtil.DataGridViewNotSort(CheckTypeDGV);
  32. BaseUtil.DataGridViewNotSort(WaitChooseDGV);
  33. dh = new DataHelper();
  34. }
  35. private void 抽样数据采集_SizeChanged(object sender, EventArgs e)
  36. {
  37. asc.controlAutoSize(this);
  38. }
  39. private void GetBatch_Click(object sender, EventArgs e)
  40. {
  41. string ErrorMessage = "";
  42. DataTable[] dt = LogicHandler.GetOQCBatch(ms_sncode.Text, obd_outboxcode.Text, ob_checkno.Text, "OQCDataCollection", out ErrorMessage);
  43. if (ErrorMessage == "")
  44. {
  45. BaseUtil.SetFormValue(Controls, dt[0]);
  46. GetBatchTypeGridData();
  47. dgvr.Clear();
  48. }
  49. else OperateResult.AppendText(">>" + ErrorMessage + "\n", Color.Red);
  50. }
  51. private void Clean_Click(object sender, EventArgs e)
  52. {
  53. OperateResult.Clear();
  54. }
  55. private void sncode_KeyDown(object sender, KeyEventArgs e)
  56. {
  57. if (e.KeyCode == Keys.Enter)
  58. {
  59. if (CheckSnCode())
  60. {
  61. GetBatchTypeGridData();
  62. }
  63. }
  64. }
  65. private bool CheckSnCode()
  66. {
  67. //输入的序列号不能为空
  68. if (sncode.Text != "")
  69. {
  70. if (LogicHandler.CheckStepAttribute(Tag.ToString(), User.UserSourceCode, out ErrorMessage))
  71. {
  72. //判断当前的检验状态
  73. if (ob_status.Text == "待检验" || ob_status.Text == "检验中")
  74. {
  75. dt = (DataTable)dh.ExecuteSql("select obd_sncode,ob_source,ob_makecode,ob_checkno from OQCBatchDetail left join OQCBatch on ob_id=obd_obid where obd_sncode='" + sncode.Text + "'", "select");
  76. if (dt.Rows.Count > 0 && dt.Rows[0]["ob_checkno"].ToString() == ob_checkno.Text)
  77. {
  78. if (dt.Rows[0]["ob_source"].ToString() != "工序")
  79. {
  80. return true;
  81. }
  82. else
  83. {
  84. string oMakeCode = "";
  85. string oMsID = "";
  86. if (LogicHandler.CheckStepSNAndMacode(dt.Rows[0]["ob_makecode"].ToString(), User.UserSourceCode, sncode.Text, User.UserCode, out oMakeCode, out oMsID, out ErrorMessage))
  87. {
  88. return true;
  89. }
  90. else {
  91. OperateResult.AppendText(">>" + ErrorMessage + "\n", Color.Red);
  92. return false;
  93. }
  94. }
  95. }
  96. else {
  97. OperateResult.AppendText(">>序列号" + sncode.Text + "不属于当前抽检批次\n", Color.Red);
  98. return false;
  99. }
  100. }
  101. else {
  102. OperateResult.AppendText(">>送检批次必须是待检验或者检验中\n", Color.Red);
  103. return false;
  104. }
  105. }
  106. else {
  107. OperateResult.AppendText(">>送检批次必须是待检验或者检验中\n", Color.Red);
  108. return false;
  109. }
  110. }
  111. else {
  112. OperateResult.AppendText(">>序列号不能为空\n", Color.Red);
  113. return false;
  114. }
  115. }
  116. private void GetBatchTypeGridData()
  117. {
  118. dt = (DataTable)dh.ExecuteSql("select oi_checkkind,max(oi_sampleqty) oi_count,nvl(max(oi_checkqty),0) oi_checkedcount from OQCBatch left join OQCItems on ob_checkno=oi_checkno where oi_checkno='" + ob_checkno.Text + "' group by oi_checkkind ", "select");
  119. BaseUtil.FillExpandDgvWithDataTable(CheckTypeDGV, dt, true);
  120. sql.Clear();
  121. sql.Append("select bg_code,bg_name from product left join productkind ");
  122. sql.Append("on pr_kind=pk_code left join PRODUCTBADGROUP on pk_code= pb_kindcode ");
  123. sql.Append("left join badgroup on bg_code=pb_badgroup where pr_code='" + ob_prodcode.Text + "'");
  124. BadCode = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
  125. BaseUtil.FillExpandDgvWithDataTable(WaitChooseDGV, BadCode, true);
  126. }
  127. private void Confirm_Click(object sender, EventArgs e)
  128. {
  129. //只能操作检验中或者待检验的批次
  130. if (ob_status.Text == "待检验" || ob_status.Text == "检验中")
  131. {
  132. if (!CheckSnCode())
  133. return;
  134. //判断检验项是否勾选,如勾选取出明细数据
  135. for (int i = TempForCheckType.Rows.Count - 1; i >= 0; i--)
  136. {
  137. if (TempForCheckType.Rows[i][0].ToString() == "False")
  138. {
  139. TempForCheckType.Rows.RemoveAt(i);
  140. }
  141. }
  142. if (TempForCheckType != null && TempForCheckType.Rows.Count > 0)
  143. {
  144. //用于存放更新的数据
  145. List<string> ois_ifng_update = new List<string>();
  146. List<string> ois_defectlevel_update = new List<string>();
  147. List<string> ois_remark_update = new List<string>();
  148. List<string> ois_id_update = new List<string>();
  149. //用于存放插入的数据
  150. List<string> ois_ifng_insert = new List<string>();
  151. List<string> ois_defectlevel_insert = new List<string>();
  152. List<string> ois_remark_insert = new List<string>();
  153. List<string> oi_itemcode_insert = new List<string>();
  154. for (int i = 0; i < TempForCheckType.Rows.Count; i++)
  155. {
  156. //将布尔值转换为0,-1
  157. if (TempForCheckType.Rows[i]["ois_id"].ToString() != "" && TempForCheckType.Rows[i]["ois_id"].ToString() != "0")
  158. {
  159. ois_ifng_update.Add(TempForCheckType.Rows[i]["oi_ng"].ToString() == "True" ? "-1" : "0");
  160. ois_defectlevel_update.Add(TempForCheckType.Rows[i]["oi_leveldefect"].ToString());
  161. ois_remark_update.Add(TempForCheckType.Rows[i]["ois_remark"].ToString());
  162. ois_id_update.Add(TempForCheckType.Rows[i]["ois_id"].ToString());
  163. }
  164. else
  165. {
  166. oi_itemcode_insert.Add(TempForCheckType.Rows[i]["oi_itemcode"].ToString());
  167. ois_ifng_insert.Add(TempForCheckType.Rows[i]["oi_ng"].ToString() == "True" ? "-1" : "0");
  168. ois_defectlevel_insert.Add(TempForCheckType.Rows[i]["oi_leveldefect"].ToString());
  169. ois_remark_insert.Add(TempForCheckType.Rows[i]["ois_remark"].ToString());
  170. }
  171. }
  172. //判断是否含不通过的内容
  173. bool AllPass = true;
  174. for (int i = 0; i < ois_ifng_insert.Count; i++)
  175. {
  176. if (ois_ifng_insert[i] == "-1")
  177. AllPass = false;
  178. }
  179. for (int i = 0; i < ois_ifng_update.Count; i++)
  180. {
  181. if (ois_ifng_update[i] == "-1")
  182. AllPass = false;
  183. }
  184. if (ChoosedDGV.RowCount > 0 || AllPass)
  185. {
  186. //执行批量更新的SQL
  187. if (ois_id_update.Count > 0)
  188. {
  189. dh.BatchInsert("update OQCItemSamples set ois_ifng=:ois_ifng,ois_defectlevel=:ois_defectlevel,ois_remark=:ois_remark where ois_id=:ois_id",
  190. new string[] { "ois_ifng", "ois_defectlevel", "ois_remark", "ois_id" }, ois_ifng_update.ToArray(), ois_defectlevel_update.ToArray(), ois_remark_update.ToArray(), ois_id_update.ToArray());
  191. }
  192. //如果主键为空,并且存在需要插入的数据则执行插入操作
  193. if (oi_itemcode_insert.Count > 0)
  194. {
  195. sql.Clear();
  196. sql.Append("insert into OQCItemSamples (ois_id,ois_checkno,ois_makecode, ois_sncode,ois_projectcode,ois_itemcode,");
  197. sql.Append("ois_ifng,ois_defectlevel,ois_remark)values(OQCItemSamples_SEQ.nextval,'" + ob_checkno.Text + "',");
  198. sql.Append("'" + ob_makecode.Text + "','" + sncode.Text + "','" + ob_projectcode.Text + "',:ois_itemcode,:ois_ifng,:ois_defectlevel,:ois_remark)");
  199. dh.BatchInsert(sql.GetString(), new string[] { "ois_itemcode", "ois_ifng", "ois_defectlevel", "ois_remark" },
  200. oi_itemcode_insert.ToArray(), ois_ifng_insert.ToArray(), ois_defectlevel_insert.ToArray(), ois_remark_insert.ToArray());
  201. }
  202. //采集不良信息
  203. List<string> bc_code = new List<string>();
  204. List<string> bc_name = new List<string>();
  205. for (int i = 0; i < ChoosedDGV.RowCount; i++)
  206. {
  207. bc_code.Add(ChoosedDGV.Rows[i].Cells[0].Value.ToString());
  208. bc_name.Add(ChoosedDGV.Rows[i].Cells[1].Value.ToString());
  209. }
  210. sql.Clear();
  211. sql.Append("insert into OQCNGReason(or_id, or_checkno, or_makecode, or_sncode, or_reasoncode, oi_description, oi_remark)");
  212. sql.Append("values (OQCNGReason_seq.nextval,'" + ob_checkno.Text + "','" + ob_makecode.Text + "','" + sncode.Text + "',:a,:b,'" + ob_remark.Text + "')");
  213. dh.BatchInsert(sql.GetString(), new string[] { "a", "b" }, bc_code.ToArray(), bc_name.ToArray());
  214. sql.Clear();
  215. //更新项目编号中的抽检数、不合格数,根据采样项目记录
  216. sql.Append("UPDATE OQCItems SET (oi_ngqty,oi_checkqty)=(select nvl(sum(case when ");
  217. sql.Append("nvl(ois_ifng,0)=0 then 0 else 1 end),0) ,count(1) from OQCItemSamples where ois_checkno=oi_checkno ");
  218. sql.Append("and ois_itemcode=oi_itemcode)where oi_checkno ='" + ob_checkno.Text + "' and oi_projectcode ='" + ob_projectcode.Text + "'");
  219. dh.ExecuteSql(sql.GetString(), "update");
  220. //更新检验状态,如果是待检验的更新为检验中
  221. dh.ExecuteSql("update OQCBatch set ob_status='CHECKING' where ob_checkno='" + ob_checkno.Text + "' and ob_status='UNCHECK'", "update");
  222. //更新批次中的合格数不合格数:用抽检批检验项目表获取最大的抽检数和不合格数
  223. dh.ExecuteSql("update OQCBATCH set (ob_ngqty,ob_okqty)=(select nvl(max(oi_ngqty),0),max(oi_checkqty)-nvl(max(oi_ngqty),0) from OQCItems where oi_checkno ='" + ob_checkno.Text + "') where ob_checkno ='" + ob_checkno.Text + "'", "update");
  224. OperateResult.AppendText(">>操作成功\n", Color.Green);
  225. GetBatch.PerformClick();
  226. ChoosedDGV.DataSource = null;
  227. TempForCheckType.Clear();
  228. }
  229. else OperateResult.AppendText(">>含有未通过项请勾选不良明细\n", Color.Red);
  230. }
  231. else OperateResult.AppendText(">>请勾选送检明细\n", Color.Red);
  232. }
  233. else OperateResult.AppendText(">>必须是待检验或者检测中的送检批才能进行此操作\n", Color.Red);
  234. }
  235. private void Cancel_Click(object sender, EventArgs e)
  236. {
  237. }
  238. private void BatchPass_Click(object sender, EventArgs e)
  239. {
  240. if (CheckBefore())
  241. {
  242. sql.Clear();
  243. sql.Append("select max(nvl(ad_maxngacceptqty,0)) maxngacceptqty from QUA_Aql,QUA_AqlDetail where al_id=ad_alid ");
  244. sql.Append("and al_statuscode='AUDITED' and al_code ='" + ob_aqlcode.Text + "' and " + (ob_batchqty.Text != "" ? ob_batchqty.Text : "0") + " >= ad_minqty");
  245. sql.Append(" and " + (ob_batchqty.Text != "" ? ob_batchqty.Text : "0") + "<=ad_maxqty ");
  246. dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
  247. if (int.Parse(ob_ngqty.Text == "" ? "0" : ob_ngqty.Text) <= int.Parse(dt.Rows[0]["maxngacceptqty"].ToString() == "" ? ob_maxngacceptqty.Text : dt.Rows[0]["maxngacceptqty"].ToString()))
  248. {
  249. dh.ExecuteSql("update OQCBatch set ob_status='OK',ob_result='OK' where ob_checkno='" + ob_checkno.Text + "'", "select");
  250. string ErrorMessage;
  251. LogicHandler.UpdateOQCMessage(ms_sncode.Text, ob_makecode.Text, "OQC批判过", User.UserSourceCode, User.UserName, "批次通过", out ErrorMessage);
  252. //记录操作日志
  253. LogicHandler.InsertMakeProcess(ms_sncode.Text, ob_makecode.Text, User.UserSourceCode, "批结果判定", "批次通过", User.UserName);
  254. GetBatch.PerformClick();
  255. OperateResult.AppendText(">>通过批成功\n", Color.Green);
  256. }
  257. else
  258. OperateResult.AppendText(">>当前批次不合格数为" + ob_ngqty.Text + ",大于最大不合格允通过数" + ob_maxngacceptqty.Text + "\n", Color.Red);
  259. }
  260. }
  261. private void Refresh_Click(object sender, EventArgs e)
  262. {
  263. }
  264. private bool CheckBefore()
  265. {
  266. //如果AQL标准为空
  267. if (ob_aqlcode.Text == "")
  268. {
  269. if (ob_maxngacceptqty.Text == "")
  270. OperateResult.AppendText(">>AQL标准为空的时候必须填写最大不合格允许通过数\n", Color.Red);
  271. else
  272. {
  273. sql.Clear();
  274. sql.Append("select wm_concat(oi_itemcode) codes from OQCitems where ");
  275. sql.Append("nvl(oi_checkqty,0)<oi_sampleqty and oi_sampleqty>0 and rownum<30 and oi_checkno='" + ob_checkno.Text + "'");
  276. dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
  277. if (dt.Rows.Count > 0)
  278. {
  279. if (dt.Rows[0]["codes"].ToString() != "")
  280. {
  281. OperateResult.AppendText(">>项目编号抽检数未达到样本数,项目编号['" + ob_makecode.Text + "']\n", Color.Red);
  282. return false;
  283. }
  284. else
  285. return true;
  286. }
  287. }
  288. }
  289. return false;
  290. }
  291. private void WaitReject_Click(object sender, EventArgs e)
  292. {
  293. BaseUtil.CleanDGVData(ChoosedDGV);
  294. }
  295. private void ChooseedReject_Click(object sender, EventArgs e)
  296. {
  297. dt = BaseUtil.DGVIfChecked(WaitChooseDGV);
  298. if (dt != null)
  299. BaseUtil.FillDgvWithDataTable(ChoosedDGV, dt);
  300. else
  301. OperateResult.AppendText(">>请先勾选不良明细\n", Color.Red);
  302. }
  303. private void CheckTypeDGV_RowHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e)
  304. {
  305. if (!dgvr.Contains(CheckTypeDGV.Rows[e.RowIndex]))
  306. {
  307. string checkkind = CheckTypeDGV.Rows[e.RowIndex].Cells["oi_itemcode"].Value.ToString();
  308. sql.Clear();
  309. sql.Append("select oi_checkkind,ois_sncode,nvl(ois_id,0) ois_id ,oi_itemcode ,nvl(ois_ifng,0) oi_ng,nvl(ois_defectlevel,'-1')");
  310. sql.Append("oi_leveldefect,ois_remark,case ois_id when 0 then '未检验' else '已检验' end ois_status from OQCItems ");
  311. sql.Append("left join OQCItemSamples on ois_sncode='" + sncode.Text + "' and ois_checkno=oi_checkno and ");
  312. sql.Append("ois_itemcode=oi_itemcode and ois_projectcode = oi_projectcode where oi_checkno ='" + ob_checkno.Text + "' ");
  313. sql.Append("and oi_checkkind='" + checkkind + "'");
  314. DataTable dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
  315. DataGridViewRow headerRow = new DataGridViewRow();
  316. DataGridViewTextBoxCell textcell = new DataGridViewTextBoxCell();
  317. textcell.Value = "";
  318. headerRow.Cells.Add(textcell);
  319. textcell = new DataGridViewTextBoxCell();
  320. textcell.Value = "检验项目";
  321. headerRow.Cells.Add(textcell);
  322. textcell = new DataGridViewTextBoxCell();
  323. textcell.Value = "不通过";
  324. headerRow.Cells.Add(textcell);
  325. textcell = new DataGridViewTextBoxCell();
  326. textcell.Value = "缺陷等级";
  327. headerRow.Cells.Add(textcell);
  328. textcell = new DataGridViewTextBoxCell();
  329. textcell.Value = "备注";
  330. headerRow.Cells.Add(textcell);
  331. textcell = new DataGridViewTextBoxCell();
  332. textcell.Value = "检验状态";
  333. headerRow.Cells.Add(textcell);
  334. headerRow.ReadOnly = true;
  335. try
  336. {
  337. CollapseDataGridViewRow cl = (CollapseDataGridViewRow)(CheckTypeDGV.Rows[e.RowIndex]);
  338. cl.Rows.Add(headerRow);
  339. for (int i = 0; i < dt.Rows.Count; i++)
  340. {
  341. DataGridViewRow dataRow = new DataGridViewRow();
  342. //标记展开的子行
  343. dataRow.Tag = "SonRow";
  344. DataGridViewCheckBoxCell checkcell = new DataGridViewCheckBoxCell();
  345. checkcell.Tag = "SonRow";
  346. dataRow.Cells.Add(checkcell);
  347. textcell = new DataGridViewTextBoxCell();
  348. textcell.Value = dt.Rows[i]["oi_itemcode"].ToString();
  349. dataRow.Cells.Add(textcell);
  350. textcell.ReadOnly = true;
  351. DataGridViewCheckBoxCell checkcel2 = new DataGridViewCheckBoxCell();
  352. checkcel2.Value = dt.Rows[i]["oi_ng"].ToString() != "0" ? true : false;
  353. dataRow.Cells.Add(checkcel2);
  354. textcell.ReadOnly = false;
  355. DataGridViewComboBoxCell combocell = new DataGridViewComboBoxCell();
  356. BaseUtil.SetDGVCellComboxData(combocell, "display", "value", LevelDefect);
  357. combocell.Value = dt.Rows[i]["oi_leveldefect"].ToString();
  358. dataRow.Cells.Add(combocell);
  359. textcell.ReadOnly = false;
  360. textcell = new DataGridViewTextBoxCell();
  361. textcell.Value = dt.Rows[i]["ois_remark"].ToString();
  362. dataRow.Cells.Add(textcell);
  363. textcell.ReadOnly = false;
  364. textcell = new DataGridViewTextBoxCell();
  365. textcell.Value = dt.Rows[i]["ois_status"].ToString();
  366. dataRow.Cells.Add(textcell);
  367. textcell.ReadOnly = true;
  368. textcell = new DataGridViewTextBoxCell();
  369. textcell.Value = dt.Rows[i]["ois_id"].ToString();
  370. dataRow.Cells.Add(textcell);
  371. cl.Rows.Add(dataRow);
  372. }
  373. dgvr.Add(CheckTypeDGV.Rows[e.RowIndex]);
  374. }
  375. catch (Exception) { }
  376. }
  377. }
  378. private void CheckTypeDGV_DataError(object sender, DataGridViewDataErrorEventArgs e) { }
  379. private void WaitChooseDGV_RowHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e)
  380. {
  381. if (!dgvr.Contains(WaitChooseDGV.Rows[e.RowIndex]))
  382. {
  383. string bg_code = WaitChooseDGV.Rows[e.RowIndex].Cells["bg_code"].Value.ToString();
  384. DataTable dt = (DataTable)dh.ExecuteSql("select bc_code,bc_name from BADCODE where bc_groupcode='" + bg_code + "'", "select");
  385. DataGridViewRow headerRow = new DataGridViewRow();
  386. DataGridViewTextBoxCell textcell = new DataGridViewTextBoxCell();
  387. textcell.Value = "";
  388. headerRow.Cells.Add(textcell);
  389. textcell = new DataGridViewTextBoxCell();
  390. textcell.Value = "不良代码";
  391. headerRow.Cells.Add(textcell);
  392. textcell = new DataGridViewTextBoxCell();
  393. textcell.Value = "不良原因";
  394. headerRow.Cells.Add(textcell);
  395. headerRow.ReadOnly = true;
  396. CollapseDataGridViewRow cl = (CollapseDataGridViewRow)(WaitChooseDGV.Rows[e.RowIndex]);
  397. cl.Rows.Add(headerRow);
  398. for (int i = 0; i < dt.Rows.Count; i++)
  399. {
  400. DataGridViewRow dataRow = new DataGridViewRow();
  401. //标记展开的子行
  402. dataRow.Tag = "SonRow";
  403. DataGridViewCheckBoxCell checkcell = new DataGridViewCheckBoxCell();
  404. dataRow.Cells.Add(checkcell);
  405. textcell = new DataGridViewTextBoxCell();
  406. textcell.Value = dt.Rows[i]["bc_code"].ToString();
  407. dataRow.Cells.Add(textcell);
  408. textcell = new DataGridViewTextBoxCell();
  409. textcell.Value = dt.Rows[i]["bc_name"].ToString();
  410. dataRow.Cells.Add(textcell);
  411. cl.Rows.Add(dataRow);
  412. }
  413. dgvr.Add(WaitChooseDGV.Rows[e.RowIndex]);
  414. }
  415. }
  416. //如果当前行的Cell有修改过就将CheckBox勾选上
  417. private void CheckTypeDGV_CellValueChanged(object sender, DataGridViewCellEventArgs e)
  418. {
  419. if (e.RowIndex > 0 && e.ColumnIndex > 0)
  420. CheckTypeDGV.Rows[e.RowIndex].Cells[0].Value = true;
  421. try
  422. {
  423. if (CheckTypeDGV.Rows[e.RowIndex].Cells[0].Tag != null)
  424. {
  425. if (CheckTypeDGV.Rows[e.RowIndex].Cells[0].Tag.ToString() == "SonRow")
  426. BaseUtil.GetExpandDGVCheckedRow(CheckTypeDGV, TempForCheckType, e.RowIndex, 1);
  427. }
  428. }
  429. catch (Exception)
  430. {
  431. }
  432. }
  433. private void WaitChooseDGV_DataError(object sender, DataGridViewDataErrorEventArgs e) { }
  434. private void WaitChooseDGV_CellContentClick(object sender, DataGridViewCellEventArgs e)
  435. {
  436. BaseUtil.ExpandDGVCheck(WaitChooseDGV, e);
  437. }
  438. private void CheckTypeDGV_CellContentClick(object sender, DataGridViewCellEventArgs e)
  439. {
  440. BaseUtil.ExpandDGVCheck(CheckTypeDGV, e);
  441. }
  442. private void bccode_KeyDown(object sender, KeyEventArgs e)
  443. {
  444. if (e.KeyCode == Keys.Enter)
  445. {
  446. dt = (DataTable)dh.ExecuteSql("select bc_code bg_code,bc_name bg_name from badgroup left join badcode on bg_code=bc_groupcode where bc_code='" + bccode.Text + "'", "select");
  447. if (dt.Rows.Count > 0)
  448. {
  449. try
  450. {
  451. dt.Merge(ChoosedDGV.DataSource as DataTable);
  452. BaseUtil.FillDgvWithDataTable(ChoosedDGV, dt);
  453. }
  454. catch (Exception) { }
  455. }
  456. else OperateResult.AppendText(">>不良代码不存在\n", Color.Red);
  457. }
  458. }
  459. private void ob_checkno_KeyDown(object sender, KeyEventArgs e)
  460. {
  461. if (e.KeyCode == Keys.Enter)
  462. GetBatch.PerformClick();
  463. }
  464. private void ms_sncode_KeyDown(object sender, KeyEventArgs e)
  465. {
  466. if (e.KeyCode == Keys.Enter)
  467. GetBatch.PerformClick();
  468. }
  469. private void obd_outboxcode_KeyDown(object sender, KeyEventArgs e)
  470. {
  471. if (e.KeyCode == Keys.Enter)
  472. GetBatch.PerformClick();
  473. }
  474. }
  475. }