UAS_出货标签管理.cs 49 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078
  1. using System;
  2. using System.Data;
  3. using System.Drawing;
  4. using System.Windows.Forms;
  5. using System.Text.RegularExpressions;
  6. using System.Text;
  7. using System.Collections.Generic;
  8. using System.Linq;
  9. using System.Diagnostics;
  10. using UAS_LabelMachine.PublicMethod;
  11. using UAS_LabelMachine.Entity;
  12. using System.Reflection;
  13. namespace UAS_LabelMachine
  14. {
  15. public partial class UAS_出货标签打印 : Form
  16. {
  17. //自适应屏幕
  18. AutoSizeFormClass asc = new AutoSizeFormClass();
  19. DataHelper dh;
  20. DataTable dt;
  21. /// <summary>
  22. /// 已经打印过的Vivo外箱号
  23. /// </summary>
  24. StringBuilder sql = new StringBuilder();
  25. /// <summary>
  26. /// 当前品牌
  27. /// </summary>
  28. string Brand;
  29. string PI_ID;
  30. /// <summary>
  31. /// 当前扫描的项目
  32. /// </summary>
  33. int CurrentItemIndex = 0;
  34. /// <summary>
  35. /// 当前扫描的所在行
  36. /// </summary>
  37. int CurrentRowIndex = 0;
  38. /// <summary>
  39. /// 正则表达式用于项目匹配
  40. /// </summary>
  41. Regex reg;
  42. /*标识供应商物料编号采集是否通过*/
  43. bool CollectVeProdCodePass = true;
  44. bool CollectQTYPass = true;
  45. bool logout = false;
  46. //每个不同序号存在的
  47. object[] ItemData;
  48. Dictionary<string, string> CollectData;
  49. /// <summary>
  50. /// 是否全选
  51. /// </summary>
  52. bool AllChecked = false;
  53. /*用于存放采集项目的Grid信息*/
  54. Dictionary<string, Dictionary<string, string>> SiItem;
  55. int CloumnCount = 0;
  56. //使用二维数组进行排序
  57. ArrayList<ArrayList<string>> ScanData;
  58. ArrayList<string> GetData;
  59. public UAS_出货标签打印(string Master)
  60. {
  61. this.SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.ResizeRedraw | ControlStyles.AllPaintingInWmPaint, true);
  62. this.UpdateStyles();
  63. InitializeComponent();
  64. Type dgvType = this.LabelInf.GetType();
  65. PropertyInfo pi = dgvType.GetProperty("DoubleBuffered", BindingFlags.Instance | BindingFlags.NonPublic);
  66. pi.SetValue(this.LabelInf, true, null);
  67. Text = Text + "-" + Master;
  68. }
  69. protected override void WndProc(ref Message m)
  70. {
  71. //拦截双击标题栏、移动窗体的系统消息
  72. if (m.Msg != 0xA3)
  73. {
  74. base.WndProc(ref m);
  75. }
  76. }
  77. private void 贴标机条码打印_Load(object sender, EventArgs e)
  78. {
  79. //杀死之前全部未关闭的进程
  80. Process[] processes = System.Diagnostics.Process.GetProcessesByName("lppa");
  81. for (int i = 0; i < processes.Length; i++)
  82. {
  83. processes[i].Kill();
  84. }
  85. //用计时器重置数据库链接
  86. LogManager.DoLog("程序启动,登陆人员【" + User.UserName + "】");
  87. dh = SystemInf.dh;
  88. CheckForIllegalCrossThreadCalls = false;
  89. CloumnCount = LabelInf.Columns.Count;
  90. pi_inoutno.Focus();
  91. //将本地读取的打印机设置进Combox,并选中默认打印机
  92. sg_brand.FormName = Name;
  93. sg_brand.SetValueField = new string[] { "sg_brand" };
  94. sg_brand.SelectField = "sg_code # 策略编号 ,sg_name # 策略名称,sg_brand # 品牌,sg_separator # 分隔符";
  95. sg_brand.TableName = "scangroup";
  96. sg_brand.DbChange += Sg_brand_DbChange;
  97. pr_code.FormName = Name;
  98. pr_code.SetValueField = new string[] { "pr_code" };
  99. pr_code.TableName = "prodiodetail left join product on pd_prodcode=pr_code";
  100. pr_code.SelectField = "pd_pdno # 行号,pr_code # 物料编号";
  101. cu_code.FormName = Name;
  102. cu_code.SetValueField = new string[] { "cu_code" };
  103. cu_code.TableName = "customer";
  104. cu_code.SelectField = "cu_code # 客户编号,cu_name # 客户名称";
  105. Point pt = new Point();
  106. //禁止所有列的排序
  107. foreach (DataGridViewColumn dgv in LabelInf.Columns)
  108. {
  109. dgv.SortMode = DataGridViewColumnSortMode.NotSortable;
  110. }
  111. int ScreenWidth = Screen.GetWorkingArea(pt).Width;
  112. //设置获取当前屏幕大小自动全屏但是保留任务栏
  113. Rectangle ScreenArea = Screen.GetWorkingArea(this);
  114. Top = 0;
  115. Left = 0;
  116. Width = ScreenArea.Width;
  117. Height = ScreenArea.Height;
  118. asc.controllInitializeSize(this);
  119. asc.controlAutoSize(this);
  120. }
  121. private void Sg_brand_DbChange(object sender, EventArgs e)
  122. {
  123. DataTable dt = sg_brand.ReturnData;
  124. BaseUtil.SetFormValue(this.Controls, dt);
  125. }
  126. //只执行一次窗体自适应
  127. bool AutoSized = false;
  128. private void 贴标机条码打印_SizeChanged(object sender, EventArgs e)
  129. {
  130. if (!AutoSized)
  131. {
  132. asc.controlAutoSize(this);
  133. AutoSized = true;
  134. }
  135. }
  136. private void GenerateBarCode_Click(object sender, EventArgs e)
  137. {
  138. 生成条码 form = new 生成条码(pi_inoutno.Text);
  139. form.FormClosed += LoadGridData;
  140. BaseUtil.SetFormCenter(form);
  141. form.ShowDialog();
  142. }
  143. private void CollectionSetting_Click(object sender, EventArgs e)
  144. {
  145. 采集策略 form = new 采集策略(sg_brand.Text);
  146. form.WindowState = FormWindowState.Maximized;
  147. form.FormClosed += sg_brand_UserControlTextChanged;
  148. BaseUtil.SetFormCenter(form);
  149. form.ShowDialog();
  150. }
  151. private void LabelFormClose(object sender, EventArgs e)
  152. {
  153. }
  154. /// <summary>
  155. /// 保存明细
  156. /// </summary>
  157. /// <param name="sender"></param>
  158. /// <param name="e"></param>
  159. private void SaveGrid_Click(object sender, EventArgs e)
  160. {
  161. DataTable savedt = (LabelInf.DataSource as DataTable);
  162. if (savedt != null && savedt.GetChanges() != null)
  163. {
  164. MidSource.EndEdit();
  165. dh.SaveDataTable(savedt.GetChanges(), "ProdioBarCode", "pib_id");
  166. CheckRecheckStatus();
  167. MessageBox.Show("保存成功!");
  168. }
  169. }
  170. //放大镜选择后出发的事件
  171. private void sg_brand_UserControlTextChanged(object sender, EventArgs e)
  172. {
  173. //取已启用的的按照采集次序排序
  174. DataTable dt = (DataTable)dh.ExecuteSql("select si_item,si_detno,sg_separator,si_kind,si_expression,si_expressionitem,si_index,si_indexstring,si_length from scanitem left join scangroup on si_sgid=sg_id where sg_brand='" + sg_brand.Text + "' and si_enable<>0 order by si_detno,si_innerdetno", "select");
  175. if (dt.Rows.Count == 0)
  176. {
  177. dt = (DataTable)dh.ExecuteSql("select si_item,si_detno,sg_separator,si_kind,si_expression,si_expressionitem,si_index,si_indexstring,si_length from scanitem left join scangroup on si_sgid=sg_id where nvl(sg_brand,' ')=' ' and si_enable<>0 order by si_detno,si_innerdetno", "select");
  178. }
  179. BaseUtil.FillDgvWithDataTable(Si_ItemDGV, dt);
  180. if (dt.Rows.Count > 0)
  181. {
  182. sg_separator.Text = dt.Rows[0]["sg_separator"].ToString();
  183. }
  184. //按DetNo排列之后的采集项
  185. ScanData = new ArrayList<ArrayList<string>>();
  186. //每个采集项目的子项
  187. GetData = new ArrayList<string>();
  188. //将数据添加进一个List的二维数组中
  189. for (int i = 0; i < Si_ItemDGV.RowCount; i++)
  190. {
  191. //如果不包含这个则添加进数组
  192. if (!GetData.Contains(Si_ItemDGV.Rows[i].Cells["si_item"].Value.ToString()))
  193. {
  194. GetData.Add(Si_ItemDGV.Rows[i].Cells["si_item"].Value.ToString());
  195. }
  196. //如果和后一个的采集次序相同
  197. if (((i + 1) < Si_ItemDGV.RowCount) && Si_ItemDGV.Rows[i].Cells["si_detno"].Value.ToString() == Si_ItemDGV.Rows[i + 1].Cells["si_detno"].Value.ToString())
  198. {
  199. GetData.Add(Si_ItemDGV.Rows[i + 1].Cells["si_item"].Value.ToString());
  200. }
  201. else
  202. {
  203. ScanData.Add(GetData);
  204. //添加完一次数据需要一个新的List
  205. GetData = new ArrayList<string>();
  206. }
  207. }
  208. RemindUser();
  209. if (ScanData.ToArray().Length > 0)
  210. {
  211. object[] arr = (ScanData.ToArray()[0] as ArrayList<string>).ToArray();
  212. if (arr.Contains("MPN") || arr.Contains("CPN"))
  213. {
  214. AutoMatch.CheckState = CheckState.Checked;
  215. AutoMatch.Enabled = true;
  216. }
  217. else
  218. {
  219. AutoMatch.CheckState = CheckState.Unchecked;
  220. AutoMatch.Enabled = false;
  221. }
  222. }
  223. }
  224. //输入框Enter事件
  225. private void Input_KeyDown(object sender, KeyEventArgs e)
  226. {
  227. if (e.KeyCode == Keys.Enter)
  228. {
  229. if (Input.Text == "")
  230. {
  231. MessageBox.Show("采集的数据不能为空");
  232. return;
  233. }
  234. if (Si_ItemDGV.Rows.Count == 0)
  235. {
  236. MessageBox.Show("未维护采集策略");
  237. return;
  238. }
  239. CollectInputData();
  240. DataTable savedt = (LabelInf.DataSource as DataTable);
  241. if (savedt != null && savedt.GetChanges() != null)
  242. {
  243. MidSource.EndEdit();
  244. dh.SaveDataTable(savedt.GetChanges(), "ProdioBarCode", "pib_id");
  245. }
  246. }
  247. }
  248. /// <summary>
  249. /// 设置自动匹配的数据的行号
  250. /// </summary>
  251. /// <returns></returns>
  252. private void SetAutoMatchRow()
  253. {
  254. //采集策略的第一组数据
  255. string[] arr = new string[ItemData.Length];
  256. if (sg_separator.Text == "")
  257. {
  258. for (int i = 0; i < arr.Length; i++)
  259. {
  260. arr[i] = Input.Text;
  261. }
  262. }
  263. else
  264. {
  265. arr = Input.Text.Split(sg_separator.Text.ToCharArray()).ToArray();
  266. }
  267. bool FindAutoMatch = false;
  268. for (int i = 0; i < LabelInf.RowCount; i++)
  269. {
  270. for (int j = 0; j < arr.Length; j++)
  271. {
  272. string orispeccode = LabelInf.Rows[i].Cells["pr_orispeccode"].Value.ToString();
  273. Console.WriteLine((MatchStr(arr[j].ToString(), "MPN")));
  274. Console.WriteLine(MatchStr(arr[j].ToString(), "MPN").Trim().Replace(" ", ""));
  275. if ((MatchStr(arr[j].ToString(), "MPN").Contains(orispeccode) || MatchStr(arr[j].ToString(), "MPN").Trim().Replace(" ", "").Contains(orispeccode) || orispeccode == MatchStr(arr[j].ToString(), "MPN") || LabelInf.Rows[i].Cells["pd_custprodcode"].Value.ToString() == MatchStr(arr[j].ToString(), "CPN")) && LabelInf.Rows[i].Cells["pib_ifpick"].FormattedValue.ToString() != "True")
  276. {
  277. CurrentRowIndex = i;
  278. if (CurrentRowIndex - 5 > 0)
  279. LabelInf.FirstDisplayedScrollingRowIndex = CurrentRowIndex - 5;
  280. else
  281. LabelInf.FirstDisplayedScrollingRowIndex = 0;
  282. Brand = LabelInf.Rows[CurrentRowIndex].Cells["pib_brand"].FormattedValue.ToString();
  283. if (Brand != "")
  284. sg_brand.Text = Brand;
  285. FindAutoMatch = true;
  286. break;
  287. }
  288. }
  289. if (FindAutoMatch)
  290. break;
  291. }
  292. }
  293. /// <summary>
  294. /// 采集数据
  295. /// </summary>
  296. private void CollectInputData()
  297. {
  298. LogManager.DoLog("采集数据【" + Input.Text + "】,使用采集策略编号【" + sg_brand.Text + "】");
  299. //按DetNo排列之后的采集项
  300. ScanData = new ArrayList<ArrayList<string>>();
  301. //每个采集项目的子项
  302. GetData = new ArrayList<string>();
  303. //用于保存采集策略的具体信息
  304. SiItem = new Dictionary<string, Dictionary<string, string>>();
  305. for (int i = 0; i < Si_ItemDGV.RowCount; i++)
  306. {
  307. //如果不包含这个则添加进数组
  308. if (!GetData.Contains(Si_ItemDGV.Rows[i].Cells["si_item"].Value.ToString()))
  309. GetData.Add(Si_ItemDGV.Rows[i].Cells["si_item"].Value.ToString());
  310. //如果和后一个的采集次序相同
  311. if (((i + 1) < Si_ItemDGV.RowCount) && Si_ItemDGV.Rows[i].Cells["si_detno"].Value.ToString() == Si_ItemDGV.Rows[i + 1].Cells["si_detno"].Value.ToString())
  312. GetData.Add(Si_ItemDGV.Rows[i + 1].Cells["si_item"].Value.ToString());
  313. else
  314. {
  315. ScanData.Add(GetData);
  316. //添加完一次数据需要一个新的List
  317. GetData = new ArrayList<string>();
  318. }
  319. Dictionary<string, string> item = new Dictionary<string, string>();
  320. for (int j = 0; j < Si_ItemDGV.ColumnCount; j++)
  321. {
  322. item.Add(Si_ItemDGV.Columns[j].DataPropertyName, Si_ItemDGV.Rows[i].Cells[j].Value.ToString());
  323. }
  324. SiItem.Add(Si_ItemDGV.Rows[i].Cells["si_item"].Value.ToString().ToUpper(), item);
  325. }
  326. //采集项目的数组
  327. ItemData = (ScanData.ToArray()[CurrentItemIndex] as ArrayList<string>).ToArray();
  328. //分隔符不为空的时候 //采集的项和Grid的数目不等
  329. //用户采集的数据的分割数组
  330. CollectData = new Dictionary<string, string>();
  331. if (sg_separator.Text == "")
  332. {
  333. for (int i = 0; i < ItemData.Length; i++)
  334. CollectData.Add(ItemData[i].ToString().ToUpper(), Input.Text);
  335. }
  336. else
  337. {
  338. int DataCount = Input.Text.Split(sg_separator.Text.ToCharArray()).Length;
  339. if (DataCount > ItemData.Length)
  340. {
  341. MessageBox.Show("采集数据大于采集项次");
  342. return;
  343. }
  344. else if (DataCount < ItemData.Length)
  345. {
  346. MessageBox.Show("采集数据小于采集项次");
  347. return;
  348. }
  349. for (int i = 0; i < DataCount; i++)
  350. CollectData.Add(ItemData[i].ToString().ToUpper(), Input.Text.Split(sg_separator.Text.ToCharArray())[i]);
  351. }
  352. //首先判断当前采集的个数,如果采集的个数为1则不对数据进行分隔符验证
  353. if (ItemData.Length == 1)
  354. {
  355. CollectData.Clear();
  356. CollectData.Add(ItemData[0].ToString().ToUpper(), Input.Text);
  357. //勾选了自动匹配调用该函数
  358. if (AutoMatch.Checked)
  359. SetAutoMatchRow();
  360. //将筛选之后的值赋给Cell
  361. SetDataToCell(ref CollectData, ItemData[0].ToString().ToUpper());
  362. }
  363. //如果本次采集的数据分割后和当前的采集项目个数不一样提示用户错误
  364. else if (CollectData.ToArray().Length == ItemData.Length)
  365. {
  366. for (int i = 0; i < ItemData.Length; i++)
  367. {
  368. //勾选了自动匹配调用该函数
  369. if (AutoMatch.Checked)
  370. SetAutoMatchRow();
  371. //将筛选之后的值赋给Cell
  372. SetDataToCell(ref CollectData, ItemData[i].ToString().ToUpper());
  373. }
  374. }
  375. else
  376. {
  377. MessageBox.Show("所采集的数据个数和采集项目不符");
  378. return;
  379. }
  380. //采集项目的索引+1
  381. CurrentItemIndex = CurrentItemIndex + 1;
  382. //如果已经采集完了最后一个
  383. if (CurrentItemIndex == ScanData.ToArray().Length)
  384. {
  385. //数据校验均已通过则勾选上已采集
  386. if (CollectVeProdCodePass && CollectQTYPass)
  387. {
  388. //如果按盒号采集,所有的此盒的均更新为
  389. DataTable dt = (DataTable)MidSource.DataSource;
  390. LabelInf.Rows[CurrentRowIndex].Cells["pib_ifpick"].Value = true;
  391. LabelInf.Rows[CurrentRowIndex].Cells["Choose"].Value = true;
  392. string datecode = LabelInf.Rows[CurrentRowIndex].Cells["pib_datecode"].Value.ToString();
  393. string lotno = LabelInf.Rows[CurrentRowIndex].Cells["pib_lotno"].Value.ToString();
  394. string pib_id = LabelInf.Rows[CurrentRowIndex].Cells["pib_id1"].Value.ToString();
  395. ErrorType.Clear();
  396. dh.ExecuteSql("update prodiobarcode set pib_datecode='" + datecode + "',pib_lotno='" + lotno + "',pib_ifpick=-1 where pib_id='" + pib_id + "'", "update");
  397. CheckRecheckStatus();
  398. LabelInf.Invalidate();
  399. }
  400. //采集未通过的时候
  401. else
  402. {
  403. ErrorType.Clear();
  404. //如果自动采集采集未成功需要移动到下一行
  405. if (!AutoMatch.Checked)
  406. SetRowIndexToCollectRow();
  407. }
  408. //当前项目已采集完成,重置采集项目
  409. CurrentItemIndex = 0;
  410. //未勾选自动匹配,设置到下一个未采集的行
  411. if (!AutoMatch.Checked)
  412. SetRowIndexToCollectRow();
  413. }
  414. RemindUser();
  415. //提醒用户需要采集的数据
  416. MessageLog.AppendText(">>扫描到数据" + Input.Text + "\n", Color.Blue);
  417. //如果所采集的行的物料不一样的话,重新计算箱内容量
  418. if (CurrentRowIndex - 1 > 0)
  419. {
  420. string LastRowProd = LabelInf.Rows[CurrentRowIndex - 1].Cells["pib_prodcode"].Value.ToString();
  421. string CurrentRowProd = LabelInf.Rows[CurrentRowIndex].Cells["pib_prodcode"].Value.ToString();
  422. }
  423. if (CleanInputAfterCollect.Checked)
  424. Input.Text = "";
  425. }
  426. //设置行的索引到当前需要采集的行
  427. private void SetRowIndexToCollectRow()
  428. {
  429. //获取当前需要采集的行
  430. for (int i = CurrentRowIndex; i < LabelInf.RowCount; i++)
  431. {
  432. if (LabelInf.Rows[i].Cells["pib_ifpick"].FormattedValue.ToString() != "True")
  433. {
  434. griddetno.Text = LabelInf.Rows[i].Cells["pib_pdno"].FormattedValue.ToString();
  435. pr_code.Text = LabelInf.Rows[i].Cells["pib_prodcode"].FormattedValue.ToString();
  436. CurrentRowIndex = LabelInf.Rows[i].Cells["pib_prodcode"].RowIndex;
  437. break;
  438. }
  439. }
  440. }
  441. /// <summary>
  442. /// 提醒用户当前采集的项目
  443. /// </summary>
  444. private void RemindUser()
  445. {
  446. SetRowIndexToCollectRow();
  447. if (ScanData.ToArray().Length > 0)
  448. {
  449. object[] arr = (ScanData.ToArray()[CurrentItemIndex] as ArrayList<string>).ToArray();
  450. string Inf = "";
  451. for (int i = 0; i < arr.Length; i++)
  452. {
  453. Inf += arr[i] + " ";
  454. }
  455. MessageLog.AppendText(">>当前采集行" + (CurrentRowIndex + 1) + ",请采集" + Inf + "\n", Color.Green);
  456. }
  457. }
  458. List<string> ErrorType = new List<string>();
  459. /// <summary>
  460. /// 自定义函数 将匹配之后的值设置到Cell中,传递引用,每次赋值之后从List中移除已使用过的
  461. /// </summary>
  462. /// <param name="data"></param>
  463. /// <param name="kind"></param>
  464. private void SetDataToCell(ref Dictionary<string, string> setdata, string kind)
  465. {
  466. int length = setdata.Count;
  467. for (int j = 0; j < length; j++)
  468. {
  469. string[] data = new string[setdata.Count];
  470. for (int i = 0; i < length; i++)
  471. {
  472. data[i] = setdata[kind];
  473. }
  474. for (int i = 0; i < data.Length; i++)
  475. {
  476. DataGridViewCell cell = null;
  477. string Matchstr = "";
  478. switch (kind.ToString().ToUpper())
  479. {
  480. case "DATECODE":
  481. cell = LabelInf.Rows[CurrentRowIndex].Cells["pib_datecode"];
  482. Matchstr = MatchStr(data[j], "DATECODE");
  483. setdata.Remove("DATECODE");
  484. length--;
  485. break;
  486. case "LOTNO":
  487. cell = LabelInf.Rows[CurrentRowIndex].Cells["pib_lotno"];
  488. Matchstr = MatchStr(data[j], "LOTNO");
  489. setdata.Remove("LOTNO");
  490. length--;
  491. break;
  492. case "MPN":
  493. cell = LabelInf.Rows[CurrentRowIndex].Cells["pr_orispeccode"];
  494. Matchstr = MatchStr(data[j], "MPN");
  495. //采集的供应商号不匹配的话
  496. Console.WriteLine(Matchstr.Trim().Replace(" ", ""));
  497. if (cell.Value.ToString() == Matchstr || Matchstr.Trim().Replace(" ", "").Contains(cell.Value.ToString()) || Matchstr.Contains(cell.Value.ToString()))
  498. {
  499. ErrorType.Add("OK_MPN");
  500. BaseUtil.PlaySound("OK.wav");
  501. LabelInf.Refresh();
  502. CollectVeProdCodePass = true;
  503. }
  504. else
  505. {
  506. ErrorType.Add("NG_MPN");
  507. CollectVeProdCodePass = false;
  508. BaseUtil.PlaySound("NG.wav");
  509. //添加需要重绘的Cell
  510. LabelInf.Refresh();
  511. MessageLog.AppendText(">>供应商物料编号不匹配\n", Color.Red);
  512. }
  513. setdata.Remove("MPN");
  514. length--;
  515. break;
  516. case "QTY":
  517. cell = LabelInf.Rows[CurrentRowIndex].Cells["pib_qty"];
  518. Matchstr = MatchStr(data[j], "QTY");
  519. //如果采集的数量不相等的话
  520. if (cell.Value.ToString() != Matchstr)
  521. {
  522. CollectQTYPass = false;
  523. LabelInf.Refresh();
  524. MessageLog.AppendText(">>数量不匹配\n", Color.Red);
  525. }
  526. else
  527. {
  528. LabelInf.Refresh();
  529. CollectQTYPass = true;
  530. }
  531. setdata.Remove("QTY");
  532. length--;
  533. break;
  534. case "CPN":
  535. cell = LabelInf.Rows[CurrentRowIndex].Cells["pd_custprodcode"];
  536. Matchstr = MatchStr(data[j], "CPN");
  537. //如果采集的数量不相等的话
  538. if (cell.Value.ToString() != Matchstr)
  539. {
  540. ErrorType.Add("NG_CPN");
  541. BaseUtil.PlaySound("NG.wav");
  542. CollectQTYPass = false;
  543. LabelInf.Refresh();
  544. MessageLog.AppendText(">>CPN不匹配\n", Color.Red);
  545. }
  546. else
  547. {
  548. ErrorType.Add("OK_CPN");
  549. BaseUtil.PlaySound("OK.wav");
  550. LabelInf.Refresh();
  551. CollectQTYPass = true;
  552. }
  553. setdata.Remove("CPN");
  554. length--;
  555. break;
  556. default:
  557. break;
  558. }
  559. //如果数据为空或者数据不为空的时候但是和需要采集的数据不相等的情况下进行采集
  560. //MPN和QTY只做比较不需要赋值
  561. if (cell.Value.ToString() == "" || cell.Value.ToString() != Matchstr)
  562. {
  563. string MatchResult = "";
  564. if (kind != "MPN" && kind != "QTY" && kind != "CPN")
  565. {
  566. DataTable dt = (DataTable)MidSource.DataSource;
  567. cell.Value = Matchstr;
  568. MatchResult = "成功";
  569. }
  570. else
  571. MatchResult = "失败";
  572. switch (SiItem[kind]["si_kind"])
  573. {
  574. case "索引字符":
  575. LogManager.DoLog("采集项" + kind + ",匹配结果:【" + MatchResult + "】,匹配方式:" + SiItem[kind]["si_kind"] + ",使用字符" + SiItem[kind]["si_indexstring"] + ",匹配后字符串" + Matchstr);
  576. break;
  577. case "起始位置":
  578. LogManager.DoLog("采集项" + kind + ",匹配结果:【" + MatchResult + "】,匹配方式:" + SiItem[kind]["si_kind"] + ",从第" + SiItem[kind]["si_index"] + "位开始匹配,匹配后字符串" + Matchstr);
  579. break;
  580. case "二次解析":
  581. LogManager.DoLog("采集项" + kind + ",匹配结果:【" + MatchResult + "】,匹配方式:" + SiItem[kind]["si_kind"] + ",匹配后字符串" + Matchstr);
  582. break;
  583. case "全部":
  584. LogManager.DoLog("采集项" + kind + ",匹配结果:【" + MatchResult + "】,匹配方式:" + SiItem[kind]["si_kind"] + ",匹配后字符串" + Matchstr);
  585. break;
  586. default:
  587. break;
  588. }
  589. }
  590. else
  591. LogManager.DoLog("采集项" + kind + ",匹配结果:【成功】,匹配方式:" + SiItem[kind]["si_kind"] + ",,匹配后字符串" + Matchstr);
  592. }
  593. }
  594. }
  595. /// <summary>
  596. /// 自定义函数 根据匹配规则
  597. /// si_item的二维数组,str是需要赋值的字符串,item表示DateCode,LotNo等
  598. /// </summary>
  599. /// <param name="SiItem"></param>
  600. /// <param name="str"></param>
  601. /// <param name="item"></param>
  602. /// <returns></returns>
  603. private string MatchStr(string str, string item)
  604. {
  605. string kind = SiItem[item]["si_kind"];
  606. //起始字符不为空的时候
  607. switch (kind)
  608. {
  609. case "起始位置":
  610. if (SiItem[item]["si_index"] != "")
  611. {
  612. try
  613. {
  614. //长度不为空的时候按照指定的长度去取数据
  615. if (SiItem[item]["si_length"] != "")
  616. str = str.Substring(int.Parse(SiItem[item]["si_index"]), int.Parse(SiItem[item]["si_length"]));
  617. //长度为空的时候取index之后的全部数据
  618. else
  619. str = str.Substring(int.Parse(SiItem[item]["si_index"]));
  620. }
  621. catch (Exception e) { LogManager.DoLog(e.StackTrace); }
  622. }
  623. break;
  624. case "索引字符":
  625. try
  626. {
  627. if (SiItem[item]["si_indexstring"] != "")
  628. {
  629. //长度不为空的时候按照指定的长度去取数据
  630. if (SiItem[item]["si_length"] != "")
  631. str = str.Substring(str.IndexOf(SiItem[item]["si_indexstring"]) + 1, int.Parse(SiItem[item]["si_length"]));
  632. //长度为空的时候取index之后的全部数据
  633. else
  634. str = str.Substring(str.IndexOf(SiItem[item]["si_indexstring"]) + 1);
  635. }
  636. }
  637. catch (Exception e) { LogManager.DoLog(e.StackTrace); }
  638. break;
  639. case "全部":
  640. break;
  641. default:
  642. break;
  643. }
  644. if (SiItem[item]["si_expression"] != "")
  645. {
  646. string log = "使用正则表达式" + SiItem[item]["si_expression"] + "匹配数据" + str;
  647. reg = new Regex(SiItem[item]["si_expression"]);
  648. try
  649. {
  650. str = reg.Matches(str)[int.Parse(SiItem[item]["si_expressionitem"].ToString()) - 1].Value;
  651. }
  652. catch (Exception)
  653. {
  654. }
  655. log += ",匹配后数据" + str;
  656. LogManager.DoLog(log);
  657. }
  658. return str;
  659. }
  660. //关闭窗口前提示用户确认
  661. private void 贴标机条码打印_FormClosing(object sender, FormClosingEventArgs e)
  662. {
  663. //如果不是注销的话
  664. if (!logout)
  665. {
  666. string close = MessageBox.Show(this.ParentForm, "是否关闭", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question).ToString();
  667. if (close.ToString() != "Yes")
  668. e.Cancel = true;
  669. else
  670. {
  671. LogManager.DoLog("关闭程序");
  672. }
  673. }
  674. }
  675. /// <summary>
  676. /// 出入库单录入框的回车事件
  677. /// </summary>
  678. /// <param name="sender"></param>
  679. /// <param name="e"></param>
  680. private void pi_inoutno_KeyDown(object sender, KeyEventArgs e)
  681. {
  682. if (e.KeyCode == Keys.Enter)
  683. {
  684. sql.Clear();
  685. sql.Append("select pi_id,pi_cardcode,to_char(pi_date,'yyyymmdd')pi_date,nvl(cu_needrecheck,0)cu_needrecheck from prodinout left join customer on cu_code=pi_cardcode where pi_inoutno='" + pi_inoutno.Text + "' ");
  686. DataTable dt = (DataTable)dh.ExecuteSql(sql.ToString(), "select");
  687. ErrorType.Clear();
  688. if (dt.Rows.Count > 0)
  689. {
  690. cu_code.Text = dt.Rows[0]["pi_cardcode"].ToString();
  691. cu_needrecheck.Text = dt.Rows[0]["cu_needrecheck"].ToString();
  692. pi_date.Text = dt.Rows[0]["pi_date"].ToString();
  693. PI_ID = dt.Rows[0]["pi_id"].ToString();
  694. dt = (DataTable)dh.ExecuteSql("select 1 from prodiobarcode where pib_inoutno='" + pi_inoutno.Text + "'", "select");
  695. if (dh.GetConfig("AutoBarcode", "ProdInOut!Sale").ToString() != "" && dt.Rows.Count == 0)
  696. {
  697. string Error = "";
  698. string[] param = new string[] { PI_ID, "", Error };
  699. dh.CallProcedure("GetCustBarcode", param);
  700. }
  701. LoadGridData(sender, e);
  702. //设置当前的最大箱号
  703. CurrentItemIndex = 0;
  704. LogManager.DoLog("输入单号【" + pi_inoutno.Text + "】");
  705. }
  706. else
  707. MessageBox.Show("当前出入库单号不存在或者未审核!");
  708. }
  709. }
  710. private void CleanDetail_Click(object sender, EventArgs e)
  711. {
  712. ArrayList<string> DeleteID = new ArrayList<string>();
  713. for (int i = 0; i < LabelInf.RowCount; i++)
  714. {
  715. if (LabelInf.Rows[i].Cells["Choose"].FormattedValue.ToString() == "True")
  716. DeleteID.Add(LabelInf.Rows[i].Cells["pib_id1"].Value.ToString());
  717. }
  718. //勾选了删除的明细之后
  719. if (DeleteID.ToArray().Length > 0)
  720. {
  721. string close = MessageBox.Show(this.ParentForm, "删除后不可恢复,是否确认删除", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question).ToString();
  722. if (close.ToString() == "Yes")
  723. {
  724. dh.BatchInsert("delete from prodiobarcode where pib_id=:pib_id", new string[] { "pib_id" }, DeleteID.ToArray());
  725. MessageBox.Show("删除成功");
  726. LoadGridData(sender, e);
  727. }
  728. }
  729. else
  730. MessageBox.Show("尚未勾选需要删除的明细");
  731. }
  732. private void LoadGridData()
  733. {
  734. LoadGridData(new object(), new EventArgs());
  735. }
  736. /// <summary>
  737. /// 自定义函数 加载明细行的数据,多处使用添加进函数
  738. /// </summary>
  739. /// <param name="sender"></param>
  740. /// <param name="e"></param>
  741. private void LoadGridData(object sender, EventArgs e)
  742. {
  743. sql.Clear();
  744. sql.Append("select 0 choose,pd_custprodcode,pd_custprodspec,pr_orispeccode,pd_pocode,pib_madein,pib_custbarcode,pib_custoutboxcode,pib_id,pib_datecode1,pib_pdid,pib_piid,pib_pdno,pib_prodcode,nvl(nvl(pd_brand,pib_brand),pr_brand)pib_brand, pr_vendprodcode,");
  745. sql.Append("pib_lotno,pib_datecode,pib_qty,pr_spec,pr_detail,pr_zxbzs,pr_unit,pib_barcode,pib_outboxcode1,pib_outboxcode2,nvl(pib_ifpick,0)pib_ifpick,nvl(pib_ifprint,0)pib_ifprint");
  746. sql.Append(" from prodiobarcode left join prodiodetail on pib_piid=pd_piid and pd_pdno=pib_pdno and ");
  747. sql.Append(" pd_prodcode=pib_prodcode left join product on pr_code=pib_prodcode left join sale on sa_code=pib_ordercode ");
  748. sql.Append("where pib_piid='" + PI_ID + "' order by pd_pdno");
  749. dt = (DataTable)dh.ExecuteSql(sql.ToString(), "select");
  750. MidSource.DataSource = dt;
  751. BaseUtil.FillDgvWithDataTable(LabelInf, (DataTable)MidSource.DataSource);
  752. //有数据的话默认取第一条的品牌去取采集策略
  753. TotalCount.Text = LabelInf.RowCount.ToString();
  754. if (LabelInf.RowCount > 0)
  755. {
  756. Brand = LabelInf.Rows[0].Cells["pib_brand"].FormattedValue.ToString();
  757. if (Brand != "")
  758. sg_brand.Text = Brand;
  759. }
  760. //绑定数据之后往下找到未采集的数据显示在当前采集的栏目
  761. for (int i = 0; i < LabelInf.RowCount; i++)
  762. {
  763. if (LabelInf.Rows[i].Cells["pib_ifpick"].FormattedValue.ToString() != "True")
  764. {
  765. griddetno.Text = LabelInf.Rows[i].Cells["pib_pdno"].FormattedValue.ToString();
  766. pr_code.Text = LabelInf.Rows[i].Cells["pib_prodcode"].FormattedValue.ToString();
  767. pib_id.Text = LabelInf.Rows[i].Cells["pib_id1"].FormattedValue.ToString();
  768. CurrentRowIndex = LabelInf.Rows[i].Cells["pib_prodcode"].RowIndex;
  769. break;
  770. }
  771. }
  772. }
  773. /// <summary>
  774. /// 重绘Cell的颜色
  775. /// </summary>
  776. /// <param name="sender"></param>
  777. /// <param name="e"></param>
  778. private void LabelInf_CellPainting(object sender, DataGridViewCellPaintingEventArgs e)
  779. {
  780. bool mouseOver = e.CellBounds.Contains(this.PointToClient(Cursor.Position));
  781. if (e.ColumnIndex > 0)
  782. {
  783. if (LabelInf.Columns[e.ColumnIndex].Name == "pib_custbarcode" || LabelInf.Columns[e.ColumnIndex].Name == "pib_barcode" || LabelInf.Columns[e.ColumnIndex].Name == "pib_madein" || LabelInf.Columns[e.ColumnIndex].Name == "pib_lotno" || LabelInf.Columns[e.ColumnIndex].Name == "pib_datecode" || LabelInf.Columns[e.ColumnIndex].Name == "pib_outboxcode1" || LabelInf.Columns[e.ColumnIndex].Name == "pib_outboxcode2" || LabelInf.Columns[e.ColumnIndex].Name == "pib_brand")
  784. {
  785. SolidBrush solidBrush = new SolidBrush(Color.FromArgb(51, 153, 255));
  786. e.Graphics.FillRectangle(mouseOver ? solidBrush : Brushes.LightSeaGreen, e.CellBounds);
  787. Rectangle border = e.CellBounds;
  788. border.Width -= 1;
  789. e.Graphics.DrawRectangle(Pens.White, border);
  790. e.PaintContent(e.CellBounds);
  791. e.Handled = true;
  792. }
  793. if (e.RowIndex >= 0)
  794. {
  795. if (LabelInf.Rows[e.RowIndex].Cells["pib_ifpick"].FormattedValue.ToString() == "True")
  796. {
  797. if (LabelInf.Columns[e.ColumnIndex].Name == "pr_orispeccode" || LabelInf.Columns[e.ColumnIndex].Name == "pd_custprodcode")
  798. {
  799. SolidBrush solidBrush = new SolidBrush(Color.FromArgb(51, 153, 255));
  800. e.Graphics.FillRectangle(Brushes.ForestGreen, e.CellBounds);
  801. Rectangle border = e.CellBounds;
  802. border.Width -= 1;
  803. e.Graphics.DrawRectangle(Pens.Black, border);
  804. e.PaintContent(e.CellBounds);
  805. e.Handled = true;
  806. }
  807. }
  808. }
  809. if (e.RowIndex == CurrentRowIndex)
  810. {
  811. if (LabelInf.Columns[e.ColumnIndex].Name == "pr_orispeccode")
  812. {
  813. SolidBrush solidBrush = new SolidBrush(Color.FromArgb(51, 153, 255));
  814. if (ErrorType.Count > 0)
  815. {
  816. if (ErrorType.Contains("OK_MPN"))
  817. {
  818. e.Graphics.FillRectangle(Brushes.ForestGreen, e.CellBounds);
  819. Rectangle border = e.CellBounds;
  820. border.Width -= 1;
  821. e.Graphics.DrawRectangle(Pens.Black, border);
  822. e.PaintContent(e.CellBounds);
  823. e.Handled = true;
  824. }
  825. else if (ErrorType.Contains("NG_MPN"))
  826. {
  827. e.Graphics.FillRectangle(Brushes.Red, e.CellBounds);
  828. Rectangle border = e.CellBounds;
  829. border.Width -= 1;
  830. e.Graphics.DrawRectangle(Pens.Black, border);
  831. e.PaintContent(e.CellBounds);
  832. e.Handled = true;
  833. }
  834. }
  835. }
  836. if (LabelInf.Columns[e.ColumnIndex].Name == "pd_custprodcode")
  837. {
  838. SolidBrush solidBrush = new SolidBrush(Color.FromArgb(51, 153, 255));
  839. if (ErrorType.Count > 0)
  840. {
  841. if (ErrorType.Contains("OK_CPN"))
  842. {
  843. e.Graphics.FillRectangle(Brushes.ForestGreen, e.CellBounds);
  844. Rectangle border = e.CellBounds;
  845. border.Width -= 1;
  846. e.Graphics.DrawRectangle(Pens.Black, border);
  847. e.PaintContent(e.CellBounds);
  848. e.Handled = true;
  849. }
  850. else if (ErrorType.Contains("NG_CPN"))
  851. {
  852. e.Graphics.FillRectangle(Brushes.Red, e.CellBounds);
  853. Rectangle border = e.CellBounds;
  854. border.Width -= 1;
  855. e.Graphics.DrawRectangle(Pens.Black, border);
  856. e.PaintContent(e.CellBounds);
  857. e.Handled = true;
  858. }
  859. }
  860. }
  861. }
  862. }
  863. }
  864. private void pr_code_SearchIconClick(object sender, EventArgs e)
  865. {
  866. pr_code.Condition = " pd_inoutno='" + pi_inoutno.Text + "'";
  867. }
  868. private void pr_code_UserControlTextChanged(object sender, EventArgs e)
  869. {
  870. //用户在重新勾选后重置采集项目的索引
  871. for (int i = 0; i < LabelInf.RowCount; i++)
  872. {
  873. if (pr_code.Text == LabelInf.Rows[i].Cells["pib_prodcode"].Value.ToString() && LabelInf.Rows[i].Cells["pib_ifpick"].FormattedValue.ToString() != "True")
  874. {
  875. CurrentRowIndex = i;
  876. break;
  877. }
  878. }
  879. }
  880. private void Refresh_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
  881. {
  882. KeyEventArgs e2 = new KeyEventArgs(Keys.Enter);
  883. pi_inoutno_KeyDown(sender, e2);
  884. }
  885. /// <summary>
  886. /// 采集明细切换
  887. /// </summary>
  888. /// <param name="sender"></param>
  889. /// <param name="e"></param>
  890. private void griddetno_KeyDown(object sender, KeyEventArgs e)
  891. {
  892. if (Keys.Enter == e.KeyData)
  893. {
  894. bool FindDetno = false;
  895. for (int i = 0; i < LabelInf.RowCount; i++)
  896. {
  897. if (LabelInf.Rows[i].Cells["pib_pdno"].Value.ToString() == griddetno.Text && LabelInf.Rows[i].Cells["pib_ifpick"].FormattedValue.ToString() != "True")
  898. {
  899. FindDetno = true;
  900. CurrentItemIndex = 0;
  901. CurrentRowIndex = i;
  902. RemindUser();
  903. break;
  904. }
  905. }
  906. if (!FindDetno)
  907. {
  908. MessageBox.Show("不存在未采集的明细序号" + griddetno.Text);
  909. return;
  910. }
  911. }
  912. }
  913. private void LogingOut_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
  914. {
  915. string close = MessageBox.Show(this.ParentForm, "是否注销", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question).ToString();
  916. if (close.ToString() == "Yes")
  917. {
  918. Login login = new Login();
  919. //注销的时候需要将拼接的连接字符串置空
  920. DataHelper.DBConnectionString = null;
  921. logout = true;
  922. this.Hide();
  923. login.ShowDialog();
  924. this.Close();
  925. }
  926. }
  927. private void LabelInf_DataError(object sender, DataGridViewDataErrorEventArgs e) { }
  928. private void ChooseAll_Click(object sender, EventArgs e)
  929. {
  930. if (AllChecked)
  931. {
  932. foreach (DataGridViewRow dr in LabelInf.Rows)
  933. dr.Cells[0].Value = false;
  934. AllChecked = false;
  935. }
  936. else
  937. {
  938. foreach (DataGridViewRow dr in LabelInf.Rows)
  939. dr.Cells[0].Value = true;
  940. AllChecked = true;
  941. }
  942. }
  943. private void ExportData_Click(object sender, EventArgs e)
  944. {
  945. ExportFileDialog.Description = "选择导出的路径";
  946. DialogResult result = ExportFileDialog.ShowDialog();
  947. if (result == DialogResult.OK)
  948. {
  949. ExcelHandler eh = new ExcelHandler();
  950. DataTable dt = ((DataTable)MidSource.DataSource).Copy();
  951. for (int i = dt.Columns.Count - 1; i >= 0; i--)
  952. {
  953. for (int j = 0; j < LabelInf.Columns.Count; j++)
  954. {
  955. //去除ID列
  956. if (dt.Columns[i].ColumnName.ToLower().Contains("id") || dt.Columns[i].ColumnName.ToLower() == "pib_barcode" || dt.Columns[i].ColumnName.ToLower() == "pib_pdno" || dt.Columns[i].ColumnName.ToLower() == "pib_ifpick" || dt.Columns[i].ColumnName.ToLower() == "pib_ifprint" || dt.Columns[i].ColumnName.ToLower() == "pib_datecode1" || dt.Columns[i].ColumnName.ToLower() == "pr_vendprodcode")
  957. {
  958. dt.Columns.RemoveAt(i);
  959. break;
  960. }
  961. switch (dt.Columns[i].ColumnName.ToLower())
  962. {
  963. case "pib_lotno":
  964. dt.Columns[i].ColumnName = "批次号";
  965. break;
  966. case "pib_datecode":
  967. dt.Columns[i].ColumnName = "生产日期";
  968. break;
  969. case "pib_custbarcode":
  970. dt.Columns[i].ColumnName = "最小产品包装条码";
  971. break;
  972. default:
  973. break;
  974. }
  975. if (dt.Columns[i].ColumnName.ToLower() == LabelInf.Columns[j].DataPropertyName.ToLower())
  976. {
  977. dt.Columns[i].ColumnName = LabelInf.Columns[j].HeaderText;
  978. break;
  979. }
  980. }
  981. }
  982. eh.ExportExcel(dt, ExportFileDialog.SelectedPath, pi_date.Text + "-" + pi_inoutno.Text);
  983. string close = MessageBox.Show(this.ParentForm, "导出成功,是否打开文件", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question).ToString();
  984. if (close.ToString() == "Yes")
  985. System.Diagnostics.Process.Start(ExportFileDialog.SelectedPath + "\\" + pi_date.Text + "-" + pi_inoutno.Text + ".xls");
  986. }
  987. }
  988. private void CleanBarCode_Click(object sender, EventArgs e)
  989. {
  990. string close = MessageBox.Show(this.ParentForm, "是否清除该出货单条码", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question).ToString();
  991. if (close.ToString() == "Yes")
  992. {
  993. dh.ExecuteSql("delete from prodiobarcode where pib_inoutno='" + pi_inoutno.Text + "'", "delete");
  994. LoadGridData(sender, e);
  995. }
  996. }
  997. private void CollectAll_Click(object sender, EventArgs e)
  998. {
  999. int PickedCount = 0;
  1000. for (int i = 0; i < LabelInf.Rows.Count; i++)
  1001. {
  1002. if (LabelInf.Rows[i].Cells["pib_ifpick"].FormattedValue.ToString() != "True")
  1003. {
  1004. LabelInf.Rows[i].Cells["pib_ifpick"].Value = true;
  1005. }
  1006. else
  1007. {
  1008. PickedCount = PickedCount + 1;
  1009. }
  1010. }
  1011. if (PickedCount == LabelInf.Rows.Count)
  1012. {
  1013. for (int i = 0; i < LabelInf.Rows.Count; i++)
  1014. {
  1015. LabelInf.Rows[i].Cells["pib_ifpick"].Value = false;
  1016. }
  1017. }
  1018. }
  1019. private void CheckRecheckStatus()
  1020. {
  1021. if (cu_needrecheck.Text == "0")
  1022. {
  1023. dh.ExecuteSql("update customer set cu_needrecheck=-1 where cu_code='" + cu_code.Text + "'", "update");
  1024. }
  1025. if (dh.getRowCount("prodiobarcode", "nvl(pib_ifpick,0)<>0 and pib_inoutno='" + pi_inoutno.Text + "'") == LabelInf.Rows.Count)
  1026. {
  1027. dh.ExecuteSql("update prodinout set pi_recheckstatus='已复核' where pi_inoutno='" + pi_inoutno.Text + "'", "update");
  1028. }
  1029. }
  1030. }
  1031. }