UAS_出货标签管理.cs 69 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505
  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 LabelManager2;
  11. using UAS_LabelMachine.PublicMethod;
  12. using UAS_LabelMachine.Entity;
  13. using UAS_特殊解析规则;
  14. using UAS_LabelMachine.PublicForm;
  15. using System.Threading;
  16. using System.IO;
  17. using System.Globalization;
  18. using System.IO.Ports;
  19. using UAS_LabelMachine.CustomControl;
  20. namespace UAS_LabelMachine
  21. {
  22. public partial class UAS_出货标签打印 : Form
  23. {
  24. //自适应屏幕
  25. AutoSizeFormClass asc = new AutoSizeFormClass();
  26. DataHelper dh;
  27. AccessDBHelper adh;
  28. DataTable dt;
  29. StringBuilder sql = new StringBuilder();
  30. /// <summary>
  31. /// CodeSoft新建打印机引擎
  32. /// </summary>
  33. ApplicationClass lbl;
  34. /// <summary>
  35. /// 单盘打印文件
  36. /// </summary>
  37. Document SingleDoc;
  38. /// <summary>
  39. /// 中盒打印文件
  40. /// </summary>
  41. Document MidDoc;
  42. /// <summary>
  43. /// 外箱打印文件
  44. /// </summary>
  45. Document OutBoxDoc;
  46. /// <summary>
  47. /// Loading窗口
  48. /// </summary>
  49. SetLoadingWindow stw;
  50. /// <summary>
  51. /// 弹窗线程
  52. /// </summary>
  53. Thread thread;
  54. /// <summary>
  55. /// 当前品牌
  56. /// </summary>
  57. string Brand;
  58. string PI_ID;
  59. /// <summary>
  60. /// 当前扫描的所在行
  61. /// </summary>
  62. int CurrentRowIndex = 0;
  63. /// <summary>
  64. /// 最大的出入口单号
  65. /// </summary>
  66. int MaxOutBoxCode = 1;
  67. /// <summary>
  68. /// 正则表达式用于项目匹配
  69. /// </summary>
  70. Regex reg;
  71. /*标识供应商物料编号采集是否通过*/
  72. bool CollectVeProdCodePass = true;
  73. bool CollectQTYPass = true;
  74. bool logout = false;
  75. DataTable SingleLabelParam;
  76. DataTable MidLabelParam;
  77. DataTable OutLabelParam;
  78. /// <summary>
  79. /// 存放单盘的ID
  80. /// </summary>
  81. List<string> SingleID = new List<string>();
  82. /// <summary>
  83. /// 单盘的打印参数
  84. /// </summary>
  85. List<string> SingleBoxArgument = new List<string>();
  86. /// <summary>
  87. /// 存放中盒的ID和盒号
  88. /// </summary>
  89. Dictionary<string, string> MidIDAndOutboxcode = new Dictionary<string, string>();
  90. /// <summary>
  91. /// 中盒的打印参数
  92. /// </summary>
  93. List<string> MidBoxArgument = new List<string>();
  94. /// <summary>
  95. /// 全部采集
  96. /// </summary>
  97. bool AllCollect = false;
  98. /// <summary>
  99. /// 是否全选
  100. /// </summary>
  101. bool AllChecked = false;
  102. /// <summary>
  103. /// 默认采集了指定的数据上传
  104. /// </summary>
  105. int UploadNum = 100;
  106. /// <summary>
  107. /// 是否获取过箱号
  108. /// </summary>
  109. bool GetPackingCode = false;
  110. string SG_Script;
  111. Dictionary<int, string> Si_Item = new Dictionary<int, string>();
  112. /*需要重绘的Cell*/
  113. Dictionary<DataGridViewCell, bool> PaintCell = new Dictionary<DataGridViewCell, bool>();
  114. /// <summary>
  115. /// 是否通过选择Combox来改变打开的文件
  116. /// </summary>
  117. bool ComBoxClickChangeLabelDoc = false;
  118. DataTable Attach;
  119. public UAS_出货标签打印(string Master)
  120. {
  121. InitializeComponent();
  122. Text = Text + "-" + Master;
  123. }
  124. protected override void WndProc(ref Message m)
  125. {
  126. //拦截双击标题栏、移动窗体的系统消息
  127. if (m.Msg != 0xA3)
  128. {
  129. base.WndProc(ref m);
  130. }
  131. }
  132. private void 贴标机条码打印_Load(object sender, EventArgs e)
  133. {
  134. //杀死之前全部未关闭的进程
  135. Process[] processes = System.Diagnostics.Process.GetProcessesByName("lppa");
  136. for (int i = 0; i < processes.Length; i++)
  137. {
  138. processes[i].Kill();
  139. }
  140. //用计时器重置数据库链接
  141. LogManager.DoLog("程序启动,登陆人员【" + User.UserName + "】");
  142. dh = SystemInf.dh;
  143. adh = SystemInf.adh;
  144. CheckForIllegalCrossThreadCalls = false;
  145. pi_inoutno.Focus();
  146. Point pt = new Point();
  147. //禁止所有列的排序
  148. foreach (DataGridViewColumn dgv in LabelInf.Columns)
  149. {
  150. dgv.SortMode = DataGridViewColumnSortMode.NotSortable;
  151. }
  152. int ScreenWidth = Screen.GetWorkingArea(pt).Width;
  153. //设置获取当前屏幕大小自动全屏但是保留任务栏
  154. Rectangle ScreenArea = Screen.GetWorkingArea(this);
  155. Top = 0;
  156. Left = 0;
  157. Width = ScreenArea.Width;
  158. Height = ScreenArea.Height;
  159. MidBoxCapacity.Value = Properties.Settings.Default.MidBoxCapacity;
  160. OutboxCapacity.Value = Properties.Settings.Default.OutboxCapacity;
  161. asc.controllInitializeSize(this);
  162. asc.controlAutoSize(this);
  163. //实例化打印进程
  164. try
  165. {
  166. lbl = new ApplicationClass();
  167. }
  168. catch (Exception)
  169. {
  170. MessageBox.Show("未安装CodeSoft软件或者版本不正确");
  171. }
  172. RefreshDBConnect.Interval = 60000;
  173. RefreshDBConnect.Start();
  174. DataTable dt = (DataTable)adh.ExecuteSql("select * from cominfo", "select");
  175. DataRow[] dr = dt.Select("comtype='FrontendCheck'");
  176. if (dr.Length > 0)
  177. {
  178. FrontendCheck.PortName = dr[0]["COM"].ToString();
  179. FrontendCheck.Tag = "FrontendCheck";
  180. FrontendCheck.BaudRate = int.Parse(dr[0]["BaudRate"].ToString());
  181. FrontendCheck.DataReceived += Serial_DataReceived;
  182. FrontendCheck.Open();
  183. }
  184. dr = dt.Select("comtype='BackendCheck'");
  185. if (dr.Length > 0)
  186. {
  187. BackendCheck.PortName = dr[0]["COM"].ToString();
  188. BackendCheck.Tag = "BackendCheck";
  189. BackendCheck.BaudRate = int.Parse(dr[0]["BaudRate"].ToString());
  190. BackendCheck.DataReceived += Serial_DataReceived;
  191. BackendCheck.Open();
  192. }
  193. }
  194. //获取串口数据
  195. private void Serial_DataReceived(object sender, SerialDataReceivedEventArgs e)
  196. {
  197. try
  198. {
  199. SerialPortWithTag port = sender as SerialPortWithTag;
  200. int len = port.BytesToRead;
  201. byte[] readBuffer = new byte[len];
  202. port.Read(readBuffer, 0, len); //将数据读入缓存
  203. string msg = Encoding.ASCII.GetString(readBuffer, 0, len); //获取出入库产品编号
  204. string LotNo = "";
  205. string DateCode = "";
  206. string Order = "";
  207. string QTY = "";
  208. string PN = "";
  209. string OutBox = "";
  210. string pib_id = LabelInf.Rows[CurrentRowIndex].Cells["pib_id1"].Value.ToString();
  211. switch (port.Tag)
  212. {
  213. case "FrontendCheck":
  214. FrontCollect.Text = msg;
  215. MatchCollection matchs = reg.Matches(msg);
  216. int index = 0;
  217. foreach (var item in Si_Item)
  218. {
  219. switch (item.Value)
  220. {
  221. case "DateCode":
  222. DateCode = matchs[index].Value;
  223. break;
  224. case "LotNo":
  225. LotNo = matchs[index].Value;
  226. break;
  227. case "PN":
  228. PN = matchs[index].Value;
  229. break;
  230. case "Order":
  231. Order = matchs[index].Value;
  232. break;
  233. case "QTY":
  234. QTY = matchs[index].Value;
  235. break;
  236. case "OutBox":
  237. OutBox = matchs[index].Value;
  238. break;
  239. default:
  240. break;
  241. }
  242. index = index + 1;
  243. }
  244. adh.ExecuteSql("update prodiobarcode set pib_lotno='" + LotNo + "',pib_datecode='" + DateCode + "' where pib_id=" + pib_id, "update");
  245. break;
  246. case "BackendCheck":
  247. BackCheck.Text = msg;
  248. break;
  249. default:
  250. break;
  251. }
  252. }
  253. catch (Exception ex)
  254. {
  255. MessageBox.Show("接收返回消息异常!具体原因:" + ex.Message, "提示信息");
  256. }
  257. }
  258. //只执行一次窗体自适应
  259. bool AutoSized = false;
  260. private void 贴标机条码打印_SizeChanged(object sender, EventArgs e)
  261. {
  262. if (!AutoSized)
  263. {
  264. asc.controlAutoSize(this);
  265. AutoSized = true;
  266. }
  267. }
  268. private void LabelMaintain_Click(object sender, EventArgs e)
  269. {
  270. 客户标签维护 form = new 客户标签维护();
  271. BaseUtil.SetFormCenter(form);
  272. if (SingleDoc != null)
  273. SingleDoc.Close();
  274. if (MidDoc != null)
  275. MidDoc.Close();
  276. if (OutBoxDoc != null)
  277. OutBoxDoc.Close();
  278. form.FormClosed += LabelFormClose;
  279. form.ShowDialog();
  280. }
  281. private void LabelFormClose(object sender, EventArgs e)
  282. {
  283. if (GetGridOnly.Checked)
  284. GetInOutInfAndLabelFile();
  285. else
  286. {
  287. GetGridOnly.Checked = true;
  288. GetInOutInfAndLabelFile();
  289. GetGridOnly.Checked = false;
  290. }
  291. }
  292. //输入框Enter事件
  293. private void Input_KeyDown(object sender, KeyEventArgs e)
  294. {
  295. if (e.KeyCode == Keys.Enter)
  296. {
  297. if (BackCheck.Text == "")
  298. {
  299. MessageBox.Show("采集的数据不能为空");
  300. return;
  301. }
  302. CollectInputData();
  303. }
  304. }
  305. /// <summary>
  306. /// 采集数据
  307. /// </summary>
  308. private void CollectInputData()
  309. {
  310. //数据校验均已通过则勾选上已采集
  311. if (CollectVeProdCodePass && CollectQTYPass)
  312. {
  313. //如果按盒号采集,所有的此盒的均更新为
  314. DataTable dt = (DataTable)MidSource.DataSource;
  315. LabelInf.Rows[CurrentRowIndex].Cells["pib_ifpick"].Value = true;
  316. LogicHandler.UpdateRowPicked(LabelInf.Rows[CurrentRowIndex].Cells["pib_id"].Value);
  317. LabelInf.Rows[CurrentRowIndex].Cells["Choose"].Value = true;
  318. //勾选了单盘自动打印
  319. if (SingleLabelAutoPrint.Checked)
  320. {
  321. if (SingleLabelCombox.SelectedValue != null)
  322. {
  323. AutoPrintSingleLabel();
  324. }
  325. else
  326. {
  327. MessageBox.Show("未维护单盘标签");
  328. return;
  329. }
  330. }
  331. //勾选了中盒自动打印
  332. if (MidLabelAutoPrint.Checked)
  333. AutoPrintMidLabel();
  334. }
  335. RefreshProcessData();
  336. MessageLog.AppendText(">>扫描到数据" + BackCheck.Text + "\n", Color.Blue);
  337. //如果所采集的行的物料不一样的话,重新计算箱内容量
  338. if (CurrentRowIndex - 1 > 0)
  339. {
  340. string LastRowProd = LabelInf.Rows[CurrentRowIndex - 1].Cells["pib_prodcode"].Value.ToString();
  341. string CurrentRowProd = LabelInf.Rows[CurrentRowIndex].Cells["pib_prodcode"].Value.ToString();
  342. }
  343. }
  344. private void AutoPrintSingleLabel()
  345. {
  346. //用标签本身的变量作为最外层的循环条件去匹配;
  347. string pib_id = LabelInf.Rows[CurrentRowIndex].Cells["pib_id1"].Value.ToString();
  348. StringBuilder ParamLog = new StringBuilder();
  349. sql.Clear();
  350. sql.Append("select * from ");
  351. for (int i = 0; i < SingleLabelParam.Rows.Count; i++)
  352. {
  353. if (i != SingleLabelParam.Rows.Count - 1)
  354. sql.Append("(" + SingleLabelParam.Rows[i]["lp_sql"].ToString() + "),");
  355. else
  356. sql.Append("(" + SingleLabelParam.Rows[i]["lp_sql"].ToString() + ")");
  357. }
  358. DataTable dt = (DataTable)dh.ExecuteSql(sql.ToString().ToLower().Replace("{pib_id}", pib_id), "select");
  359. for (int i = 0; i < SingleDoc.Variables.FreeVariables.Count; i++)
  360. {
  361. if (dt.Columns.Contains(SingleDoc.Variables.FreeVariables.Item(i + 1).Name.ToLower()))
  362. SingleDoc.Variables.FreeVariables.Item(i + 1).Value = dt.Rows[0][SingleDoc.Variables.FreeVariables.Item(i + 1).Name.ToLower()].ToString();
  363. if (SingleDoc.Variables.FreeVariables.Item(i + 1).Value == "")
  364. {
  365. DataRow[] dr1 = Attach.Select("lp_name='" + SingleDoc.Variables.FreeVariables.Item(i + 1).Name.ToLower() + "'");
  366. if (dr1.Length > 0)
  367. SingleDoc.Variables.FreeVariables.Item(i + 1).Value = dr1[0]["lp_sql"].ToString();
  368. }
  369. }
  370. SingleDoc.Printer.SwitchTo(SingleLabelPrinter.Text);
  371. SingleDoc.PrintDocument();
  372. LogicHandler.UpdateRowPrinted(pib_id);
  373. LabelInf.Rows[CurrentRowIndex].Cells["pib_ifprint"].Value = true;
  374. }
  375. //
  376. /// <summary>
  377. /// 设置外箱号
  378. /// </summary>
  379. /// <param name="BatchCollect">是否批量采集</param>
  380. private void SetOutBoxCode2(bool BatchCollect)
  381. {
  382. if (OutboxCapacity.Value != 0)
  383. {
  384. //获取当前出入口单最大的外箱号
  385. for (int i = 0; i < LabelInf.RowCount; i++)
  386. {
  387. string outboxcode = LabelInf.Rows[i].Cells["pib_outboxcode2"].Value.ToString();
  388. if (outboxcode.Contains("-"))
  389. {
  390. if (int.Parse(outboxcode.Split('-')[0] == "" ? "1" : outboxcode.Split('-')[0]) > MaxOutBoxCode)
  391. MaxOutBoxCode = int.Parse(outboxcode.Split('-')[0]);
  392. }
  393. else
  394. {
  395. if (int.Parse(outboxcode == "" ? "0" : outboxcode) > MaxOutBoxCode)
  396. MaxOutBoxCode = int.Parse(outboxcode);
  397. }
  398. }
  399. //统计最大的箱号存在多少
  400. int MaxOutBoxCodeCount = 0;
  401. for (int i = 0; i < LabelInf.RowCount; i++)
  402. {
  403. if (LabelInf.Rows[i].Cells["pib_outboxcode2"].Value.ToString() == MaxOutBoxCode.ToString())
  404. MaxOutBoxCodeCount = MaxOutBoxCodeCount + 1;
  405. }
  406. //如果是获取过包装单的话则不再继续追加箱号
  407. if (!GetPackingCode)
  408. {
  409. //如果箱内的盒数量小于容量,继续使用此箱号赋值,否则箱号+1
  410. if (BatchCollect)
  411. {
  412. if (MaxOutBoxCodeCount < OutboxCapacity.Value)
  413. LabelInf.Rows[CurrentRowIndex].Cells["pib_outboxcode2"].Value = MaxOutBoxCode;
  414. else
  415. {
  416. MaxOutBoxCode = MaxOutBoxCode + 1;
  417. LabelInf.Rows[CurrentRowIndex].Cells["pib_outboxcode2"].Value = MaxOutBoxCode;
  418. }
  419. }
  420. else
  421. {
  422. if (MaxOutBoxCodeCount <= OutboxCapacity.Value)
  423. LabelInf.Rows[CurrentRowIndex].Cells["pib_outboxcode2"].Value = MaxOutBoxCode;
  424. else
  425. {
  426. MaxOutBoxCode = MaxOutBoxCode + 1;
  427. LabelInf.Rows[CurrentRowIndex].Cells["pib_outboxcode2"].Value = MaxOutBoxCode;
  428. }
  429. }
  430. }
  431. }
  432. }
  433. //关闭窗口前提示用户确认
  434. private void 贴标机条码打印_FormClosing(object sender, FormClosingEventArgs e)
  435. {
  436. //如果不是注销的话
  437. if (!logout)
  438. {
  439. string close = MessageBox.Show(this.ParentForm, "是否关闭", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question).ToString();
  440. if (close.ToString() != "Yes")
  441. e.Cancel = true;
  442. else
  443. {
  444. lbl.Quit();
  445. LogManager.DoLog("关闭程序");
  446. }
  447. }
  448. }
  449. /// <summary>
  450. /// 获取打印标签
  451. /// </summary>
  452. private void GetInOutInfAndLabelFile()
  453. {
  454. ComBoxClickChangeLabelDoc = false;
  455. Attach = (DataTable)dh.ExecuteSql("select lap_param lp_name,lap_value lp_sql from LabelAttachPARAMETER where lap_custcode='" + pi_cardcode.Text + "'", "select");
  456. sql.Clear();
  457. sql.Append("select to_char(nvl(cl_date,sysdate),'YYYY-MM-DD HH24:Mi:SS') cl_date,cl_labelname,cl_isdefault,la_id||'#'||cl_labelurl||'#'||to_char(cl_date,'YYYY-MM-DD HH24:Mi:SS') la_id,cl_custcode from customerlabel left join prodinout on pi_cardcode=cl_custcode ");
  458. sql.Append("left join customer on cu_code=cl_custcode left join label on la_code=CL_LABELCODE where ((pi_cardcode='" + pi_cardcode.Text + "' ");
  459. sql.Append("and pi_inoutno='" + pi_inoutno.Text + "') or( cl_custcode is null)) and cl_labeltype='单盘' order by cl_custcode");
  460. dt = (DataTable)dh.ExecuteSql(sql.ToString(), "select");
  461. SingleLabelCombox.DisplayMember = "cl_labelname";
  462. SingleLabelCombox.ValueMember = "la_id";
  463. SingleLabelCombox.DataSource = dt;
  464. if (SingleDoc != null)
  465. SingleDoc.Close();
  466. if (!GetGridOnly.Checked)
  467. for (int i = 0; i < dt.Rows.Count; i++)
  468. {
  469. string LabelUrl = dt.Rows[i]["la_id"].ToString().Split('#')[1];
  470. string LabelName = dt.Rows[i]["cl_labelname"].ToString();
  471. System.DateTime time = Convert.ToDateTime(dt.Rows[i]["cl_date"].ToString());
  472. FileInfo file = new FileInfo(ftpOperater.DownLoadTo + LabelName);
  473. if (time.ToString() != file.LastWriteTime.ToString())
  474. BaseUtil.GetLabelUrl(LabelUrl, LabelName, time);
  475. }
  476. if (SingleLabelCombox.Text != "")
  477. {
  478. SingleDoc = lbl.Documents.Open(ftpOperater.DownLoadTo + SingleLabelCombox.Text);
  479. SingleLabelParam = (DataTable)dh.ExecuteSql("select lp_name,lp_sql from label left join LABELPARAMETER on la_id= lp_laid where la_id=" + SingleLabelCombox.SelectedValue.ToString().Split('#')[0], "select");
  480. }
  481. sql.Clear();
  482. sql.Append("select to_char(nvl(cl_date,sysdate),'YYYY-MM-DD HH24:Mi:SS') cl_date,cl_labelname,cl_isdefault,la_id||'#'||cl_labelurl||'#'||to_char(cl_date,'YYYY-MM-DD HH24:Mi:SS') la_id,cl_custcode from customerlabel left join prodinout on pi_cardcode=cl_custcode ");
  483. sql.Append("left join customer on cu_code=cl_custcode left join label on la_code=CL_LABELCODE where ((pi_cardcode='" + pi_cardcode.Text + "' ");
  484. sql.Append("and pi_inoutno='" + pi_inoutno.Text + "') or( cl_custcode is null)) and cl_labeltype='中盒' order by cl_custcode");
  485. dt = (DataTable)dh.ExecuteSql(sql.ToString(), "select");
  486. MidLabelCombox.DisplayMember = "cl_labelname";
  487. MidLabelCombox.ValueMember = "la_id";
  488. MidLabelCombox.DataSource = dt;
  489. if (MidDoc != null)
  490. MidDoc.Close();
  491. if (!GetGridOnly.Checked)
  492. for (int i = 0; i < dt.Rows.Count; i++)
  493. {
  494. string LabelUrl = dt.Rows[i]["la_id"].ToString().Split('#')[1];
  495. string LabelName = dt.Rows[i]["cl_labelname"].ToString();
  496. System.DateTime time = Convert.ToDateTime(dt.Rows[i]["cl_date"].ToString());
  497. FileInfo file = new FileInfo(ftpOperater.DownLoadTo + LabelName);
  498. if (time.ToString() != file.LastWriteTime.ToString())
  499. BaseUtil.GetLabelUrl(LabelUrl, LabelName, time);
  500. }
  501. if (MidLabelCombox.Text != "")
  502. {
  503. MidDoc = lbl.Documents.Open(ftpOperater.DownLoadTo + MidLabelCombox.Text);
  504. MidLabelParam = (DataTable)dh.ExecuteSql("select lp_name,lp_sql from label left join LABELPARAMETER on la_id= lp_laid where la_id=" + MidLabelCombox.SelectedValue.ToString().Split('#')[0], "select");
  505. }
  506. //缓存中盒参数
  507. sql.Clear();
  508. sql.Append("select to_char(nvl(cl_date,sysdate),'YYYY-MM-DD HH24:Mi:SS') cl_date,cl_labelname,cl_isdefault,la_id||'#'||cl_labelurl||'#'||to_char(cl_date,'YYYY-MM-DD HH24:Mi:SS') la_id,cl_custcode from customerlabel left join prodinout on pi_cardcode=cl_custcode ");
  509. sql.Append("left join customer on cu_code=cl_custcode left join label on la_code=CL_LABELCODE where ((pi_cardcode='" + pi_cardcode.Text + "' ");
  510. sql.Append("and pi_inoutno='" + pi_inoutno.Text + "') or( cl_custcode is null)) and cl_labeltype='外箱' order by cl_custcode");
  511. dt = (DataTable)dh.ExecuteSql(sql.ToString(), "select");
  512. OutBoxCombox.DisplayMember = "cl_labelname";
  513. OutBoxCombox.ValueMember = "la_id";
  514. OutBoxCombox.DataSource = dt;
  515. if (OutBoxDoc != null)
  516. OutBoxDoc.Close();
  517. if (!GetGridOnly.Checked)
  518. for (int i = 0; i < dt.Rows.Count; i++)
  519. {
  520. string LabelUrl = dt.Rows[i]["la_id"].ToString().Split('#')[1];
  521. string LabelName = dt.Rows[i]["cl_labelname"].ToString();
  522. System.DateTime time = Convert.ToDateTime(dt.Rows[i]["cl_date"].ToString());
  523. FileInfo file = new FileInfo(ftpOperater.DownLoadTo + LabelName);
  524. if (time.ToString() != file.LastWriteTime.ToString())
  525. BaseUtil.GetLabelUrl(LabelUrl, LabelName, time);
  526. }
  527. if (OutBoxCombox.Text != "")
  528. {
  529. OutBoxDoc = lbl.Documents.Open(ftpOperater.DownLoadTo + OutBoxCombox.Text);
  530. OutLabelParam = (DataTable)dh.ExecuteSql("select lp_name,lp_sql,lp_valuetype from label left join LABELPARAMETER on la_id= lp_laid where la_id=" + OutBoxCombox.SelectedValue.ToString().Split('#')[0], "select");
  531. }
  532. //缓存外箱参数
  533. ComBoxClickChangeLabelDoc = true;
  534. }
  535. /// <summary>
  536. /// 出入库单录入框的回车事件
  537. /// </summary>
  538. /// <param name="sender"></param>
  539. /// <param name="e"></param>
  540. private void pi_inoutno_KeyDown(object sender, KeyEventArgs e)
  541. {
  542. if (e.KeyCode == Keys.Enter)
  543. {
  544. sql.Clear();
  545. sql.Append("select pi_id,pi_cardcode,to_char(pi_date,'yyyymmdd')pi_date from prodinout where pi_inoutno='" + pi_inoutno.Text + "'");
  546. dt = (DataTable)dh.ExecuteSql(sql.ToString(), "select");
  547. if (dt.Rows.Count > 0)
  548. {
  549. pi_cardcode.Text = dt.Rows[0]["pi_cardcode"].ToString();
  550. pi_date.Text = dt.Rows[0]["pi_date"].ToString();
  551. PI_ID = dt.Rows[0]["pi_id"].ToString();
  552. if (dh.GetConfig("AutoBarcode", "ProdInOut!Sale").ToString() != "")
  553. {
  554. string[] param = new string[] { PI_ID, "", "" };
  555. dh.CallProcedure("GetCustBarcode", param);
  556. }
  557. //获取客户自定义设置
  558. sql.Clear();
  559. sql.Append("select cu_print_midlotno,nvl(cu_print_custprodmatchmodel,'Equal')cu_print_custprodmatchmodel,cu_print_midspec,cu_print_midpo,cu_print_midprod,cu_print_outlotno,cu_print_outspec,cu_print_outpo");
  560. sql.Append(",cu_print_outprod,cu_print_checkonly,nvl(cu_print_papercount,0)cu_print_papercount,cu_print_regexpression from customer where cu_code='" + pi_cardcode.Text + "'");
  561. dt = (DataTable)dh.ExecuteSql(sql.ToString(), "select");
  562. if (dt.Rows.Count > 0)
  563. {
  564. BaseUtil.SetFormValue(this.Controls, dt);
  565. switch (dt.Rows[0]["cu_print_custprodmatchmodel"].ToString())
  566. {
  567. case "Equal":
  568. Equal.Checked = true;
  569. break;
  570. case "Expression":
  571. Expression.Checked = true;
  572. break;
  573. default:
  574. break;
  575. }
  576. }
  577. dt = (DataTable)dh.ExecuteSql("select distinct sg_brand from prodiodetail left join product on pd_prodcode=pr_code left join scangroup on nvl(pd_brand,pr_brand)=sg_brand where pd_inoutno='" + pi_inoutno.Text + "' and sg_brand is not null", "select");
  578. for (int i = 0; i < dt.Rows.Count; i++)
  579. {
  580. FrontCombo.DataSource = dt;
  581. FrontCombo.DisplayMember = "sg_brand";
  582. FrontCombo.ValueMember = "sg_brand";
  583. BackCombo.DataSource = dt;
  584. BackCombo.DisplayMember = "sg_brand";
  585. BackCombo.ValueMember = "sg_brand";
  586. }
  587. LoadGridData(sender, e);
  588. //重新输入单号后清除缓存
  589. MidBoxArgument.Clear();
  590. SingleBoxArgument.Clear();
  591. MidIDAndOutboxcode.Clear();
  592. SingleID.Clear();
  593. //刷新采集进度
  594. RefreshProcessData();
  595. thread = new Thread(GetInOutInfAndLabelFile);
  596. stw = new SetLoadingWindow(thread, "正在获取打印标签");
  597. BaseUtil.SetFormCenter(stw);
  598. stw.ShowDialog();
  599. LogManager.DoLog("输入单号【" + pi_inoutno.Text + "】");
  600. }
  601. else
  602. MessageBox.Show("当前出入库单号不存在!");
  603. }
  604. }
  605. private void SingleBoxPrint()
  606. {
  607. try
  608. {
  609. if (SingleDoc.Variables.FreeVariables.Count == 0) { }
  610. }
  611. catch (Exception)
  612. {
  613. MessageBox.Show("单盘标签未维护参数");
  614. }
  615. if (MidLabelAutoPrint.Checked)
  616. {
  617. try
  618. {
  619. if (MidDoc.Variables.FreeVariables.Count == 0) { }
  620. }
  621. catch (Exception)
  622. {
  623. MessageBox.Show("中盘标签未维护参数");
  624. }
  625. }
  626. if (SingleLabelParam.Rows.Count > 0 && LabelInf.Rows.Count > 0)
  627. {
  628. //每次打印清除之前缓存的行号和ID,后面会判断需要打印的数据重新加载
  629. MidIDAndOutboxcode.Clear();
  630. SingleID.Clear();
  631. //获取全部的中盒号
  632. Dictionary<string, bool> outboxcode1 = new Dictionary<string, bool>();
  633. //判断所有盒号为该盒的是否勾选已采集
  634. outboxcode1.Add(LabelInf.Rows[0].Cells["pib_outboxcode1"].Value.ToString(), true);
  635. for (int i = 0; i < LabelInf.Rows.Count; i++)
  636. {
  637. if (!SingleID.Contains(LabelInf.Rows[i].Cells["pib_id1"].Value.ToString()))
  638. SingleID.Add(LabelInf.Rows[i].Cells["pib_id1"].Value.ToString());
  639. if (LabelInf.Rows[i].Cells["Choose"].FormattedValue.ToString() == "True" && LabelInf.Rows[i].Cells["pib_ifpick"].FormattedValue.ToString() == "True" && LabelInf.Rows[i].Cells["pib_ifprint"].FormattedValue.ToString() != "True")
  640. {
  641. //如果不存在中盒号则进行添加
  642. if (!MidIDAndOutboxcode.ContainsValue(LabelInf.Rows[i].Cells["pib_outboxcode1"].Value.ToString()))
  643. {
  644. MidIDAndOutboxcode.Add(LabelInf.Rows[i].Cells["pib_id1"].Value.ToString(), LabelInf.Rows[i].Cells["pib_outboxcode1"].Value.ToString());
  645. }
  646. }
  647. }
  648. if (SingleID.ToArray().Length == 0)
  649. {
  650. MessageBox.Show("选择的行未勾选采集或者已打印");
  651. return;
  652. }
  653. for (int i = 0; i < LabelInf.RowCount; i++)
  654. {
  655. if (i + 1 < LabelInf.RowCount)
  656. {
  657. //如果本行的中盒号和下一行不相等的话
  658. if (LabelInf.Rows[i].Cells["pib_outboxcode1"].Value.ToString() != LabelInf.Rows[i + 1].Cells["pib_outboxcode1"].Value.ToString())
  659. {
  660. if (!outboxcode1.ContainsKey(LabelInf.Rows[i + 1].Cells["pib_outboxcode1"].Value.ToString()))
  661. outboxcode1.Add(LabelInf.Rows[i + 1].Cells["pib_outboxcode1"].Value.ToString(), true);
  662. }
  663. }
  664. //只要有一行没有采集满就不打印
  665. if (LabelInf.Rows[i].Cells["pib_outboxcode1"].Value.ToString() == LabelInf.Rows[CurrentRowIndex].Cells["pib_outboxcode1"].Value.ToString())
  666. {
  667. if (LabelInf.Rows[i].Cells["pib_ifpick"].FormattedValue.ToString() != "True")
  668. outboxcode1[LabelInf.Rows[i].Cells["pib_outboxcode1"].Value.ToString()] = false;
  669. }
  670. }
  671. //用于判断用户是否勾选了行
  672. int CheckedRowCount = 0;
  673. for (int i = 0; i < LabelInf.RowCount; i++)
  674. {
  675. //勾选了并且未打印
  676. if (LabelInf.Rows[i].Cells["Choose"].FormattedValue.ToString() == "True" && LabelInf.Rows[i].Cells["pib_ifpick"].FormattedValue.ToString() == "True" && LabelInf.Rows[i].Cells["pib_ifprint"].FormattedValue.ToString() != "True")
  677. {
  678. CheckedRowCount = CheckedRowCount + 1;
  679. CurrentRowIndex = i;
  680. //以标签模板的参数为基准,循环取数
  681. try
  682. {
  683. string pib_id = LabelInf.Rows[i].Cells["pib_id1"].Value.ToString();
  684. sql.Clear();
  685. sql.Append("select * from ");
  686. for (int j = 0; j < SingleLabelParam.Rows.Count; j++)
  687. {
  688. if (j != SingleLabelParam.Rows.Count - 1)
  689. sql.Append("(" + SingleLabelParam.Rows[j]["lp_sql"].ToString() + "),");
  690. else
  691. sql.Append("(" + SingleLabelParam.Rows[j]["lp_sql"].ToString() + ")");
  692. }
  693. DataTable dt = (DataTable)dh.ExecuteSql(sql.ToString().ToLower().Replace("{pib_id}", pib_id), "select");
  694. for (int j = 0; j < SingleDoc.Variables.FreeVariables.Count; j++)
  695. {
  696. if (dt.Columns.Contains(SingleDoc.Variables.FreeVariables.Item(j + 1).Name.ToLower()))
  697. SingleDoc.Variables.FreeVariables.Item(j + 1).Value = dt.Rows[0][SingleDoc.Variables.FreeVariables.Item(j + 1).Name.ToLower()].ToString();
  698. if (SingleDoc.Variables.FreeVariables.Item(j + 1).Value == "")
  699. {
  700. DataRow[] dr1 = Attach.Select("lp_name='" + SingleDoc.Variables.FreeVariables.Item(j + 1).Name.ToLower() + "'");
  701. if (dr1.Length > 0)
  702. SingleDoc.Variables.FreeVariables.Item(j + 1).Value = dr1[0]["lp_sql"].ToString();
  703. }
  704. }
  705. SingleDoc.Printer.SwitchTo(SingleLabelPrinter.Text);
  706. SingleDoc.PrintDocument();
  707. LogicHandler.UpdateRowPrinted(pib_id);
  708. if (MidLabelAutoPrint.Checked)
  709. {
  710. //判断当前行的盒号和下一行不相等或者已经是最后一行了
  711. if (i + 1 == LabelInf.RowCount || LabelInf.Rows[i].Cells["pib_outboxcode1"].Value.ToString() != LabelInf.Rows[i + 1 == LabelInf.RowCount ? i : i + 1].Cells["pib_outboxcode1"].Value.ToString())
  712. {
  713. if (outboxcode1[LabelInf.Rows[i].Cells["pib_outboxcode1"].Value.ToString()])
  714. {
  715. if (MidLabelCombox.SelectedValue != null)
  716. {
  717. MidBoxCodePrint(CurrentRowIndex);
  718. }
  719. }
  720. }
  721. }
  722. //勾选为已打印
  723. LabelInf.Rows[i].Cells["pib_ifprint"].Value = true;
  724. }
  725. catch (Exception ex) { LogManager.DoLog(ex.Message); }
  726. }
  727. }
  728. dh.BatchInsert("update prodiobarcode set pib_printdate=sysdate where pib_id=:pib_id", new string[] { "pib_id" }, SingleID.ToArray());
  729. if (CheckedRowCount == 0)
  730. MessageBox.Show("未勾选打印明细!");
  731. else if (CurrentRowIndex + 1 < LabelInf.Rows.Count)
  732. CurrentRowIndex = CurrentRowIndex + 1;
  733. outboxcode1.Clear();
  734. }
  735. else
  736. {
  737. MessageBox.Show("此模板尚未维护参数或不存在打印明细");
  738. return;
  739. }
  740. }
  741. private void SingleLabelPrint_Click(object sender, EventArgs e)
  742. {
  743. if (SingleLabelCombox.Text != "")
  744. {
  745. if (SingleBoxBegin.Text != "" || SingleBoxEnd.Text != "")
  746. {
  747. try
  748. {
  749. int begin = int.Parse(SingleBoxBegin.Text == "" ? "1" : SingleBoxBegin.Text);
  750. int end = int.Parse(SingleBoxEnd.Text == "" ? LabelInf.Rows.Count.ToString() : SingleBoxEnd.Text);
  751. if (begin > 0 && end <= LabelInf.Rows.Count && begin <= end)
  752. {
  753. for (int i = begin - 1; i < end; i++)
  754. {
  755. LabelInf.Rows[i].Cells["Choose"].Value = true;
  756. LabelInf.Rows[i].Cells["pib_ifpick"].Value = true;
  757. LabelInf.Rows[i].Cells["pib_ifprint"].Value = false;
  758. }
  759. }
  760. else
  761. {
  762. MessageBox.Show("单盘打印范围错误");
  763. return;
  764. }
  765. }
  766. catch (Exception)
  767. {
  768. MessageBox.Show("单盘打印范围错误");
  769. return;
  770. }
  771. }
  772. thread = new Thread(SingleBoxPrint);
  773. stw = new SetLoadingWindow(thread, "正在打印单盘");
  774. BaseUtil.SetFormCenter(stw);
  775. stw.ShowDialog();
  776. }
  777. else
  778. MessageBox.Show("未维护单盘标签");
  779. }
  780. private void MidBoxLabelPrint()
  781. {
  782. //未输入内容打印全部中盒
  783. if (MidLabelNum.Text == "")
  784. {
  785. int begin = 0;
  786. int end = 0;
  787. if (MidBoxBegin.Text != "" || MidBoxEnd.Text != "")
  788. {
  789. try
  790. {
  791. begin = int.Parse(MidBoxBegin.Text == "" ? "1" : MidBoxBegin.Text);
  792. end = int.Parse(MidBoxEnd.Text == "" ? LabelInf.Rows[LabelInf.Rows.Count - 1].Cells["pib_outboxcode1"].Value.ToString() : MidBoxEnd.Text);
  793. int minmidbox = int.Parse(LabelInf.Rows[0].Cells["pib_outboxcode1"].Value.ToString());
  794. int maxmidbox = int.Parse(LabelInf.Rows[LabelInf.Rows.Count - 1].Cells["pib_outboxcode1"].Value.ToString());
  795. if (begin >= minmidbox && end <= maxmidbox && begin <= end)
  796. {
  797. //设置中盒打印范围的行号
  798. for (int i = 0; i < LabelInf.Rows.Count; i++)
  799. {
  800. if (int.Parse(LabelInf.Rows[i].Cells["pib_outboxcode1"].Value.ToString()) == begin)
  801. {
  802. begin = i;
  803. }
  804. if (int.Parse(LabelInf.Rows[i].Cells["pib_outboxcode1"].Value.ToString()) == end)
  805. {
  806. end = i;
  807. }
  808. }
  809. }
  810. else
  811. {
  812. MessageBox.Show("中盒打印范围错误");
  813. return;
  814. }
  815. }
  816. catch (Exception)
  817. {
  818. MessageBox.Show("中盒打印范围错误");
  819. return;
  820. }
  821. }
  822. MidBoxArgument.Clear();
  823. List<int> MidOutBoxCode = new List<int>();
  824. List<int> MidOutBoxCodeIndex = new List<int>();
  825. string la_id = MidLabelCombox.SelectedValue.ToString().Split('#')[0];
  826. for (int i = (begin == 0 ? 0 : begin); i <= (end == 0 ? LabelInf.Rows.Count - 1 : end); i++)
  827. {
  828. if (!MidIDAndOutboxcode.ContainsValue(LabelInf.Rows[i].Cells["pib_outboxcode1"].Value.ToString()))
  829. MidIDAndOutboxcode.Add(LabelInf.Rows[i].Cells["pib_id1"].Value.ToString(), LabelInf.Rows[i].Cells["pib_outboxcode1"].Value.ToString());
  830. if (!MidOutBoxCode.Contains(int.Parse(LabelInf.Rows[i].Cells["pib_outboxcode1"].Value.ToString())))
  831. {
  832. MidOutBoxCode.Add(int.Parse(LabelInf.Rows[i].Cells["pib_outboxcode1"].Value.ToString()));
  833. MidOutBoxCodeIndex.Add(i);
  834. }
  835. }
  836. for (int i = 0; i < MidOutBoxCodeIndex.Count; i++)
  837. {
  838. MidBoxCodePrint(MidOutBoxCodeIndex[i]);
  839. }
  840. MidBoxArgument.Clear();
  841. return;
  842. }
  843. bool FindMidLabel = false;
  844. if (MidLabelCombox.SelectedValue != null)
  845. {
  846. //中盒号所在的行
  847. int MidLabelRowIndex = 0;
  848. //缓存中盒数据
  849. for (int i = 0; i < LabelInf.RowCount; i++)
  850. {
  851. if (MidLabelNum.Text == LabelInf.Rows[i].Cells["pib_outboxcode1"].Value.ToString())
  852. {
  853. //找到了输入的中盒号停止循环
  854. FindMidLabel = true;
  855. MidLabelRowIndex = i;
  856. }
  857. }
  858. //找到了指定的盒号
  859. if (FindMidLabel)
  860. MidBoxCodePrint(MidLabelRowIndex);
  861. else
  862. MessageBox.Show("该出入库单未找到该中盒号!");
  863. }
  864. else
  865. MessageBox.Show("未维护中盒模板");
  866. }
  867. private void MidLabelPrint_Click(object sender, EventArgs e)
  868. {
  869. if (MidLabelCombox.Text != "")
  870. {
  871. thread = new Thread(MidBoxLabelPrint);
  872. stw = new SetLoadingWindow(thread, "正在打印中盒");
  873. BaseUtil.SetFormCenter(stw);
  874. stw.ShowDialog();
  875. }
  876. else
  877. MessageBox.Show("未维护中盒标签");
  878. }
  879. private void OutBoxPrint()
  880. {
  881. List<string> Outboxcode = new List<string>();
  882. //如果未勾选箱号则对勾选的数据的箱号进行整合
  883. if (OutBoxNum.Text == "")
  884. {
  885. for (int i = 0; i < LabelInf.RowCount; i++)
  886. {
  887. if (LabelInf.Rows[i].Cells["Choose"].FormattedValue.ToString() == "True")
  888. {
  889. string outboxcode2 = LabelInf.Rows[i].Cells["pib_outboxcode2"].Value.ToString();
  890. //富为使用包装单的逻辑
  891. //如果不包含该箱号则进行添加
  892. if (!Outboxcode.Contains(outboxcode2))
  893. Outboxcode.Add(outboxcode2);
  894. }
  895. }
  896. //按获取到的箱号列表进行打印
  897. if (Outboxcode.ToArray().Length > 0)
  898. {
  899. try
  900. {
  901. // 循环打印外箱号
  902. for (int i = 0; i < Outboxcode.ToArray().Length; i++)
  903. {
  904. for (int h = 0; h < LabelInf.RowCount; h++)
  905. {
  906. if (LabelInf.Rows[h].Cells["pib_outboxcode2"].Value.ToString() == Outboxcode.ToArray()[i])
  907. {
  908. OutBoxCodePrint(h);
  909. break;
  910. }
  911. }
  912. }
  913. }
  914. catch { }
  915. }
  916. else
  917. {
  918. MessageBox.Show("请勾选需要打印的外箱");
  919. }
  920. }
  921. else
  922. {
  923. bool FindMidLabel = false;
  924. try
  925. {
  926. int OutBoxLabelRowIndex = 0;
  927. //查找是否存在该中盒号
  928. for (int i = 0; i < LabelInf.RowCount; i++)
  929. {
  930. if (OutBoxNum.Text == LabelInf.Rows[i].Cells["pib_outboxcode2"].Value.ToString())
  931. {
  932. //找到了输入的中盒号停止循环
  933. FindMidLabel = true;
  934. OutBoxLabelRowIndex = i;
  935. break;
  936. }
  937. }
  938. //找到了指定的盒号
  939. if (FindMidLabel)
  940. OutBoxCodePrint(OutBoxLabelRowIndex);
  941. else
  942. MessageBox.Show("该出入库单未找到该外箱号!");
  943. }
  944. catch (Exception) { }
  945. }
  946. Outboxcode.Clear();
  947. }
  948. private void MidBoxCodePrint(int rowindex)
  949. {
  950. //获取对应行的pib_id
  951. string pib_id = LabelInf.Rows[rowindex].Cells["pib_id1"].Value.ToString();
  952. string pib_outboxcode1 = LabelInf.Rows[rowindex].Cells["pib_outboxcode1"].Value.ToString();
  953. sql.Clear();
  954. sql.Append("select * from ");
  955. for (int i = 0; i < MidLabelParam.Rows.Count; i++)
  956. {
  957. if (i != MidLabelParam.Rows.Count - 1)
  958. sql.Append("(" + MidLabelParam.Rows[i]["lp_sql"].ToString() + "),");
  959. else
  960. sql.Append("(" + MidLabelParam.Rows[i]["lp_sql"].ToString() + ")");
  961. }
  962. DataTable dt = (DataTable)dh.ExecuteSql(sql.ToString().ToLower().Replace("{pib_id}", pib_id).Replace("{pib_outboxcode1}", pib_outboxcode1), "select");
  963. for (int i = 0; i < MidDoc.Variables.FreeVariables.Count; i++)
  964. {
  965. if (dt.Columns.Contains(MidDoc.Variables.FreeVariables.Item(i + 1).Name.ToLower()))
  966. MidDoc.Variables.FreeVariables.Item(i + 1).Value = dt.Rows[0][MidDoc.Variables.FreeVariables.Item(i + 1).Name.ToLower()].ToString();
  967. if (MidDoc.Variables.FreeVariables.Item(i + 1).Value == "")
  968. {
  969. DataRow[] dr1 = Attach.Select("lp_name='" + MidDoc.Variables.FreeVariables.Item(i + 1).Name.ToLower() + "'");
  970. if (dr1.Length > 0)
  971. MidDoc.Variables.FreeVariables.Item(i + 1).Value = dr1[0]["lp_sql"].ToString();
  972. }
  973. }
  974. MidDoc.Printer.SwitchTo(MidLabelPrinter.Text);
  975. MidDoc.PrintDocument();
  976. }
  977. /// <summary>
  978. /// 执行打印外箱号
  979. /// </summary>
  980. private void OutBoxCodePrint(int rowindex)
  981. {
  982. //获取对应行的pib_id
  983. string pib_id = LabelInf.Rows[rowindex].Cells["pib_id1"].Value.ToString();
  984. string pib_outboxcode2 = LabelInf.Rows[rowindex].Cells["pib_outboxcode2"].Value.ToString();
  985. sql.Clear();
  986. sql.Append("select * from ");
  987. for (int i = 0; i < OutLabelParam.Rows.Count; i++)
  988. {
  989. if (i != OutLabelParam.Rows.Count - 1)
  990. sql.Append("(" + OutLabelParam.Rows[i]["lp_sql"].ToString() + "),");
  991. else
  992. sql.Append("(" + OutLabelParam.Rows[i]["lp_sql"].ToString() + ")");
  993. }
  994. DataTable dt = (DataTable)dh.ExecuteSql(sql.ToString().ToLower().Replace("{pib_id}", pib_id).Replace("{pib_outboxcode2}", pib_outboxcode2), "select");
  995. for (int i = 0; i < OutBoxDoc.Variables.FreeVariables.Count; i++)
  996. {
  997. if (dt.Columns.Contains(OutBoxDoc.Variables.FreeVariables.Item(i + 1).Name.ToLower()))
  998. OutBoxDoc.Variables.FreeVariables.Item(i + 1).Value = dt.Rows[0][OutBoxDoc.Variables.FreeVariables.Item(i + 1).Name.ToLower()].ToString();
  999. if (OutBoxDoc.Variables.FreeVariables.Item(i + 1).Value == "")
  1000. {
  1001. DataRow[] dr1 = Attach.Select("lp_name='" + OutBoxDoc.Variables.FreeVariables.Item(i + 1).Name.ToLower() + "'");
  1002. if (dr1.Length > 0)
  1003. OutBoxDoc.Variables.FreeVariables.Item(i + 1).Value = dr1[0]["lp_sql"].ToString();
  1004. }
  1005. }
  1006. OutBoxDoc.Printer.SwitchTo(OutBoxPrinter.Text);
  1007. OutBoxDoc.PrintDocument();
  1008. }
  1009. private void OutBoxLabelPrint_Click(object sender, EventArgs e)
  1010. {
  1011. if (OutBoxCombox.Text != "")
  1012. {
  1013. thread = new Thread(OutBoxPrint);
  1014. stw = new SetLoadingWindow(thread, "正在打印外箱");
  1015. BaseUtil.SetFormCenter(stw);
  1016. stw.ShowDialog();
  1017. }
  1018. else
  1019. MessageBox.Show("未维护外箱标签");
  1020. }
  1021. /// <summary>
  1022. /// 刷新采集进度
  1023. /// </summary>
  1024. private void RefreshProcessData()
  1025. {
  1026. if (LabelInf.Rows.Count > 0)
  1027. {
  1028. //设置初始化的采集进度
  1029. int Count = 0;
  1030. int CurrentMidBoxCollectedCount = 0;
  1031. //当前盒号的总盘数
  1032. int CurrentMidBoxTotalCount = 0;
  1033. //未超出当前范围的时候
  1034. for (int i = 0; i < LabelInf.RowCount; i++)
  1035. {
  1036. if (LabelInf.Rows[i].Cells["pib_ifpick"].FormattedValue.ToString() == "True")
  1037. Count++;
  1038. //和当前编辑箱号相等行
  1039. if (LabelInf.Rows[i].Cells["pib_ifpick"].FormattedValue.ToString() == "True" && LabelInf.Rows[CurrentRowIndex].Cells["pib_outboxcode1"].Value.ToString() == LabelInf.Rows[i].Cells["pib_outboxcode1"].Value.ToString())
  1040. CurrentMidBoxCollectedCount++;
  1041. //当前盒号一共有几盘
  1042. if (LabelInf.Rows[CurrentRowIndex].Cells["pib_outboxcode1"].Value.ToString() == LabelInf.Rows[i].Cells["pib_outboxcode1"].Value.ToString())
  1043. CurrentMidBoxTotalCount++;
  1044. }
  1045. //设置当前的箱号和盒号
  1046. Process_outboxcode.Text = LabelInf.Rows[CurrentRowIndex].Cells["pib_outboxcode2"].Value.ToString();
  1047. Process_midboxcode.Text = LabelInf.Rows[CurrentRowIndex].Cells["pib_outboxcode1"].Value.ToString();
  1048. //设置当前总数和已采集数量
  1049. CollectedCount.Text = Count.ToString();
  1050. }
  1051. }
  1052. private void LoadGridData()
  1053. {
  1054. LoadGridData(new object(), new EventArgs());
  1055. }
  1056. /// <summary>
  1057. /// 自定义函数 加载明细行的数据,多处使用添加进函数
  1058. /// </summary>
  1059. /// <param name="sender"></param>
  1060. /// <param name="e"></param>
  1061. private void LoadGridData(object sender, EventArgs e)
  1062. {
  1063. AllCollect = false;
  1064. dt = (DataTable)adh.ExecuteSql("select * from prodiobarcode where pib_inoutno='" + pi_inoutno.Text + "'", "select");
  1065. if (dt.Rows.Count == 0)
  1066. {
  1067. sql.Clear();
  1068. sql.Append("select pd_custprodcode,pib_inoutno,pd_custprodspec,nvl(pib_ifrecheck,0)pib_ifrecheck,nvl(pib_ifupload,0)pib_ifupload,nvl(pib_ifmodify,0)pib_ifmodify,pd_pocode,pib_madein,pib_custbarcode,pib_custoutboxcode,pib_id,pib_pdid,pib_piid,pib_pdno,pib_prodcode,nvl(nvl(pd_brand,pib_brand),pr_brand)pib_brand, pr_vendprodcode,");
  1069. sql.Append("pib_lotno,pib_datecode,pib_qty,pr_spec,pr_zxbzs,pr_unit,pib_barcode,pib_outboxcode1,pib_outboxcode2,nvl(pib_ifpick,0)pib_ifpick,nvl(pib_ifprint,0)pib_ifprint");
  1070. sql.Append(" from prodiobarcode left join prodiodetail on pib_piid=pd_piid and pd_pdno=pib_pdno and ");
  1071. sql.Append(" pd_prodcode=pib_prodcode left join product on pr_code=pib_prodcode left join sale on sa_code=pib_ordercode ");
  1072. sql.Append("where pib_piid='" + PI_ID + "' order by to_number(pib_outboxcode1),pib_id,pd_prodcode");
  1073. dt = (DataTable)dh.ExecuteSql(sql.ToString(), "select");
  1074. adh.SaveDataTable(dt, "prodiobarcode");
  1075. }
  1076. //获取系统设置的上传数量,如参数异常则默认为100
  1077. if (!int.TryParse(adh.getFieldDataByCondition("dataextra", "uploadnum", "id=1").ToString(), out UploadNum))
  1078. {
  1079. UploadNum = 100;
  1080. }
  1081. MidSource.DataSource = dt;
  1082. BaseUtil.FillDgvWithDataTable(LabelInf, (DataTable)MidSource.DataSource);
  1083. if (LabelInf.RowCount > 0)
  1084. {
  1085. Brand = LabelInf.Rows[0].Cells["pib_brand"].FormattedValue.ToString();
  1086. if (Brand != "")
  1087. {
  1088. dt = (DataTable)dh.ExecuteSql("select sg_script,sg_id from scangroup where sg_brand='" + Brand + "'", "select");
  1089. if (dt.Rows.Count > 0)
  1090. {
  1091. string sgid = dt.Rows[0]["sg_id"].ToString();
  1092. SG_Script = dt.Rows[0]["sg_script"].ToString();
  1093. reg = new Regex(SG_Script);
  1094. DataTable dt1 = (DataTable)dh.ExecuteSql("select si_name,si_item,si_expression from scanitem where si_sgid='" + sgid + "' and si_enable<>0", "select");
  1095. for (int i = 0; i < dt1.Rows.Count; i++)
  1096. {
  1097. if (SG_Script.IndexOf(dt1.Rows[i]["si_name"].ToString()) >= 0)
  1098. {
  1099. Si_Item.Add(SG_Script.IndexOf(dt1.Rows[i]["si_name"].ToString()), dt1.Rows[i]["si_item"].ToString());
  1100. }
  1101. }
  1102. //根据索引进行排序
  1103. Si_Item = (from entry in Si_Item orderby entry.Key ascending select entry).ToDictionary(pair => pair.Key, pair => pair.Value);
  1104. }
  1105. }
  1106. }
  1107. //绑定数据之后往下找到未采集的数据显示在当前采集的栏目
  1108. for (int i = 0; i < LabelInf.RowCount; i++)
  1109. {
  1110. if (LabelInf.Rows[i].Cells["pib_ifpick"].FormattedValue.ToString() != "True")
  1111. {
  1112. CurrentRowIndex = LabelInf.Rows[i].Cells["pib_prodcode"].RowIndex;
  1113. break;
  1114. }
  1115. }
  1116. }
  1117. /// <summary>
  1118. /// 重绘Cell的颜色
  1119. /// </summary>
  1120. /// <param name="sender"></param>
  1121. /// <param name="e"></param>
  1122. private void LabelInf_CellPainting(object sender, DataGridViewCellPaintingEventArgs e)
  1123. {
  1124. bool mouseOver = e.CellBounds.Contains(this.PointToClient(Cursor.Position));
  1125. if (e.ColumnIndex > 0)
  1126. {
  1127. if (LabelInf.Columns[e.ColumnIndex].Name == "pib_lotno" || LabelInf.Columns[e.ColumnIndex].Name == "pib_datecode")
  1128. {
  1129. SolidBrush solidBrush = new SolidBrush(Color.FromArgb(51, 153, 255));
  1130. e.Graphics.FillRectangle(mouseOver ? solidBrush : Brushes.LightSeaGreen, e.CellBounds);
  1131. Rectangle border = e.CellBounds;
  1132. border.Width -= 1;
  1133. e.Graphics.DrawRectangle(Pens.White, border);
  1134. e.PaintContent(e.CellBounds);
  1135. e.Handled = true;
  1136. }
  1137. if (e.RowIndex >= 0)
  1138. {
  1139. //重绘制定的Cell,表示采集的数量不匹配
  1140. if (LabelInf.Columns[e.ColumnIndex].Name == "pib_qty" && PaintCell.ContainsKey(LabelInf.Rows[e.RowIndex].Cells["pib_qty"]))
  1141. {
  1142. SolidBrush solidBrush = new SolidBrush(Color.FromArgb(51, 153, 255));
  1143. e.Graphics.FillRectangle(PaintCell[LabelInf.Rows[e.RowIndex].Cells["pib_qty"]] ? Brushes.ForestGreen : Brushes.Red, e.CellBounds);
  1144. Rectangle border = e.CellBounds;
  1145. border.Width -= 1;
  1146. e.Graphics.DrawRectangle(Pens.Black, border);
  1147. e.PaintContent(e.CellBounds);
  1148. e.Handled = true;
  1149. }
  1150. //表示采集的供应商物料编号不匹配
  1151. if (LabelInf.Columns[e.ColumnIndex].Name == "pr_vendprodcode" && PaintCell.ContainsKey(LabelInf.Rows[e.RowIndex].Cells["pr_vendprodcode"]))
  1152. {
  1153. SolidBrush solidBrush = new SolidBrush(Color.FromArgb(51, 153, 255));
  1154. e.Graphics.FillRectangle(PaintCell[LabelInf.Rows[e.RowIndex].Cells["pr_vendprodcode"]] ? Brushes.ForestGreen : Brushes.Red, e.CellBounds);
  1155. Rectangle border = e.CellBounds;
  1156. border.Width -= 1;
  1157. e.Graphics.DrawRectangle(Pens.Black, border);
  1158. e.PaintContent(e.CellBounds);
  1159. e.Handled = true;
  1160. }
  1161. //表示采集的供应商物料编号不匹配
  1162. if (LabelInf.Columns[e.ColumnIndex].Name == "pib_brand" && PaintCell.ContainsKey(LabelInf.Rows[e.RowIndex].Cells["pib_brand"]))
  1163. {
  1164. SolidBrush solidBrush = new SolidBrush(Color.FromArgb(51, 153, 255));
  1165. e.Graphics.FillRectangle(PaintCell[LabelInf.Rows[e.RowIndex].Cells["pib_brand"]] ? Brushes.ForestGreen : Brushes.Red, e.CellBounds);
  1166. Rectangle border = e.CellBounds;
  1167. border.Width -= 1;
  1168. e.Graphics.DrawRectangle(Pens.Black, border);
  1169. e.PaintContent(e.CellBounds);
  1170. e.Handled = true;
  1171. }
  1172. }
  1173. }
  1174. }
  1175. private void CusLabelPrint()
  1176. {
  1177. //MaxOutBoxCode = MaxOutBoxCode + 1;
  1178. List<int> CusOutBoxCode = new List<int>();
  1179. //统计客户外箱号
  1180. if (LabelInf.Rows.Count > 0)
  1181. CusOutBoxCode.Add(0);
  1182. for (int i = 0; i < LabelInf.Rows.Count; i++)
  1183. {
  1184. if (i - 1 > 0 && LabelInf.Rows[i].Cells["pib_ifprint"].FormattedValue.ToString() == "True")
  1185. {
  1186. string cutboxcode = LabelInf.Rows[i].Cells["pib_cusoutboxcode"].Value.ToString();
  1187. string nextcutboxcode = LabelInf.Rows[i - 1].Cells["pib_cusoutboxcode"].Value.ToString();
  1188. if (cutboxcode != nextcutboxcode)
  1189. CusOutBoxCode.Add(i);
  1190. }
  1191. }
  1192. }
  1193. private void Refresh_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
  1194. {
  1195. KeyEventArgs e2 = new KeyEventArgs(Keys.Enter);
  1196. pi_inoutno_KeyDown(sender, e2);
  1197. }
  1198. private void AutoPrintMidLabel()
  1199. {
  1200. bool FullBox = true;
  1201. //判断所有盒号未该盒的是否勾选已采集
  1202. for (int i = 0; i < LabelInf.RowCount; i++)
  1203. {
  1204. if (LabelInf.Rows[i].Cells["pib_outboxcode1"].Value.ToString() == LabelInf.Rows[CurrentRowIndex].Cells["pib_outboxcode1"].Value.ToString())
  1205. {
  1206. if (LabelInf.Rows[i].Cells["pib_ifpick"].FormattedValue.ToString() != "True")
  1207. FullBox = false;
  1208. }
  1209. }
  1210. //如果当前箱号已经装满了
  1211. if (FullBox)
  1212. {
  1213. if (MidLabelCombox.SelectedValue != null)
  1214. {
  1215. MidBoxCodePrint(CurrentRowIndex);
  1216. }
  1217. else
  1218. MessageBox.Show("未维护中盒模板");
  1219. }
  1220. }
  1221. private void AllCollected_Click(object sender, EventArgs e)
  1222. {
  1223. if (AllCollect == false)
  1224. {
  1225. foreach (DataGridViewRow dr in LabelInf.Rows)
  1226. dr.Cells["pib_ifpick"].Value = true;
  1227. AllCollect = true;
  1228. }
  1229. else
  1230. {
  1231. foreach (DataGridViewRow dr in LabelInf.Rows)
  1232. dr.Cells["pib_ifpick"].Value = false;
  1233. AllCollect = false;
  1234. }
  1235. }
  1236. private void LogingOut_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
  1237. {
  1238. string close = MessageBox.Show(this.ParentForm, "是否注销", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question).ToString();
  1239. if (close.ToString() == "Yes")
  1240. {
  1241. Login login = new Login();
  1242. //注销的时候需要将拼接的连接字符串置空
  1243. DataHelper.DBConnectionString = null;
  1244. logout = true;
  1245. lbl.Quit();
  1246. this.Hide();
  1247. login.ShowDialog();
  1248. this.Close();
  1249. }
  1250. }
  1251. private void LabelInf_DataError(object sender, DataGridViewDataErrorEventArgs e) { }
  1252. /// <summary>
  1253. /// 切换打开的单盘文件
  1254. /// </summary>
  1255. /// <param name="sender"></param>
  1256. /// <param name="e"></param>
  1257. private void SingleLabelCombox_SelectedIndexChanged(object sender, EventArgs e)
  1258. {
  1259. try
  1260. {
  1261. if (ComBoxClickChangeLabelDoc)
  1262. {
  1263. if (SingleDoc != null)
  1264. SingleDoc.Close();
  1265. if (SingleLabelCombox.Text != "" && SingleLabelCombox.SelectedValue != null && !GetGridOnly.Checked)
  1266. {
  1267. System.DateTime time = Convert.ToDateTime(SingleLabelCombox.SelectedValue.ToString().Split('#')[2]);
  1268. SingleDoc = lbl.Documents.Open(BaseUtil.GetLabelUrl(SingleLabelCombox.SelectedValue.ToString().Split('#')[1], SingleLabelCombox.Text, time));
  1269. }
  1270. }
  1271. }
  1272. catch (Exception) { }
  1273. }
  1274. /// <summary>
  1275. /// 切换打开的中盒文件
  1276. /// </summary>
  1277. /// <param name="sender"></param>
  1278. /// <param name="e"></param>
  1279. private void MidLabelCombox_SelectedIndexChanged(object sender, EventArgs e)
  1280. {
  1281. try
  1282. {
  1283. if (ComBoxClickChangeLabelDoc)
  1284. {
  1285. if (MidDoc != null)
  1286. MidDoc.Close();
  1287. if (MidLabelCombox.Text != "" && MidLabelCombox.SelectedValue != null && !GetGridOnly.Checked)
  1288. {
  1289. System.DateTime time = Convert.ToDateTime(MidLabelCombox.SelectedValue.ToString().Split('#')[2]);
  1290. MidDoc = lbl.Documents.Open(BaseUtil.GetLabelUrl(MidLabelCombox.SelectedValue.ToString().Split('#')[1], MidLabelCombox.Text, time));
  1291. }
  1292. }
  1293. }
  1294. catch (Exception) { }
  1295. }
  1296. /// <summary>
  1297. /// 切换打开的外箱文件
  1298. /// </summary>
  1299. /// <param name="sender"></param>
  1300. /// <param name="e"></param>
  1301. private void OutBoxCombox_SelectedIndexChanged(object sender, EventArgs e)
  1302. {
  1303. try
  1304. {
  1305. if (ComBoxClickChangeLabelDoc)
  1306. {
  1307. if (OutBoxDoc != null)
  1308. OutBoxDoc.Close();
  1309. if (OutBoxCombox.Text != "" && OutBoxCombox.SelectedValue != null && !GetGridOnly.Checked)
  1310. {
  1311. System.DateTime time = Convert.ToDateTime(OutBoxCombox.SelectedValue.ToString().Split('#')[2]);
  1312. OutBoxDoc = lbl.Documents.Open(BaseUtil.GetLabelUrl(OutBoxCombox.SelectedValue.ToString().Split('#')[1], OutBoxCombox.Text, time));
  1313. }
  1314. }
  1315. }
  1316. catch (Exception) { }
  1317. }
  1318. private void ChooseAll_Click(object sender, EventArgs e)
  1319. {
  1320. if (AllChecked)
  1321. {
  1322. foreach (DataGridViewRow dr in LabelInf.Rows)
  1323. dr.Cells[0].Value = false;
  1324. AllChecked = false;
  1325. }
  1326. else
  1327. {
  1328. foreach (DataGridViewRow dr in LabelInf.Rows)
  1329. dr.Cells[0].Value = true;
  1330. AllChecked = true;
  1331. }
  1332. }
  1333. private void ExportData_Click(object sender, EventArgs e)
  1334. {
  1335. ExportFileDialog.Description = "选择导出的路径";
  1336. DialogResult result = ExportFileDialog.ShowDialog();
  1337. if (result == DialogResult.OK)
  1338. {
  1339. ExcelHandler eh = new ExcelHandler();
  1340. DataTable dt = ((DataTable)MidSource.DataSource).Copy();
  1341. for (int i = dt.Columns.Count - 1; i >= 0; i--)
  1342. {
  1343. for (int j = 0; j < LabelInf.Columns.Count; j++)
  1344. {
  1345. //去除ID列
  1346. 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")
  1347. {
  1348. dt.Columns.RemoveAt(i);
  1349. break;
  1350. }
  1351. switch (dt.Columns[i].ColumnName.ToLower())
  1352. {
  1353. case "pib_lotno":
  1354. dt.Columns[i].ColumnName = "批次号";
  1355. break;
  1356. case "pib_datecode":
  1357. dt.Columns[i].ColumnName = "生产日期";
  1358. break;
  1359. case "pib_custbarcode":
  1360. dt.Columns[i].ColumnName = "最小产品包装条码";
  1361. break;
  1362. default:
  1363. break;
  1364. }
  1365. if (dt.Columns[i].ColumnName.ToLower() == LabelInf.Columns[j].DataPropertyName.ToLower())
  1366. {
  1367. dt.Columns[i].ColumnName = LabelInf.Columns[j].HeaderText;
  1368. break;
  1369. }
  1370. }
  1371. }
  1372. eh.ExportExcel(dt, ExportFileDialog.SelectedPath, pi_date.Text + "-" + pi_inoutno.Text);
  1373. string close = MessageBox.Show(this.ParentForm, "导出成功,是否打开文件", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question).ToString();
  1374. if (close.ToString() == "Yes")
  1375. System.Diagnostics.Process.Start(ExportFileDialog.SelectedPath + "\\" + pi_date.Text + "-" + pi_inoutno.Text + ".xls");
  1376. }
  1377. }
  1378. private void MidBoxCapacity_Leave(object sender, EventArgs e)
  1379. {
  1380. NumericUpDown nup = (NumericUpDown)sender;
  1381. switch (nup.Name)
  1382. {
  1383. case "MidBoxCapacity":
  1384. Properties.Settings.Default.MidBoxCapacity = nup.Value;
  1385. Properties.Settings.Default.Save();
  1386. break;
  1387. case "OutboxCapacity":
  1388. Properties.Settings.Default.OutboxCapacity = nup.Value;
  1389. Properties.Settings.Default.Save();
  1390. break;
  1391. default:
  1392. break;
  1393. }
  1394. }
  1395. private void RefreshDBConnect_Tick(object sender, EventArgs e)
  1396. {
  1397. dh.getRowCount("employee", "1=1");
  1398. }
  1399. private void ButtonSetting_Click(object sender, EventArgs e)
  1400. {
  1401. ListButtonMenu.BringToFront();
  1402. ListButtonMenu.Visible = true;
  1403. }
  1404. private void ListButtonMenu_SelectedIndexChanged(object sender, EventArgs e)
  1405. {
  1406. ListButtonMenu.Visible = false;
  1407. switch (ListButtonMenu.SelectedItem.ToString())
  1408. {
  1409. case "采集策略设置":
  1410. 采集策略_NEW form = new 采集策略_NEW();
  1411. BaseUtil.SetFormCenter(form);
  1412. form.ShowDialog();
  1413. break;
  1414. case "附加信息设置":
  1415. if (pi_cardcode.Text != "")
  1416. {
  1417. 附件内容打印 att = new 附件内容打印(pi_cardcode.Text);
  1418. att.ShowDialog();
  1419. }
  1420. else MessageBox.Show("请先获取出库单信息");
  1421. break;
  1422. case "客户标签维护":
  1423. 客户标签维护 form1 = new 客户标签维护();
  1424. BaseUtil.SetFormCenter(form1);
  1425. if (SingleDoc != null)
  1426. SingleDoc.Close();
  1427. if (MidDoc != null)
  1428. MidDoc.Close();
  1429. if (OutBoxDoc != null)
  1430. OutBoxDoc.Close();
  1431. form1.FormClosed += LabelFormClose;
  1432. form1.ShowDialog();
  1433. break;
  1434. case "客户采集规则":
  1435. CustomerRule cust = new CustomerRule();
  1436. BaseUtil.SetFormCenter(cust);
  1437. cust.ShowDialog();
  1438. break;
  1439. case "参数配置":
  1440. ParamSetting form2 = new ParamSetting();
  1441. BaseUtil.SetFormCenter(form2);
  1442. form2.ShowDialog();
  1443. break;
  1444. default:
  1445. break;
  1446. }
  1447. }
  1448. }
  1449. }