12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167 |
- using System;
- using System.Data;
- using System.Drawing;
- using System.Windows.Forms;
- using System.Text.RegularExpressions;
- using System.Text;
- using System.Collections.Generic;
- using System.Diagnostics;
- using UAS_LabelMachine.PublicMethod;
- using UAS_LabelMachine.Entity;
- using UAS_LabelMachine.PublicForm;
- using System.Threading;
- using FastReport;
- using System.Linq;
- using System.Reflection;
- using UAS_LabelMachine.CustomControl;
- using System.Net.Sockets;
- namespace UAS_LabelMachine
- {
- public partial class UAS_出货标签打印 : Form
- {
- bool ConnectToMachine = false;
-
- AutoSizeFormClass asc = new AutoSizeFormClass();
- DataHelper dh;
- DataTable dt;
- StringBuilder sql = new StringBuilder();
-
-
-
- Report SingleReport = new Report();
-
-
-
- Report MidReport = new Report();
-
-
-
- Report OutReport = new Report();
-
-
-
- Report FootReport = new Report();
-
-
-
- SetLoadingWindow stw;
-
-
-
- Thread thread;
-
-
-
- string PI_ID;
- bool logout = false;
-
- DataTable LabelInfDataTable;
-
-
-
- List<string> SingleID = new List<string>();
-
-
-
- bool AllChecked = false;
- DataTable SumQty;
-
-
-
- bool ComBoxClickChangeLabelDoc = false;
-
- string CurrentPrCode = "";
-
- string CurrentZXBZ = "";
-
- string CurrentUnit = "";
-
- string CurrentPrCount = "";
-
- string CurrentPDNO = "";
-
- string CurrentBrand = "";
- string NrCode = "";
- string Prefix = "";
- string Suffix = "";
- int MaxNum = 0;
- int NumLength = 0;
- int Radix = 0;
- private bool EnablePrint = true;
- string[] PIBID;
- DataTable Attach;
-
- string Angle = "";
- string X = "";
- string Y = "";
-
- int MachineCollectRowIndex = 0;
- public UAS_出货标签打印(string Master)
- {
- this.SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.ResizeRedraw | ControlStyles.AllPaintingInWmPaint, true);
- this.UpdateStyles();
- InitializeComponent();
-
- Type dgvType = this.LabelInf.GetType();
- PropertyInfo pi = dgvType.GetProperty("DoubleBuffered", BindingFlags.Instance | BindingFlags.NonPublic);
- pi.SetValue(this.LabelInf, true, null);
- pi.SetValue(this.GridPrcode, true, null);
- (new EnvironmentSettings()).ReportSettings.ShowProgress = false;
- Text = Text + "-" + Master;
- }
-
-
-
-
-
-
-
-
- delegate void BindDataSource(DataGridView dgv, DataTable dt);
- void bindingsource(DataGridView dgv, DataTable dt)
- {
- if (dgv.InvokeRequired)
- {
- dgv.Invoke(new BindDataSource(bindingsource), new object[] { dgv, dt });
- }
- else
- {
- dgv.AutoGenerateColumns = false;
- dgv.DataSource = dt;
- }
- }
- private void 贴标机条码打印_Load(object sender, EventArgs e)
- {
-
- LogManager.DoLog("程序启动,登陆人员【" + User.UserName + "】");
- dh = SystemInf.dh;
- CheckForIllegalCrossThreadCalls = false;
- pi_inoutno.Focus();
- Point pt = new Point();
-
- foreach (DataGridViewColumn dgv in LabelInf.Columns)
- {
- dgv.SortMode = DataGridViewColumnSortMode.NotSortable;
- }
- foreach (DataGridViewColumn dgv in GridPrcode.Columns)
- {
- dgv.SortMode = DataGridViewColumnSortMode.NotSortable;
- }
- int ScreenWidth = Screen.GetWorkingArea(pt).Width;
-
- Rectangle ScreenArea = Screen.GetWorkingArea(this);
- Top = 0;
- Left = 0;
- Width = ScreenArea.Width;
- Height = ScreenArea.Height;
-
- MidboxCapacity.Value = Properties.Settings.Default.MidBoxCapacity;
- if (MidboxCapacity.Value == 0)
- {
- MidboxCapacity.Value = 10;
- }
- DCCheck.Text = Properties.Settings.Default.DCCheck.ToString();
- OutBoxPrinter.Text = Properties.Settings.Default.OPrinter;
- MidLabelPrinter.Text = Properties.Settings.Default.MPrinter;
- SingleLabelPrinter.Text = Properties.Settings.Default.SPrinter;
- asc.controllInitializeSize(this);
- asc.controlAutoSize(this);
- RefreshDBConnect.Interval = 60000;
- RefreshDBConnect.Start();
- }
-
- bool AutoSized = false;
- private void 贴标机条码打印_SizeChanged(object sender, EventArgs e)
- {
- if (!AutoSized)
- {
- asc.controlAutoSize(this);
- AutoSized = true;
- }
- }
- private void LabelMaintain_Click(object sender, EventArgs e)
- {
- 客户标签维护 form = new 客户标签维护();
- BaseUtil.SetFormCenter(form);
- form.FormClosed += LabelFormClose;
- form.ShowDialog();
- }
- int combined = 0;
- private void LabelFormClose(object sender, EventArgs e)
- {
- GetInOutInfAndLabelFile();
- }
- int PassTenCount = 1;
- int PassSixTenCount = 1;
-
- private void Input_KeyDown(object sender, KeyEventArgs e)
- {
- if (e.KeyCode == Keys.Enter)
- {
- if (Input.Text == "")
- {
- richTextAutoBottom1.AppendText("采集的数据不能为空\n");
- receiveClient.Client.Send(Encoding.ASCII.GetBytes("ReadId1|,|NG|,|" + (SingleLabelAutoPrint.Checked ? "Y" : "N")));
- return;
- }
- CollectInputData();
- }
- }
-
-
-
- private void CollectInputData()
- {
- if (Input.Text == "SC")
- {
- PrintStatus.PerformClick();
- Input.Text = "";
- return;
- }
- Input.Text = Input.Text.Replace("\n", "").Replace(" ", "").Replace("\t", "").Replace("\r", "");
- Dictionary<string, string> Data = new Dictionary<string, string>();
- string[] SplitData = Input.Text.Split('*');
- if (SplitData.Length < 5)
- {
- richTextAutoBottom1.AppendText("数据格式错误,无法解析\n");
- if (ConnectToMachine)
- {
- receiveClient.Client.Send(Encoding.ASCII.GetBytes("ReadId1|,|NG|,|" + (SingleLabelAutoPrint.Checked ? "Y" : "N")));
- }
-
- return;
- }
- for (int i = 0; i < SplitData.Length; i++)
- {
- switch (i.ToString())
- {
- case "0":
- Data.Add("PRCODE", SplitData[i]);
- break;
- case "1":
- Data.Add("QTY", SplitData[i]);
- break;
- case "2":
- Data.Add("DATECODE", SplitData[i]);
- break;
- case "3":
- Data.Add("BRAND", SplitData[i]);
- break;
- case "4":
- Data.Add("LOTNO", SplitData[i]);
- break;
- case "5":
- Data.Add("PO", SplitData[i]);
- break;
- case "6":
- Data.Add("SERIAL", SplitData[i]);
- break;
- default:
- break;
- }
- }
- if (Data["PRCODE"] != CurrentPrCode)
- {
- if (!MixPrCode.Checked)
- {
- richTextAutoBottom1.AppendText("当前采集【物料编号" + Data["PRCODE"] + "】不对应,请重新采集\n");
-
- if (ConnectToMachine)
- receiveClient.Client.Send(Encoding.ASCII.GetBytes(GetSendCode("ReadId1|,|NG|,|" + (SingleLabelAutoPrint.Checked ? "Y" : "N"))));
- return;
- }
- else
- {
- bool FindProd = false;
- for (int i = 0; i < GridPrcode.Rows.Count; i++)
- {
- string prodcode = GridPrcode.Rows[i].Cells["pd_prodcode"].Value.ToString();
- string outqty = GridPrcode.Rows[i].Cells["pd_outqty"].Value.ToString();
- string collectnum = GridPrcode.Rows[i].Cells["collectednum"].Value.ToString();
-
- if (prodcode == Data["PRCODE"] && decimal.Parse(outqty) > decimal.Parse(collectnum))
- {
- GridPrcode.Rows[i].Selected = true;
- FindProd = true;
- }
- }
- if (!FindProd)
- {
- richTextAutoBottom1.AppendText("当前采集【物料编号" + Data["PRCODE"] + "】没有需要采集的内容\n");
-
- if (ConnectToMachine)
- receiveClient.Client.Send(Encoding.ASCII.GetBytes(GetSendCode("ReadId1|,|NG|,|" + (SingleLabelAutoPrint.Checked ? "Y" : "N"))));
- return;
- }
- }
- }
-
- if (!CheckDateCode(Data["DATECODE"]))
- {
- if (ConnectToMachine)
- {
- richTextAutoBottom1.AppendText("物料" + Data["PRCODE"] + "【DateCode】超出校验日期\n");
- receiveClient.Client.Send(Encoding.ASCII.GetBytes(GetSendCode("ReadId1|,|NG|,|" + (SingleLabelAutoPrint.Checked ? "Y" : "N"))));
- return;
- }
- else
- {
- string close = MessageBox.Show(this.ParentForm, "物料" + Data["PRCODE"] + "【DateCode】超出校验日期\n", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question).ToString();
- if (close.ToString() != "Yes")
- return;
- }
- }
- if (Data["BRAND"] != CurrentBrand)
- {
- if (ConnectToMachine)
- {
- richTextAutoBottom1.AppendText("当前采集【品牌" + Data["BRAND"] + "】不对应\n");
- receiveClient.Client.Send(Encoding.ASCII.GetBytes(GetSendCode("ReadId1|,|NG|,|" + (SingleLabelAutoPrint.Checked ? "Y" : "N"))));
- return;
- }
- else
- {
- string close = MessageBox.Show(this.ParentForm, "当前采集【品牌" + Data["BRAND"] + "】不对应", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question).ToString();
- if (close.ToString() != "Yes")
- return;
- }
- }
- int CodeCount = 0;
-
- double CollectNum = 0;
- if (CurrentUnit == "KPCS")
- {
- try
- {
- double.Parse(CurrentZXBZ);
- }
- catch (Exception)
- {
- MessageBox.Show("请检查最小包装数");
- }
-
- if (decimal.Parse((Convert.ToDouble((double.Parse(Data["QTY"]) / 1000).ToString("0.000")) / Convert.ToDouble(double.Parse(CurrentZXBZ).ToString("0.000"))).ToString()) % 1 != 0)
- {
- richTextAutoBottom1.AppendText("物料" + Data["PRCODE"] + "采集数量无法按照最小包装数拆分\n");
-
- if (ConnectToMachine)
- receiveClient.Client.Send(Encoding.ASCII.GetBytes(GetSendCode("ReadId1|,|NG|,|" + (SingleLabelAutoPrint.Checked ? "Y" : "N"))));
- return;
- }
- CodeCount = int.Parse((double.Parse(Data["QTY"]) / 1000 / double.Parse(CurrentZXBZ)).ToString());
- CollectNum = double.Parse(Data["QTY"]) / 1000;
- }
- else
- {
- if (double.Parse(Data["QTY"]) % double.Parse(CurrentZXBZ) != 0)
- {
- richTextAutoBottom1.AppendText("采集【数量】无法按照最小包装数拆分\n");
- if (ConnectToMachine)
- receiveClient.Client.Send(Encoding.ASCII.GetBytes(GetSendCode("ReadId1|,|NG|,|" + (SingleLabelAutoPrint.Checked ? "Y" : "N"))));
-
- return;
- }
- CodeCount = int.Parse((double.Parse(Data["QTY"]) / double.Parse(CurrentZXBZ)).ToString());
- CollectNum = double.Parse(Data["QTY"]);
- }
- string pib_barcode = Data.ContainsKey("SERIAL") ? Data["SERIAL"] : "";
-
- PIBID = dh.GetSEQ("prodiobarcode_seq", CodeCount);
-
- string pib_outboxcode2 = "";
- int BoxNum = LabelInfDataTable.Select("pib_outboxcode2='" + OutBoxNum.Text + "'").Length;
- if (ConnectToMachine)
- {
- if (BoxNum + CodeCount > OutboxCapacity.Value && AutoSetOutBox.Checked)
- {
- string maxoutbox = dh.getFieldDataByCondition("prodiobarcode", "max(to_number(pib_outboxcode2))", "pib_inoutno='" + pi_inoutno.Text + "'").ToString();
-
- if (maxoutbox == "")
- {
- pib_outboxcode2 = "1";
- }
- else
- {
- pib_outboxcode2 = (int.Parse(maxoutbox) + 1).ToString();
- }
- OutBoxNum.Items.Clear();
- 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");
- ItemObject io = new ItemObject("新增", "新增");
- OutBoxNum.Items.Add(io);
- io = new ItemObject("全部", "全部");
- OutBoxNum.Items.Add(io);
- io = new ItemObject(pib_outboxcode2, pib_outboxcode2);
- PassSixTenCount = 1;
- OutBoxNum.Items.Add(io);
- for (int i = 0; i < dt.Rows.Count; i++)
- {
- string piboutboxcode2 = dt.Rows[i]["pib_outboxcode2"].ToString();
- io = new ItemObject(piboutboxcode2, piboutboxcode2);
- OutBoxNum.Items.Add(io);
- }
- if (OutBoxNum.Items.Count > 2)
- OutBoxNum.SelectedIndex = 2;
- BoxNum = LabelInfDataTable.Select("pib_outboxcode2='" + OutBoxNum.Text + "'").Length;
- }
- else
- {
- if (OutBoxNum.Text == "新增")
- {
- string maxoutbox = dh.getFieldDataByCondition("prodiobarcode", "max(to_number(pib_outboxcode2))", "pib_inoutno='" + pi_inoutno.Text + "'").ToString();
-
- if (maxoutbox == "")
- {
- pib_outboxcode2 = "1";
- }
- else
- {
- pib_outboxcode2 = (int.Parse(maxoutbox) + 1).ToString();
- }
- OutBoxNum.Items.Clear();
- PassSixTenCount = 1;
- 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");
- ItemObject io = new ItemObject("新增", "新增");
- OutBoxNum.Items.Add(io);
- io = new ItemObject("全部", "全部");
- OutBoxNum.Items.Add(io);
- io = new ItemObject(pib_outboxcode2, pib_outboxcode2);
- OutBoxNum.Items.Add(io);
- for (int i = 0; i < dt.Rows.Count; i++)
- {
- string piboutboxcode2 = dt.Rows[i]["pib_outboxcode2"].ToString();
- io = new ItemObject(piboutboxcode2, piboutboxcode2);
- OutBoxNum.Items.Add(io);
- }
- if (OutBoxNum.Items.Count > 2)
- OutBoxNum.SelectedIndex = 2;
- BoxNum = LabelInfDataTable.Select("pib_outboxcode2='" + OutBoxNum.Text + "'").Length;
- }
- else
- {
- pib_outboxcode2 = OutBoxNum.Text;
- }
- }
- }
- else
- {
- if (OutBoxNum.Text == "新增")
- {
- string maxoutbox = dh.getFieldDataByCondition("prodiobarcode", "max(to_number(pib_outboxcode2))", "pib_inoutno='" + pi_inoutno.Text + "'").ToString();
-
- if (maxoutbox == "")
- {
- pib_outboxcode2 = "1";
- }
- else
- {
- pib_outboxcode2 = (int.Parse(maxoutbox) + 1).ToString();
- }
- }
- else
- {
- pib_outboxcode2 = OutBoxNum.Text;
- }
- if (!AutoPrintOutBox.Checked)
- {
- if (BoxNum + CodeCount > OutboxCapacity.Value)
- {
- string close = MessageBox.Show(this.ParentForm, "箱号【" + OutBoxNum.Text + "】后超数量为" + (BoxNum + CodeCount) + ",超出容量" + OutboxCapacity.Value + ",是否继续?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question).ToString();
- if (close != "Yes")
- {
- Input.SelectAll();
- return;
- }
- }
- }
- }
- if (OutBoxNum.Text == "全部")
- {
- MessageBox.Show("请选择指定箱号或者新增");
- return;
- }
-
- string collectqty = dh.getFieldDataByCondition("prodiobarcode", "sum(pib_qty)", "pib_inoutno='" + pi_inoutno.Text + "' and pib_prodcode='" + CurrentPrCode + "' and pib_pdno='" + CurrentPDNO + "'").ToString();
- double CollectQty = (collectqty == "" ? 0 : double.Parse(collectqty));
- if (Convert.ToDouble((CollectQty + CollectNum).ToString("0.000")) > Convert.ToDouble(double.Parse(CurrentPrCount).ToString("0.000")))
- {
- richTextAutoBottom1.AppendText("物料" + Data["PRCODE"] + "采集后数量为" + (CollectQty + CollectNum) + ",【超出】本行出货数量" + CurrentPrCount + "\n");
- if (ConnectToMachine)
- receiveClient.Client.Send(Encoding.ASCII.GetBytes(GetSendCode("ReadId1|,|NG|,|" + (SingleLabelAutoPrint.Checked ? "Y" : "N"))));
-
- return;
- }
- GetBarCodeRule(out Prefix, out Suffix, out MaxNum, out NumLength, out Radix, CodeCount);
- List<string> CustBarCode = new List<string>();
- if (!(Radix > 0))
- {
- string close = MessageBox.Show(this.ParentForm, "未维护条码规则,是否继续生成", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question).ToString();
- if (close.ToString() != "Yes")
- return;
- }
- for (int i = 0; i < CodeCount; i++)
- {
- if (Radix > 0)
- {
- string serialcode = BaseUtil.DToAny(MaxNum, Radix);
- for (int j = serialcode.ToString().Length; j < NumLength; j++)
- {
- serialcode = "0" + serialcode;
- }
- CustBarCode.Add(Prefix + serialcode + Suffix);
- MaxNum = MaxNum + 1;
- }
- else
- {
- CustBarCode.Add("");
- }
- }
- sql.Clear();
- sql.Append("insert into prodiobarcode(PIB_ID,PIB_PRODCODE,PIB_INDATE,PIB_INOUTNO,PIB_PIID,PIB_PDNO, PIB_PDID,PIB_PICLASS,");
- 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,pib_ismachine) ");
- sql.Append("select :PIB_ID,pd_prodcode,sysdate,pi_inoutno,pi_id,pd_pdno,pd_id,pi_class,");
- 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 + "','" + (ConnectToMachine ? "Y" : "N") + "' ");
- 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 + "'");
- int rowsnum = 0;
- try
- {
- rowsnum = dh.BatchInsert(sql.ToString(), new string[] { "PIB_ID", "PIB_CUSTBARCODE" }, PIBID, CustBarCode.ToArray());
- }
- catch (Exception)
- {
- if (ReSetType != " ")
- {
- dh.UpdateByCondition("RULEMAXNUM", "rmn_maxnumber='" + (MaxNum + 1) + "'", "rmn_nrcode='" + (NrCode == "" ? "Default" : NrCode) + "' and nvl(rmn_type,' ')='" + ReSetType + "'");
- }
- else
- {
- dh.UpdateByCondition("RULEMAXNUM", "rmn_maxnumber='" + (MaxNum + 1) + "'", "rmn_nrcode='" + (NrCode == "" ? "Default" : NrCode) + "' and rmn_prefix='" + Prefix + "'");
- }
- CollectInputData();
- return;
- }
- if (rowsnum == 0)
- {
- MessageBox.Show("未成功插入数据,请核对出货单当前明细", "提示");
- }
-
- if (!ConnectToMachine)
- {
- if (OutBoxNum.Text == "新增")
- {
- OutBoxNum.Items.Clear();
- 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");
- ItemObject io = new ItemObject("新增", "新增");
- OutBoxNum.Items.Add(io);
- io = new ItemObject("全部", "全部");
- OutBoxNum.Items.Add(io);
- for (int i = 0; i < dt.Rows.Count; i++)
- {
- string piboutboxcode2 = dt.Rows[i]["pib_outboxcode2"].ToString();
- io = new ItemObject(piboutboxcode2, piboutboxcode2);
- OutBoxNum.Items.Add(io);
- }
- if (OutBoxNum.Items.Count > 2)
- OutBoxNum.SelectedIndex = 2;
- }
- }
- LoadGridData(new object(), new EventArgs());
- if (LabelInf.Rows.Count > 0)
- {
- LabelInf.Rows[LabelInf.Rows.Count - 1].Selected = true;
- }
- if (SingleLabelAutoPrint.Checked)
- {
- thread = new Thread(AutoPrintSingleLabel);
- stw = new SetLoadingWindow(thread, "正在打印单盘标签");
- BaseUtil.SetFormCenter(stw);
- stw.ShowDialog();
- if (ConnectToMachine)
- receiveClient.Client.Send(Encoding.ASCII.GetBytes(GetSendCode("ReadId1|,|OK|,|" + (SingleLabelAutoPrint.Checked ? "Y" : "N"))));
- }
- else
- {
- if (ConnectToMachine)
- receiveClient.Client.Send(Encoding.ASCII.GetBytes(GetSendCode("ReadId1|,|OK|,|N")));
- }
- if (SumQty.Columns.Count == 0)
- {
- sql.Clear();
- 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 ");
- sql.Append("where pib_inoutno='" + pi_inoutno.Text + "' group by pib_prodcode,pib_pdno order by pib_pdno ");
- SumQty = (DataTable)dh.ExecuteSql(sql.ToString(), "select");
- }
-
- collectqty = (SumQty.Compute("sum(pib_qty)", "pib_prodcode='" + CurrentPrCode + "' and pib_pdno='" + CurrentPDNO + "'").ToString());
- CollectQty = (collectqty == "" ? 0 : double.Parse(collectqty));
- if (Combindetail.Checked)
- combined = 1;
- if (CombindetailTwo.Checked)
- combined = 2;
- dh.UpdateByCondition("CS$InoutPrcode", "Collectednum='" + CollectQty + "'", "pd_inoutno='" + pi_inoutno.Text + "' and pd_pdno='" + CurrentPDNO + "' and combined=" + combined);
- CollectNum = 0;
- double OutNum = 0;
- if (GridPrcode.SelectedRows.Count > 0)
- {
- GridPrcode.Rows[GridPrcode.SelectedRows[0].Index].Cells["CollectedNum"].Value = CollectQty;
- for (int i = 0; i < GridPrcode.Rows.Count; i++)
- {
- CollectNum += float.Parse(GridPrcode.Rows[i].Cells["CollectedNum"].Value.ToString());
- OutNum += float.Parse(GridPrcode.Rows[i].Cells["pd_outqty"].Value.ToString());
- }
- }
- ProcessCount.Text = CollectNum + "/" + OutNum;
- if (CollectNum == OutNum)
- {
- dh.UpdateByCondition("prodinout", "pi_user_packingstatus='Packed'", "pi_inoutno='" + pi_inoutno.Text + "'");
- }
- if (CollectQty / double.Parse(CurrentZXBZ) % double.Parse(MidboxCapacity.Value.ToString()) == 0)
- {
- if (LabelInf.Rows.Count > 0)
- LabelInf.Rows[LabelInf.Rows.Count - 1].Selected = true;
- if (AutoPrintMidBox.Checked)
- MidLabelPrint.PerformClick();
- }
-
- if (CollectQty == double.Parse(CurrentPrCount))
- {
- if (AutoPrintMidBox.Checked && (CollectQty / double.Parse(CurrentZXBZ) % double.Parse(MidboxCapacity.Value.ToString()) != 0))
- MidLabelPrint.PerformClick();
-
- DataGridViewSelectedRowCollection selectrow = GridPrcode.SelectedRows;
- if (selectrow.Count > 0)
- {
- if (selectrow[0].Index + 1 < GridPrcode.Rows.Count)
- {
- string outqty = GridPrcode.Rows[selectrow[0].Index + 1].Cells["pd_outqty"].Value.ToString();
- string collectnum = GridPrcode.Rows[selectrow[0].Index + 1].Cells["CollectedNum"].Value.ToString();
- if (double.Parse(outqty) > double.Parse(collectnum == "" ? "0" : collectnum))
- {
- GridPrcode.Rows[selectrow[0].Index + 1].Selected = true;
- }
- }
- }
- }
- if (AutoPrintOutBox.Checked)
- {
- if (BoxNum + CodeCount >= OutboxCapacity.Value)
- {
- OutBoxLabelPrint.PerformClick();
- }
- }
- GridPrcode.Refresh();
- if (!IsSum)
- Input.Clear();
- }
- private void AutoPrintSingleLabel()
- {
- if (EnablePrint)
- {
-
- StringBuilder ParamLog = new StringBuilder();
- string pibid = "";
- for (int i = 0; i < PIBID.Length; i++)
- {
- if (i != PIBID.Length - 1)
- pibid += PIBID[i] + ",";
- else
- pibid += PIBID[i];
- }
- if (!SingleLabelCombox.SelectedValue.ToString().Contains("System.Data.DataRowView"))
- SingleReport.Load(SingleLabelCombox.SelectedValue.ToString());
- for (int j = 0; j < SingleReport.Parameters.Count; j++)
- {
- SingleReport.SetParameterValue(SingleReport.Parameters[j].Name, "");
- for (int k = 0; k < Attach.Rows.Count; k++)
- {
- if (Attach.Rows[k][0].ToString() == SingleReport.Parameters[j].Name)
- {
- SingleReport.SetParameterValue(SingleReport.Parameters[j].Name, Attach.Rows[k][1].ToString());
- }
- }
- }
- StringBuilder sql = new StringBuilder();
- sql.Clear();
- sql.Append("select * from (select to_char(pi_date,'yyiw')出库年周,to_char(sysdate,'yyiw')当前DateCode,pi_remark 单据备注,pi_date-1 出库前一天,pib_outboxcode2 外箱号,pd_orderdetno 订单序号,pib_totalweight 总重,pr_ywmc_user 英文名称,pib_boxweight 箱重,nvl(pib_totalweight,0)-nvl(pib_boxweight,0) 净重,pib_id 主键ID,pd_pdno 出货序号,pib_prodcode 物料编号,pr_detail 物料名称,to_char(pi_date,'yyyy-mm-dd') 送达日期,pd_custprodspec 客户型号,pd_custproddetail 客户物料名称,pi_title 客户全称,cu_shortname 客户简称,pr_spec 物料规格,pib_custbarcode 客户条码,pib_custmidboxcode 中盒条码,pib_custoutboxcode 外箱条码,pib_inoutno 出货单号,");
- sql.Append("PD_HBSL_USER 出库数量,PD_HBSL_USER*1000 出库数量k,pjd_orispeccode 原厂型号,pib_datecode DateCode,(week_to_date(pib_datecode))DateCode1,pd_remark 备注,pd_remark2 备注2,pd_remark3 备注3,pib_lotno LotNo,");
- sql.Append("nvl(nvl(pd_brand,pib_brand),pr_brand)品牌,pr_unit 单位, to_char(pi_date,'yyyy-mm-dd')出库日期,PIB_QTY 最小封装数量,PIB_QTY*1000 最小封装数量k,pd_pocode 客户PO,pd_custprodcode CPN客户料号,");
- sql.Append("to_char(ADD_MONTHS(to_date(week_to_date(pib_datecode),'yyyy-mm-dd'),12),'yyyy-mm-dd') 有效期一年,");
- sql.Append("to_char(ADD_MONTHS(to_date(week_to_date(pib_datecode),'yyyy-mm-dd'),24),'yyyy-mm-dd') 有效期两年,");
- sql.Append("to_char(ADD_MONTHS(to_date(week_to_date(pib_datecode),'yyyy-mm-dd'),36),'yyyy-mm-dd') 有效期三年,");
- sql.Append("to_char(ADD_MONTHS(to_date(week_to_date(pib_datecode),'yyyy-mm-dd'),12),'yyyy-iw')有效期一年_年周,");
- sql.Append("to_char(ADD_MONTHS(to_date(week_to_date(pib_datecode),'yyyy-mm-dd'),24),'yyyy-iw')有效期两年_年周,");
- sql.Append("to_char(ADD_MONTHS(to_date(week_to_date(pib_datecode),'yyyy-mm-dd'),36),'yyyy-iw')有效期三年_年周,");
- sql.Append("wh_ppmc_user 中文品牌,em_code 装箱员编号,em_name 装箱员名称 from prodiobarcode left join prodinout on pib_piid=pi_id left join product on pib_prodcode=pr_code left join ProdIODetail on pd_id=PIB_PDID ");
- sql.Append("left join PRODJOINVENDDETAIL on pjd_brand=pib_brand and pjd_prodcode=pib_prodcode left join customer on pi_cardcode=cu_code left join productcustomer on pc_custid=cu_id and pc_prodcode=pd_prodcode ");
- if (pibid.IndexOf(",") > 0)
- {
- sql.Append("and pc_custprodcode=pd_custprodcode left join WareHouse on wh_code=pd_whcode left join employee on em_code=pib_inman where pib_id in (" + pibid + ") order by pib_custbarcode)prodiosingleinfo_view");
- }
- else
- {
- sql.Append("and pc_custprodcode=pd_custprodcode left join WareHouse on wh_code=pd_whcode left join employee on em_code=pib_inman where pib_id='" + pibid + "' order by pib_custbarcode)prodiosingleinfo_view");
- }
- DataTable dt = (DataTable)dh.ExecuteSql(sql.ToString(), "select");
- SingleReport.RegisterData(dt, "prodiosingleinfo_view");
- SingleReport.GetDataSource("prodiosingleinfo_view").Enabled = true;
- SingleReport.PrintSettings.ShowDialog = false;
- SingleReport.PrintSettings.Printer = SingleLabelPrinter.Text;
- try
- {
- SingleReport.Print();
- }
- catch (Exception e)
- {
- MessageBox.Show(e.Message);
- return;
- }
- Properties.Settings.Default.SPrinter = SingleLabelPrinter.Text;
- Properties.Settings.Default.Save();
- LogManager.DoCommandLog(pi_inoutno.Text, User.UserCode, "自动打印箱标", "打印成功");
- }
- }
-
- private void 贴标机条码打印_FormClosing(object sender, FormClosingEventArgs e)
- {
-
- if (!logout)
- {
- string close = MessageBox.Show(this.ParentForm, "是否关闭", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question).ToString();
- if (close.ToString() != "Yes")
- e.Cancel = true;
- else
- {
- LogManager.DoLog("关闭程序");
- }
- }
- }
-
-
-
- private void GetInOutInfAndLabelFile()
- {
- ComBoxClickChangeLabelDoc = false;
- sql.Clear();
- 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 ");
- sql.Append("left join customer on cu_code=cl_custcode left join label on la_code=CL_LABELCODE where ((pi_cardcode='" + pi_cardcode.Text + "' ");
- sql.Append("and pi_inoutno='" + pi_inoutno.Text + "') or( cl_custcode is null)) and cl_labeltype='单盘' order by cl_custcode,cl_date desc");
- dt = (DataTable)dh.ExecuteSql(sql.ToString(), "select");
- SingleLabelCombox.DisplayMember = "cl_labelname";
- SingleLabelCombox.ValueMember = "cl_labelurl";
- SingleLabelCombox.DataSource = dt;
- sql.Clear();
- 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 ");
- sql.Append("left join customer on cu_code=cl_custcode left join label on la_code=CL_LABELCODE where ((pi_cardcode='" + pi_cardcode.Text + "' ");
- sql.Append("and pi_inoutno='" + pi_inoutno.Text + "') or( cl_custcode is null)) and cl_labeltype='中盒' order by cl_custcode,cl_date desc");
- dt = (DataTable)dh.ExecuteSql(sql.ToString(), "select");
- MidLabelCombox.DisplayMember = "cl_labelname";
- MidLabelCombox.ValueMember = "cl_labelurl";
- MidLabelCombox.DataSource = dt;
- sql.Clear();
- 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 ");
- sql.Append("left join customer on cu_code=cl_custcode left join label on la_code=CL_LABELCODE where ((pi_cardcode='" + pi_cardcode.Text + "' ");
- sql.Append("and pi_inoutno='" + pi_inoutno.Text + "') or( cl_custcode is null)) and cl_labeltype='外箱' order by cl_custcode,cl_date desc");
- dt = (DataTable)dh.ExecuteSql(sql.ToString(), "select");
- OutBoxCombox.DisplayMember = "cl_labelname";
- OutBoxCombox.ValueMember = "cl_labelurl";
- OutBoxCombox.DataSource = dt;
- ComBoxClickChangeLabelDoc = true;
- }
- bool LoadCheck = true;
-
-
-
-
-
- private void pi_inoutno_KeyDown(object sender, KeyEventArgs e)
- {
- if (e.KeyCode == Keys.Enter)
- {
- LoadCheck = false;
- Combindetail.Checked = false;
- CombindetailTwo.Checked = false;
- LoadCheck = true;
- Input.Clear();
- sql.Clear();
- 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'");
- dt = (DataTable)dh.ExecuteSql(sql.ToString(), "select");
- if (dt.Rows.Count > 0)
- {
- pi_cardcode.Text = dt.Rows[0]["pi_cardcode"].ToString();
- pi_title.Text = dt.Rows[0]["pi_title"].ToString();
- pi_date.Text = dt.Rows[0]["pi_date"].ToString();
- PI_ID = dt.Rows[0]["pi_id"].ToString();
- switch (dt.Rows[0]["pi_combine_user"].ToString())
- {
- case "1":
- Combindetail.Checked = true;
- break;
- case "2":
- CombindetailTwo.Checked = true;
- break;
- default:
- break;
- }
- PassTenCount = 1;
- PassSixTenCount = 1;
- if (pi_cardcode.Text != "ZGCC")
- {
- CustomerLabel.Enabled = false;
- }
- else
- {
- CustomerLabel.Enabled = true;
- }
- DataTable XY = (DataTable)dh.ExecuteSql("select * from PRINTXY where px_custcode='" + pi_cardcode.Text + "' and px_machine='" + SystemInf.Machine + "'", "select");
- if (XY.Rows.Count == 0)
- {
- XY = (DataTable)dh.ExecuteSql("select * from PRINTXY where px_custcode='" + pi_cardcode.Text + "'", "select");
- }
- if (XY.Rows.Count > 0)
- {
- Angle = XY.Rows[0]["px_angle"].ToString();
- X = XY.Rows[0]["px_x"].ToString();
- Y = XY.Rows[0]["px_y"].ToString();
- }
- OutBoxNum_Click(new object(), new EventArgs());
- LoadPrcodeData();
-
- GetBarCodeRule(out Prefix, out Suffix, out MaxNum, out NumLength, out Radix, 1);
- SingleID.Clear();
- Input.Focus();
-
- for (int i = GridPrcode.Rows.Count - 1; i >= 0; i--)
- {
- string outqty = GridPrcode.Rows[i].Cells["pd_outqty"].Value.ToString();
- string collectnum = GridPrcode.Rows[i].Cells["CollectedNum"].Value.ToString();
- if (double.Parse(outqty) > double.Parse(collectnum == "" ? "0" : collectnum))
- {
- GridPrcode.Rows[i].Selected = true;
- MachineCollectRowIndex = GridPrcode.SelectedRows[0].Index;
- if (i - 2 >= 0)
- GridPrcode.FirstDisplayedScrollingRowIndex = i - 2;
- else
- GridPrcode.FirstDisplayedScrollingRowIndex = i;
- }
- }
- pib_indate.Text = dh.getFieldDataByCondition("prodiobarcode", "min(to_char(pib_indate,'yyyy-mm-dd'))", "pib_inoutno='" + pi_inoutno.Text + "'").ToString();
- bi_inman.Text = dh.getFieldDataByCondition("barcodeio left join employee on bi_inman=em_code", "wm_concat(distinct em_name)", "bi_piid=" + PI_ID).ToString();
- pib_inman.Text = dh.getFieldDataByCondition("prodiobarcode left join employee on pib_inman=em_code", "wm_concat(distinct em_name)", "pib_piid=" + PI_ID).ToString();
- 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");
- thread = new Thread(GetInOutInfAndLabelFile);
- stw = new SetLoadingWindow(thread, "正在获取打印标签");
- BaseUtil.SetFormCenter(stw);
- stw.ShowDialog();
- LogManager.DoLog("输入单号【" + pi_inoutno.Text + "】");
- }
- else MessageBox.Show("当前出入库单号不存在或者未审核!", "提示");
- }
- }
- private void SingleBoxPrint()
- {
- if (EnablePrint)
- {
- if (LabelInf.Rows.Count > 0)
- {
-
- SingleID.Clear();
-
- Dictionary<string, bool> outboxcode1 = new Dictionary<string, bool>();
-
- outboxcode1.Add(LabelInf.Rows[0].Cells["pib_outboxcode1"].Value.ToString(), true);
- for (int i = 0; i < LabelInf.Rows.Count; i++)
- {
- if (!SingleID.Contains(LabelInf.Rows[i].Cells["pib_id1"].Value.ToString()))
- SingleID.Add(LabelInf.Rows[i].Cells["pib_id1"].Value.ToString());
- }
- if (SingleID.ToArray().Length == 0)
- {
- MessageBox.Show("选择的行未勾选采集或者已打印", "提示");
- return;
- }
- for (int i = 0; i < LabelInf.RowCount; i++)
- {
- if (i + 1 < LabelInf.RowCount)
- {
-
- if (LabelInf.Rows[i].Cells["pib_outboxcode1"].Value.ToString() != LabelInf.Rows[i + 1].Cells["pib_outboxcode1"].Value.ToString())
- {
- if (!outboxcode1.ContainsKey(LabelInf.Rows[i + 1].Cells["pib_outboxcode1"].Value.ToString()))
- outboxcode1.Add(LabelInf.Rows[i + 1].Cells["pib_outboxcode1"].Value.ToString(), true);
- }
- }
- }
- string pibid = "";
- for (int i = 0; i < LabelInf.RowCount; i++)
- {
-
- if (LabelInf.Rows[i].Cells["Choose"].FormattedValue != null && LabelInf.Rows[i].Cells["Choose"].FormattedValue.ToString().ToLower() == "true")
- {
- pibid += LabelInf.Rows[i].Cells["pib_id1"].Value.ToString() + ",";
- LabelInf.Rows[i].Cells["pib_ifprint"].Value = true;
- }
- }
- if (pibid != "")
- {
- if (!SingleLabelCombox.SelectedValue.ToString().Contains("System.Data.DataRowView"))
- SingleReport.Load(SingleLabelCombox.SelectedValue.ToString());
- for (int j = 0; j < SingleReport.Parameters.Count; j++)
- {
- SingleReport.SetParameterValue(SingleReport.Parameters[j].Name, "");
- for (int k = 0; k < Attach.Rows.Count; k++)
- {
- if (Attach.Rows[k][0].ToString() == SingleReport.Parameters[j].Name)
- {
- SingleReport.SetParameterValue(SingleReport.Parameters[j].Name, Attach.Rows[k][1].ToString());
- }
- }
- }
- DataTable dt = (DataTable)dh.ExecuteSql("select * from prodiosingleinfo_view where 主键ID in (" + pibid.Substring(0, pibid.Length - 1) + ")", "select");
- SingleReport.RegisterData(dt, "prodiosingleinfo_view");
- SingleReport.GetDataSource("prodiosingleinfo_view").Enabled = true;
-
- SingleReport.PrintSettings.ShowDialog = false;
- SingleReport.PrintSettings.Printer = SingleLabelPrinter.Text;
- try
- {
- SingleReport.Print();
- }
- catch (Exception e)
- {
- MessageBox.Show(e.Message);
- return;
- }
- Properties.Settings.Default.SPrinter = SingleLabelPrinter.Text;
- Properties.Settings.Default.Save();
- }
- else
- {
- MessageBox.Show("未勾选打印明细", "提示", MessageBoxButtons.OK, MessageBoxIcon.None, MessageBoxDefaultButton.Button1, MessageBoxOptions.ServiceNotification);
- }
- LogManager.DoCommandLog(pi_inoutno.Text, User.UserCode, "手动打印盘标", "打印成功");
- dh.BatchInsert("update prodiobarcode set pib_printdate=sysdate where pib_id=:pib_id", new string[] { "pib_id" }, SingleID.ToArray());
- outboxcode1.Clear();
- }
- else
- {
- MessageBox.Show("此模板尚未维护参数或不存在打印明细", "提示");
- return;
- }
- }
- }
- private void SingleLabelPrint_Click(object sender, EventArgs e)
- {
- if (SingleLabelCombox.Text != "")
- {
- if (SingleBoxBegin.Text != "" || SingleBoxEnd.Text != "")
- {
- try
- {
- int begin = int.Parse(SingleBoxBegin.Text == "" ? "1" : SingleBoxBegin.Text);
- int end = int.Parse(SingleBoxEnd.Text == "" ? LabelInf.Rows.Count.ToString() : SingleBoxEnd.Text);
- if (begin > 0 && end <= LabelInf.Rows.Count && begin <= end)
- {
- for (int i = begin - 1; i < end; i++)
- {
- LabelInf.Rows[i].Cells["Choose"].Value = true;
- LabelInf.Rows[i].Cells["pib_ifprint"].Value = false;
- }
- }
- else
- {
- MessageBox.Show("单盘打印范围错误", "提示");
- return;
- }
- }
- catch (Exception)
- {
- MessageBox.Show("单盘打印范围错误", "提示");
- return;
- }
- }
- thread = new Thread(SingleBoxPrint);
- stw = new SetLoadingWindow(thread, "正在打印单盘");
- BaseUtil.SetFormCenter(stw);
- stw.ShowDialog();
- Input.Focus();
- }
- else
- {
- MessageBox.Show("未维护单盘标签", "提示");
- LogManager.DoCommandLog(pi_inoutno.Text, User.UserCode, "手动打印盘标", "打印失败,未维护标签");
- }
- }
- private void MidBoxLabelPrint()
- {
-
- if (MidLabelNum.Text == "")
- {
- int begin = 0;
- int end = 0;
- if (MidBoxBegin.Text != "" || MidBoxEnd.Text != "")
- {
- try
- {
- begin = int.Parse(MidBoxBegin.Text == "" ? "1" : MidBoxBegin.Text);
- end = int.Parse(MidBoxEnd.Text == "" ? LabelInf.Rows[LabelInf.Rows.Count - 1].Cells["pib_outboxcode1"].Value.ToString() : MidBoxEnd.Text);
- int minmidbox = int.Parse(LabelInf.Rows[0].Cells["pib_outboxcode1"].Value.ToString());
- int maxmidbox = int.Parse(LabelInf.Rows[LabelInf.Rows.Count - 1].Cells["pib_outboxcode1"].Value.ToString());
- if (begin >= minmidbox && end <= maxmidbox && begin <= end)
- {
-
- for (int i = 0; i < LabelInf.Rows.Count; i++)
- {
- if (int.Parse(LabelInf.Rows[i].Cells["pib_outboxcode1"].Value.ToString()) == begin)
- {
- begin = i;
- }
- if (int.Parse(LabelInf.Rows[i].Cells["pib_outboxcode1"].Value.ToString()) == end)
- {
- end = i;
- }
- }
- }
- else
- {
- MessageBox.Show("中盒打印范围错误", "提示");
- return;
- }
- }
- catch (Exception)
- {
- MessageBox.Show("中盒打印范围错误", "提示");
- return;
- }
- }
- List<int> MidOutBoxCode = new List<int>();
- List<int> MidOutBoxCodeIndex = new List<int>();
- for (int i = (begin == 0 ? 0 : begin); i <= (end == 0 ? LabelInf.Rows.Count - 1 : end); i++)
- {
- try
- {
- if (!MidOutBoxCode.Contains(int.Parse(LabelInf.Rows[i].Cells["pib_outboxcode1"].Value.ToString())))
- {
- MidOutBoxCode.Add(int.Parse(LabelInf.Rows[i].Cells["pib_outboxcode1"].Value.ToString()));
- MidOutBoxCodeIndex.Add(i);
- }
- }
- catch (Exception)
- {
- MessageBox.Show("请先封箱!");
- return;
- }
- }
-
- if (SelectRowIndex >= 0 && LabelInf.Rows.Count > SelectRowIndex)
- {
- MidOutBoxCode.Clear();
- MidOutBoxCodeIndex.Clear();
- SelectProdcode = LabelInf.Rows[SelectRowIndex].Cells["pib_prodcode"].Value.ToString();
- for (int i = SelectRowIndex; i >= 0; i--)
- {
- if ((LabelInf.Rows[i].Cells["pib_prodcode"].Value.ToString() == SelectProdcode && LabelInf.Rows[i].Cells["pib_midifprint"].FormattedValue.ToString().ToLower() != "true") || i == SelectRowIndex)
- {
- LabelInf.Rows[i].Cells["pib_midifprint"].Value = true;
- if (!MidOutBoxCode.Contains(int.Parse(LabelInf.Rows[i].Cells["pib_outboxcode1"].Value.ToString())))
- {
- MidOutBoxCode.Add(int.Parse(LabelInf.Rows[i].Cells["pib_outboxcode1"].Value.ToString()));
- MidOutBoxCodeIndex.Add(i);
- }
- }
- else
- {
- break;
- }
- }
- for (int i = SelectRowIndex; i < LabelInf.Rows.Count - 1; i++)
- {
- if ((LabelInf.Rows[i].Cells["pib_prodcode"].Value.ToString() == SelectProdcode && LabelInf.Rows[i].Cells["pib_midifprint"].FormattedValue.ToString().ToLower() != "true") || i == SelectRowIndex)
- {
- LabelInf.Rows[i].Cells["pib_midifprint"].Value = true;
- if (!MidOutBoxCode.Contains(int.Parse(LabelInf.Rows[i].Cells["pib_outboxcode1"].Value.ToString())))
- {
- MidOutBoxCode.Add(int.Parse(LabelInf.Rows[i].Cells["pib_outboxcode1"].Value.ToString()));
- MidOutBoxCodeIndex.Add(i);
- }
- }
- else
- {
- break;
- }
- }
- }
- try
- {
- MidBoxCodePrint(MidOutBoxCodeIndex.ToArray());
- }
- catch (Exception e)
- {
- MessageBox.Show(e.Message);
- return;
- }
- return;
- }
- bool FindMidLabel = false;
- if (MidLabelCombox.SelectedValue != null)
- {
-
- int MidLabelRowIndex = 0;
-
- for (int i = 0; i < LabelInf.RowCount; i++)
- {
- if (MidLabelNum.Text == LabelInf.Rows[i].Cells["pib_outboxcode1"].Value.ToString())
- {
-
- FindMidLabel = true;
- MidLabelRowIndex = i;
- }
- }
- int[] rowindx = new int[] { MidLabelRowIndex };
-
- if (FindMidLabel)
- MidBoxCodePrint(rowindx);
- else
- MessageBox.Show("该出入库单未找到该中盒号!", "提示");
- }
- else
- MessageBox.Show("未维护中盒模板", "提示");
- }
- private void MidLabelPrint_Click(object sender, EventArgs e)
- {
- if (MidLabelCombox.Text != "")
- {
- PackMidBox_Click(sender, e);
- thread = new Thread(MidBoxLabelPrint);
- stw = new SetLoadingWindow(thread, "正在打印中盒");
- BaseUtil.SetFormCenter(stw);
- stw.ShowDialog();
- }
- else
- MessageBox.Show("未维护中盒标签", "提示");
- Input.Focus();
- }
- private void OutBoxPrint()
- {
- List<string> Outboxcode = new List<string>();
-
- if (OutBoxNum.Text == "" || OutBoxNum.Text == "全部")
- {
- for (int i = 0; i < LabelInf.RowCount; i++)
- {
- string outboxcode2 = LabelInf.Rows[i].Cells["pib_outboxcode2"].Value.ToString();
-
-
- if (!Outboxcode.Contains(outboxcode2))
- Outboxcode.Add(outboxcode2);
- }
-
- if (Outboxcode.ToArray().Length > 0)
- {
- for (int i = 0; i < Outboxcode.ToArray().Length; i++)
- {
- for (int h = 0; h < LabelInf.RowCount; h++)
- {
- if (LabelInf.Rows[h].Cells["pib_outboxcode2"].Value.ToString() == Outboxcode.ToArray()[i])
- {
- if (!AllLabel.Checked)
- OutBoxCodePrint(h);
- else
- OutBoxCodePrint(h, true);
- break;
- }
- }
- }
- }
- else
- {
- MessageBox.Show("请勾选需要打印的外箱", "提示");
- }
- }
- else
- {
- bool FindMidLabel = false;
- try
- {
- int OutBoxLabelRowIndex = 0;
-
- for (int i = 0; i < LabelInf.RowCount; i++)
- {
- if (OutBoxNum.Text == LabelInf.Rows[i].Cells["pib_outboxcode2"].Value.ToString())
- {
-
- FindMidLabel = true;
- OutBoxLabelRowIndex = i;
- break;
- }
- }
-
- if (FindMidLabel)
- {
- if (!AllLabel.Checked)
- OutBoxCodePrint(OutBoxLabelRowIndex);
- else
- OutBoxCodePrint(OutBoxLabelRowIndex, true);
- }
- else
- MessageBox.Show("该出入库单未找到该外箱号!", "提示");
- }
- catch (Exception) { }
- }
- LogManager.DoCommandLog(pi_inoutno.Text, User.UserCode, "手动打印箱标" + OutBoxNum.Text, "打印成功");
- Outboxcode.Clear();
- }
- private void MidBoxCodePrint(int[] rowindex)
- {
- if (EnablePrint)
- {
- string pib_outboxcode1 = "";
- for (int i = 0; i < rowindex.Length; i++)
- {
- if (i != rowindex.Length - 1)
- pib_outboxcode1 += "'" + LabelInf.Rows[rowindex[i]].Cells["pib_outboxcode1"].Value.ToString() + "'" + ",";
- else
- pib_outboxcode1 += "'" + LabelInf.Rows[rowindex[i]].Cells["pib_outboxcode1"].Value.ToString() + "'";
- }
-
- DataTable dt;
- sql.Clear();
- sql.Append("update prodiobarcode set pib_midboxweight='" + Weight.Text + "' where pib_inoutno='" + pi_inoutno.Text + "' ");
- sql.Append(" and pib_outboxcode1 in(" + pib_outboxcode1 + ")");
- dh.ExecuteSql(sql.ToString(), "update");
- if (MidLabelAutoPrint.Checked)
- {
- if (CurrentRowOnly.Checked)
- {
- string PDNO = "";
- if (SelectRowIndex >= 0)
- {
- PDNO = LabelInf.Rows[SelectRowIndex].Cells["pib_pdno"].Value.ToString();
- }
- dt = (DataTable)dh.ExecuteSql("select * from prodiomidinfo_view where 出货单号='" + pi_inoutno.Text + "' and 中盒号 in(" + pib_outboxcode1 + ") and 出货序号='" + (PDNO == "" ? CurrentPDNO : PDNO) + "'", "select");
- }
- else
- {
- dt = (DataTable)dh.ExecuteSql("select * from prodiomidinfo_view where 出货单号='" + pi_inoutno.Text + "' and 中盒号 in(" + pib_outboxcode1 + ")", "select");
- }
- }
- else
- {
- if (CurrentRowOnly.Checked)
- {
- string PDNO = "";
- if (SelectRowIndex >= 0)
- {
- PDNO = LabelInf.Rows[SelectRowIndex].Cells["pib_pdno"].Value.ToString();
- }
- dt = (DataTable)dh.ExecuteSql("select * from prodiomidinfo_view where 出货单号='" + pi_inoutno.Text + "' and 中盒号 in(" + pib_outboxcode1 + ") and 中盒标识='外' and 出货序号='" + (PDNO == "" ? CurrentPDNO : PDNO) + "'", "select");
- }
- else
- {
- dt = (DataTable)dh.ExecuteSql("select * from prodiomidinfo_view where 出货单号='" + pi_inoutno.Text + "' and 中盒号 in(" + pib_outboxcode1 + ") and 中盒标识='外'", "select");
- }
- }
- if (dt.Rows.Count > 0)
- {
- if (!MidLabelCombox.SelectedValue.ToString().Contains("System.Data.DataRowView"))
- MidReport.Load(MidLabelCombox.SelectedValue.ToString());
- for (int j = 0; j < MidReport.Parameters.Count; j++)
- {
- MidReport.SetParameterValue(MidReport.Parameters[j].Name, "");
- for (int i = 0; i < Attach.Rows.Count; i++)
- {
- if (Attach.Rows[i][0].ToString() == MidReport.Parameters[j].Name)
- {
- MidReport.SetParameterValue(MidReport.Parameters[j].Name, Attach.Rows[i][1].ToString());
- }
- }
- }
- MidReport.RegisterData(dt, "prodiomidinfo_view");
- MidReport.GetDataSource("prodiomidinfo_view").Enabled = true;
- MidReport.PrintSettings.ShowDialog = false;
- MidReport.PrintSettings.Printer = MidLabelPrinter.Text;
- MidReport.Print();
- dh.UpdateByCondition("prodiobarcode", "pib_midifprint=-1", "pib_inoutno='" + pi_inoutno.Text + "' and pib_outboxcode1 in (" + pib_outboxcode1 + ")");
- SelectRowIndex = -1;
- LoadGridData(new object(), new EventArgs());
- LogManager.DoCommandLog(pi_inoutno.Text, User.UserCode, "打印中盒" + pib_outboxcode1.Replace("'", ""), "打印成功");
- }
- Properties.Settings.Default.MPrinter = MidLabelPrinter.Text;
- Properties.Settings.Default.Save();
- }
- }
-
-
-
- private void OutBoxCodePrint(int rowindex)
- {
- if (EnablePrint)
- {
- if (!OutBoxCombox.SelectedValue.ToString().Contains("System.Data.DataRowView"))
- OutReport.Load(OutBoxCombox.SelectedValue.ToString());
- for (int j = 0; j < OutReport.Parameters.Count; j++)
- {
- OutReport.SetParameterValue(OutReport.Parameters[j].Name, "");
- for (int i = 0; i < Attach.Rows.Count; i++)
- {
- if (Attach.Rows[i][0].ToString() == OutReport.Parameters[j].Name)
- {
- OutReport.SetParameterValue(OutReport.Parameters[j].Name, Attach.Rows[i][1].ToString());
- }
- }
- }
- string pib_outboxcode2 = LabelInf.Rows[rowindex].Cells["pib_outboxcode2"].Value.ToString();
- string SQL = "";
- if (OnlyOneRow.Checked)
- {
- SQL = "select * from prodiooutinfo_view where 出货单号 = '" + pi_inoutno.Text + "' and 外箱号 = '" + pib_outboxcode2 + "' and rownum=1";
- }
- else
- {
- SQL = "select * from prodiooutinfo_view where 出货单号 = '" + pi_inoutno.Text + "' and 外箱号 = '" + pib_outboxcode2 + "'";
- }
- DataTable dt = (DataTable)dh.ExecuteSql(SQL, "select");
- OutReport.RegisterData(dt, "prodiooutinfo_view");
- OutReport.GetDataSource("prodiooutinfo_view").Enabled = true;
- OutReport.PrintSettings.ShowDialog = false;
- OutReport.PrintSettings.Printer = OutBoxPrinter.Text;
- OutReport.Print();
- Properties.Settings.Default.OPrinter = OutBoxPrinter.Text;
- Properties.Settings.Default.Save();
- dh.UpdateByCondition("prodiobarcode", "pib_outifprint=-1", "pib_inoutno='" + pi_inoutno.Text + "' and pib_outboxcode2='" + pib_outboxcode2 + "'");
- }
- }
-
-
-
- private void OutBoxCodePrint(int rowindex, bool AllLabel)
- {
- if (EnablePrint)
- {
- int selectedindex = OutBoxCombox.SelectedIndex;
- for (int i = 0; i < OutBoxCombox.Items.Count; i++)
- {
- OutBoxCombox.SelectedIndex = i;
- if (!OutBoxCombox.SelectedValue.ToString().Contains("System.Data.DataRowView"))
- OutReport.Load(OutBoxCombox.SelectedValue.ToString());
- for (int j = 0; j < OutReport.Parameters.Count; j++)
- {
- OutReport.SetParameterValue(OutReport.Parameters[j].Name, "");
- for (int k = 0; k < Attach.Rows.Count; k++)
- {
- if (Attach.Rows[k][0].ToString() == OutReport.Parameters[j].Name)
- {
- OutReport.SetParameterValue(OutReport.Parameters[j].Name, Attach.Rows[k][1].ToString());
- }
- }
- }
- string pib_outboxcode2 = LabelInf.Rows[rowindex].Cells["pib_outboxcode2"].Value.ToString();
- DataTable dt = (DataTable)dh.ExecuteSql("select * from prodiooutinfo_view where 出货单号='" + pi_inoutno.Text + "' and 外箱号='" + pib_outboxcode2 + "'", "select");
- OutReport.RegisterData(dt, "prodiooutinfo_view");
- OutReport.GetDataSource("prodiooutinfo_view").Enabled = true;
- OutReport.PrintSettings.ShowDialog = false;
- OutReport.PrintSettings.Printer = OutBoxPrinter.Text;
- OutReport.Print();
- }
- OutBoxCombox.SelectedIndex = selectedindex;
- Properties.Settings.Default.OPrinter = OutBoxPrinter.Text;
- Properties.Settings.Default.Save();
- dh.UpdateByCondition("prodiobarcode", "pib_outifprint=-1", "pib_inoutno='" + pi_inoutno.Text + "' and pib_outboxcode2='" + pib_outboxcode2 + "'");
- }
- }
- private void CleanDetail_Click(object sender, EventArgs e)
- {
- if (dh.getFieldDataByCondition("prodinout", "pi_statuscode", "pi_inoutno='" + pi_inoutno.Text + "'").ToString() == "POSTED")
- {
-
-
- }
- ArrayList<string> DeleteID = new ArrayList<string>();
- for (int i = 0; i < LabelInf.RowCount; i++)
- {
- if (LabelInf.Rows[i].Cells["Choose"].FormattedValue.ToString().ToLower() == "true")
- DeleteID.Add(LabelInf.Rows[i].Cells["pib_id1"].Value.ToString());
- }
-
- if (DeleteID.ToArray().Length > 0)
- {
- string close = MessageBox.Show(this.ParentForm, "删除后不可恢复,是否确认删除", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question).ToString();
- if (close.ToString() == "Yes")
- {
- dh.BatchInsert("delete from prodiobarcode where pib_id=:pib_id", new string[] { "pib_id" }, DeleteID.ToArray());
- 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 + "'");
-
- LogManager.DoCommandLog(pi_inoutno.Text, User.UserCode, "删除明细", "删除明细成功");
- MessageBox.Show("删除成功", "提示");
- Input.Clear();
- LoadPrcodeData();
- LoadGridData(sender, e);
- if (int.Parse(dh.getFieldDataByCondition("prodiobarcode", "count(1)", "pib_inoutno='" + pi_inoutno.Text + "'").ToString()) == 0)
- {
- dh.UpdateByCondition("prodinout", "pi_user_packingstatus=''", "pi_inoutno='" + pi_inoutno.Text + "'");
- }
- else
- {
- dh.UpdateByCondition("prodinout", "pi_user_packingstatus='Packing'", "pi_inoutno='" + pi_inoutno.Text + "'");
- }
- }
- }
- else
- MessageBox.Show("尚未勾选需要删除的明细", "提示");
- }
- private void OutBoxLabelPrint_Click(object sender, EventArgs e)
- {
- if (OutBoxCombox.Text != "")
- {
- Pack_Click(sender, e);
- if (Weight.Text != "" && Weight.Text != "0.000")
- {
-
- sql.Clear();
- sql.Append("update prodiobarcode set pib_totalweight='" + Weight.Text + "' where pib_inoutno='" + pi_inoutno.Text + "' ");
- sql.Append(" and pib_outboxcode2='" + OutBoxNum.Text + "'");
- dh.ExecuteSql(sql.ToString(), "update");
- }
- LoadGridData(sender, e);
- thread = new Thread(OutBoxPrint);
- stw = new SetLoadingWindow(thread, "正在打印外箱");
- BaseUtil.SetFormCenter(stw);
- stw.ShowDialog();
- Input.Focus();
- }
- else
- MessageBox.Show("未维护外箱标签", "提示");
- Input.Focus();
- }
-
-
-
-
-
- private void LoadGridData(object sender, EventArgs e)
- {
- AllChecked = false;
- string SQL = "";
- if (OutBoxNum.Text != "全部")
- {
-
- SQL = "select pib_boxweight,pib_midboxweight,pib_totalweight,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,pib_pdno,pib_prodcode,pib_brand,pr_vendprodcode,pib_lotno,pib_datecode," +
- "week_to_date(pib_datecode) datecode1,pib_qty,pr_spec,pr_zxbzs,pr_unit,pib_barcode,pib_outboxcode1,pib_outboxcode2,nvl(pib_ifprint, 0)pib_ifprint,pd_remark,pd_remark2 from prodiobarcode left join " +
- "prodiodetail on pib_piid = pd_piid and pd_pdno = pib_pdno and pd_prodcode = pib_prodcode left join product on pr_code = pib_prodcode 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 + "' and pib_outboxcode2='" + OutBoxNum.Text + "' order by to_number(pib_outboxcode2),pib_id,pd_prodcode";
- }
- else
- {
- SQL = "select pib_boxweight,pib_midboxweight,pib_totalweight,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,pib_pdno,pib_prodcode,pib_brand,pr_vendprodcode,pib_lotno,pib_datecode," +
- "week_to_date(pib_datecode) datecode1,pib_qty,pr_spec,pr_zxbzs,pr_unit,pib_barcode,pib_outboxcode1,pib_outboxcode2,nvl(pib_ifprint, 0)pib_ifprint,pd_remark,pd_remark2 from prodiobarcode left join " +
- "prodiodetail on pib_piid = pd_piid and pd_pdno = pib_pdno and pd_prodcode = pib_prodcode left join product on pr_code = pib_prodcode 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 + "' order by to_number(pib_outboxcode2),pib_id,pd_prodcode";
- }
- LabelInfDataTable = (DataTable)dh.ExecuteSql(SQL, "select");
- BoxCount.Text = LabelInfDataTable.Compute("sum(pib_qty)", "1=1").ToString() + "KPCS";
- bindingsource(LabelInf, LabelInfDataTable);
- if (LabelInf.Rows.Count > 0)
- {
- LabelInf.FirstDisplayedScrollingRowIndex = LabelInf.Rows.Count - 1;
- }
- sql.Clear();
- 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 ");
- sql.Append("where pib_inoutno='" + pi_inoutno.Text + "' group by pib_prodcode,pib_pdno order by pib_pdno ");
- SumQty = (DataTable)dh.ExecuteSql(sql.ToString(), "select");
- }
- private void Refresh_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
- {
- KeyEventArgs e2 = new KeyEventArgs(Keys.Enter);
- pi_inoutno_KeyDown(sender, e2);
- }
- private void LogingOut_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
- {
- string close = MessageBox.Show(this.ParentForm, "是否注销", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question).ToString();
- if (close.ToString() == "Yes")
- {
- Login login = new Login();
-
- DataHelper.DBConnectionString = null;
- logout = true;
- this.Hide();
- login.ShowDialog();
- this.Close();
- }
- }
- private void LabelInf_DataError(object sender, DataGridViewDataErrorEventArgs e) { }
-
-
-
-
-
- private void SingleLabelCombox_SelectedIndexChanged(object sender, EventArgs e)
- {
- try
- {
- if (ComBoxClickChangeLabelDoc)
- {
- if (!SingleLabelCombox.SelectedValue.ToString().Contains("System.Data.DataRowView"))
- SingleReport.Load(SingleLabelCombox.SelectedValue.ToString());
- }
- }
- catch (Exception) { }
- }
-
-
-
-
-
- private void MidLabelCombox_SelectedIndexChanged(object sender, EventArgs e)
- {
- try
- {
- if (ComBoxClickChangeLabelDoc)
- {
- if (!MidLabelCombox.SelectedValue.ToString().Contains("System.Data.DataRowView"))
- MidReport.Load(MidLabelCombox.SelectedValue.ToString());
- }
- }
- catch (Exception) { }
- }
-
-
-
-
-
- private void OutBoxCombox_SelectedIndexChanged(object sender, EventArgs e)
- {
- try
- {
- if (ComBoxClickChangeLabelDoc)
- {
- if (!OutBoxCombox.SelectedValue.ToString().Contains("System.Data.DataRowView"))
- OutReport.Load(OutBoxCombox.SelectedValue.ToString());
- }
- }
- catch (Exception) { }
- }
- private void ChooseAll_Click(object sender, EventArgs e)
- {
- if (AllChecked)
- {
- foreach (DataGridViewRow dr in LabelInf.Rows)
- dr.Cells[0].Value = false;
- AllChecked = false;
- }
- else
- {
- foreach (DataGridViewRow dr in LabelInf.Rows)
- dr.Cells[0].Value = true;
- AllChecked = true;
- }
- }
- private void ExportData_Click(object sender, EventArgs e)
- {
- ShowMenu.Items.Clear();
- DataTable dt = (DataTable)dh.ExecuteSql("select * from CS_EXPORTSETTING where es_custcode='" + pi_cardcode.Text + "'", "select");
- if (dt.Rows.Count == 0)
- dt = (DataTable)dh.ExecuteSql("select * from CS_EXPORTSETTING where es_custcode is null", "select");
- for (int i = 0; i < dt.Rows.Count; i++)
- {
- ShowMenu.Items.Add(new ToolStripMenuItem(dt.Rows[i]["el_remark"].ToString() + "#" + dt.Rows[i]["el_type"].ToString()));
- }
- ShowMenu.Show(new Point(ExportData.Location.X, ExportData.Location.Y + 20));
- }
- private void ShowMenu_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
- {
-
- string type = e.ClickedItem.Text.Split('#')[1];
- ExportFileDialog.Description = "选择导出的路径";
- DialogResult result = ExportFileDialog.ShowDialog();
- if (result == DialogResult.OK)
- {
- ExcelHandler eh = new ExcelHandler();
- DataTable Field = (DataTable)dh.ExecuteSql("select * from CS_EXPORTSETTINGdetail left join CS_EXPORTSETTING on es_id=esd_esid where es_custcode='" + pi_cardcode.Text + "' and esd_enable=-1 and esd_filed is not null and el_type='" + type + "' order by esd_detno", "select");
- if (Field.Rows.Count == 0)
- {
- Field = (DataTable)dh.ExecuteSql("select * from CS_EXPORTSETTINGdetail left join CS_EXPORTSETTING on es_id=esd_esid where es_custcode is null and es_isdefault=-1 and esd_enable=-1 and esd_filed is not null and el_type='" + type + "' order by esd_detno", "select");
- }
- string Fileds = "";
- for (int i = 0; i < Field.Rows.Count; i++)
- {
- Fileds += Field.Rows[i]["esd_filed"].ToString() + ",";
- }
- sql.Clear();
- sql.Append("select " + Fileds.Substring(0, Fileds.Length - 1) + " from ExportView where pib_inoutno='" + pi_inoutno.Text + "'");
- string finnalSQL = "";
- LogicHandler.GetExportDataSQL(pi_inoutno.Text, pi_cardcode.Text, type, sql.ToString(), out finnalSQL);
- dt = (DataTable)dh.ExecuteSql(finnalSQL, "select");
- eh.ExportExcel(dt, Field, ExportFileDialog.SelectedPath, pi_date.Text + "-" + pi_inoutno.Text + type);
- string close = MessageBox.Show(this.ParentForm, "导出成功,是否打开文件", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question).ToString();
- if (close.ToString() == "Yes")
- Process.Start(ExportFileDialog.SelectedPath + "\\" + pi_date.Text + "-" + pi_inoutno.Text + type + ".xls");
- }
- }
- private void AttachInfo_Click(object sender, EventArgs e)
- {
- if (pi_cardcode.Text != "")
- {
- 附件内容打印 att = new 附件内容打印(pi_cardcode.Text);
- att.ShowDialog();
- }
- else MessageBox.Show("请先获取出库单信息", "提示");
- }
- private void MidBoxCapacity_Leave(object sender, EventArgs e)
- {
- NumericUpDown nup = (NumericUpDown)sender;
- switch (nup.Name)
- {
- case "MidBoxCapacity":
- Properties.Settings.Default.MidBoxCapacity = nup.Value;
- Properties.Settings.Default.Save();
- break;
- case "OutboxCapacity":
- Properties.Settings.Default.OutboxCapacity = nup.Value;
- Properties.Settings.Default.Save();
- break;
- default:
- break;
- }
- }
- private void RefreshDBConnect_Tick(object sender, EventArgs e)
- {
- dh.ExecuteSql("select sysdate from dual", "select");
- }
- DataTable CSPrcode;
- private void LoadPrcodeData()
- {
- 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,pd_brand,pjd_zxbzs_user,pjd_id,pd_pdno,pr_spec,0 checknum 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");
- GridPrcode.DataSource = Prcode;
- List<int> RemoveIndex = new List<int>();
- double CollectNum = 0;
- double OutNum = 0;
- int combined = 0;
- if (Combindetail.Checked)
- combined = 1;
- if (CombindetailTwo.Checked)
- combined = 2;
- if (Combindetail.Checked || CombindetailTwo.Checked)
- {
- 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,nvl(checknum,0)checknum from CS$InoutPrcode where pd_inoutno='" + pi_inoutno.Text + "' and combined=" + combined + " order by pd_pdno", "select");
- if (CSPrcode.Rows.Count == 0)
- {
- int CurrentIndex = 0;
- for (int i = 0; i < GridPrcode.Rows.Count; i++)
- {
- string CurrentPrCode = GridPrcode.Rows[i].Cells["pd_prodcode"].Value.ToString();
- string CurrentPDNO = GridPrcode.Rows[i].Cells["pd_pdno"].Value.ToString();
- string CurrentOutQTY = GridPrcode.Rows[i].Cells["pd_outqty"].Value.ToString();
- string collectqty = (SumQty.Compute("sum(pib_qty)", "pib_prodcode='" + CurrentPrCode + "' and pib_pdno='" + CurrentPDNO + "'").ToString());
- CollectNum += double.Parse(collectqty == "" ? "0" : collectqty);
- OutNum += double.Parse(CurrentOutQTY);
- GridPrcode.Rows[i].Cells["CollectedNum"].Value = collectqty == "" ? "0" : collectqty;
- }
- for (int i = 0; i < GridPrcode.Rows.Count; i++)
- {
- if (i + 1 < GridPrcode.Rows.Count)
- {
- string BProdCode = GridPrcode.Rows[i].Cells["pd_prodcode"].Value.ToString();
- string BCustProdCode = GridPrcode.Rows[i].Cells["pd_custprodcode1"].Value.ToString();
- string BWhCode = GridPrcode.Rows[i].Cells["pd_whcode"].Value.ToString();
- string BPrUnit = GridPrcode.Rows[i].Cells["pr_unit"].Value.ToString();
- string BPrBrand = GridPrcode.Rows[i].Cells["pd_brand"].Value.ToString();
- string BPoCode = GridPrcode.Rows[i].Cells["pd_pocode1"].Value.ToString();
- string FProdCode = GridPrcode.Rows[i + 1].Cells["pd_prodcode"].Value.ToString();
- string FCustProdCode = GridPrcode.Rows[i + 1].Cells["pd_custprodcode1"].Value.ToString();
- string FPrUnit = GridPrcode.Rows[i + 1].Cells["pr_unit"].Value.ToString();
- string FrBrand = GridPrcode.Rows[i + 1].Cells["pd_brand"].Value.ToString();
- string FWhCode = GridPrcode.Rows[i + 1].Cells["pd_whcode"].Value.ToString();
- string FPoCode = GridPrcode.Rows[i + 1].Cells["pd_pocode1"].Value.ToString();
- if (BProdCode == FProdCode && BPrBrand == FrBrand && BCustProdCode == FCustProdCode && (CombindetailTwo.Checked && FPoCode == BPoCode || Combindetail.Checked))
- {
- 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());
- 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());
- RemoveIndex.Add(i + 1);
- }
- else
- {
- CurrentIndex = i + 1;
- }
- }
- }
- foreach (int item in RemoveIndex.OrderByDescending(x => x))
- {
- (GridPrcode.DataSource as DataTable).Rows.RemoveAt(item);
- }
- }
- else GridPrcode.DataSource = CSPrcode;
- }
- else
- {
- 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,nvl(checknum,0)checknum from CS$InoutPrcode where pd_inoutno='" + pi_inoutno.Text + "' and combined=" + combined + " order by pd_pdno", "select");
- if (CSPrcode.Rows.Count == 0)
- {
- for (int i = 0; i < GridPrcode.Rows.Count; i++)
- {
- string CurrentPrCode = GridPrcode.Rows[i].Cells["pd_prodcode"].Value.ToString();
- string CurrentPDNO = GridPrcode.Rows[i].Cells["pd_pdno"].Value.ToString();
- string CurrentOutQTY = GridPrcode.Rows[i].Cells["pd_outqty"].Value.ToString();
- string collectqty = (SumQty.Compute("sum(pib_qty)", "pib_prodcode='" + CurrentPrCode + "' and pib_pdno='" + CurrentPDNO + "'").ToString());
- CollectNum += double.Parse(collectqty == "" ? "0" : collectqty);
- OutNum += double.Parse(CurrentOutQTY);
- GridPrcode.Rows[i].Cells["CollectedNum"].Value = collectqty == "" ? "0" : collectqty;
- }
- }
- else GridPrcode.DataSource = CSPrcode;
- }
- dh.UpdateByCondition("prodinout", "pi_combine_user=" + combined, "pi_inoutno='" + pi_inoutno.Text + "'");
- if (CSPrcode.Rows.Count == 0)
- {
- sql.Clear();
- sql.Append("insert into CS$InoutPrcode (pd_piid,pd_pdno,pd_custprodcode,pd_whcode,pd_prodcode,");
- sql.Append("CollectedNum,UnCollectedNum,pd_outqty,pr_unit,pr_spec,pd_brand,pjd_zxbzs_user,pjd_id,pd_inoutno,combined,pd_pocode)");
- 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)");
- dh.SaveDataTable((GridPrcode.DataSource as DataTable), "CS$InoutPrcode", "pd_piid", sql.ToString());
- }
- else
- {
- CollectNum = float.Parse(CSPrcode.Compute("sum(CollectedNum)", "1=1").ToString());
- OutNum = float.Parse(CSPrcode.Compute("sum(pd_outqty)", "1=1").ToString());
- }
- ProcessCount.Text = CollectNum + "/" + OutNum;
- if (GridPrcode.Rows.Count > 0)
- {
- CurrentPrCode = GridPrcode.Rows[0].Cells["pd_prodcode"].Value.ToString();
- CurrentZXBZ = GridPrcode.Rows[0].Cells["pjd_zxbzs_user"].Value.ToString();
- CurrentUnit = GridPrcode.Rows[0].Cells["pr_unit"].Value.ToString();
- CurrentPDNO = GridPrcode.Rows[0].Cells["pd_pdno"].Value.ToString();
- CurrentPrCount = GridPrcode.Rows[0].Cells["pd_outqty"].Value.ToString();
- CurrentBrand = GridPrcode.Rows[0].Cells["pd_brand"].Value.ToString();
- GridPrcode.Rows[0].Selected = true;
- }
- }
- private void OutBoxNum_Click(object sender, EventArgs e)
- {
- string OutBox = OutBoxNum.Text;
- OutBoxNum.Items.Clear();
- 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");
- ItemObject io = new ItemObject("新增", "新增");
- OutBoxNum.Items.Add(io);
- io = new ItemObject("全部", "全部");
- OutBoxNum.Items.Add(io);
- for (int i = 0; i < dt.Rows.Count; i++)
- {
- string pib_outboxcode2 = dt.Rows[i]["pib_outboxcode2"].ToString();
- io = new ItemObject(pib_outboxcode2, pib_outboxcode2);
- OutBoxNum.Items.Add(io);
- }
- if (OutBoxNum.Text == "新增" || OutBoxNum.Text == "")
- {
- if (dt.Rows.Count > 0)
- OutBoxNum.SelectedIndex = 2;
- else
- OutBoxNum.SelectedIndex = 0;
- }
- if (OutBox != "新增" && OutBox != "")
- OutBoxNum.Text = OutBox;
- }
- string ReSetType = "";
-
-
-
-
-
-
-
-
-
- private void GetBarCodeRule(out string Prefix, out string Suffix, out int MaxNum, out int SerialNumLength, out int Radix, int Count)
- {
-
- Prefix = "";
- Suffix = "";
- NrCode = "";
- MaxNum = 0;
- SerialNumLength = 0;
- Radix = 0;
- DataTable Nr = (DataTable)dh.ExecuteSql("select nvl(nr_resettype,' ')nr_resettype,nr_sharerule,nr_code,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");
-
- if (Nr.Rows.Count == 0)
- Nr = (DataTable)dh.ExecuteSql("select nvl(nr_resettype,' ')nr_resettype,nr_sharerule,nr_code,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");
-
- ReSetType = "";
- if (Nr.Rows.Count > 0)
- {
- string ShareRule = Nr.Rows[0]["nr_sharerule"].ToString();
- DataTable dt1 = (DataTable)dh.ExecuteSql("select nvl(nr_resettype,' ')nr_resettype,nr_sharerule,nr_code,nrd_detno,nrd_name,nrd_radix,nrd_type,nrd_sql,nrd_length from NoRuleDetail left join norule on nrd_nrid=nr_id where nr_code='" + ShareRule + "' order by nrd_detno", "select");
- if (dt1.Rows.Count > 0)
- {
- Nr = dt1;
- }
- else
- {
- if (ShareRule != "")
- {
- MessageBox.Show("共享规则" + ShareRule + "不存在");
- return;
- }
- }
- }
- if (Nr.Rows.Count > 0)
- {
- switch (Nr.Rows[0]["nr_resettype"].ToString())
- {
- case "Year":
- sql.Clear();
- sql.Append("to_char(sysdate,'yyyy')");
- break;
- case "Month":
- sql.Clear();
- sql.Append("to_char(sysdate,'yyyyMM')");
- break;
- case "Week":
- sql.Clear();
- sql.Append("to_char(sysdate,'yyyyiw')");
- break;
- case "Day":
- sql.Clear();
- sql.Append("to_char(sysdate,'yyyyMMdd')");
- break;
- case " ":
- sql.Clear();
- sql.Append("' '");
- break;
- default:
- break;
- }
- ReSetType = dh.getFieldDataByCondition("dual", sql.ToString(), "1=1").ToString();
- }
- Regex match = new Regex("{\\w+}");
-
- string[] NrData = new string[Nr.Rows.Count];
-
- Dictionary<int, string> NrDic = new Dictionary<int, string>();
- for (int m = 0; m < Nr.Rows.Count; m++)
- {
- NrCode = Nr.Rows[m]["nr_code"].ToString();
- switch (Nr.Rows[m]["nrd_type"].ToString())
- {
-
- case "常量":
- Prefix += Nr.Rows[m]["nrd_sql"].ToString();
- Suffix += Nr.Rows[m]["nrd_sql"].ToString();
- break;
- case "SQL":
- string SQL = Nr.Rows[m]["nrd_sql"].ToString();
- DataTable Temp;
-
- if (SQL.IndexOf("{") == 0)
- {
- Temp = (DataTable)dh.ExecuteSql(SQL, "select");
- }
- else
- {
- SQL = SQL.Replace("{pd_pdno}", CurrentPDNO);
-
- foreach (Match mch in match.Matches(SQL))
- {
- SQL = SQL.Replace(mch.Value.Trim(), "'" + pi_inoutno.Text + "'");
- }
- Temp = (DataTable)dh.ExecuteSql(SQL, "select");
- }
- if (Temp.Rows.Count > 0)
- {
- Prefix += Temp.Rows[0][0].ToString();
- Suffix += Temp.Rows[0][0].ToString();
- }
- break;
-
- case "流水":
- string maxnum = "";
- if (ReSetType != " ")
- {
- maxnum = dh.getFieldDataByCondition("RuleMaxNum", "rmn_maxnumber", "rmn_nrcode='" + (NrCode == "" ? "Default" : NrCode) + "' and nvl(rmn_type,' ')='" + ReSetType + "'").ToString();
- }
- else
- {
- maxnum = dh.getFieldDataByCondition("RuleMaxNum", "rmn_maxnumber", "rmn_nrcode='" + (NrCode == "" ? "Default" : NrCode) + "' and rmn_prefix='" + Prefix + "' ").ToString();
- }
-
- if (maxnum == "")
- {
- if (ReSetType != " ")
- {
- maxnum = dh.getFieldDataByCondition("RuleMaxNum", "rmn_maxnumber", "rmn_nrcode='" + (NrCode == "" ? "Default" : NrCode) + "' and nvl(rmn_type,' ')='" + ReSetType + "'").ToString();
- }
- else
- {
- maxnum = dh.getFieldDataByCondition("RuleMaxNum", "rmn_maxnumber", "rmn_nrcode='" + (NrCode == "" ? "Default" : NrCode) + "' and rmn_prefix='" + Prefix + "' ").ToString();
- }
- if (maxnum == "")
- {
- maxnum = "1";
- }
- Count = int.Parse(maxnum) + Count;
- dh.ExecuteSql("insert into RuleMaxNum(rmn_id,rmn_nrcode,rmn_prefix,rmn_maxnumber,rmn_type) values(RuleMaxNum_seq.nextval,'" + (NrCode == "" ? "Default" : NrCode) + "','" + Prefix + "','" + Count + "','" + ReSetType + "')", "insert");
- MaxNum = int.Parse(maxnum);
- }
- else
- {
- MaxNum = int.Parse(maxnum);
- if (ReSetType != " ")
- {
- dh.UpdateByCondition("RULEMAXNUM", "rmn_maxnumber='" + (MaxNum + Count) + "'", "rmn_nrcode='" + (NrCode == "" ? "Default" : NrCode) + "' and nvl(rmn_type,' ')='" + ReSetType + "'");
- }
- else
- {
- dh.UpdateByCondition("RULEMAXNUM", "rmn_maxnumber='" + (MaxNum + Count) + "'", "rmn_nrcode='" + (NrCode == "" ? "Default" : NrCode) + "' and rmn_prefix='" + Prefix + "'");
- }
- }
- SerialNumLength = int.Parse(Nr.Rows[m]["nrd_length"].ToString());
- Radix = int.Parse(Nr.Rows[m]["nrd_radix"].ToString());
- Suffix = "";
- break;
- default:
- break;
- }
- }
- }
- private void GridPrcode_CellEndEdit(object sender, DataGridViewCellEventArgs e)
- {
- string Value = GridPrcode.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString();
- string ID = GridPrcode.Rows[e.RowIndex].Cells["pjd_id"].Value.ToString();
- string checknum = GridPrcode.Rows[e.RowIndex].Cells["checknum"].Value.ToString();
- string pdno = GridPrcode.Rows[e.RowIndex].Cells["pd_pdno"].Value.ToString();
- if (GridPrcode.Columns[e.ColumnIndex].Name == "pjd_zxbzs_user")
- {
- dh.UpdateByCondition("PRODJOINVENDDETAIL", "pjd_zxbzs_user='" + Value + "'", "pjd_id='" + ID + "'");
- dh.UpdateByCondition("CS$INOUTPRCODE", "pjd_zxbzs_user='" + Value + "'", "pjd_id='" + ID + "' and pd_inoutno='" + pi_inoutno.Text + "'");
- }
- if (GridPrcode.Columns[e.ColumnIndex].Name == "checknum")
- {
-
- dh.UpdateByCondition("CS$InoutPrcode", "checknum='" + checknum + "'", "pd_inoutno='" + pi_inoutno.Text + "' and pd_pdno='" + pdno + "' and combined=" + combined);
- }
-
- CurrentPrCode = GridPrcode.Rows[e.RowIndex].Cells["pd_prodcode"].Value.ToString();
- CurrentZXBZ = GridPrcode.Rows[e.RowIndex].Cells["pjd_zxbzs_user"].Value.ToString();
- CurrentUnit = GridPrcode.Rows[e.RowIndex].Cells["pr_unit"].Value.ToString();
- CurrentPDNO = GridPrcode.Rows[e.RowIndex].Cells["pd_pdno"].Value.ToString();
- CurrentPrCount = GridPrcode.Rows[e.RowIndex].Cells["pd_outqty"].Value.ToString();
- CurrentBrand = GridPrcode.Rows[e.RowIndex].Cells["pd_brand"].Value.ToString();
- GridPrcode.Rows[e.RowIndex].Selected = true;
- if (e.RowIndex - 2 >= 0)
- GridPrcode.FirstDisplayedScrollingRowIndex = e.RowIndex - 2;
- else
- GridPrcode.FirstDisplayedScrollingRowIndex = e.RowIndex;
- LoadGridData(sender, new EventArgs());
- }
- private void GridPrcode_SelectionChanged(object sender, EventArgs e)
- {
- if (GridPrcode.SelectedRows.Count > 0)
- {
- DataGridViewSelectedRowCollection dsc = GridPrcode.SelectedRows;
- MachineCollectRowIndex = GridPrcode.SelectedRows[0].Index;
- CurrentPrCode = GridPrcode.Rows[dsc[0].Index].Cells["pd_prodcode"].Value.ToString();
- CurrentZXBZ = GridPrcode.Rows[dsc[0].Index].Cells["pjd_zxbzs_user"].Value.ToString();
- CurrentUnit = GridPrcode.Rows[dsc[0].Index].Cells["pr_unit"].Value.ToString();
- CurrentPDNO = GridPrcode.Rows[dsc[0].Index].Cells["pd_pdno"].Value.ToString();
- CurrentPrCount = GridPrcode.Rows[dsc[0].Index].Cells["pd_outqty"].Value.ToString();
- CurrentBrand = GridPrcode.Rows[dsc[0].Index].Cells["pd_brand"].Value.ToString();
- GridPrcode.Rows[dsc[0].Index].Selected = true;
- if (dsc[0].Index - 2 >= 0)
- GridPrcode.FirstDisplayedScrollingRowIndex = dsc[0].Index - 2;
- else
- GridPrcode.FirstDisplayedScrollingRowIndex = dsc[0].Index;
- }
- }
- private void GridPrcode_DataError(object sender, DataGridViewDataErrorEventArgs e) { }
- private void GridPrcode_CellClick(object sender, DataGridViewCellEventArgs e)
- {
- if (e.RowIndex >= 0)
- {
- GridPrcode.Rows[e.RowIndex].Selected = true;
- if (e.RowIndex - 2 > 0)
- GridPrcode.FirstDisplayedScrollingRowIndex = e.RowIndex - 2;
- else
- GridPrcode.FirstDisplayedScrollingRowIndex = e.RowIndex;
- }
- }
- private void DCCheck_Leave(object sender, EventArgs e)
- {
- try
- {
- Properties.Settings.Default.DCCheck = int.Parse(DCCheck.Text);
- Properties.Settings.Default.Save();
- }
- catch (Exception)
- {
- MessageBox.Show("DC校验时间必须是整数");
- }
- }
-
-
-
-
- private bool CheckDateCode(string DateCode)
- {
- try
- {
-
- string Year = DateCode.Substring(0, 2);
- System.DateTime dt = new System.DateTime(int.Parse("20" + Year), 01, 01);
- string Week = DateCode.Substring(2, 2);
- System.DateTime dt1 = dt.AddDays(int.Parse(Week) * 7);
-
- System.DateTime now = System.DateTime.Now;
- System.DateTime now1 = now.AddDays(-int.Parse(DCCheck.Text));
-
- if (dt1 > now1)
- {
- return true;
- }
- return false;
- }
- catch (Exception)
- {
- return false;
- }
- }
- private void PrintFooter_Click(object sender, EventArgs e)
- {
- FootReport.Load(@"\\10.2.10.238\PRINTE\FASTREPORT\唛头.frx");
- 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");
- string SQL = "select pib_outboxcode2||'/'||(select max(to_number(pib_outboxcode2)) from prodiobarcode where pib_inoutno='" + pi_inoutno.Text + "') from prodiobarcode where pib_id=";
- for (int i = 0; i < dt.Rows.Count; i++)
- {
- DataTable dt1 = (DataTable)dh.ExecuteSql(SQL + dt.Rows[i]["pib_id"].ToString(), "select");
- FootReport.SetParameterValue("唛头", dt1.Rows[0][0].ToString());
- FootReport.PrintSettings.ShowDialog = false;
- FootReport.PrintSettings.Printer = SingleLabelPrinter.Text;
- FootReport.Print();
- }
- LogManager.DoCommandLog(pi_inoutno.Text, User.UserCode, "打印唛头", "成功");
- }
- private void Input_KeyUp(object sender, KeyEventArgs e)
- {
- if (e.KeyCode == Keys.Enter)
- {
- Input.SelectAll();
- }
- }
- private void GridPrcode_CellPainting(object sender, DataGridViewCellPaintingEventArgs e)
- {
- bool mouseOver = e.CellBounds.Contains(this.PointToClient(Cursor.Position));
- if (e.ColumnIndex > 0 && e.RowIndex >= 0)
- {
- if (GridPrcode.Columns[e.ColumnIndex].Name == "CollectedNum")
- {
- SolidBrush solidBrush = new SolidBrush(Color.FromArgb(51, 153, 255));
- if (GridPrcode.Rows[e.RowIndex].Cells["CollectedNum"].Value.ToString() != GridPrcode.Rows[e.RowIndex].Cells["pd_outqty"].Value.ToString())
- e.Graphics.FillRectangle(mouseOver ? solidBrush : Brushes.Yellow, e.CellBounds);
- else
- e.Graphics.FillRectangle(mouseOver ? solidBrush : Brushes.White, e.CellBounds);
- Rectangle border = e.CellBounds;
- border.Width -= 1;
- e.Graphics.DrawRectangle(Pens.White, border);
- e.PaintContent(e.CellBounds);
- e.Handled = true;
- }
- }
- }
- private void GridPrcode_CellMouseUp(object sender, DataGridViewCellMouseEventArgs e)
- {
- if (e.Button == MouseButtons.Right)
- {
- if (e.RowIndex >= 0 && e.ColumnIndex > 0)
- {
- string Conetent = GridPrcode.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString();
- Clipboard.SetText(Conetent);
- MessageBox.Show("已复制内容" + Conetent);
- }
- }
- }
- private void Pack_Click(object sender, EventArgs e)
- {
- if (LabelInf.Rows.Count > 0)
- {
- int GetNumCount = 1;
- for (int i = 0; i < LabelInf.Rows.Count; i++)
- {
- if (LabelInf.Rows[i].Cells["pib_custoutboxcode"].Value.ToString() == "")
- {
- if (i + 1 < LabelInf.Rows.Count)
- {
- string FPrcode = LabelInf.Rows[i].Cells["pib_prodcode"].Value.ToString();
- string FPocode = LabelInf.Rows[i].Cells["pd_pocode"].Value.ToString();
- string FWhcode = LabelInf.Rows[i].Cells["pib_brand"].Value.ToString();
- string FDC = LabelInf.Rows[i].Cells["pib_datecode"].Value.ToString();
- string FLOTNO = LabelInf.Rows[i].Cells["pib_lotno"].Value.ToString();
- string FPDCustProdCode = LabelInf.Rows[i].Cells["pd_custprodcode"].Value.ToString();
- string BPrcode = LabelInf.Rows[i + 1].Cells["pib_prodcode"].Value.ToString();
- string BPocode = LabelInf.Rows[i + 1].Cells["pd_pocode"].Value.ToString();
- string BWhcode = LabelInf.Rows[i + 1].Cells["pib_brand"].Value.ToString();
- string BDC = LabelInf.Rows[i + 1].Cells["pib_datecode"].Value.ToString();
- string BLOTNO = LabelInf.Rows[i + 1].Cells["pib_lotno"].Value.ToString();
- string BPDCustProdCode = LabelInf.Rows[i + 1].Cells["pd_custprodcode"].Value.ToString();
- if (FPDCustProdCode != BPDCustProdCode || FPrcode != BPrcode || FPocode != BPocode || FWhcode != BWhcode || (DiffDC.Checked && FDC != BDC) || (DiffLotNo.Checked && FLOTNO != BLOTNO))
- {
- GetNumCount = GetNumCount + 1;
- }
- }
- }
- }
- GetBarCodeRule(out Prefix, out Suffix, out MaxNum, out NumLength, out Radix, GetNumCount);
- List<string> OutBoxCode = new List<string>();
- List<string> PIBID = new List<string>();
- string Str_OutBoxCode = "";
- for (int i = 0; i < LabelInf.Rows.Count; i++)
- {
- if (LabelInf.Rows[i].Cells["pib_custoutboxcode"].Value.ToString() == "")
- {
- PIBID.Add(LabelInf.Rows[i].Cells["pib_id1"].Value.ToString());
- string serialcode = BaseUtil.DToAny(MaxNum, Radix);
- for (int k = serialcode.ToString().Length; k < NumLength; k++)
- {
- serialcode = "0" + serialcode;
- }
- if (i + 1 < LabelInf.Rows.Count)
- {
- string FPrcode = LabelInf.Rows[i].Cells["pib_prodcode"].Value.ToString();
- string FPocode = LabelInf.Rows[i].Cells["pd_pocode"].Value.ToString();
- string FWhcode = LabelInf.Rows[i].Cells["pib_brand"].Value.ToString();
- string FDC = LabelInf.Rows[i].Cells["pib_datecode"].Value.ToString();
- string FLOTNO = LabelInf.Rows[i].Cells["pib_lotno"].Value.ToString();
- string FPDCustProdCode = LabelInf.Rows[i].Cells["pd_custprodcode"].Value.ToString();
- string FPDNO = LabelInf.Rows[i].Cells["pib_pdno"].Value.ToString();
- string BPrcode = LabelInf.Rows[i + 1].Cells["pib_prodcode"].Value.ToString();
- string BPocode = LabelInf.Rows[i + 1].Cells["pd_pocode"].Value.ToString();
- string BWhcode = LabelInf.Rows[i + 1].Cells["pib_brand"].Value.ToString();
- string BDC = LabelInf.Rows[i + 1].Cells["pib_datecode"].Value.ToString();
- string BLOTNO = LabelInf.Rows[i + 1].Cells["pib_lotno"].Value.ToString();
- string BPDCustProdCode = LabelInf.Rows[i + 1].Cells["pd_custprodcode"].Value.ToString();
- string BPDNO = LabelInf.Rows[i + 1].Cells["pib_pdno"].Value.ToString();
- if ((DiffDetno.Checked && BPDNO != FPDNO) || (DiffCPN.Checked && FPDCustProdCode != BPDCustProdCode) || FPrcode != BPrcode || FPocode != BPocode || FWhcode != BWhcode || (DiffDC.Checked && FDC != BDC) || (DiffLotNo.Checked && FLOTNO != BLOTNO))
- {
- MaxNum = MaxNum + 1;
- }
- }
- OutBoxCode.Add(Prefix + serialcode + Suffix);
- Str_OutBoxCode += "'" + Prefix + serialcode + Suffix + "',";
- }
- }
- if (OutBoxCode.ToArray().Length > 0)
- {
- if (!dh.CheckExist("prodiobarcode", "pib_custcode='" + pi_cardcode.Text + "' and pib_custoutboxcode in (" + Str_OutBoxCode.Substring(0, Str_OutBoxCode.Length - 1) + ")"))
- {
- 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());
- }
- else
- {
- if (ReSetType != " ")
- {
- dh.UpdateByCondition("RULEMAXNUM", "rmn_maxnumber='" + (MaxNum + 1) + "'", "rmn_nrcode='" + (NrCode == "" ? "Default" : NrCode) + "' and nvl(rmn_type,' ')='" + ReSetType + "'");
- }
- else
- {
- dh.UpdateByCondition("RULEMAXNUM", "rmn_maxnumber='" + (MaxNum + 1) + "'", "rmn_nrcode='" + (NrCode == "" ? "Default" : NrCode) + "' and rmn_prefix='" + Prefix + "'");
- }
- Pack_Click(sender, e);
- return;
- }
- LoadGridData(sender, e);
- }
- }
- }
- private void PackMidBox_Click(object sender, EventArgs e)
- {
- DataTable dt = (DataTable)dh.ExecuteSql("select distinct pib_outboxcode2 from prodiobarcode where pib_inoutno='" + pi_inoutno.Text + "' and pib_outboxcode2='" + OutBoxNum.Text + "' order by pib_outboxcode2", "select");
- DataTable dt1 = null;
- int GetNumCount = 0;
- for (int i = 0; i < dt.Rows.Count; i++)
- {
- 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");
-
- int tencount = 0;
- for (int j = 0; j < dt1.Rows.Count; j++)
- {
- 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()))
- {
- GetNumCount = GetNumCount + 1;
- }
- tencount = tencount + 1;
- }
- }
- GetBarCodeRule(out Prefix, out Suffix, out MaxNum, out NumLength, out Radix, GetNumCount);
- if (Radix > 0)
- {
-
- int pib_outboxcode1 = int.Parse(dh.getFieldDataByCondition("prodiobarcode", "max(to_number(nvl(pib_outboxcode1,0)))", "pib_inoutno='" + pi_inoutno.Text + "'").ToString());
- MaxNum = MaxNum - 1;
- for (int i = 0; i < dt.Rows.Count; i++)
- {
- List<string> MidBoxCode = new List<string>();
- List<string> PIBID = new List<string>();
- List<string> PIBOUTBOXCODE1 = new List<string>();
- 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");
-
- int tencount = 0;
- for (int j = 0; j < dt1.Rows.Count; j++)
- {
- 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()))
- {
- pib_outboxcode1 = pib_outboxcode1 + 1;
- MaxNum = MaxNum + 1;
- tencount = 0;
- }
- tencount = tencount + 1;
- string serialcode = BaseUtil.DToAny(MaxNum, Radix);
- for (int k = serialcode.ToString().Length; k < NumLength; k++)
- {
- serialcode = "0" + serialcode;
- }
- MidBoxCode.Add(Prefix + serialcode + Suffix);
- PIBID.Add(dt1.Rows[j]["pib_id"].ToString());
- PIBOUTBOXCODE1.Add(pib_outboxcode1.ToString());
- }
- 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());
- }
- }
- LoadGridData(sender, e);
- }
- private void PrintStatus_Click(object sender, EventArgs e)
- {
- EnablePrint = !EnablePrint;
- if (EnablePrint)
- {
- SetPrintStatus_label.ForeColor = Color.Green;
- SetPrintStatus_label.Text = "可打印";
- }
- else
- {
- SetPrintStatus_label.ForeColor = Color.Red;
- SetPrintStatus_label.Text = "暂停打印";
- }
- Input.Focus();
- }
- private void CustomerLabel_Click(object sender, EventArgs e)
- {
- sql.Clear();
- sql.Append("update prodiobarcode set pib_custbarcode=case when instr(pib_custbarcode,'SL')=0 ");
- sql.Append("then ('SL'||pib_custbarcode)else pib_custbarcode end, pib_custoutboxcode=case when instr");
- sql.Append("(pib_custoutboxcode,'SC')=0 then ('SC'||pib_custoutboxcode)else pib_custoutboxcode end where pib_inoutno='" + pi_inoutno.Text + "'");
- dh.ExecuteSql(sql.ToString(), "select");
- LoadGridData(sender, e);
- CustomerLabel.Enabled = false;
- }
- private void Combindetail_CheckedChanged(object sender, EventArgs e)
- {
- if (Combindetail.Checked)
- {
- CombindetailTwo.Checked = false;
- }
- if (LoadCheck)
- {
- LoadPrcodeData();
- string response = "";
- string[] param = new string[] { PI_ID, "1", response };
- dh.CallProcedure("USER_PRODOUT_GROUPQTY", param);
- }
- }
- private void CombindetailTwo_CheckedChanged(object sender, EventArgs e)
- {
- if (CombindetailTwo.Checked)
- {
- Combindetail.Checked = false;
- }
- if (LoadCheck)
- {
- LoadPrcodeData();
- string response = "";
- string[] param = new string[] { PI_ID, "2", response };
- dh.CallProcedure("USER_PRODOUT_GROUPQTY", param);
- }
- }
- string SelectProdcode = "";
- int SelectRowIndex = -1;
- private void LabelInf_CellClick(object sender, DataGridViewCellEventArgs e)
- {
- if (e.RowIndex >= 0)
- {
- LabelInf.Rows[e.RowIndex].Selected = true;
- SelectRowIndex = e.RowIndex;
- }
- }
- private void OutBoxNum_SelectedIndexChanged(object sender, EventArgs e)
- {
- OutBoxNum1 = OutBoxNum.Text;
- LoadGridData(sender, e);
- }
- private void LabelInf_SelectionChanged(object sender, EventArgs e)
- {
- DataGridViewSelectedRowCollection dsc = LabelInf.SelectedRows;
- if (dsc.Count > 0)
- {
- SelectRowIndex = dsc[0].Index;
- }
- }
- string OutBoxNum1 = "";
- private void OutBoxNum_SelectionChangeCommitted(object sender, EventArgs e)
- {
- if (OutBoxNum1 != "全部" && OutBoxNum1 != "新增")
- if (dh.getFieldDataByCondition("prodiobarcode", "pib_outifprint", "pib_inoutno='" + pi_inoutno.Text + "' and pib_outboxcode2='" + OutBoxNum1 + "'").ToString() != "-1")
- {
- MessageBox.Show("外箱号" + OutBoxNum1 + "尚未打印标签");
- }
- OutBoxNum1 = OutBoxNum.Text;
- if (OutBoxNum1 == "新增")
- {
- PassSixTenCount = 1;
- PassTenCount = 1;
- CurrentBoxNum.Value = 0;
- CurrentOutBoxNum.Value = 0;
- }
- }
- private void Reset_Click(object sender, EventArgs e)
- {
- string close = MessageBox.Show(this.ParentForm, "清除当前已采集数据,刷新待采集数据", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question).ToString();
- if (close.ToString() == "Yes")
- {
- dh.ExecuteSql("delete from prodiobarcode where pib_inoutno='" + pi_inoutno.Text + "'", "delete");
- dh.ExecuteSql("delete from CS$InoutPrcode where pd_inoutno='" + pi_inoutno.Text + "'", "delete");
- dh.UpdateByCondition("prodinout", "pi_user_packingstatus=''", "pi_inoutno='" + pi_inoutno.Text + "'");
- pi_inoutno_KeyDown(sender, new KeyEventArgs(Keys.Enter));
- }
- }
- private void AddNewOutBox_Click(object sender, EventArgs e)
- {
- OutBoxNum.Text = "新增";
- }
- private void GetPDdata_Click(object sender, EventArgs e)
- {
- dh.ExecuteSql("delete from CS$InoutPrcode where pd_inoutno='" + pi_inoutno.Text + "'", "delete");
- LoadPrcodeData();
- 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 + "'");
- MessageBox.Show("同步出货单明细数据成功", "提示");
- }
- private void ResetHBXH_Click(object sender, EventArgs e)
- {
- dh.ExecuteSql("update prodiodetail set PD_HBXH_USER=pd_pdno where pd_inoutno='" + pi_inoutno.Text + "'", "update");
- MessageBox.Show("重置序号成功", "提示");
- }
- private void ButtonWeigh_Click(object sender, EventArgs e)
- {
- if (Weight.Text != "" && Weight.Text != "0.000")
- {
- sql.Clear();
- sql.Append("update prodiobarcode set pib_boxweight='" + Weight.Text + "' where pib_inoutno='" + pi_inoutno.Text + "' ");
- sql.Append(" and pib_outboxcode2='" + OutBoxNum.Text + "'");
- dh.ExecuteSql(sql.ToString(), "update");
- LoadGridData(sender, e);
- }
- else
- {
- MessageBox.Show("请先连接电子秤!");
- }
- }
- Regex reg = new Regex(@"\d+.\d+");
- ComInfoSet cis;
- private void ConnectCom_Click(object sender, EventArgs e)
- {
- cis = new ComInfoSet();
- (cis.Controls["PortName"] as SerialPortCombox).SelectedValue = Properties.Settings.Default.PortName;
- cis.Controls["BaudRate"].Text = Properties.Settings.Default.BaudRate;
- cis.Controls["Confirm"].Click += UAS_出货标签打印_Click;
- cis.ShowDialog();
- }
- private void UAS_出货标签打印_Click(object sender, EventArgs e)
- {
- if (Com.IsOpen && Com.PortName == cis.Controls["PortName"].Text)
- {
- MessageBox.Show("串口" + Com.PortName + "已打开");
- return;
- }
- else
- {
- if (Com.IsOpen)
- {
- Com.Close();
- }
- }
- int BaudRate = 0;
- Com.PortName = cis.Controls["PortName"].Text;
- if (int.TryParse(cis.Controls["BaudRate"].Text, out BaudRate))
- {
- Com.BaudRate = BaudRate;
- }
- Properties.Settings.Default.BaudRate = BaudRate.ToString();
- Properties.Settings.Default.PortName = cis.Controls["PortName"].Text;
- Properties.Settings.Default.Save();
- Com.DataReceived += Com_DataReceived;
- Com.Open();
- cis.Close();
- }
- private void Com_DataReceived(object sender, System.IO.Ports.SerialDataReceivedEventArgs e)
- {
- try
- {
- int len = Com.BytesToRead;
- byte[] readBuffer = new byte[len];
- Com.Read(readBuffer, 0, len);
- string value = reg.Match(Encoding.ASCII.GetString(readBuffer, 0, len)).Value;
- if (value != "")
- {
- Weight.Text = value;
- }
-
- }
- catch (Exception)
- {
- return;
- }
- }
- private void CloseSerialPort_Click(object sender, EventArgs e)
- {
- if (Com.IsOpen)
- {
- Com.Close();
- Com.DataReceived -= Com_DataReceived;
- }
- }
- private void ShowMenu_Total_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
- {
- ShowMenu_Total.Close();
- switch (e.ClickedItem.Text)
- {
- case "清除明细":
- CleanDetail_Click(sender, e);
- break;
- case "标签维护":
- LabelMaintain_Click(sender, e);
- break;
- case "打印唛头":
- PrintFooter_Click(sender, e);
- break;
- case "附加信息":
- AttachInfo_Click(sender, e);
- break;
- case "打印状态":
- PrintStatus_Click(sender, e);
- break;
- case "标签自定义":
- CustomerLabel_Click(sender, e);
- break;
- case "同步出货数据":
- GetPDdata_Click(sender, e);
- break;
- case "重置单据":
- Reset_Click(sender, e);
- break;
- case "贴标机参数设置":
- MachineSetting ms = new MachineSetting();
- BaseUtil.SetFormCenter(ms);
- ms.ShowDialog();
- break;
- case "断开贴标机":
- receiveClient.Close();
- sendClient.Close();
- resetClient.Close();
- break;
- case "贴标角度设置":
- if (pi_cardcode.Text != "")
- {
- 贴标角度设置 ms1 = new 贴标角度设置(pi_cardcode.Text);
- ms1.FormClosed += Ms1_FormClosed;
- BaseUtil.SetFormCenter(ms1);
- ms1.ShowDialog();
- }
- else
- {
- MessageBox.Show("请先获取客户信息");
- }
- break;
- }
- }
- private void Ms1_FormClosed(object sender, FormClosedEventArgs e)
- {
- DataTable XY = (DataTable)dh.ExecuteSql("select * from PRINTXY where px_custcode='" + pi_cardcode.Text + "' and px_machine='" + SystemInf.Machine + "'", "select");
- if (XY.Rows.Count == 0)
- {
- XY = (DataTable)dh.ExecuteSql("select * from PRINTXY where px_custcode='" + pi_cardcode.Text + "'", "select");
- }
- if (XY.Rows.Count > 0)
- {
- Angle = XY.Rows[0]["px_angle"].ToString();
- X = XY.Rows[0]["px_x"].ToString();
- Y = XY.Rows[0]["px_y"].ToString();
- }
- }
- private void MenuManage_Click(object sender, EventArgs e)
- {
- ShowMenu_Total.Show(new Point(MenuManage.Location.X, MenuManage.Location.Y + 20));
- }
- SqliteDBHelper sdh = SystemInf.sdh;
-
- TcpClient receiveClient;
-
- TcpClient sendClient;
-
- TcpClient resetClient;
- NetworkStream ns;
- NetworkStream ns1;
- Thread receiveThread;
- Thread sendThread;
- int dataindex = 0;
- string ps_split = "";
- private void Connect_Click(object sender, EventArgs e)
- {
- SingleLabelAutoPrint.Checked = true;
- MidLabelAutoPrint.Checked = true;
- CurrentRowOnly.Checked = true;
- AutoPrintMidBox.Checked = true;
- receiveClient = new TcpClient();
- sendClient = new TcpClient();
- resetClient = new TcpClient();
- DataTable dt = (DataTable)sdh.ExecuteSql("select * from ParamSetting", "select");
- if (dt.Rows.Count > 0)
- {
- try
- {
-
- receiveClient.Connect(dt.Rows[0]["ps_ip"].ToString(), int.Parse(dt.Rows[0]["ps_receiveport"].ToString()));
- sendClient.Connect(dt.Rows[0]["ps_ip"].ToString(), int.Parse(dt.Rows[0]["ps_sendport"].ToString()));
- resetClient.Connect(dt.Rows[0]["ps_ip"].ToString(), int.Parse(dt.Rows[0]["ps_resetport"].ToString()));
- dataindex = int.Parse(dt.Rows[0]["ps_dataindex"].ToString());
- ps_split = dt.Rows[0]["ps_split"].ToString();
- if (receiveClient != null)
- {
- MessageBox.Show("连接服务器成功");
- ConnectToMachine = true;
-
- ns = receiveClient.GetStream();
- ns1 = sendClient.GetStream();
- Control.CheckForIllegalCrossThreadCalls = false;
-
- receiveThread = new Thread(receive_message);
- receiveThread.Start();
- sendThread = new Thread(send_message);
- sendThread.Start();
- }
- else
- {
- MessageBox.Show("连接服务器失败");
- }
- }
- catch (Exception ex)
- {
- MessageBox.Show(ex.Message);
- }
- }
- }
- bool IsSum = false;
- private void receive_message()
- {
- while (IsOnline(receiveClient))
- {
- try
- {
-
- byte[] getData = new byte[1024];
-
- ns.Read(getData, 0, getData.Length);
-
- string getMsg = Encoding.Default.GetString(getData);
- if (getMsg.Contains("ReadId"))
- {
- string msgStr = getMsg.Trim('\0').Replace("ReadId1|,|", "");
- if (!msgStr.Contains("三星"))
- {
- msgStr = Regex.Match(msgStr, @"[-{0,5}/{0,5}.{0,5}0-9A-Za-z]+\*[-{0,5}/{0,5}.{0,5}0-9A-Za-z]+\*[-{0,5}/{0,5}.{0,5}0-9A-Za-z]+\*[-{0,5}/{0,5}.{0,5}0-9A-Za-z]+\*[-{0,5}/{0,5}.{0,5}0-9A-Za-z]+").Value;
-
-
- Input.Text = msgStr;
- IsSum = false;
- }
- else
- {
- IsSum = true;
- }
- Input_KeyDown(Input, new KeyEventArgs(Keys.Enter));
- }
- }
- catch (Exception e)
- {
-
- break;
-
-
-
-
- }
- }
- MessageBox.Show("网络中断");
- }
- private void send_message()
- {
- while (IsOnline(sendClient))
- {
- try
- {
-
- byte[] getData = new byte[1024];
-
- ns1.Read(getData, 0, getData.Length);
-
- string getMsg = Encoding.Default.GetString(getData);
- if (getMsg.Contains("ReadId3"))
- {
- string msgStr = getMsg.Trim('\0').Replace("ReadId3|,|", "");
- string temp = Regex.Match(msgStr, @"[-{0,5}/{0,5}.{0,5}0-9A-Za-z]+\*[-{0,5}/{0,5}.{0,5}0-9A-Za-z]+\*[-{0,5}/{0,5}.{0,5}0-9A-Za-z]+\*[-{0,5}/{0,5}.{0,5}0-9A-Za-z]+\*[-{0,5}/{0,5}.{0,5}0-9A-Za-z]+").Value;
- string pr_code = "";
-
- if (temp != "")
- {
- pr_code = temp.Split('*')[0];
- }
-
- bool OutBoxSplit = false;
- if (PassSixTenCount > OutboxCapacity.Value)
- {
- string close = MessageBox.Show(this.ParentForm, "此箱号采集后超数量,是否继续?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly).ToString();
- if (close == "Yes")
- {
- OutBoxSplit = true;
- PassSixTenCount = 1;
-
- }
- else
- {
- }
- }
- if (MixPrCode.Checked)
- {
- bool SendLast = false;
- for (int i = 0; i < GridPrcode.Rows.Count; i++)
- {
-
- int checknum = int.Parse(GridPrcode.Rows[i].Cells["checknum"].Value.ToString());
- double outqty = double.Parse(GridPrcode.Rows[i].Cells["pd_outqty"].Value.ToString());
- double zxbzs = double.Parse(GridPrcode.Rows[i].Cells["PJD_ZXBZS_USER"].Value.ToString());
- string Prcode = GridPrcode.Rows[i].Cells["pd_prodcode"].Value.ToString();
- string pdno = GridPrcode.Rows[i].Cells["pd_pdno"].Value.ToString();
- if (checknum < outqty / zxbzs)
- {
- checknum = checknum + 1;
- GridPrcode.Rows[i].Cells["checknum"].Value = checknum;
- dh.ExecuteSql("update CS$InoutPrcode set checknum=nvl(checknum,0)+1 where pd_inoutno='" + pi_inoutno.Text + "' and pd_pdno='" + pdno + "' and combined=" + combined, "update");
- if (i == GridPrcode.Rows.Count - 1 && checknum == outqty / zxbzs)
- SendLast = true;
- break;
- }
- }
- if (PassTenCount == MidboxCapacity.Value)
- {
- sendClient.Client.Send(Encoding.ASCII.GetBytes("ReadId3|,|OK|,|1"));
- PassTenCount = 0;
- }
- else
- {
- if (SendLast)
- {
- sendClient.Client.Send(Encoding.ASCII.GetBytes("ReadId3|,|OK|,|1"));
- string close = MessageBox.Show("采集完此行数据,是否继续?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly).ToString();
- if (close == "Yes")
- {
- }
- else
- {
- }
- }
- else
- {
- if (!OutBoxSplit)
- sendClient.Client.Send(Encoding.ASCII.GetBytes("ReadId3|,|OK|,|0"));
- }
- }
- }
- else
- {
- bool SendLast = false;
- for (int i = 0; i < GridPrcode.Rows.Count; i++)
- {
-
- int checknum = int.Parse(GridPrcode.Rows[i].Cells["checknum"].Value.ToString());
- double outqty = double.Parse(GridPrcode.Rows[i].Cells["pd_outqty"].Value.ToString());
- double zxbzs = double.Parse(GridPrcode.Rows[i].Cells["PJD_ZXBZS_USER"].Value.ToString());
- string Prcode = GridPrcode.Rows[i].Cells["pd_prodcode"].Value.ToString();
- string pdno = GridPrcode.Rows[i].Cells["pd_pdno"].Value.ToString();
- string SelectPrCode = GridPrcode.Rows[MachineCollectRowIndex].Cells["pd_prodcode"].Value.ToString();
- if ((MachineCollectRowIndex == i && SelectPrCode == pr_code) || ((pr_code == Prcode || pr_code == "") && SelectPrCode != pr_code) && checknum < outqty / zxbzs)
- {
- checknum = checknum + 1;
- GridPrcode.Rows[i].Cells["checknum"].Value = checknum;
- if (checknum < outqty / zxbzs)
- {
- dh.ExecuteSql("update CS$InoutPrcode set checknum=nvl(checknum,0)+1 where pd_inoutno='" + pi_inoutno.Text + "' and pd_pdno='" + pdno + "' and combined=" + combined, "update");
- }
- else if (checknum == outqty / zxbzs)
- {
- dh.ExecuteSql("update CS$InoutPrcode set checknum=nvl(checknum,0)+1 where pd_inoutno='" + pi_inoutno.Text + "' and pd_pdno='" + pdno + "' and combined=" + combined, "update");
- sendClient.Client.Send(Encoding.ASCII.GetBytes("ReadId3|,|OK|,|1"));
- checknum = 0;
- SendLast = true;
- PassTenCount = 0;
- string close = MessageBox.Show("采集完此行数据,是否继续?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly).ToString();
- if (close == "Yes")
- {
- }
- else
- {
- }
- }
- break;
- }
- }
-
- if (PassTenCount == MidboxCapacity.Value)
- {
- sendClient.Client.Send(Encoding.ASCII.GetBytes("ReadId3|,|OK|,|1"));
- PassTenCount = 0;
- }
- else
- {
-
- if ((!SendLast && !OutBoxSplit) || OutBoxSplit)
- {
- sendClient.Client.Send(Encoding.ASCII.GetBytes("ReadId3|,|OK|,|0"));
- }
- }
- }
-
- CurrentBoxNum.Value = PassTenCount;
- PassTenCount = PassTenCount + 1;
-
- CurrentOutBoxNum.Value = PassSixTenCount;
- PassSixTenCount = PassSixTenCount + 1;
- }
-
-
-
-
-
-
-
-
-
-
- }
- catch (Exception e)
- {
-
- break;
-
-
-
-
- }
- }
- MessageBox.Show("网络中断");
- }
- private string GetSendCode(string Code)
- {
- if (Angle != "")
- {
- Code = Code + "|,|" + Angle;
- }
- if (X != "")
- {
- Code = Code + "|,|" + X;
- }
- if (Y != "")
- {
- Code = Code + "|,|" + Y;
- }
- return Code;
- }
-
-
-
-
-
- public bool IsOnline(TcpClient c)
- {
- try
- {
- bool result = !((c.Client.Poll(1000, SelectMode.SelectRead) && (c.Client.Available == 0)) || !c.Client.Connected);
- return result;
- }
- catch
- {
- return false;
- }
- }
- private void CurrentBoxNum_ValueChanged(object sender, EventArgs e)
- {
- }
- private void CurrentBoxNum_KeyDown(object sender, KeyEventArgs e)
- {
- if (e.KeyCode == Keys.Enter)
- {
- PassTenCount = int.Parse(CurrentBoxNum.Value.ToString()) + 1;
- }
- }
- private void CurrentOutBoxNum_KeyDown(object sender, KeyEventArgs e)
- {
- if (e.KeyCode == Keys.Enter)
- {
- PassSixTenCount = int.Parse(CurrentOutBoxNum.Value.ToString()) + 1;
- }
- }
- private void richTextAutoBottom1_TextChanged(object sender, EventArgs e)
- {
- }
- private void Weight_Click(object sender, EventArgs e)
- {
- }
- private void groupBoxWithBorder2_Enter(object sender, EventArgs e)
- {
- }
- private void DCCheck_TextChanged(object sender, EventArgs e)
- {
- }
- private void GridPrcode_CellContentClick(object sender, DataGridViewCellEventArgs e)
- {
- }
- private void label18_Click(object sender, EventArgs e)
- {
- }
- private void MidBoxEnd_TextChanged(object sender, EventArgs e)
- {
- }
- private void MidBoxBegin_TextChanged(object sender, EventArgs e)
- {
- }
- private void label16_Click(object sender, EventArgs e)
- {
- }
- private void SingleBoxEnd_TextChanged(object sender, EventArgs e)
- {
- }
- private void SingleBoxBegin_TextChanged(object sender, EventArgs e)
- {
- }
- private void label12_Click(object sender, EventArgs e)
- {
- }
- private void label7_Click(object sender, EventArgs e)
- {
- }
- private void groupBoxWithBorder1_Enter(object sender, EventArgs e)
- {
- }
- private void Input_TextChanged(object sender, EventArgs e)
- {
- }
- private void LabelInf_CellContentClick(object sender, DataGridViewCellEventArgs e)
- {
- }
- private void pi_inoutno_TextChanged(object sender, EventArgs e)
- {
- }
- private void label14_Click(object sender, EventArgs e)
- {
- }
- private void CurrentOutBoxNum_ValueChanged(object sender, EventArgs e)
- {
- }
- private void label13_Click(object sender, EventArgs e)
- {
- }
- private void SingleLabelPrinter_Load(object sender, EventArgs e)
- {
- }
- private void SingleLabelAutoPrint_CheckedChanged(object sender, EventArgs e)
- {
- }
- private void SingleLabel_Enter(object sender, EventArgs e)
- {
- }
- private void CurrentRowOnly_CheckedChanged(object sender, EventArgs e)
- {
- }
- private void MidboxCapacity_ValueChanged(object sender, EventArgs e)
- {
- }
- private void label2_Click(object sender, EventArgs e)
- {
- }
- private void MidLabelNum_TextChanged(object sender, EventArgs e)
- {
- }
- private void label5_Click(object sender, EventArgs e)
- {
- }
- private void MidLabelPrinter_Load(object sender, EventArgs e)
- {
- }
- private void MidLabelAutoPrint_CheckedChanged(object sender, EventArgs e)
- {
- }
- private void MidLabel_Enter(object sender, EventArgs e)
- {
- }
- private void DiffDetno_CheckedChanged(object sender, EventArgs e)
- {
- }
- private void DiffCPN_CheckedChanged(object sender, EventArgs e)
- {
- }
- private void BoxCount_Click(object sender, EventArgs e)
- {
- }
- private void DiffLotNo_CheckedChanged(object sender, EventArgs e)
- {
- }
- private void DiffDC_CheckedChanged(object sender, EventArgs e)
- {
- }
- private void OnlyOneRow_CheckedChanged(object sender, EventArgs e)
- {
- }
- private void AllLabel_CheckedChanged(object sender, EventArgs e)
- {
- }
- private void label10_Click(object sender, EventArgs e)
- {
- }
- private void label6_Click(object sender, EventArgs e)
- {
- }
- private void OutBoxPrinter_Load(object sender, EventArgs e)
- {
- }
- private void OutboxCapacity_ValueChanged(object sender, EventArgs e)
- {
- }
- private void OutBoxLabel_Enter(object sender, EventArgs e)
- {
- }
- private void ButtonMidWeigh_Click(object sender, EventArgs e)
- {
- if (Weight.Text != "" && Weight.Text != "0.000")
- {
- string pib_outboxcode1 = LabelInf.Rows[SelectRowIndex].Cells["pib_outboxcode1"].Value.ToString();
- sql.Clear();
- sql.Append("update prodiobarcode set pib_midboxweight='" + Weight.Text + "' where pib_inoutno='" + pi_inoutno.Text + "' ");
- sql.Append(" and pib_outboxcode2='" + OutBoxNum.Text + "' and pib_outboxcode1='" + pib_outboxcode1 + "'");
- dh.ExecuteSql(sql.ToString(), "update");
- LoadGridData(sender, e);
- }
- else
- {
- MessageBox.Show("请先连接电子秤!");
- }
- }
- }
- }
|