UAS_出货标签管理.cs 90 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868
  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.Diagnostics;
  9. using UAS_LabelMachine.PublicMethod;
  10. using UAS_LabelMachine.Entity;
  11. using UAS_LabelMachine.PublicForm;
  12. using System.Threading;
  13. using FastReport;
  14. using System.Linq;
  15. namespace UAS_LabelMachine
  16. {
  17. public partial class UAS_出货标签打印 : Form
  18. {
  19. //自适应屏幕
  20. AutoSizeFormClass asc = new AutoSizeFormClass();
  21. DataHelper dh;
  22. DataTable dt;
  23. StringBuilder sql = new StringBuilder();
  24. /// <summary>
  25. /// 单盘打印文件
  26. /// </summary>
  27. Report SingleReport = new Report();
  28. /// <summary>
  29. /// 中盒打印文件
  30. /// </summary>
  31. Report MidReport = new Report();
  32. /// <summary>
  33. /// 外箱打印文件
  34. /// </summary>
  35. Report OutReport = new Report();
  36. /// <summary>
  37. /// 唛头文件打印
  38. /// </summary>
  39. Report FootReport = new Report();
  40. /// <summary>
  41. /// Loading窗口
  42. /// </summary>
  43. SetLoadingWindow stw;
  44. /// <summary>
  45. /// 弹窗线程
  46. /// </summary>
  47. Thread thread;
  48. /// <summary>
  49. /// 当前品牌
  50. /// </summary>
  51. string PI_ID;
  52. bool logout = false;
  53. //主表数据源
  54. DataTable LabelInfDataTable;
  55. /// <summary>
  56. /// 存放单盘的ID
  57. /// </summary>
  58. List<string> SingleID = new List<string>();
  59. /// <summary>
  60. /// 是否全选
  61. /// </summary>
  62. bool AllChecked = false;
  63. DataTable SumQty;
  64. /// <summary>
  65. /// 是否通过选择Combox来改变打开的文件
  66. /// </summary>
  67. bool ComBoxClickChangeLabelDoc = false;
  68. //当前采集的物料编号
  69. string CurrentPrCode = "";
  70. //当前采集的最小包装
  71. string CurrentZXBZ = "";
  72. //当前采集的单位
  73. string CurrentUnit = "";
  74. //当前采集的总数
  75. string CurrentPrCount = "";
  76. //当前明细序号
  77. string CurrentPDNO = "";
  78. //当前的物料品牌
  79. string CurrentBrand = "";
  80. string Prefix = "";
  81. string Suffix = "";
  82. int MaxNum = 0;
  83. int NumLength = 0;
  84. int Radix = 0;
  85. private bool EnablePrint = true;
  86. string[] PIBID;
  87. DataTable Attach;
  88. public UAS_出货标签打印(string Master)
  89. {
  90. InitializeComponent();
  91. (new EnvironmentSettings()).ReportSettings.ShowProgress = false;
  92. Text = Text + "-" + Master;
  93. }
  94. protected override void WndProc(ref Message m)
  95. {
  96. //拦截双击标题栏、移动窗体的系统消息
  97. if (m.Msg != 0xA3)
  98. {
  99. base.WndProc(ref m);
  100. }
  101. }
  102. private void 贴标机条码打印_Load(object sender, EventArgs e)
  103. {
  104. //用计时器重置数据库链接
  105. LogManager.DoLog("程序启动,登陆人员【" + User.UserName + "】");
  106. dh = SystemInf.dh;
  107. CheckForIllegalCrossThreadCalls = false;
  108. pi_inoutno.Focus();
  109. Point pt = new Point();
  110. //禁止所有列的排序
  111. foreach (DataGridViewColumn dgv in LabelInf.Columns)
  112. {
  113. dgv.SortMode = DataGridViewColumnSortMode.NotSortable;
  114. }
  115. int ScreenWidth = Screen.GetWorkingArea(pt).Width;
  116. //设置获取当前屏幕大小自动全屏但是保留任务栏
  117. Rectangle ScreenArea = Screen.GetWorkingArea(this);
  118. Top = 0;
  119. Left = 0;
  120. Width = ScreenArea.Width;
  121. Height = ScreenArea.Height;
  122. //OutboxCapacity.Value = Properties.Settings.Default.OutboxCapacity;
  123. MidboxCapacity.Value = Properties.Settings.Default.MidBoxCapacity;
  124. if (MidboxCapacity.Value == 0)
  125. {
  126. MidboxCapacity.Value = 10;
  127. }
  128. DCCheck.Text = Properties.Settings.Default.DCCheck.ToString();
  129. OutBoxPrinter.Text = Properties.Settings.Default.OPrinter;
  130. MidLabelPrinter.Text = Properties.Settings.Default.MPrinter;
  131. SingleLabelPrinter.Text = Properties.Settings.Default.SPrinter;
  132. asc.controllInitializeSize(this);
  133. asc.controlAutoSize(this);
  134. RefreshDBConnect.Interval = 60000;
  135. RefreshDBConnect.Start();
  136. }
  137. //只执行一次窗体自适应
  138. bool AutoSized = false;
  139. private void 贴标机条码打印_SizeChanged(object sender, EventArgs e)
  140. {
  141. if (!AutoSized)
  142. {
  143. asc.controlAutoSize(this);
  144. AutoSized = true;
  145. }
  146. }
  147. private void LabelMaintain_Click(object sender, EventArgs e)
  148. {
  149. 客户标签维护 form = new 客户标签维护();
  150. BaseUtil.SetFormCenter(form);
  151. form.FormClosed += LabelFormClose;
  152. form.ShowDialog();
  153. }
  154. private void LabelFormClose(object sender, EventArgs e)
  155. {
  156. GetInOutInfAndLabelFile();
  157. }
  158. //输入框Enter事件
  159. private void Input_KeyDown(object sender, KeyEventArgs e)
  160. {
  161. if (e.KeyCode == Keys.Enter)
  162. {
  163. if (Input.Text == "")
  164. {
  165. MessageBox.Show("采集的数据不能为空");
  166. return;
  167. }
  168. CollectInputData();
  169. }
  170. }
  171. /// <summary>
  172. /// 采集数据
  173. /// </summary>
  174. private void CollectInputData()
  175. {
  176. if (Input.Text == "SC")
  177. {
  178. PrintStatus.PerformClick();
  179. Input.Text = "";
  180. return;
  181. }
  182. Input.Text = Input.Text.Replace("\n", "").Replace(" ", "").Replace("\t", "").Replace("\r", "");
  183. Dictionary<string, string> Data = new Dictionary<string, string>();
  184. string[] SplitData = Input.Text.Split('*');
  185. if (SplitData.Length < 5)
  186. {
  187. MessageBox.Show("数据格式错误,无法解析", "提示");
  188. Input.SelectAll();
  189. return;
  190. }
  191. for (int i = 0; i < SplitData.Length; i++)
  192. {
  193. switch (i.ToString())
  194. {
  195. case "0":
  196. Data.Add("PRCODE", SplitData[i]);
  197. break;
  198. case "1":
  199. Data.Add("QTY", SplitData[i]);
  200. break;
  201. case "2":
  202. Data.Add("DATECODE", SplitData[i]);
  203. break;
  204. case "3":
  205. Data.Add("BRAND", SplitData[i]);
  206. break;
  207. case "4":
  208. Data.Add("LOTNO", SplitData[i]);
  209. break;
  210. case "5":
  211. Data.Add("PO", SplitData[i]);
  212. break;
  213. case "6":
  214. Data.Add("SERIAL", SplitData[i]);
  215. break;
  216. default:
  217. break;
  218. }
  219. }
  220. //校验DateCode是否过期
  221. if (!CheckDateCode(Data["DATECODE"]))
  222. {
  223. string close = MessageBox.Show(this.ParentForm, "物料" + Data["PRCODE"] + "【DateCode】超出校验日期,是否继续", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question).ToString();
  224. if (close != "Yes")
  225. {
  226. Input.SelectAll();
  227. return;
  228. }
  229. }
  230. if (Data["PRCODE"] != CurrentPrCode)
  231. {
  232. MessageBox.Show("当前采集【物料编号】不对应,请重新采集", "提示");
  233. Input.SelectAll();
  234. return;
  235. }
  236. if (Data["BRAND"] != CurrentBrand)
  237. {
  238. string close = MessageBox.Show(this.ParentForm, "当前采集【品牌】不对应,是否继续采集", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question).ToString();
  239. if (close != "Yes")
  240. {
  241. Input.SelectAll();
  242. return;
  243. }
  244. }
  245. int CodeCount = 0;
  246. //如果单位是KPCS则需要除1000
  247. double CollectNum = 0;
  248. if (CurrentUnit == "KPCS")
  249. {
  250. try
  251. {
  252. double.Parse(CurrentZXBZ);
  253. }
  254. catch (Exception)
  255. {
  256. MessageBox.Show("请检查最小包装数");
  257. }
  258. //如果单位是KPCS则必须是1000的整数倍
  259. if (Convert.ToDouble((double.Parse(Data["QTY"]) / 1000).ToString("0.000")) / Convert.ToDouble(double.Parse(CurrentZXBZ).ToString("0.000")) % 1 != 0)
  260. {
  261. MessageBox.Show("物料" + Data["PRCODE"] + "采集数量无法按照最小包装数拆分", "提示");
  262. Input.SelectAll();
  263. return;
  264. }
  265. CodeCount = int.Parse((double.Parse(Data["QTY"]) / 1000 / double.Parse(CurrentZXBZ)).ToString());
  266. CollectNum = double.Parse(Data["QTY"]) / 1000;
  267. }
  268. else
  269. {
  270. if (double.Parse(Data["QTY"]) % double.Parse(CurrentZXBZ) != 0)
  271. {
  272. MessageBox.Show("采集【数量】无法按照最小包装数拆分", "提示");
  273. Input.SelectAll();
  274. return;
  275. }
  276. CodeCount = int.Parse((double.Parse(Data["QTY"]) / double.Parse(CurrentZXBZ)).ToString());
  277. CollectNum = double.Parse(Data["QTY"]);
  278. }
  279. string pib_barcode = Data.ContainsKey("SERIAL") ? Data["SERIAL"] : "";
  280. //获取ID
  281. PIBID = dh.GetSEQ("prodiobarcode_seq", CodeCount);
  282. string pib_outboxcode2 = "";
  283. if (OutBoxNum.Text == "新增")
  284. {
  285. string maxoutbox = dh.getFieldDataByCondition("prodiobarcode", "max(to_number(pib_outboxcode2))", "pib_inoutno='" + pi_inoutno.Text + "'").ToString();
  286. //如果没有则从开始插入
  287. if (maxoutbox == "")
  288. {
  289. pib_outboxcode2 = "1";
  290. }
  291. else
  292. {
  293. pib_outboxcode2 = (int.Parse(maxoutbox) + 1).ToString();
  294. }
  295. }
  296. else
  297. {
  298. pib_outboxcode2 = OutBoxNum.Text;
  299. }
  300. if (OutBoxNum.Text == "全部")
  301. {
  302. MessageBox.Show("请选择指定箱号或者新增");
  303. return;
  304. }
  305. //加载完数据之后进行容量的判断
  306. int BoxNum = LabelInfDataTable.Select("pib_outboxcode2='" + OutBoxNum.Text + "'").Length;
  307. if (BoxNum + CodeCount > OutboxCapacity.Value)
  308. {
  309. string close = MessageBox.Show(this.ParentForm, "箱号【" + OutBoxNum.Text + "】后超数量为" + (BoxNum + CodeCount) + ",超出容量" + OutboxCapacity.Value + ",是否继续?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question).ToString();
  310. if (close != "Yes")
  311. {
  312. Input.SelectAll();
  313. return;
  314. }
  315. }
  316. //计算当前采集数量
  317. string collectqty = dh.getFieldDataByCondition("prodiobarcode", "sum(pib_qty)", "pib_inoutno='" + pi_inoutno.Text + "' and pib_prodcode='" + CurrentPrCode + "' and pib_pdno='" + CurrentPDNO + "'").ToString();
  318. double CollectQty = (collectqty == "" ? 0 : double.Parse(collectqty));
  319. if (Convert.ToDouble((CollectQty + CollectNum).ToString("0.000")) > Convert.ToDouble(double.Parse(CurrentPrCount).ToString("0.000")))
  320. {
  321. MessageBox.Show("物料" + Data["PRCODE"] + "采集后数量为" + (CollectQty + CollectNum) + ",【超出】本行出货数量" + CurrentPrCount, "提示");
  322. Input.SelectAll();
  323. return;
  324. }
  325. GetBarCodeRule(out Prefix, out Suffix, out MaxNum, out NumLength, out Radix);
  326. List<string> CustBarCode = new List<string>();
  327. if (!(Radix > 0))
  328. {
  329. string close = MessageBox.Show(this.ParentForm, "未维护条码规则,是否继续生成", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question).ToString();
  330. if (close.ToString() != "Yes")
  331. return;
  332. }
  333. for (int i = 0; i < CodeCount; i++)
  334. {
  335. if (Radix > 0)
  336. {
  337. string serialcode = BaseUtil.DToAny(MaxNum, Radix);
  338. for (int j = serialcode.ToString().Length; j < NumLength; j++)
  339. {
  340. serialcode = "0" + serialcode;
  341. }
  342. CustBarCode.Add(Prefix + serialcode + Suffix);
  343. MaxNum = MaxNum + 1;
  344. }
  345. else
  346. {
  347. CustBarCode.Add("");
  348. }
  349. }
  350. sql.Clear();
  351. sql.Append("insert into prodiobarcode(PIB_ID,PIB_PRODCODE,PIB_INDATE,PIB_INOUTNO,PIB_PIID,PIB_PDNO, PIB_PDID,PIB_PICLASS,");
  352. sql.Append("PIB_BARCODE,PIB_CUSTBARCODE,PIB_QTY,pib_brand,pib_datecode,pib_lotno,PIB_OUTBOXCODE2,pib_inman,PIB_IFPRINT,PIB_ORDERCODE,PIB_CUSTPO,pib_remark,pib_midcapatity,pib_custcode) ");
  353. sql.Append("select :PIB_ID,pd_prodcode,sysdate,pi_inoutno,pi_id,pd_pdno,pd_id,pi_class,");
  354. sql.Append("'" + pib_barcode + "',:PIB_CUSTBARCODE,'" + CurrentZXBZ + "','" + Data["BRAND"] + "','" + Data["DATECODE"] + "','" + Data["LOTNO"] + "','" + pib_outboxcode2 + "','" + User.UserCode + "','" + (EnablePrint && SingleLabelAutoPrint.Checked ? 1 : 0).ToString() + "',pd_ordercode,pd_pocode,pd_remark,'" + MidboxCapacity.Value + "','" + pi_cardcode.Text + "' ");
  355. sql.Append("from prodinout left join prodiodetail on pi_id=pd_piid left join PRODJOINVENDDETAIL on pjd_brand =pd_brand and pjd_prodcode=pd_prodcode where pi_id='" + PI_ID + "' and pd_prodcode='" + CurrentPrCode + "' and pd_pdno='" + CurrentPDNO + "'");
  356. dh.BatchInsert(sql.ToString(), new string[] { "PIB_ID", "PIB_CUSTBARCODE" }, PIBID, CustBarCode.ToArray());
  357. //更新流水号
  358. dh.UpdateByCondition("RULEMAXNUM", "rmn_maxnumber='" + (MaxNum) + "'", "rmn_nrcode='" + (pi_cardcode.Text == "" ? "Default" : pi_cardcode.Text) + "' and rmn_prefix='" + Prefix + "'");
  359. LoadGridData(new object(), new EventArgs());
  360. if (LabelInf.Rows.Count > 0)
  361. {
  362. LabelInf.Rows[LabelInf.Rows.Count - 1].Selected = true;
  363. }
  364. if (SingleLabelAutoPrint.Checked)
  365. {
  366. thread = new Thread(AutoPrintSingleLabel);
  367. stw = new SetLoadingWindow(thread, "正在打印单盘标签");
  368. BaseUtil.SetFormCenter(stw);
  369. stw.ShowDialog();
  370. }
  371. //采集后重新计数,自动跳到下一行
  372. collectqty = (SumQty.Compute("sum(pib_qty)", "pib_prodcode='" + CurrentPrCode + "' and pib_pdno='" + CurrentPDNO + "'").ToString());
  373. CollectQty = (collectqty == "" ? 0 : double.Parse(collectqty));
  374. int combined = 0;
  375. if (Combindetail.Checked)
  376. combined = 1;
  377. if (CombindetailTwo.Checked)
  378. combined = 2;
  379. dh.UpdateByCondition("CS$InoutPrcode", "Collectednum='" + collectqty + "'", "pd_inoutno='" + pi_inoutno.Text + "' and pd_pdno='" + CurrentPDNO + "' and combined=" + combined);
  380. CollectNum = 0;
  381. double OutNum = 0;
  382. if (GridPrcode.SelectedRows.Count > 0)
  383. {
  384. GridPrcode.Rows[GridPrcode.SelectedRows[0].Index].Cells["CollectedNum"].Value = collectqty;
  385. for (int i = 0; i < GridPrcode.Rows.Count; i++)
  386. {
  387. CollectNum += float.Parse(GridPrcode.Rows[i].Cells["CollectedNum"].Value.ToString());
  388. OutNum += float.Parse(GridPrcode.Rows[i].Cells["pd_outqty"].Value.ToString());
  389. }
  390. }
  391. ProcessCount.Text = CollectNum + "/" + OutNum;
  392. if (CollectNum == OutNum)
  393. {
  394. dh.UpdateByCondition("prodinout", "pi_user_packingstatus='Packed'", "pi_inoutno='" + pi_inoutno.Text + "'");
  395. }
  396. //采集达到了数量进行换行
  397. if (CollectQty == double.Parse(CurrentPrCount))
  398. {
  399. DataGridViewSelectedRowCollection selectrow = GridPrcode.SelectedRows;
  400. if (selectrow.Count > 0)
  401. {
  402. if (selectrow[0].Index + 1 < GridPrcode.Rows.Count)
  403. {
  404. string outqty = GridPrcode.Rows[selectrow[0].Index + 1].Cells["pd_outqty"].Value.ToString();
  405. string collectnum = GridPrcode.Rows[selectrow[0].Index + 1].Cells["CollectedNum"].Value.ToString();
  406. if (double.Parse(outqty) > double.Parse(collectnum == "" ? "0" : collectnum))
  407. {
  408. GridPrcode.Rows[selectrow[0].Index + 1].Selected = true;
  409. }
  410. }
  411. }
  412. }
  413. Input.Clear();
  414. if (OutBoxNum.Text == "新增")
  415. {
  416. OutBoxNum.Items.Clear();
  417. DataTable dt = (DataTable)dh.ExecuteSql("select distinct pib_outboxcode2 from prodiobarcode where pib_inoutno='" + pi_inoutno.Text + "' order by to_number(pib_outboxcode2) desc", "select");
  418. ItemObject io = new ItemObject("新增", "新增");
  419. OutBoxNum.Items.Add(io);
  420. io = new ItemObject("全部", "全部");
  421. OutBoxNum.Items.Add(io);
  422. for (int i = 0; i < dt.Rows.Count; i++)
  423. {
  424. string piboutboxcode2 = dt.Rows[i]["pib_outboxcode2"].ToString();
  425. io = new ItemObject(piboutboxcode2, piboutboxcode2);
  426. OutBoxNum.Items.Add(io);
  427. }
  428. if (OutBoxNum.Items.Count > 2)
  429. OutBoxNum.SelectedIndex = 2;
  430. }
  431. }
  432. private void AutoPrintSingleLabel()
  433. {
  434. if (EnablePrint)
  435. {
  436. //用标签本身的变量作为最外层的循环条件去匹配;
  437. StringBuilder ParamLog = new StringBuilder();
  438. string pibid = "";
  439. for (int i = 0; i < PIBID.Length; i++)
  440. {
  441. if (i != PIBID.Length - 1)
  442. pibid += PIBID[i] + ",";
  443. else
  444. pibid += PIBID[i];
  445. }
  446. if (!SingleLabelCombox.SelectedValue.ToString().Contains("System.Data.DataRowView"))
  447. SingleReport.Load(SingleLabelCombox.SelectedValue.ToString());
  448. for (int j = 0; j < SingleReport.Parameters.Count; j++)
  449. {
  450. SingleReport.SetParameterValue(SingleReport.Parameters[j].Name, "");
  451. for (int k = 0; k < Attach.Rows.Count; k++)
  452. {
  453. if (Attach.Rows[k][0].ToString() == SingleReport.Parameters[j].Name)
  454. {
  455. SingleReport.SetParameterValue(SingleReport.Parameters[j].Name, Attach.Rows[k][1].ToString());
  456. }
  457. }
  458. }
  459. DataTable dt = (DataTable)dh.ExecuteSql("select * from prodiosingleinfo_view where 主键ID in (" + pibid + ")", "select");
  460. SingleReport.RegisterData(dt, "prodiosingleinfo_view");
  461. SingleReport.GetDataSource("prodiosingleinfo_view").Enabled = true;
  462. SingleReport.PrintSettings.ShowDialog = false;
  463. SingleReport.PrintSettings.Printer = SingleLabelPrinter.Text;
  464. try
  465. {
  466. SingleReport.Print();
  467. }
  468. catch (Exception e)
  469. {
  470. MessageBox.Show(e.Message);
  471. return;
  472. }
  473. Properties.Settings.Default.SPrinter = SingleLabelPrinter.Text;
  474. Properties.Settings.Default.Save();
  475. LogManager.DoCommandLog(pi_inoutno.Text, User.UserCode, "自动打印箱标", "打印成功");
  476. }
  477. }
  478. //关闭窗口前提示用户确认
  479. private void 贴标机条码打印_FormClosing(object sender, FormClosingEventArgs e)
  480. {
  481. //如果不是注销的话
  482. if (!logout)
  483. {
  484. string close = MessageBox.Show(this.ParentForm, "是否关闭", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question).ToString();
  485. if (close.ToString() != "Yes")
  486. e.Cancel = true;
  487. else
  488. {
  489. LogManager.DoLog("关闭程序");
  490. }
  491. }
  492. }
  493. /// <summary>
  494. /// 获取打印标签
  495. /// </summary>
  496. private void GetInOutInfAndLabelFile()
  497. {
  498. ComBoxClickChangeLabelDoc = false;
  499. sql.Clear();
  500. sql.Append("select to_char(nvl(cl_date,sysdate),'YYYY-MM-DD HH24:Mi:SS') cl_date,cl_labelurl,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 ");
  501. sql.Append("left join customer on cu_code=cl_custcode left join label on la_code=CL_LABELCODE where ((pi_cardcode='" + pi_cardcode.Text + "' ");
  502. sql.Append("and pi_inoutno='" + pi_inoutno.Text + "') or( cl_custcode is null)) and cl_labeltype='单盘' order by cl_custcode,cl_date desc");
  503. dt = (DataTable)dh.ExecuteSql(sql.ToString(), "select");
  504. SingleLabelCombox.DisplayMember = "cl_labelname";
  505. SingleLabelCombox.ValueMember = "cl_labelurl";
  506. SingleLabelCombox.DataSource = dt;
  507. sql.Clear();
  508. sql.Append("select to_char(nvl(cl_date,sysdate),'YYYY-MM-DD HH24:Mi:SS') cl_date,cl_labelurl,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,cl_date desc");
  511. dt = (DataTable)dh.ExecuteSql(sql.ToString(), "select");
  512. MidLabelCombox.DisplayMember = "cl_labelname";
  513. MidLabelCombox.ValueMember = "cl_labelurl";
  514. MidLabelCombox.DataSource = dt;
  515. sql.Clear();
  516. sql.Append("select to_char(nvl(cl_date,sysdate),'YYYY-MM-DD HH24:Mi:SS') cl_date,cl_labelurl,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 ");
  517. sql.Append("left join customer on cu_code=cl_custcode left join label on la_code=CL_LABELCODE where ((pi_cardcode='" + pi_cardcode.Text + "' ");
  518. sql.Append("and pi_inoutno='" + pi_inoutno.Text + "') or( cl_custcode is null)) and cl_labeltype='外箱' order by cl_custcode,cl_date desc");
  519. dt = (DataTable)dh.ExecuteSql(sql.ToString(), "select");
  520. OutBoxCombox.DisplayMember = "cl_labelname";
  521. OutBoxCombox.ValueMember = "cl_labelurl";
  522. OutBoxCombox.DataSource = dt;
  523. ComBoxClickChangeLabelDoc = true;
  524. }
  525. bool LoadCheck = true;
  526. /// <summary>
  527. /// 出入库单录入框的回车事件
  528. /// </summary>
  529. /// <param name="sender"></param>
  530. /// <param name="e"></param>
  531. private void pi_inoutno_KeyDown(object sender, KeyEventArgs e)
  532. {
  533. if (e.KeyCode == Keys.Enter)
  534. {
  535. LoadCheck = false;
  536. Combindetail.Checked = false;
  537. CombindetailTwo.Checked = false;
  538. LoadCheck = true;
  539. Input.Clear();
  540. sql.Clear();
  541. sql.Append("select pi_id,pi_cardcode,pi_combine_user,pi_title,to_char(pi_date,'yyyymmdd')pi_date,nvl(pi_combine_user,0)pi_combine_user from prodinout where pi_inoutno='" + pi_inoutno.Text + "' and pi_invostatuscode='AUDITED'");
  542. dt = (DataTable)dh.ExecuteSql(sql.ToString(), "select");
  543. if (dt.Rows.Count > 0)
  544. {
  545. switch (dt.Rows[0]["pi_combine_user"].ToString())
  546. {
  547. case "1":
  548. Combindetail.Checked = true;
  549. break;
  550. case "2":
  551. CombindetailTwo.Checked = true;
  552. break;
  553. default:
  554. break;
  555. }
  556. pi_cardcode.Text = dt.Rows[0]["pi_cardcode"].ToString();
  557. pi_title.Text = dt.Rows[0]["pi_title"].ToString();
  558. if (pi_cardcode.Text != "ZGCC")
  559. {
  560. CustomerLabel.Enabled = false;
  561. }
  562. else
  563. {
  564. CustomerLabel.Enabled = true;
  565. }
  566. pi_date.Text = dt.Rows[0]["pi_date"].ToString();
  567. PI_ID = dt.Rows[0]["pi_id"].ToString();
  568. OutBoxNum_Click(new object(), new EventArgs());
  569. LoadPrcodeData();
  570. //获取条码规则
  571. GetBarCodeRule(out Prefix, out Suffix, out MaxNum, out NumLength, out Radix);
  572. SingleID.Clear();
  573. Input.Focus();
  574. ////从后往前找未采集的行
  575. for (int i = GridPrcode.Rows.Count - 1; i >= 0; i--)
  576. {
  577. string outqty = GridPrcode.Rows[i].Cells["pd_outqty"].Value.ToString();
  578. string collectnum = GridPrcode.Rows[i].Cells["CollectedNum"].Value.ToString();
  579. if (double.Parse(outqty) > double.Parse(collectnum == "" ? "0" : collectnum))
  580. {
  581. GridPrcode.Rows[i].Selected = true;
  582. if (i - 2 >= 0)
  583. GridPrcode.FirstDisplayedScrollingRowIndex = i - 2;
  584. else
  585. GridPrcode.FirstDisplayedScrollingRowIndex = i;
  586. }
  587. }
  588. bi_inman.Text = dh.getFieldDataByCondition("barcodeio left join employee on bi_inman=em_code", "wm_concat(distinct em_name)", "bi_piid=" + PI_ID).ToString();
  589. pib_inman.Text = dh.getFieldDataByCondition("prodiobarcode left join employee on pib_inman=em_code", "wm_concat(distinct em_name)", "pib_piid=" + PI_ID).ToString();
  590. Attach = (DataTable)dh.ExecuteSql("select lap_param lp_name,lap_value lp_sql from LABELATTACHPARAMETER where lap_custcode='" + pi_cardcode.Text + "' and lap_inman='" + User.UserCode + "'", "select");
  591. thread = new Thread(GetInOutInfAndLabelFile);
  592. stw = new SetLoadingWindow(thread, "正在获取打印标签");
  593. BaseUtil.SetFormCenter(stw);
  594. stw.ShowDialog();
  595. LogManager.DoLog("输入单号【" + pi_inoutno.Text + "】");
  596. }
  597. else MessageBox.Show("当前出入库单号不存在或者未审核!", "提示");
  598. }
  599. }
  600. private void SingleBoxPrint()
  601. {
  602. if (EnablePrint)
  603. {
  604. if (LabelInf.Rows.Count > 0)
  605. {
  606. //每次打印清除之前缓存的行号和ID,后面会判断需要打印的数据重新加载
  607. SingleID.Clear();
  608. //获取全部的中盒号
  609. Dictionary<string, bool> outboxcode1 = new Dictionary<string, bool>();
  610. //判断所有盒号为该盒的是否勾选已采集
  611. outboxcode1.Add(LabelInf.Rows[0].Cells["pib_outboxcode1"].Value.ToString(), true);
  612. for (int i = 0; i < LabelInf.Rows.Count; i++)
  613. {
  614. if (!SingleID.Contains(LabelInf.Rows[i].Cells["pib_id1"].Value.ToString()))
  615. SingleID.Add(LabelInf.Rows[i].Cells["pib_id1"].Value.ToString());
  616. }
  617. if (SingleID.ToArray().Length == 0)
  618. {
  619. MessageBox.Show("选择的行未勾选采集或者已打印", "提示");
  620. return;
  621. }
  622. for (int i = 0; i < LabelInf.RowCount; i++)
  623. {
  624. if (i + 1 < LabelInf.RowCount)
  625. {
  626. //如果本行的中盒号和下一行不相等的话
  627. if (LabelInf.Rows[i].Cells["pib_outboxcode1"].Value.ToString() != LabelInf.Rows[i + 1].Cells["pib_outboxcode1"].Value.ToString())
  628. {
  629. if (!outboxcode1.ContainsKey(LabelInf.Rows[i + 1].Cells["pib_outboxcode1"].Value.ToString()))
  630. outboxcode1.Add(LabelInf.Rows[i + 1].Cells["pib_outboxcode1"].Value.ToString(), true);
  631. }
  632. }
  633. }
  634. string pibid = "";
  635. for (int i = 0; i < LabelInf.RowCount; i++)
  636. {
  637. //勾选了并且未打印
  638. if (LabelInf.Rows[i].Cells["Choose"].FormattedValue != null && LabelInf.Rows[i].Cells["Choose"].FormattedValue.ToString().ToLower() == "true")
  639. {
  640. pibid += LabelInf.Rows[i].Cells["pib_id1"].Value.ToString() + ",";
  641. LabelInf.Rows[i].Cells["pib_ifprint"].Value = true;
  642. }
  643. }
  644. if (pibid != "")
  645. {
  646. if (!SingleLabelCombox.SelectedValue.ToString().Contains("System.Data.DataRowView"))
  647. SingleReport.Load(SingleLabelCombox.SelectedValue.ToString());
  648. for (int j = 0; j < SingleReport.Parameters.Count; j++)
  649. {
  650. SingleReport.SetParameterValue(SingleReport.Parameters[j].Name, "");
  651. for (int k = 0; k < Attach.Rows.Count; k++)
  652. {
  653. if (Attach.Rows[k][0].ToString() == SingleReport.Parameters[j].Name)
  654. {
  655. SingleReport.SetParameterValue(SingleReport.Parameters[j].Name, Attach.Rows[k][1].ToString());
  656. }
  657. }
  658. }
  659. DataTable dt = (DataTable)dh.ExecuteSql("select * from prodiosingleinfo_view where 主键ID in (" + pibid.Substring(0, pibid.Length - 1) + ")", "select");
  660. SingleReport.RegisterData(dt, "prodiosingleinfo_view");
  661. SingleReport.GetDataSource("prodiosingleinfo_view").Enabled = true;
  662. //保存参数打印
  663. SingleReport.PrintSettings.ShowDialog = false;
  664. SingleReport.PrintSettings.Printer = SingleLabelPrinter.Text;
  665. try
  666. {
  667. SingleReport.Print();
  668. }
  669. catch (Exception e)
  670. {
  671. MessageBox.Show(e.Message);
  672. return;
  673. }
  674. Properties.Settings.Default.SPrinter = SingleLabelPrinter.Text;
  675. Properties.Settings.Default.Save();
  676. }
  677. else
  678. {
  679. MessageBox.Show("未勾选打印明细", "提示", MessageBoxButtons.OK, MessageBoxIcon.None, MessageBoxDefaultButton.Button1, MessageBoxOptions.ServiceNotification);
  680. }
  681. LogManager.DoCommandLog(pi_inoutno.Text, User.UserCode, "手动打印箱标", "打印成功");
  682. dh.BatchInsert("update prodiobarcode set pib_printdate=sysdate where pib_id=:pib_id", new string[] { "pib_id" }, SingleID.ToArray());
  683. outboxcode1.Clear();
  684. }
  685. else
  686. {
  687. MessageBox.Show("此模板尚未维护参数或不存在打印明细", "提示");
  688. return;
  689. }
  690. }
  691. }
  692. private void SingleLabelPrint_Click(object sender, EventArgs e)
  693. {
  694. if (SingleLabelCombox.Text != "")
  695. {
  696. if (SingleBoxBegin.Text != "" || SingleBoxEnd.Text != "")
  697. {
  698. try
  699. {
  700. int begin = int.Parse(SingleBoxBegin.Text == "" ? "1" : SingleBoxBegin.Text);
  701. int end = int.Parse(SingleBoxEnd.Text == "" ? LabelInf.Rows.Count.ToString() : SingleBoxEnd.Text);
  702. if (begin > 0 && end <= LabelInf.Rows.Count && begin <= end)
  703. {
  704. for (int i = begin - 1; i < end; i++)
  705. {
  706. LabelInf.Rows[i].Cells["Choose"].Value = true;
  707. LabelInf.Rows[i].Cells["pib_ifprint"].Value = false;
  708. }
  709. }
  710. else
  711. {
  712. MessageBox.Show("单盘打印范围错误", "提示");
  713. return;
  714. }
  715. }
  716. catch (Exception)
  717. {
  718. MessageBox.Show("单盘打印范围错误", "提示");
  719. return;
  720. }
  721. }
  722. thread = new Thread(SingleBoxPrint);
  723. stw = new SetLoadingWindow(thread, "正在打印单盘");
  724. BaseUtil.SetFormCenter(stw);
  725. stw.ShowDialog();
  726. Input.Focus();
  727. }
  728. else
  729. {
  730. MessageBox.Show("未维护单盘标签", "提示");
  731. LogManager.DoCommandLog(pi_inoutno.Text, User.UserCode, "手动打印箱标", "打印失败,未维护标签");
  732. }
  733. }
  734. private void MidBoxLabelPrint()
  735. {
  736. //未输入内容打印全部中盒
  737. if (MidLabelNum.Text == "")
  738. {
  739. int begin = 0;
  740. int end = 0;
  741. if (MidBoxBegin.Text != "" || MidBoxEnd.Text != "")
  742. {
  743. try
  744. {
  745. begin = int.Parse(MidBoxBegin.Text == "" ? "1" : MidBoxBegin.Text);
  746. end = int.Parse(MidBoxEnd.Text == "" ? LabelInf.Rows[LabelInf.Rows.Count - 1].Cells["pib_outboxcode1"].Value.ToString() : MidBoxEnd.Text);
  747. int minmidbox = int.Parse(LabelInf.Rows[0].Cells["pib_outboxcode1"].Value.ToString());
  748. int maxmidbox = int.Parse(LabelInf.Rows[LabelInf.Rows.Count - 1].Cells["pib_outboxcode1"].Value.ToString());
  749. if (begin >= minmidbox && end <= maxmidbox && begin <= end)
  750. {
  751. //设置中盒打印范围的行号
  752. for (int i = 0; i < LabelInf.Rows.Count; i++)
  753. {
  754. if (int.Parse(LabelInf.Rows[i].Cells["pib_outboxcode1"].Value.ToString()) == begin)
  755. {
  756. begin = i;
  757. }
  758. if (int.Parse(LabelInf.Rows[i].Cells["pib_outboxcode1"].Value.ToString()) == end)
  759. {
  760. end = i;
  761. }
  762. }
  763. }
  764. else
  765. {
  766. MessageBox.Show("中盒打印范围错误", "提示");
  767. return;
  768. }
  769. }
  770. catch (Exception)
  771. {
  772. MessageBox.Show("中盒打印范围错误", "提示");
  773. return;
  774. }
  775. }
  776. List<int> MidOutBoxCode = new List<int>();
  777. List<int> MidOutBoxCodeIndex = new List<int>();
  778. for (int i = (begin == 0 ? 0 : begin); i <= (end == 0 ? LabelInf.Rows.Count - 1 : end); i++)
  779. {
  780. try
  781. {
  782. if (!MidOutBoxCode.Contains(int.Parse(LabelInf.Rows[i].Cells["pib_outboxcode1"].Value.ToString())))
  783. {
  784. MidOutBoxCode.Add(int.Parse(LabelInf.Rows[i].Cells["pib_outboxcode1"].Value.ToString()));
  785. MidOutBoxCodeIndex.Add(i);
  786. }
  787. }
  788. catch (Exception)
  789. {
  790. MessageBox.Show("请先封箱!");
  791. return;
  792. }
  793. }
  794. //如果有选中行
  795. if (SelectRowIndex >= 0)
  796. {
  797. MidOutBoxCode.Clear();
  798. MidOutBoxCodeIndex.Clear();
  799. SelectProdcode = LabelInf.Rows[SelectRowIndex].Cells["pib_prodcode"].Value.ToString();
  800. for (int i = SelectRowIndex; i >= 0; i--)
  801. {
  802. if ((LabelInf.Rows[i].Cells["pib_prodcode"].Value.ToString() == SelectProdcode && LabelInf.Rows[i].Cells["pib_midifprint"].FormattedValue.ToString().ToLower() != "true") || i == SelectRowIndex)
  803. {
  804. LabelInf.Rows[i].Cells["pib_midifprint"].Value = true;
  805. if (!MidOutBoxCode.Contains(int.Parse(LabelInf.Rows[i].Cells["pib_outboxcode1"].Value.ToString())))
  806. {
  807. MidOutBoxCode.Add(int.Parse(LabelInf.Rows[i].Cells["pib_outboxcode1"].Value.ToString()));
  808. MidOutBoxCodeIndex.Add(i);
  809. }
  810. }
  811. else
  812. {
  813. break;
  814. }
  815. }
  816. for (int i = SelectRowIndex; i < LabelInf.Rows.Count - 1; i++)
  817. {
  818. if ((LabelInf.Rows[i].Cells["pib_prodcode"].Value.ToString() == SelectProdcode && LabelInf.Rows[i].Cells["pib_midifprint"].FormattedValue.ToString().ToLower() != "true") || i == SelectRowIndex)
  819. {
  820. LabelInf.Rows[i].Cells["pib_midifprint"].Value = true;
  821. if (!MidOutBoxCode.Contains(int.Parse(LabelInf.Rows[i].Cells["pib_outboxcode1"].Value.ToString())))
  822. {
  823. MidOutBoxCode.Add(int.Parse(LabelInf.Rows[i].Cells["pib_outboxcode1"].Value.ToString()));
  824. MidOutBoxCodeIndex.Add(i);
  825. }
  826. }
  827. else
  828. {
  829. break;
  830. }
  831. }
  832. }
  833. try
  834. {
  835. MidBoxCodePrint(MidOutBoxCodeIndex.ToArray());
  836. }
  837. catch (Exception e)
  838. {
  839. MessageBox.Show(e.Message);
  840. return;
  841. }
  842. return;
  843. }
  844. bool FindMidLabel = false;
  845. if (MidLabelCombox.SelectedValue != null)
  846. {
  847. //中盒号所在的行
  848. int MidLabelRowIndex = 0;
  849. //缓存中盒数据
  850. for (int i = 0; i < LabelInf.RowCount; i++)
  851. {
  852. if (MidLabelNum.Text == LabelInf.Rows[i].Cells["pib_outboxcode1"].Value.ToString())
  853. {
  854. //找到了输入的中盒号停止循环
  855. FindMidLabel = true;
  856. MidLabelRowIndex = i;
  857. }
  858. }
  859. int[] rowindx = new int[] { MidLabelRowIndex };
  860. //找到了指定的盒号
  861. if (FindMidLabel)
  862. MidBoxCodePrint(rowindx);
  863. else
  864. MessageBox.Show("该出入库单未找到该中盒号!", "提示");
  865. }
  866. else
  867. MessageBox.Show("未维护中盒模板", "提示");
  868. }
  869. private void MidLabelPrint_Click(object sender, EventArgs e)
  870. {
  871. if (MidLabelCombox.Text != "")
  872. {
  873. PackMidBox_Click(sender, e);
  874. thread = new Thread(MidBoxLabelPrint);
  875. stw = new SetLoadingWindow(thread, "正在打印中盒");
  876. BaseUtil.SetFormCenter(stw);
  877. stw.ShowDialog();
  878. }
  879. else
  880. MessageBox.Show("未维护中盒标签", "提示");
  881. Input.Focus();
  882. }
  883. private void OutBoxPrint()
  884. {
  885. List<string> Outboxcode = new List<string>();
  886. //如果未勾选箱号则对勾选的数据的箱号进行整合
  887. if (OutBoxNum.Text == "" || OutBoxNum.Text == "全部")
  888. {
  889. for (int i = 0; i < LabelInf.RowCount; i++)
  890. {
  891. string outboxcode2 = LabelInf.Rows[i].Cells["pib_outboxcode2"].Value.ToString();
  892. //富为使用包装单的逻辑
  893. //如果不包含该箱号则进行添加
  894. if (!Outboxcode.Contains(outboxcode2))
  895. Outboxcode.Add(outboxcode2);
  896. }
  897. //按获取到的箱号列表进行打印
  898. if (Outboxcode.ToArray().Length > 0)
  899. {
  900. for (int i = 0; i < Outboxcode.ToArray().Length; i++)
  901. {
  902. for (int h = 0; h < LabelInf.RowCount; h++)
  903. {
  904. if (LabelInf.Rows[h].Cells["pib_outboxcode2"].Value.ToString() == Outboxcode.ToArray()[i])
  905. {
  906. OutBoxCodePrint(h);
  907. break;
  908. }
  909. }
  910. }
  911. }
  912. else
  913. {
  914. MessageBox.Show("请勾选需要打印的外箱", "提示");
  915. }
  916. }
  917. else
  918. {
  919. bool FindMidLabel = false;
  920. try
  921. {
  922. int OutBoxLabelRowIndex = 0;
  923. //查找是否存在该中盒号
  924. for (int i = 0; i < LabelInf.RowCount; i++)
  925. {
  926. if (OutBoxNum.Text == LabelInf.Rows[i].Cells["pib_outboxcode2"].Value.ToString())
  927. {
  928. //找到了输入的中盒号停止循环
  929. FindMidLabel = true;
  930. OutBoxLabelRowIndex = i;
  931. break;
  932. }
  933. }
  934. //找到了指定的盒号
  935. if (FindMidLabel)
  936. OutBoxCodePrint(OutBoxLabelRowIndex);
  937. else
  938. MessageBox.Show("该出入库单未找到该外箱号!", "提示");
  939. }
  940. catch (Exception) { }
  941. }
  942. Outboxcode.Clear();
  943. }
  944. private void MidBoxCodePrint(int[] rowindex)
  945. {
  946. if (EnablePrint)
  947. {
  948. string pib_outboxcode1 = "";
  949. for (int i = 0; i < rowindex.Length; i++)
  950. {
  951. if (i != rowindex.Length - 1)
  952. pib_outboxcode1 += "'" + LabelInf.Rows[rowindex[i]].Cells["pib_outboxcode1"].Value.ToString() + "'" + ",";
  953. else
  954. pib_outboxcode1 += "'" + LabelInf.Rows[rowindex[i]].Cells["pib_outboxcode1"].Value.ToString() + "'";
  955. }
  956. //名称相等的时候,取SQL进行值的查询
  957. DataTable dt;
  958. if (MidLabelAutoPrint.Checked)
  959. {
  960. dt = (DataTable)dh.ExecuteSql("select * from prodiomidinfo_view where 出货单号='" + pi_inoutno.Text + "' and 中盒号 in(" + pib_outboxcode1 + ")", "select");
  961. }
  962. else
  963. {
  964. dt = (DataTable)dh.ExecuteSql("select * from prodiomidinfo_view where 出货单号='" + pi_inoutno.Text + "' and 中盒号 in(" + pib_outboxcode1 + ") and 中盒标识='外'", "select");
  965. }
  966. if (dt.Rows.Count > 0)
  967. {
  968. if (!MidLabelCombox.SelectedValue.ToString().Contains("System.Data.DataRowView"))
  969. MidReport.Load(MidLabelCombox.SelectedValue.ToString());
  970. for (int j = 0; j < MidReport.Parameters.Count; j++)
  971. {
  972. MidReport.SetParameterValue(MidReport.Parameters[j].Name, "");
  973. for (int i = 0; i < Attach.Rows.Count; i++)
  974. {
  975. if (Attach.Rows[i][0].ToString() == MidReport.Parameters[j].Name)
  976. {
  977. MidReport.SetParameterValue(MidReport.Parameters[j].Name, Attach.Rows[i][1].ToString());
  978. }
  979. }
  980. }
  981. MidReport.RegisterData(dt, "prodiomidinfo_view");
  982. MidReport.GetDataSource("prodiomidinfo_view").Enabled = true;
  983. MidReport.PrintSettings.ShowDialog = false;
  984. MidReport.PrintSettings.Printer = MidLabelPrinter.Text;
  985. MidReport.Print();
  986. dh.UpdateByCondition("prodiobarcode", "pib_midifprint=-1", "pib_inoutno='" + pi_inoutno.Text + "' and pib_outboxcode1 in (" + pib_outboxcode1 + ")");
  987. SelectRowIndex = -1;
  988. }
  989. Properties.Settings.Default.MPrinter = MidLabelPrinter.Text;
  990. Properties.Settings.Default.Save();
  991. }
  992. }
  993. /// <summary>
  994. /// 执行打印外箱号
  995. /// </summary>
  996. private void OutBoxCodePrint(int rowindex)
  997. {
  998. if (EnablePrint)
  999. {
  1000. if (!OutBoxCombox.SelectedValue.ToString().Contains("System.Data.DataRowView"))
  1001. OutReport.Load(OutBoxCombox.SelectedValue.ToString());
  1002. for (int j = 0; j < OutReport.Parameters.Count; j++)
  1003. {
  1004. OutReport.SetParameterValue(OutReport.Parameters[j].Name, "");
  1005. for (int i = 0; i < Attach.Rows.Count; i++)
  1006. {
  1007. if (Attach.Rows[i][0].ToString() == OutReport.Parameters[j].Name)
  1008. {
  1009. OutReport.SetParameterValue(OutReport.Parameters[j].Name, Attach.Rows[i][1].ToString());
  1010. }
  1011. }
  1012. }
  1013. string pib_outboxcode2 = LabelInf.Rows[rowindex].Cells["pib_outboxcode2"].Value.ToString();
  1014. DataTable dt = (DataTable)dh.ExecuteSql("select * from prodiooutinfo_view where 出货单号='" + pi_inoutno.Text + "' and 外箱号='" + pib_outboxcode2 + "'", "select");
  1015. OutReport.RegisterData(dt, "prodiooutinfo_view");
  1016. OutReport.GetDataSource("prodiooutinfo_view").Enabled = true;
  1017. OutReport.PrintSettings.ShowDialog = false;
  1018. OutReport.PrintSettings.Printer = OutBoxPrinter.Text;
  1019. OutReport.Print();
  1020. Properties.Settings.Default.OPrinter = OutBoxPrinter.Text;
  1021. Properties.Settings.Default.Save();
  1022. dh.UpdateByCondition("prodiobarcode", "pib_outifprint=-1", "pib_inoutno='" + pi_inoutno.Text + "' and pib_outboxcode2='" + pib_outboxcode2 + "'");
  1023. }
  1024. }
  1025. private void CleanDetail_Click(object sender, EventArgs e)
  1026. {
  1027. if (dh.getFieldDataByCondition("prodinout", "pi_statuscode", "pi_inoutno='" + pi_inoutno.Text + "'").ToString() == "POSTED")
  1028. {
  1029. MessageBox.Show("单据" + pi_inoutno.Text + "已过账,不允许删除条码");
  1030. return;
  1031. }
  1032. ArrayList<string> DeleteID = new ArrayList<string>();
  1033. for (int i = 0; i < LabelInf.RowCount; i++)
  1034. {
  1035. if (LabelInf.Rows[i].Cells["Choose"].FormattedValue.ToString().ToLower() == "true")
  1036. DeleteID.Add(LabelInf.Rows[i].Cells["pib_id1"].Value.ToString());
  1037. }
  1038. //勾选了删除的明细之后
  1039. if (DeleteID.ToArray().Length > 0)
  1040. {
  1041. string close = MessageBox.Show(this.ParentForm, "删除后不可恢复,是否确认删除", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question).ToString();
  1042. if (close.ToString() == "Yes")
  1043. {
  1044. dh.BatchInsert("delete from prodiobarcode where pib_id=:pib_id", new string[] { "pib_id" }, DeleteID.ToArray());
  1045. dh.UpdateByCondition("CS$InoutPrcode", "collectednum=(select nvl(sum(pib_qty),0) from prodiobarcode where pib_inoutno=pd_inoutno and pib_pdno=pd_pdno)", "pd_inoutno='" + pi_inoutno.Text + "'");
  1046. LogManager.DoCommandLog(pi_inoutno.Text, User.UserCode, "删除明细", "删除明细成功");
  1047. MessageBox.Show("删除成功", "提示");
  1048. Input.Clear();
  1049. LoadPrcodeData();
  1050. LoadGridData(sender, e);
  1051. dh.UpdateByCondition("prodinout", "pi_user_packingstatus='Packing'", "pi_inoutno='" + pi_inoutno.Text + "'");
  1052. }
  1053. }
  1054. else
  1055. MessageBox.Show("尚未勾选需要删除的明细", "提示");
  1056. }
  1057. private void OutBoxLabelPrint_Click(object sender, EventArgs e)
  1058. {
  1059. if (OutBoxCombox.Text != "")
  1060. {
  1061. Pack_Click(sender, e);
  1062. thread = new Thread(OutBoxPrint);
  1063. stw = new SetLoadingWindow(thread, "正在打印外箱");
  1064. BaseUtil.SetFormCenter(stw);
  1065. stw.ShowDialog();
  1066. Input.Focus();
  1067. }
  1068. else
  1069. MessageBox.Show("未维护外箱标签", "提示");
  1070. Input.Focus();
  1071. }
  1072. /// <summary>
  1073. /// 自定义函数 加载明细行的数据,多处使用添加进函数
  1074. /// </summary>
  1075. /// <param name="sender"></param>
  1076. /// <param name="e"></param>
  1077. private void LoadGridData(object sender, EventArgs e)
  1078. {
  1079. AllChecked = false;
  1080. sql.Clear();
  1081. sql.Append("select pd_custprodcode,pd_custprodspec,nvl(pib_midifprint,0)pib_midifprint,pib_custmidboxcode,pd_pocode,pjd_orispeccode,pib_madein,pib_custbarcode,pib_custoutboxcode,pib_id,pib_datecode1,pib_pdid,pib_piid,");
  1082. sql.Append("pib_pdno,pib_prodcode,pib_brand,pr_vendprodcode,pib_lotno,pib_datecode,week_to_date(pib_datecode) datecode1,pib_qty,pr_spec,");
  1083. sql.Append("pr_zxbzs,pr_unit,pib_barcode,pib_outboxcode1,pib_outboxcode2,nvl(pib_ifprint,0)pib_ifprint from prodiobarcode left join ");
  1084. sql.Append("prodiodetail on pib_piid=pd_piid and pd_pdno=pib_pdno and pd_prodcode=pib_prodcode left join product on pr_code=pib_prodcode ");
  1085. sql.Append("left join sale on sa_code=pib_ordercode left join PRODJOINVENDDETAIL on pjd_brand =pd_brand and pjd_prodcode=pd_prodcode where pib_piid='" + PI_ID + "' ");
  1086. if (OutBoxNum.Text != "全部")
  1087. {
  1088. sql.Append(" and pib_outboxcode2='" + OutBoxNum.Text + "' ");
  1089. }
  1090. sql.Append(" order by to_number(pib_outboxcode2),pib_id,pd_prodcode");
  1091. LabelInfDataTable = (DataTable)dh.ExecuteSql(sql.ToString(), "select");
  1092. BaseUtil.FillDgvWithDataTable(LabelInf, LabelInfDataTable);
  1093. if (LabelInf.Rows.Count > 0)
  1094. {
  1095. LabelInf.FirstDisplayedScrollingRowIndex = LabelInf.Rows.Count - 1;
  1096. }
  1097. sql.Clear();
  1098. sql.Append("select pib_pdno,pib_prodcode,sum(pib_qty) pib_qty from prodiodetail left join prodiobarcode on pd_id=pib_pdid and pd_pdno=pib_pdno ");
  1099. sql.Append("where pib_inoutno='" + pi_inoutno.Text + "' group by pib_prodcode,pib_pdno order by pib_pdno ");
  1100. SumQty = (DataTable)dh.ExecuteSql(sql.ToString(), "select");
  1101. }
  1102. private void Refresh_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
  1103. {
  1104. KeyEventArgs e2 = new KeyEventArgs(Keys.Enter);
  1105. pi_inoutno_KeyDown(sender, e2);
  1106. }
  1107. private void LogingOut_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
  1108. {
  1109. string close = MessageBox.Show(this.ParentForm, "是否注销", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question).ToString();
  1110. if (close.ToString() == "Yes")
  1111. {
  1112. Login login = new Login();
  1113. //注销的时候需要将拼接的连接字符串置空
  1114. DataHelper.DBConnectionString = null;
  1115. logout = true;
  1116. this.Hide();
  1117. login.ShowDialog();
  1118. this.Close();
  1119. }
  1120. }
  1121. private void LabelInf_DataError(object sender, DataGridViewDataErrorEventArgs e) { }
  1122. /// <summary>
  1123. /// 切换打开的单盘文件
  1124. /// </summary>
  1125. /// <param name="sender"></param>
  1126. /// <param name="e"></param>
  1127. private void SingleLabelCombox_SelectedIndexChanged(object sender, EventArgs e)
  1128. {
  1129. try
  1130. {
  1131. if (ComBoxClickChangeLabelDoc)
  1132. {
  1133. if (!SingleLabelCombox.SelectedValue.ToString().Contains("System.Data.DataRowView"))
  1134. SingleReport.Load(SingleLabelCombox.SelectedValue.ToString());
  1135. }
  1136. }
  1137. catch (Exception) { }
  1138. }
  1139. /// <summary>
  1140. /// 切换打开的中盒文件
  1141. /// </summary>
  1142. /// <param name="sender"></param>
  1143. /// <param name="e"></param>
  1144. private void MidLabelCombox_SelectedIndexChanged(object sender, EventArgs e)
  1145. {
  1146. try
  1147. {
  1148. if (ComBoxClickChangeLabelDoc)
  1149. {
  1150. if (!MidLabelCombox.SelectedValue.ToString().Contains("System.Data.DataRowView"))
  1151. MidReport.Load(MidLabelCombox.SelectedValue.ToString());
  1152. }
  1153. }
  1154. catch (Exception) { }
  1155. }
  1156. /// <summary>
  1157. /// 切换打开的外箱文件
  1158. /// </summary>
  1159. /// <param name="sender"></param>
  1160. /// <param name="e"></param>
  1161. private void OutBoxCombox_SelectedIndexChanged(object sender, EventArgs e)
  1162. {
  1163. try
  1164. {
  1165. if (ComBoxClickChangeLabelDoc)
  1166. {
  1167. if (!OutBoxCombox.SelectedValue.ToString().Contains("System.Data.DataRowView"))
  1168. OutReport.Load(OutBoxCombox.SelectedValue.ToString());
  1169. }
  1170. }
  1171. catch (Exception) { }
  1172. }
  1173. private void ChooseAll_Click(object sender, EventArgs e)
  1174. {
  1175. if (AllChecked)
  1176. {
  1177. foreach (DataGridViewRow dr in LabelInf.Rows)
  1178. dr.Cells[0].Value = false;
  1179. AllChecked = false;
  1180. }
  1181. else
  1182. {
  1183. foreach (DataGridViewRow dr in LabelInf.Rows)
  1184. dr.Cells[0].Value = true;
  1185. AllChecked = true;
  1186. }
  1187. }
  1188. private void ExportData_Click(object sender, EventArgs e)
  1189. {
  1190. ExportFileDialog.Description = "选择导出的路径";
  1191. DialogResult result = ExportFileDialog.ShowDialog();
  1192. if (result == DialogResult.OK)
  1193. {
  1194. ExcelHandler eh = new ExcelHandler();
  1195. DataTable dt = LabelInfDataTable.Copy();
  1196. for (int i = dt.Columns.Count - 1; i >= 0; i--)
  1197. {
  1198. for (int j = 0; j < LabelInf.Columns.Count; j++)
  1199. {
  1200. //去除ID列
  1201. 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_ifprint" || dt.Columns[i].ColumnName.ToLower() == "pib_datecode1" || dt.Columns[i].ColumnName.ToLower() == "pr_vendprodcode")
  1202. {
  1203. dt.Columns.RemoveAt(i);
  1204. break;
  1205. }
  1206. switch (dt.Columns[i].ColumnName.ToLower())
  1207. {
  1208. case "pib_lotno":
  1209. dt.Columns[i].ColumnName = "批次号";
  1210. break;
  1211. case "pib_datecode":
  1212. dt.Columns[i].ColumnName = "生产年周";
  1213. break;
  1214. case "pib_custbarcode":
  1215. dt.Columns[i].ColumnName = "最小产品包装条码";
  1216. break;
  1217. case "datecode1":
  1218. dt.Columns[i].ColumnName = "生产日期";
  1219. break;
  1220. default:
  1221. break;
  1222. }
  1223. if (dt.Columns[i].ColumnName.ToLower() == LabelInf.Columns[j].DataPropertyName.ToLower())
  1224. {
  1225. dt.Columns[i].ColumnName = LabelInf.Columns[j].HeaderText;
  1226. break;
  1227. }
  1228. }
  1229. }
  1230. eh.ExportExcel(dt, ExportFileDialog.SelectedPath, pi_date.Text + "-" + pi_inoutno.Text);
  1231. string close = MessageBox.Show(this.ParentForm, "导出成功,是否打开文件", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question).ToString();
  1232. if (close.ToString() == "Yes")
  1233. Process.Start(ExportFileDialog.SelectedPath + "\\" + pi_date.Text + "-" + pi_inoutno.Text + ".xls");
  1234. }
  1235. }
  1236. private void AttachInfo_Click(object sender, EventArgs e)
  1237. {
  1238. if (pi_cardcode.Text != "")
  1239. {
  1240. 附件内容打印 att = new 附件内容打印(pi_cardcode.Text);
  1241. att.ShowDialog();
  1242. }
  1243. else MessageBox.Show("请先获取出库单信息", "提示");
  1244. }
  1245. private void MidBoxCapacity_Leave(object sender, EventArgs e)
  1246. {
  1247. NumericUpDown nup = (NumericUpDown)sender;
  1248. switch (nup.Name)
  1249. {
  1250. case "MidBoxCapacity":
  1251. Properties.Settings.Default.MidBoxCapacity = nup.Value;
  1252. Properties.Settings.Default.Save();
  1253. break;
  1254. case "OutboxCapacity":
  1255. Properties.Settings.Default.OutboxCapacity = nup.Value;
  1256. Properties.Settings.Default.Save();
  1257. break;
  1258. default:
  1259. break;
  1260. }
  1261. }
  1262. private void RefreshDBConnect_Tick(object sender, EventArgs e)
  1263. {
  1264. dh.ExecuteSql("select sysdate from dual", "select");
  1265. }
  1266. DataTable CSPrcode;
  1267. private void LoadPrcodeData()
  1268. {
  1269. DataTable Prcode = (DataTable)dh.ExecuteSql("select '' pd_piid,pd_inoutno,pd_custprodcode,pd_pocode,pd_whcode,pd_prodcode,'0' CollectedNum,'0' UnCollectedNum,pd_outqty,pr_unit,pr_spec,pd_brand,pjd_zxbzs_user,pjd_id,pd_pdno from prodiodetail left join prodinout on pi_id=pd_piid left join PRODJOINVENDDETAIL on pjd_brand =pd_brand and pjd_prodcode=pd_prodcode left join product on pd_prodcode=pr_code where pi_id='" + PI_ID + "' order by pd_pdno", "select");
  1270. GridPrcode.DataSource = Prcode;
  1271. List<int> RemoveIndex = new List<int>();
  1272. double CollectNum = 0;
  1273. double OutNum = 0;
  1274. int combined = 0;
  1275. if (Combindetail.Checked)
  1276. combined = 1;
  1277. if (CombindetailTwo.Checked)
  1278. combined = 2;
  1279. if (Combindetail.Checked || CombindetailTwo.Checked)
  1280. {
  1281. CSPrcode = (DataTable)dh.ExecuteSql("select pd_piid,pd_pdno,pd_custprodcode,pd_whcode,pd_prodcode,CollectedNum,UnCollectedNum,pd_outqty,pr_unit,pr_spec,pd_brand,pjd_zxbzs_user,pjd_id,pd_inoutno,pd_pocode from CS$InoutPrcode where pd_inoutno='" + pi_inoutno.Text + "' and combined=" + combined + " order by pd_pdno", "select");
  1282. if (CSPrcode.Rows.Count == 0)
  1283. {
  1284. int CurrentIndex = 0;
  1285. for (int i = 0; i < GridPrcode.Rows.Count; i++)
  1286. {
  1287. string CurrentPrCode = GridPrcode.Rows[i].Cells["pd_prodcode"].Value.ToString();
  1288. string CurrentPDNO = GridPrcode.Rows[i].Cells["pd_pdno"].Value.ToString();
  1289. string CurrentOutQTY = GridPrcode.Rows[i].Cells["pd_outqty"].Value.ToString();
  1290. string collectqty = (SumQty.Compute("sum(pib_qty)", "pib_prodcode='" + CurrentPrCode + "' and pib_pdno='" + CurrentPDNO + "'").ToString());
  1291. CollectNum += double.Parse(collectqty == "" ? "0" : collectqty);
  1292. OutNum += double.Parse(CurrentOutQTY);
  1293. GridPrcode.Rows[i].Cells["CollectedNum"].Value = collectqty == "" ? "0" : collectqty;
  1294. }
  1295. for (int i = 0; i < GridPrcode.Rows.Count; i++)
  1296. {
  1297. if (i + 1 < GridPrcode.Rows.Count)
  1298. {
  1299. string BProdCode = GridPrcode.Rows[i].Cells["pd_prodcode"].Value.ToString();
  1300. string BCustProdCode = GridPrcode.Rows[i].Cells["pd_custprodcode1"].Value.ToString();
  1301. string BWhCode = GridPrcode.Rows[i].Cells["pd_whcode"].Value.ToString();
  1302. string BPrUnit = GridPrcode.Rows[i].Cells["pr_unit"].Value.ToString();
  1303. string BPrBrand = GridPrcode.Rows[i].Cells["pd_brand"].Value.ToString();
  1304. string BPoCode = GridPrcode.Rows[i].Cells["pd_pocode1"].Value.ToString();
  1305. string FProdCode = GridPrcode.Rows[i + 1].Cells["pd_prodcode"].Value.ToString();
  1306. string FCustProdCode = GridPrcode.Rows[i + 1].Cells["pd_custprodcode1"].Value.ToString();
  1307. string FPrUnit = GridPrcode.Rows[i + 1].Cells["pr_unit"].Value.ToString();
  1308. string FrBrand = GridPrcode.Rows[i + 1].Cells["pd_brand"].Value.ToString();
  1309. string FWhCode = GridPrcode.Rows[i + 1].Cells["pd_whcode"].Value.ToString();
  1310. string FPoCode = GridPrcode.Rows[i + 1].Cells["pd_pocode1"].Value.ToString();
  1311. if (BProdCode == FProdCode && BPrBrand == FrBrand && BCustProdCode == FCustProdCode && (CombindetailTwo.Checked && FPoCode == BPoCode || Combindetail.Checked))
  1312. {
  1313. GridPrcode.Rows[CurrentIndex].Cells["pd_outqty"].Value = double.Parse(GridPrcode.Rows[CurrentIndex].Cells["pd_outqty"].Value.ToString()) + double.Parse(GridPrcode.Rows[i + 1].Cells["pd_outqty"].Value.ToString());
  1314. GridPrcode.Rows[CurrentIndex].Cells["CollectedNum"].Value = double.Parse(GridPrcode.Rows[CurrentIndex].Cells["CollectedNum"].Value.ToString()) + double.Parse(GridPrcode.Rows[i + 1].Cells["CollectedNum"].Value.ToString());
  1315. RemoveIndex.Add(i + 1);
  1316. }
  1317. else
  1318. {
  1319. CurrentIndex = i + 1;
  1320. }
  1321. }
  1322. }
  1323. foreach (int item in RemoveIndex.OrderByDescending(x => x))
  1324. {
  1325. (GridPrcode.DataSource as DataTable).Rows.RemoveAt(item);
  1326. }
  1327. }
  1328. else GridPrcode.DataSource = CSPrcode;
  1329. }
  1330. else
  1331. {
  1332. CSPrcode = (DataTable)dh.ExecuteSql("select pd_piid,pd_pdno,pd_custprodcode,pd_whcode,pd_prodcode,CollectedNum,UnCollectedNum,pd_outqty,pr_unit,pr_spec,pd_brand,pjd_zxbzs_user,pjd_id,pd_inoutno,pd_pocode from CS$InoutPrcode where pd_inoutno='" + pi_inoutno.Text + "' and combined=" + combined + " order by pd_pdno", "select");
  1333. if (CSPrcode.Rows.Count == 0)
  1334. {
  1335. for (int i = 0; i < GridPrcode.Rows.Count; i++)
  1336. {
  1337. string CurrentPrCode = GridPrcode.Rows[i].Cells["pd_prodcode"].Value.ToString();
  1338. string CurrentPDNO = GridPrcode.Rows[i].Cells["pd_pdno"].Value.ToString();
  1339. string CurrentOutQTY = GridPrcode.Rows[i].Cells["pd_outqty"].Value.ToString();
  1340. string collectqty = (SumQty.Compute("sum(pib_qty)", "pib_prodcode='" + CurrentPrCode + "' and pib_pdno='" + CurrentPDNO + "'").ToString());
  1341. CollectNum += double.Parse(collectqty == "" ? "0" : collectqty);
  1342. OutNum += double.Parse(CurrentOutQTY);
  1343. GridPrcode.Rows[i].Cells["CollectedNum"].Value = collectqty == "" ? "0" : collectqty;
  1344. }
  1345. }
  1346. else GridPrcode.DataSource = CSPrcode;
  1347. }
  1348. dh.UpdateByCondition("prodinout", "pi_combine_user=" + combined, "pi_inoutno='" + pi_inoutno.Text + "'");
  1349. if (CSPrcode.Rows.Count == 0)
  1350. {
  1351. sql.Clear();
  1352. sql.Append("insert into CS$InoutPrcode (pd_piid,pd_pdno,pd_custprodcode,pd_whcode,pd_prodcode,");
  1353. sql.Append("CollectedNum,UnCollectedNum,pd_outqty,pr_unit,pr_spec,pd_brand,pjd_zxbzs_user,pjd_id,pd_inoutno,combined,pd_pocode)");
  1354. sql.Append("values ('',:pd_pdno,:pd_custprodcode,:pd_whcode,:pd_prodcode,:CollectedNum,:UnCollectedNum,:pd_outqty,:pr_unit,:pr_spec,:pd_brand,:pjd_zxbzs_user,:pjd_id,:pd_inoutno,'" + combined + "',:pd_pocode)");
  1355. dh.SaveDataTable((GridPrcode.DataSource as DataTable), "CS$InoutPrcode", "pd_piid", sql.ToString());
  1356. }
  1357. else
  1358. {
  1359. CollectNum = float.Parse(CSPrcode.Compute("sum(CollectedNum)", "1=1").ToString());
  1360. OutNum = float.Parse(CSPrcode.Compute("sum(pd_outqty)", "1=1").ToString());
  1361. }
  1362. ProcessCount.Text = CollectNum + "/" + OutNum;
  1363. if (GridPrcode.Rows.Count > 0)
  1364. {
  1365. CurrentPrCode = GridPrcode.Rows[0].Cells["pd_prodcode"].Value.ToString();
  1366. CurrentZXBZ = GridPrcode.Rows[0].Cells["pjd_zxbzs_user"].Value.ToString();
  1367. CurrentUnit = GridPrcode.Rows[0].Cells["pr_unit"].Value.ToString();
  1368. CurrentPDNO = GridPrcode.Rows[0].Cells["pd_pdno"].Value.ToString();
  1369. CurrentPrCount = GridPrcode.Rows[0].Cells["pd_outqty"].Value.ToString();
  1370. CurrentBrand = GridPrcode.Rows[0].Cells["pd_brand"].Value.ToString();
  1371. GridPrcode.Rows[0].Selected = true;
  1372. }
  1373. }
  1374. private void OutBoxNum_Click(object sender, EventArgs e)
  1375. {
  1376. string OutBox = OutBoxNum.Text;
  1377. OutBoxNum.Items.Clear();
  1378. DataTable dt = (DataTable)dh.ExecuteSql("select distinct pib_outboxcode2 from prodiobarcode where pib_inoutno='" + pi_inoutno.Text + "' order by to_number(pib_outboxcode2) desc", "select");
  1379. ItemObject io = new ItemObject("新增", "新增");
  1380. OutBoxNum.Items.Add(io);
  1381. io = new ItemObject("全部", "全部");
  1382. OutBoxNum.Items.Add(io);
  1383. for (int i = 0; i < dt.Rows.Count; i++)
  1384. {
  1385. string pib_outboxcode2 = dt.Rows[i]["pib_outboxcode2"].ToString();
  1386. io = new ItemObject(pib_outboxcode2, pib_outboxcode2);
  1387. OutBoxNum.Items.Add(io);
  1388. }
  1389. if (OutBoxNum.Text == "新增" || OutBoxNum.Text == "")
  1390. {
  1391. if (dt.Rows.Count > 0)
  1392. OutBoxNum.SelectedIndex = 2;
  1393. else
  1394. OutBoxNum.SelectedIndex = 0;
  1395. }
  1396. if (OutBox != "新增" && OutBox != "")
  1397. OutBoxNum.Text = OutBox;
  1398. }
  1399. /// <summary>
  1400. /// 获取条码规则
  1401. /// </summary>
  1402. /// <param name="Type"></param>
  1403. /// <param name="Prefix"></param>
  1404. /// <param name="Suffix"></param>
  1405. /// <param name="MaxNum"></param>
  1406. /// <param name="SerialNumLength"></param>
  1407. /// <param name="Radix"></param>
  1408. private void GetBarCodeRule(out string Prefix, out string Suffix, out int MaxNum, out int SerialNumLength, out int Radix)
  1409. {
  1410. //获取编码规则
  1411. Prefix = "";
  1412. Suffix = "";
  1413. MaxNum = 0;
  1414. SerialNumLength = 0;
  1415. Radix = 0;
  1416. DataTable Nr = (DataTable)dh.ExecuteSql("select nrd_detno,nrd_name,nrd_type,nrd_radix,nrd_sql,nrd_length from NoRuleDetail left join norule on nrd_nrid=nr_id where nr_custcode='" + pi_cardcode.Text + "' order by nrd_detno", "select");
  1417. //如果没有则取公共规则
  1418. if (Nr.Rows.Count == 0)
  1419. Nr = (DataTable)dh.ExecuteSql("select nrd_detno,nrd_name,nrd_radix,nrd_type,nrd_sql,nrd_length from NoRuleDetail left join norule on nrd_nrid=nr_id where nr_custcode is null and nr_isdefault <> 0 order by nrd_detno", "select");
  1420. //用于过滤参数的正则表达式
  1421. Regex match = new Regex("{\\w+}");
  1422. //用于存放每一项的明细的数据
  1423. string[] NrData = new string[Nr.Rows.Count];
  1424. //流水长度
  1425. Dictionary<int, string> NrDic = new Dictionary<int, string>();
  1426. Prefix = "";
  1427. for (int m = 0; m < Nr.Rows.Count; m++)
  1428. {
  1429. switch (Nr.Rows[m]["nrd_type"].ToString())
  1430. {
  1431. //常量直接进行拼接
  1432. case "常量":
  1433. Prefix += Nr.Rows[m]["nrd_sql"].ToString();
  1434. Suffix += Nr.Rows[m]["nrd_sql"].ToString();
  1435. break;
  1436. case "SQL":
  1437. string SQL = Nr.Rows[m]["nrd_sql"].ToString();
  1438. DataTable Temp;
  1439. //如果不包含参数替换
  1440. if (SQL.IndexOf("{") == 0)
  1441. {
  1442. Temp = (DataTable)dh.ExecuteSql(SQL, "select");
  1443. }
  1444. else
  1445. {
  1446. SQL = SQL.Replace("{pd_pdno}", CurrentPDNO);
  1447. //替换参数后重新执行SQL
  1448. foreach (Match mch in match.Matches(SQL))
  1449. {
  1450. SQL = SQL.Replace(mch.Value.Trim(), "'" + pi_inoutno.Text + "'");
  1451. }
  1452. Temp = (DataTable)dh.ExecuteSql(SQL, "select");
  1453. }
  1454. if (Temp.Rows.Count > 0)
  1455. {
  1456. Prefix += Temp.Rows[0][0].ToString();
  1457. Suffix += Temp.Rows[0][0].ToString();
  1458. }
  1459. break;
  1460. //流水需要通过MaxNumber去取
  1461. case "流水":
  1462. string maxnum = dh.getFieldDataByCondition("RuleMaxNum", "rmn_maxnumber", "rmn_nrcode='" + (pi_cardcode.Text == "" ? "Default" : pi_cardcode.Text) + "' and rmn_prefix='" + Prefix + "'").ToString();
  1463. //设置当前流水
  1464. if (maxnum == "")
  1465. {
  1466. dh.ExecuteSql("insert into RuleMaxNum(rmn_id,rmn_nrcode,rmn_prefix,rmn_maxnumber) values(RuleMaxNum_seq.nextval,'" + (pi_cardcode.Text == "" ? "Default" : pi_cardcode.Text) + "','" + Prefix + "','1')", "insert");
  1467. MaxNum = 1;
  1468. }
  1469. else
  1470. {
  1471. MaxNum = int.Parse(maxnum);
  1472. }
  1473. SerialNumLength = int.Parse(Nr.Rows[m]["nrd_length"].ToString());
  1474. Radix = int.Parse(Nr.Rows[m]["nrd_radix"].ToString());
  1475. Suffix = "";
  1476. break;
  1477. default:
  1478. break;
  1479. }
  1480. }
  1481. }
  1482. private void GridPrcode_CellEndEdit(object sender, DataGridViewCellEventArgs e)
  1483. {
  1484. string Value = GridPrcode.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString();
  1485. string ID = GridPrcode.Rows[e.RowIndex].Cells["pjd_id"].Value.ToString();
  1486. dh.UpdateByCondition("PRODJOINVENDDETAIL", "pjd_zxbzs_user='" + Value + "'", "pjd_id='" + ID + "'");
  1487. dh.UpdateByCondition("CS$INOUTPRCODE", "pjd_zxbzs_user='" + Value + "'", "pjd_id='" + ID + "' and pd_inoutno='" + pi_inoutno.Text + "'");
  1488. //删除对应物料的明细
  1489. CurrentPrCode = GridPrcode.Rows[e.RowIndex].Cells["pd_prodcode"].Value.ToString();
  1490. CurrentZXBZ = GridPrcode.Rows[e.RowIndex].Cells["pjd_zxbzs_user"].Value.ToString();
  1491. CurrentUnit = GridPrcode.Rows[e.RowIndex].Cells["pr_unit"].Value.ToString();
  1492. CurrentPDNO = GridPrcode.Rows[e.RowIndex].Cells["pd_pdno"].Value.ToString();
  1493. CurrentPrCount = GridPrcode.Rows[e.RowIndex].Cells["pd_outqty"].Value.ToString();
  1494. CurrentBrand = GridPrcode.Rows[e.RowIndex].Cells["pd_brand"].Value.ToString();
  1495. GridPrcode.Rows[e.RowIndex].Selected = true;
  1496. if (e.RowIndex - 2 >= 0)
  1497. GridPrcode.FirstDisplayedScrollingRowIndex = e.RowIndex - 2;
  1498. else
  1499. GridPrcode.FirstDisplayedScrollingRowIndex = e.RowIndex;
  1500. LoadGridData(sender, new EventArgs());
  1501. }
  1502. private void GridPrcode_SelectionChanged(object sender, EventArgs e)
  1503. {
  1504. if (GridPrcode.SelectedRows.Count > 0)
  1505. {
  1506. DataGridViewSelectedRowCollection dsc = GridPrcode.SelectedRows;
  1507. CurrentPrCode = GridPrcode.Rows[dsc[0].Index].Cells["pd_prodcode"].Value.ToString();
  1508. CurrentZXBZ = GridPrcode.Rows[dsc[0].Index].Cells["pjd_zxbzs_user"].Value.ToString();
  1509. CurrentUnit = GridPrcode.Rows[dsc[0].Index].Cells["pr_unit"].Value.ToString();
  1510. CurrentPDNO = GridPrcode.Rows[dsc[0].Index].Cells["pd_pdno"].Value.ToString();
  1511. CurrentPrCount = GridPrcode.Rows[dsc[0].Index].Cells["pd_outqty"].Value.ToString();
  1512. CurrentBrand = GridPrcode.Rows[dsc[0].Index].Cells["pd_brand"].Value.ToString();
  1513. GridPrcode.Rows[dsc[0].Index].Selected = true;
  1514. if (dsc[0].Index - 2 >= 0)
  1515. GridPrcode.FirstDisplayedScrollingRowIndex = dsc[0].Index - 2;
  1516. else
  1517. GridPrcode.FirstDisplayedScrollingRowIndex = dsc[0].Index;
  1518. }
  1519. }
  1520. private void GridPrcode_DataError(object sender, DataGridViewDataErrorEventArgs e) { }
  1521. private void GridPrcode_CellClick(object sender, DataGridViewCellEventArgs e)
  1522. {
  1523. if (e.RowIndex >= 0)
  1524. {
  1525. GridPrcode.Rows[e.RowIndex].Selected = true;
  1526. if (e.RowIndex - 2 > 0)
  1527. GridPrcode.FirstDisplayedScrollingRowIndex = e.RowIndex - 2;
  1528. else
  1529. GridPrcode.FirstDisplayedScrollingRowIndex = e.RowIndex;
  1530. }
  1531. }
  1532. private void DCCheck_Leave(object sender, EventArgs e)
  1533. {
  1534. try
  1535. {
  1536. Properties.Settings.Default.DCCheck = int.Parse(DCCheck.Text);
  1537. Properties.Settings.Default.Save();
  1538. }
  1539. catch (Exception)
  1540. {
  1541. MessageBox.Show("DC校验时间必须是整数");
  1542. }
  1543. }
  1544. /// <summary>
  1545. /// 校验DateCode
  1546. /// </summary>
  1547. /// <param name="DateCode"></param>
  1548. private bool CheckDateCode(string DateCode)
  1549. {
  1550. try
  1551. {
  1552. //根据DateCode计算的日期
  1553. string Year = DateCode.Substring(0, 2);
  1554. System.DateTime dt = new System.DateTime(int.Parse("20" + Year), 01, 01);
  1555. string Week = DateCode.Substring(2, 2);
  1556. System.DateTime dt1 = dt.AddDays(int.Parse(Week) * 7);
  1557. //减去DC校验后的日期
  1558. System.DateTime now = System.DateTime.Now;
  1559. System.DateTime now1 = now.AddDays(-int.Parse(DCCheck.Text));
  1560. //物料的DateCode大于限制日期即可
  1561. if (dt1 > now1)
  1562. {
  1563. return true;
  1564. }
  1565. return false;
  1566. }
  1567. catch (Exception)
  1568. {
  1569. return false;
  1570. }
  1571. }
  1572. private void PrintFooter_Click(object sender, EventArgs e)
  1573. {
  1574. FootReport.Load(@"\\10.2.10.238\PRINTE\FASTREPORT\唛头.frx");
  1575. DataTable dt = (DataTable)dh.ExecuteSql("select pib_outboxcode2,max(pib_id) pib_id from prodiobarcode where pib_inoutno='" + pi_inoutno.Text + "' group by pib_outboxcode2 order by to_number(pib_outboxcode2)", "select");
  1576. string SQL = "select pib_outboxcode2||'/'||(select max(to_number(pib_outboxcode2)) from prodiobarcode where pib_inoutno='" + pi_inoutno.Text + "') from prodiobarcode where pib_id=";
  1577. for (int i = 0; i < dt.Rows.Count; i++)
  1578. {
  1579. DataTable dt1 = (DataTable)dh.ExecuteSql(SQL + dt.Rows[i]["pib_id"].ToString(), "select");
  1580. FootReport.SetParameterValue("唛头", dt1.Rows[0][0].ToString());
  1581. FootReport.PrintSettings.ShowDialog = false;
  1582. FootReport.PrintSettings.Printer = SingleLabelPrinter.Text;
  1583. FootReport.Print();
  1584. }
  1585. LogManager.DoCommandLog(pi_inoutno.Text, User.UserCode, "打印唛头", "成功");
  1586. }
  1587. private void Input_KeyUp(object sender, KeyEventArgs e)
  1588. {
  1589. if (e.KeyCode == Keys.Enter)
  1590. {
  1591. Input.SelectAll();
  1592. }
  1593. }
  1594. private void GridPrcode_CellPainting(object sender, DataGridViewCellPaintingEventArgs e)
  1595. {
  1596. bool mouseOver = e.CellBounds.Contains(this.PointToClient(Cursor.Position));
  1597. if (e.ColumnIndex > 0 && e.RowIndex >= 0)
  1598. {
  1599. if (GridPrcode.Columns[e.ColumnIndex].Name == "CollectedNum")
  1600. {
  1601. SolidBrush solidBrush = new SolidBrush(Color.FromArgb(51, 153, 255));
  1602. if (GridPrcode.Rows[e.RowIndex].Cells["CollectedNum"].Value.ToString() != GridPrcode.Rows[e.RowIndex].Cells["pd_outqty"].Value.ToString())
  1603. e.Graphics.FillRectangle(mouseOver ? solidBrush : Brushes.Yellow, e.CellBounds);
  1604. else
  1605. e.Graphics.FillRectangle(mouseOver ? solidBrush : Brushes.White, e.CellBounds);
  1606. Rectangle border = e.CellBounds;
  1607. border.Width -= 1;
  1608. e.Graphics.DrawRectangle(Pens.White, border);
  1609. e.PaintContent(e.CellBounds);
  1610. e.Handled = true;
  1611. }
  1612. }
  1613. }
  1614. private void GridPrcode_CellMouseUp(object sender, DataGridViewCellMouseEventArgs e)
  1615. {
  1616. if (e.Button == MouseButtons.Right)
  1617. {
  1618. if (e.RowIndex >= 0 && e.ColumnIndex > 0)
  1619. {
  1620. string Conetent = GridPrcode.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString();
  1621. Clipboard.SetText(Conetent);
  1622. MessageBox.Show("已复制内容" + Conetent);
  1623. }
  1624. }
  1625. }
  1626. private void Pack_Click(object sender, EventArgs e)
  1627. {
  1628. if (LabelInf.Rows.Count > 0)
  1629. {
  1630. GetBarCodeRule(out Prefix, out Suffix, out MaxNum, out NumLength, out Radix);
  1631. List<string> OutBoxCode = new List<string>();
  1632. List<string> PIBID = new List<string>();
  1633. for (int i = 0; i < LabelInf.Rows.Count; i++)
  1634. {
  1635. if (LabelInf.Rows[i].Cells["pib_custoutboxcode"].Value.ToString() == "")
  1636. {
  1637. PIBID.Add(LabelInf.Rows[i].Cells["pib_id1"].Value.ToString());
  1638. string serialcode = BaseUtil.DToAny(MaxNum, Radix);
  1639. for (int k = serialcode.ToString().Length; k < NumLength; k++)
  1640. {
  1641. serialcode = "0" + serialcode;
  1642. }
  1643. if (i + 1 < LabelInf.Rows.Count)
  1644. {
  1645. string FPrcode = LabelInf.Rows[i].Cells["pib_prodcode"].Value.ToString();
  1646. string FPocode = LabelInf.Rows[i].Cells["pd_pocode"].Value.ToString();
  1647. string BPrcode = LabelInf.Rows[i + 1].Cells["pib_prodcode"].Value.ToString();
  1648. string BPocode = LabelInf.Rows[i + 1].Cells["pd_pocode"].Value.ToString();
  1649. if (FPrcode != BPrcode || FPocode != BPocode)
  1650. {
  1651. MaxNum = MaxNum + 1;
  1652. }
  1653. }
  1654. OutBoxCode.Add(Prefix + serialcode + Suffix);
  1655. }
  1656. }
  1657. dh.BatchInsert("update prodiobarcode set pib_custoutboxcode=:pib_custoutboxcode where pib_id=:pib_id and pib_custoutboxcode is null", new string[] { "pib_custoutboxcode", "pib_outboxcode2" }, OutBoxCode.ToArray(), PIBID.ToArray());
  1658. MaxNum = MaxNum + 1;
  1659. dh.UpdateByCondition("RULEMAXNUM", "rmn_maxnumber='" + MaxNum + "'", "rmn_nrcode='" + (pi_cardcode.Text == "" ? "Default" : pi_cardcode.Text) + "' and rmn_prefix='" + Prefix + "'");
  1660. LoadGridData(sender, e);
  1661. }
  1662. }
  1663. private void PackMidBox_Click(object sender, EventArgs e)
  1664. {
  1665. DataTable dt = (DataTable)dh.ExecuteSql("select distinct pib_outboxcode2 from prodiobarcode where pib_inoutno='" + pi_inoutno.Text + "' order by pib_outboxcode2", "select");
  1666. GetBarCodeRule(out Prefix, out Suffix, out MaxNum, out NumLength, out Radix);
  1667. if (Radix > 0)
  1668. {
  1669. //生成中盒条码
  1670. int pib_outboxcode1 = int.Parse(dh.getFieldDataByCondition("prodiobarcode", "max(to_number(nvl(pib_outboxcode1,0)))", "pib_inoutno='" + pi_inoutno.Text + "'").ToString());
  1671. MaxNum = MaxNum - 1;
  1672. for (int i = 0; i < dt.Rows.Count; i++)
  1673. {
  1674. List<string> MidBoxCode = new List<string>();
  1675. List<string> PIBID = new List<string>();
  1676. List<string> PIBOUTBOXCODE1 = new List<string>();
  1677. DataTable dt1 = (DataTable)dh.ExecuteSql("select pib_id,pib_prodcode,pd_custprodcode from prodiobarcode left join prodiodetail on pib_pdid=pd_id where pib_inoutno='" + pi_inoutno.Text + "' and pib_outboxcode2='" + dt.Rows[i]["pib_outboxcode2"].ToString() + "' and pib_outboxcode1 is null order by to_number(pib_id)", "select");
  1678. //如果不是10的整数倍则为尾盒
  1679. int tencount = 0;
  1680. for (int j = 0; j < dt1.Rows.Count; j++)
  1681. {
  1682. if (tencount % MidboxCapacity.Value == 0 || (dt1.Rows[j]["pib_prodcode"].ToString() != dt1.Rows[j - 1]["pib_prodcode"].ToString()) || (dt1.Rows[j]["pd_custprodcode"].ToString() != dt1.Rows[j - 1]["pd_custprodcode"].ToString()))
  1683. {
  1684. pib_outboxcode1 = pib_outboxcode1 + 1;
  1685. MaxNum = MaxNum + 1;
  1686. tencount = 0;
  1687. }
  1688. tencount = tencount + 1;
  1689. string serialcode = BaseUtil.DToAny(MaxNum, Radix);
  1690. for (int k = serialcode.ToString().Length; k < NumLength; k++)
  1691. {
  1692. serialcode = "0" + serialcode;
  1693. }
  1694. MidBoxCode.Add(Prefix + serialcode + Suffix);
  1695. PIBID.Add(dt1.Rows[j]["pib_id"].ToString());
  1696. PIBOUTBOXCODE1.Add(pib_outboxcode1.ToString());
  1697. }
  1698. dh.BatchInsert("update prodiobarcode set pib_custmidboxcode=:pib_custmidboxcode,pib_outboxcode1=:pib_outboxcode1 where pib_id=:pib_id and pib_custmidboxcode is null", new string[] { "pib_custmidboxcode", "pib_outboxcode1", "pib_id" }, MidBoxCode.ToArray(), PIBOUTBOXCODE1.ToArray(), PIBID.ToArray());
  1699. }
  1700. MaxNum = MaxNum + 1;
  1701. dh.UpdateByCondition("RULEMAXNUM", "rmn_maxnumber='" + MaxNum + "'", "rmn_nrcode='" + (pi_cardcode.Text == "" ? "Default" : pi_cardcode.Text) + "' and rmn_prefix='" + Prefix + "'");
  1702. }
  1703. LoadGridData(sender, e);
  1704. }
  1705. private void PrintStatus_Click(object sender, EventArgs e)
  1706. {
  1707. EnablePrint = !EnablePrint;
  1708. if (EnablePrint)
  1709. {
  1710. SetPrintStatus_label.ForeColor = Color.Green;
  1711. SetPrintStatus_label.Text = "可打印";
  1712. }
  1713. else
  1714. {
  1715. SetPrintStatus_label.ForeColor = Color.Red;
  1716. SetPrintStatus_label.Text = "暂停打印";
  1717. }
  1718. Input.Focus();
  1719. }
  1720. private void CustomerLabel_Click(object sender, EventArgs e)
  1721. {
  1722. sql.Clear();
  1723. sql.Append("update prodiobarcode set pib_custbarcode=case when instr(pib_custbarcode,'SL')=0 ");
  1724. sql.Append("then ('SL'||pib_custbarcode)else pib_custbarcode end, pib_custoutboxcode=case when instr");
  1725. sql.Append("(pib_custoutboxcode,'SC')=0 then ('SC'||pib_custoutboxcode)else pib_custoutboxcode end where pib_inoutno='" + pi_inoutno.Text + "'");
  1726. dh.ExecuteSql(sql.ToString(), "select");
  1727. LoadGridData(sender, e);
  1728. CustomerLabel.Enabled = false;
  1729. }
  1730. private void Combindetail_CheckedChanged(object sender, EventArgs e)
  1731. {
  1732. if (Combindetail.Checked)
  1733. {
  1734. CombindetailTwo.Checked = false;
  1735. }
  1736. if (LoadCheck)
  1737. LoadPrcodeData();
  1738. }
  1739. private void CombindetailTwo_CheckedChanged(object sender, EventArgs e)
  1740. {
  1741. if (CombindetailTwo.Checked)
  1742. {
  1743. Combindetail.Checked = false;
  1744. }
  1745. if (LoadCheck)
  1746. LoadPrcodeData();
  1747. }
  1748. string SelectProdcode = "";
  1749. int SelectRowIndex = -1;
  1750. private void LabelInf_CellClick(object sender, DataGridViewCellEventArgs e)
  1751. {
  1752. if (e.RowIndex >= 0)
  1753. {
  1754. LabelInf.Rows[e.RowIndex].Selected = true;
  1755. SelectRowIndex = e.RowIndex;
  1756. }
  1757. }
  1758. private void OutBoxNum_SelectedIndexChanged(object sender, EventArgs e)
  1759. {
  1760. OutBoxNum1 = OutBoxNum.Text;
  1761. LoadGridData(sender, e);
  1762. }
  1763. private void LabelInf_SelectionChanged(object sender, EventArgs e)
  1764. {
  1765. DataGridViewSelectedRowCollection dsc = LabelInf.SelectedRows;
  1766. if (dsc.Count > 0)
  1767. {
  1768. SelectRowIndex = dsc[0].Index;
  1769. }
  1770. }
  1771. string OutBoxNum1 = "";
  1772. private void OutBoxNum_SelectionChangeCommitted(object sender, EventArgs e)
  1773. {
  1774. if (OutBoxNum1 != "全部" && OutBoxNum1 != "新增")
  1775. if (dh.getFieldDataByCondition("prodiobarcode", "pib_outifprint", "pib_inoutno='" + pi_inoutno.Text + "' and pib_outboxcode2='" + OutBoxNum1 + "'").ToString() != "-1")
  1776. {
  1777. MessageBox.Show("外箱号" + OutBoxNum1 + "尚未打印标签");
  1778. }
  1779. OutBoxNum1 = OutBoxNum.Text;
  1780. }
  1781. private void Reset_Click(object sender, EventArgs e)
  1782. {
  1783. string close = MessageBox.Show(this.ParentForm, "清除当前已采集数据,刷新待采集数据", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question).ToString();
  1784. if (close.ToString() == "Yes")
  1785. {
  1786. dh.ExecuteSql("delete from prodiobarcode where pib_inoutno='" + pi_inoutno.Text + "'", "delete");
  1787. dh.ExecuteSql("delete from CS$InoutPrcode where pd_inoutno='" + pi_inoutno.Text + "'", "delete");
  1788. pi_inoutno_KeyDown(sender, new KeyEventArgs(Keys.Enter));
  1789. }
  1790. }
  1791. private void AddNewOutBox_Click(object sender, EventArgs e)
  1792. {
  1793. OutBoxNum.Text = "新增";
  1794. }
  1795. }
  1796. }