UAS_出货标签管理.cs 52 KB

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