UAS_出货标签管理.cs 49 KB

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