UAS_出货标签管理.cs 48 KB

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