Sin descripción
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Frm_Ship_daily_1.vb 425KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611
  1. Imports System.Data.SqlClient
  2. Imports OfficeOpenXml
  3. Imports System.Net
  4. Imports Microsoft.Office.Interop
  5. Imports System.Windows.Media
  6. Imports Microsoft.Office.Interop.Excel.XlUnderlineStyle
  7. Imports Microsoft.Office.Interop.Excel.Constants
  8. Imports Microsoft.Office.Interop.Excel.XlBordersIndex
  9. Imports Microsoft.Office.Interop.Excel.XlLineStyle
  10. Imports Microsoft.Office.Interop.Excel.XlBorderWeight
  11. Imports Microsoft.Office.Interop.Excel.XlPrintLocation
  12. Imports Microsoft.Office.Interop.Excel.XlPageOrientation
  13. Imports Microsoft.Office.Interop.Excel.XlPaperSize
  14. Imports Microsoft.Office.Interop.Excel.XlOrder
  15. Imports Microsoft.Office.Interop.Excel.XlPrintErrors
  16. 'Imports Excel = Microsoft.Office.Interop.Excel
  17. Imports Microsoft.Office.Core
  18. Imports Microsoft.Office.Interop.Excel.XlThemeColor
  19. Imports Microsoft.Office.Interop.Excel.XlThemeFont
  20. Public Class Frm_Ship_daily_1
  21. Dim cmd As New SqlCommand
  22. Dim da As New SqlDataAdapter
  23. Dim my_year111 As Integer
  24. Dim my_month111 As Integer
  25. Dim mysplit() As String
  26. Dim sql As String
  27. 'Dim my_year As Integer
  28. Dim dt1 As New DataTable
  29. Dim conn As New SqlConnection
  30. Dim xlApp As Microsoft.Office.Interop.Excel.Application
  31. Dim xlBook As Microsoft.Office.Interop.Excel.Workbook
  32. Dim xlSheet As Microsoft.Office.Interop.Excel.Worksheet
  33. Dim xlRange As Microsoft.Office.Interop.Excel.Range
  34. Dim PTCache As Microsoft.Office.Interop.Excel.PivotCache
  35. Dim PT As Microsoft.Office.Interop.Excel.PivotTable
  36. Private Sub Button22_Click(sender As Object, e As EventArgs) Handles Button22.Click
  37. Dim xlApp As Microsoft.Office.Interop.Excel.Application
  38. Dim xlBook As Microsoft.Office.Interop.Excel.Workbook
  39. Dim xlSheet As Microsoft.Office.Interop.Excel.Worksheet
  40. Dim name(1000) As String
  41. Dim no(1000) As String
  42. Dim SERIAL(1000) As String
  43. Dim YEAR1(1000) As String
  44. Dim MONTH1(1000) As String
  45. Dim DATE1(1000) As String
  46. Dim COMMENT(1000) As String
  47. Dim qty(1000) As Double
  48. Dim QTY1(1000) As Double
  49. Dim po_no(1000) As String
  50. Dim sku_no(1000) As String
  51. Dim nw(1000) As Double
  52. Dim gw(1000) As Double
  53. Dim price(1000) As Double
  54. Dim dt As New DataTable
  55. Dim file_name As String = ""
  56. Dim file_name1 As String = ""
  57. ListBox1.Items.Clear()
  58. Dim my_weight As Double = 0
  59. Dim a As Integer = 0
  60. Dim my_count As Integer = 0
  61. 'OpenFileDialog1.Multiselect = True
  62. If OpenFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
  63. file_name = OpenFileDialog1.FileName
  64. file_name1 = OpenFileDialog1.SafeFileName
  65. Else
  66. Exit Sub
  67. End If
  68. Dim yy As Integer = 0
  69. ListBox1.Items.Add(file_name)
  70. Dim my_customer As String = ""
  71. If OpenFileDialog1.SafeFileName Like "*上杰*" And OpenFileDialog1.SafeFileName Like "越南*" Then '---------------------------------------上杰越南货柜
  72. Dim s1 As Integer = 1
  73. sql = "select count(*) from rt_ship_temp_1 where filename=N'" & file_name & "'"
  74. cmd.CommandText = Sql
  75. Dim msg As String
  76. If cmd.ExecuteScalar > 0 Then
  77. msg = MsgBox("资料已经存在,是否要覆盖?", MsgBoxStyle.YesNo, "警告")
  78. If msg = vbNo Then
  79. Exit Sub
  80. End If
  81. End If
  82. If msg = vbYes Then
  83. sql = "delete from rt_ship_temp_1 where filename=N'" & file_name & "'"
  84. cmd.CommandText = sql
  85. cmd.ExecuteNonQuery()
  86. End If
  87. my_weight = 0
  88. xlApp = CreateObject("Excel.Application")
  89. xlApp.Visible = True
  90. xlApp.DisplayAlerts = False
  91. xlBook = xlApp.Workbooks.Open(file_name,, True)
  92. xlBook.Activate()
  93. xlSheet = xlApp.Workbooks(1).Worksheets(1)
  94. xlSheet.Activate()
  95. Dim y As Integer = 0
  96. For y = 14 To xlApp.ActiveSheet.UsedRange.Rows.Count
  97. If Len(xlSheet.Cells(y, 2).value) < 1 Then
  98. Exit For
  99. End If
  100. Next y
  101. xlApp.Range("A14:N" & y - 1).Select()
  102. xlApp.Selection.UnMerge
  103. 'xlApp.Selection.SpecialCells(Microsoft.Office.Interop.Excel.XlCellType.xlCellTypeBlanks).Select
  104. 'xlApp.CutCopyMode = False
  105. 'xlApp.Selection.FormulaR1C1 = "=R[-1]C"
  106. For y = 14 To y - 1
  107. If IsNumeric(xlSheet.Cells(y, 10).value) Then
  108. If xlSheet.Cells(13, 4).value = "张数" Then
  109. sql = "insert into rt_ship_temp_1 (order_item,serial,filename,name,qty,card,po_no,work_no) values(N'" & xlSheet.Cells(y, 9).value & "',N'" & s1 & "',N'" & file_name & "',N'" & xlSheet.Cells(y, 2).value & "'," & xlSheet.Cells(y, 3).value & ",'" & xlSheet.Cells(y, 6).value & "',N'" & xlSheet.Cells(y, 8).value & "',N'" & xlSheet.Cells(y, 12).value & "')"
  110. ElseIf xlSheet.Cells(13, 9).value = "张数" Or xlSheet.Cells(13, 10).value = "张数" Then
  111. sql = "insert into rt_ship_temp_1 (order_item,serial,filename,name,qty,card,po_no,work_no) values(N'" & xlSheet.Cells(y, 8).value & "',N'" & s1 & "',N'" & file_name & "',N'" & xlSheet.Cells(y, 2).value & "'," & xlSheet.Cells(y, 3).value & ",'" & xlSheet.Cells(y, 5).value & "',N'" & xlSheet.Cells(y, 7).value & "',N'" & xlSheet.Cells(y, 12).value & "')"
  112. ElseIf xlSheet.Cells(13, 7).value = "张数" Then
  113. sql = "insert into rt_ship_temp_1 (order_item,serial,filename,name,qty,card,po_no,work_no) values(N'" & xlSheet.Cells(y, 9).value & "',N'" & s1 & "',N'" & file_name & "',N'" & xlSheet.Cells(y, 2).value & "'," & xlSheet.Cells(y, 3).value & ",'" & xlSheet.Cells(y, 4).value & "',N'" & xlSheet.Cells(y, 8).value & "',N'" & xlSheet.Cells(y, 12).value & "')"
  114. ElseIf xlSheet.Cells(13, 5).value = "张数" Then
  115. sql = "insert into rt_ship_temp_1 (order_item,serial,filename,name,qty,card,po_no,work_no) values(N'" & xlSheet.Cells(y, 8).value & "',N'" & s1 & "',N'" & file_name & "',N'" & xlSheet.Cells(y, 2).value & "'," & xlSheet.Cells(y, 10).value & ",'" & xlSheet.Cells(y, 4).value & "',N'" & xlSheet.Cells(y, 7).value & "',N'" & xlSheet.Cells(y, 12).value & "')"
  116. ElseIf xlSheet.Cells(13, 6).value = "张数" Then
  117. sql = "insert into rt_ship_temp_1 (order_item,serial,filename,name,qty,card,po_no,work_no) values(N'" & xlSheet.Cells(y, 8).value & "',N'" & s1 & "',N'" & file_name & "',N'" & xlSheet.Cells(y, 2).value & "'," & xlSheet.Cells(y, 10).value & ",'" & xlSheet.Cells(y, 4).value & "',N'" & xlSheet.Cells(y, 7).value & "',N'" & xlSheet.Cells(y, 12).value & "')"
  118. End If
  119. cmd.CommandText = sql
  120. cmd.ExecuteScalar()
  121. s1 = s1 + 1
  122. Else
  123. End If
  124. Next
  125. sql = "SELECT * FROM rt_ship_daily_sj_vn " '--------------------------改颜色
  126. cmd.CommandText = Sql
  127. dt = New DataTable
  128. da.SelectCommand = cmd
  129. da.Fill(dt)
  130. For x As Integer = 0 To dt.Rows.Count - 1
  131. mysplit = Split(dt.Rows(x).Item("name"), ",")
  132. If UBound(mysplit) = 0 Then
  133. mysplit = Split(dt.Rows(x).Item("name"), ",")
  134. End If
  135. If UBound(mysplit) >= 1 Then
  136. sql = "update rt_ship_temp_1 set color=N'" & mysplit(UBound(mysplit)) & "' where po_no='" & dt.Rows(x).Item("po_no") & "' and name=N'" & dt.Rows(x).Item("name") & "' and work_no='" & dt.Rows(x).Item("work_no") & "' and no='" & dt.Rows(x).Item("no") & "'"
  137. cmd.CommandText = sql
  138. cmd.ExecuteScalar()
  139. Else
  140. sql = "update rt_ship_temp_1 set color=N'" & mysplit(UBound(mysplit)) & "' where po_no='" & dt.Rows(x).Item("po_no") & "' and name=N'" & dt.Rows(x).Item("name") & "' and work_no='" & dt.Rows(x).Item("work_no") & "' and no='" & dt.Rows(x).Item("no") & "'"
  141. cmd.CommandText = sql
  142. cmd.ExecuteScalar()
  143. End If
  144. Next
  145. ElseIf OpenFileDialog1.SafeFileName Like "加和样品*" Then '------------------------------------------------------------------
  146. sql = "select count(*) from rt_ship_temp_1 where filename=N'" & file_name & "'"
  147. cmd.CommandText = Sql
  148. Dim msg As String
  149. If cmd.ExecuteScalar > 0 Then
  150. msg = MsgBox("资料已经存在,是否要覆盖?", MsgBoxStyle.YesNo, "警告")
  151. If msg = vbNo Then
  152. Exit Sub
  153. End If
  154. End If
  155. If msg = vbYes Then
  156. sql = "delete from rt_ship_temp_1 where filename=N'" & file_name & "'"
  157. cmd.CommandText = sql
  158. cmd.ExecuteNonQuery()
  159. End If
  160. xlApp = CreateObject("Excel.Application")
  161. xlApp.Visible = True
  162. xlApp.DisplayAlerts = False
  163. xlBook = xlApp.Workbooks.Open(file_name,, True)
  164. xlBook.Activate()
  165. xlSheet = xlApp.Workbooks(1).Worksheets(1)
  166. Dim y As Integer = 0
  167. For y = 3 To xlApp.Workbooks(1).Worksheets(1).UsedRange.Rows.Count
  168. If xlSheet.Cells(y, 2).value Is Nothing Then
  169. Exit For
  170. End If
  171. Next y
  172. yy = y - 1
  173. 'xlApp.Range("A2:g" & yy).Select()
  174. 'xlApp.Selection.UnMerge
  175. 'xlApp.Selection.SpecialCells(Microsoft.Office.Interop.Excel.XlCellType.xlCellTypeBlanks).Select
  176. 'xlApp.CutCopyMode = False
  177. 'xlApp.Selection.FormulaR1C1 = "=R[-1]C"
  178. Dim my_card As String
  179. Dim my_no As String
  180. Dim my_nw As String
  181. Dim my_gw As String
  182. Dim my_name As String
  183. Dim thick As String
  184. Dim my_comment As String
  185. Dim my_po As String
  186. Dim my_price As String
  187. Dim s1 As String = 1
  188. Dim my_skuno As String
  189. Dim my_order_item As String
  190. Dim my_color As String
  191. For y = 3 To y - 1
  192. If y = 3 Then
  193. my_no = xlSheet.Cells(y, 1).value
  194. my_comment = xlSheet.Cells(y, 7).value
  195. my_color = xlSheet.Cells(y, 5).value
  196. thick = xlSheet.Cells(y, 6).value
  197. my_po = xlSheet.Cells(y, 4).value
  198. End If
  199. If xlSheet.Cells(y, 1).value Is Nothing Then
  200. Else
  201. my_no = xlSheet.Cells(y, 1).value
  202. End If
  203. If Not (xlSheet.Cells(y, 2).value Is Nothing) Then
  204. If xlSheet.Cells(y, 4).value Is Nothing Then
  205. Else
  206. my_comment = xlSheet.Cells(y, 7).value
  207. my_color = xlSheet.Cells(y, 5).value
  208. thick = xlSheet.Cells(y, 6).value
  209. my_po = xlSheet.Cells(y, 4).value
  210. End If
  211. End If
  212. If my_comment Is Nothing Then
  213. sql = "insert into rt_ship_temp_1 (CARD,color1,work_no,thick,po_no,filename,serial,no,name,qty) values(N'" & xlSheet.Cells(y, 3).value & "',N'" & my_color & "',N'" & my_comment & "',N'" & thick & "',N'" & my_po & "',N'" & file_name & "','" & s1 & "','" & my_no & "',N'" & my_color & "','" & xlSheet.Cells(y, 2).value & "')"
  214. Else
  215. sql = "insert into rt_ship_temp_1 (CARD,color1,work_no,thick,po_no,filename,serial,no,name,qty) values(N'" & xlSheet.Cells(y, 3).value & "',N'" & my_color & "',N'" & my_comment.ToString.Replace("'", "''") & "',N'" & thick & "',N'" & my_po & "',N'" & file_name & "','" & s1 & "','" & my_no & "',N'" & my_color & "','" & xlSheet.Cells(y, 2).value & "')"
  216. End If
  217. cmd.CommandText = sql
  218. cmd.ExecuteScalar()
  219. s1 = s1 + 1
  220. Next
  221. ElseIf OpenFileDialog1.SafeFileName Like "名志样品*" Then '------------------------------------------------------------------
  222. sql = "select count(*) from rt_ship_temp_1 where filename=N'" & file_name & "'"
  223. cmd.CommandText = Sql
  224. Dim msg As String
  225. If cmd.ExecuteScalar > 0 Then
  226. msg = MsgBox("资料已经存在,是否要覆盖?", MsgBoxStyle.YesNo, "警告")
  227. If msg = vbNo Then
  228. Exit Sub
  229. End If
  230. End If
  231. If msg = vbYes Then
  232. sql = "delete from rt_ship_temp_1 where filename=N'" & file_name & "'"
  233. cmd.CommandText = sql
  234. cmd.ExecuteNonQuery()
  235. End If
  236. xlApp = CreateObject("Excel.Application")
  237. xlApp.Visible = True
  238. xlApp.DisplayAlerts = False
  239. xlBook = xlApp.Workbooks.Open(file_name,, True)
  240. xlBook.Activate()
  241. xlSheet = xlApp.Workbooks(1).Worksheets(1)
  242. Dim y As Integer = 0
  243. For y = 3 To xlApp.Workbooks(1).Worksheets(1).UsedRange.Rows.Count
  244. If xlSheet.Cells(y, 2).value Is Nothing Then
  245. Exit For
  246. End If
  247. Next y
  248. yy = y - 1
  249. 'xlApp.Range("A2:g" & yy).Select()
  250. 'xlApp.Selection.UnMerge
  251. 'xlApp.Selection.SpecialCells(Microsoft.Office.Interop.Excel.XlCellType.xlCellTypeBlanks).Select
  252. 'xlApp.CutCopyMode = False
  253. 'xlApp.Selection.FormulaR1C1 = "=R[-1]C"
  254. Dim my_card As String
  255. Dim my_no As String
  256. Dim my_nw As String
  257. Dim my_gw As String
  258. Dim my_name As String
  259. Dim thick As String
  260. Dim my_comment As String
  261. Dim my_po As String
  262. Dim my_price As String
  263. Dim s1 As String = 1
  264. Dim my_skuno As String
  265. Dim my_order_item As String
  266. Dim my_color As String
  267. For y = 3 To y - 1
  268. If y = 3 Then
  269. my_no = xlSheet.Cells(y, 1).value
  270. my_comment = xlSheet.Cells(y, 7).value
  271. my_color = xlSheet.Cells(y, 5).value
  272. thick = xlSheet.Cells(y, 6).value
  273. my_po = xlSheet.Cells(y, 4).value
  274. End If
  275. If xlSheet.Cells(y, 1).value Is Nothing Then
  276. Else
  277. my_no = xlSheet.Cells(y, 1).value
  278. End If
  279. If Not (xlSheet.Cells(y, 2).value Is Nothing) Then
  280. If xlSheet.Cells(y, 4).value Is Nothing Then
  281. Else
  282. my_comment = xlSheet.Cells(y, 7).value
  283. my_color = xlSheet.Cells(y, 5).value
  284. thick = xlSheet.Cells(y, 6).value
  285. my_po = xlSheet.Cells(y, 4).value
  286. End If
  287. End If
  288. If my_comment Is Nothing Then
  289. sql = "insert into rt_ship_temp_1 (CARD,color1,work_no,thick,po_no,filename,serial,no,name,qty) values(N'" & xlSheet.Cells(y, 3).value & "',N'" & my_color & "',N'" & my_comment & "',N'" & thick & "',N'" & my_po & "',N'" & file_name & "','" & s1 & "','" & my_no & "',N'" & my_color & "','" & xlSheet.Cells(y, 2).value & "')"
  290. Else
  291. sql = "insert into rt_ship_temp_1 (CARD,color1,work_no,thick,po_no,filename,serial,no,name,qty) values(N'" & xlSheet.Cells(y, 3).value & "',N'" & my_color & "',N'" & my_comment.ToString.Replace("'", "''") & "',N'" & thick & "',N'" & my_po & "',N'" & file_name & "','" & s1 & "','" & my_no & "',N'" & my_color & "','" & xlSheet.Cells(y, 2).value & "')"
  292. End If
  293. cmd.CommandText = sql
  294. cmd.ExecuteScalar()
  295. s1 = s1 + 1
  296. Next
  297. ElseIf OpenFileDialog1.SafeFileName Like "瑞泰出货明细*" And (OpenFileDialog1.SafeFileName Like "*温州*" Or OpenFileDialog1.SafeFileName Like "*湖北*" Or OpenFileDialog1.SafeFileName Like "*泉州*") Then '------------------------------------------------------------------
  298. sql = "select count(*) from rt_ship_temp_1 where filename=N'" & file_name & "'"
  299. cmd.CommandText = Sql
  300. Dim msg As String
  301. If cmd.ExecuteScalar > 0 Then
  302. msg = MsgBox("资料已经存在,是否要覆盖?", MsgBoxStyle.YesNo, "警告")
  303. If msg = vbNo Then
  304. Exit Sub
  305. End If
  306. End If
  307. If msg = vbYes Then
  308. sql = "delete from rt_ship_temp_1 where filename=N'" & file_name & "'"
  309. cmd.CommandText = sql
  310. cmd.ExecuteNonQuery()
  311. End If
  312. xlApp = CreateObject("Excel.Application")
  313. xlApp.Visible = True
  314. xlApp.DisplayAlerts = False
  315. xlBook = xlApp.Workbooks.Open(file_name,, True)
  316. xlBook.Activate()
  317. xlSheet = xlApp.Workbooks(1).Worksheets(1)
  318. Dim y As Integer = 0
  319. For y = 3 To xlApp.Workbooks(1).Worksheets(1).UsedRange.Rows.Count
  320. If Not (IsNumeric(xlSheet.Cells(y, 6).value)) Then
  321. Exit For
  322. End If
  323. Next y
  324. yy = y - 1
  325. 'xlApp.Range("A2:g" & yy).Select()
  326. 'xlApp.Selection.UnMerge
  327. 'xlApp.Selection.SpecialCells(Microsoft.Office.Interop.Excel.XlCellType.xlCellTypeBlanks).Select
  328. 'xlApp.CutCopyMode = False
  329. 'xlApp.Selection.FormulaR1C1 = "=R[-1]C"
  330. Dim my_card As String
  331. Dim my_no As String
  332. Dim my_nw As String
  333. Dim my_gw As String
  334. Dim my_name As String
  335. Dim thick As String
  336. Dim my_comment As String
  337. Dim my_po As String
  338. Dim my_price As String
  339. Dim s1 As String = 1
  340. Dim my_skuno As String
  341. Dim my_order_item As String
  342. Dim my_color As String
  343. For y = 3 To y - 1
  344. If xlSheet.Cells(y, 1).value Is Nothing Then
  345. Else
  346. my_no = xlSheet.Cells(y, 2).value
  347. 'my_comment = xlSheet.Cells(y, 7).value
  348. my_color = xlSheet.Cells(y, 4).value
  349. 'thick = xlSheet.Cells(y, 6).value
  350. my_po = xlSheet.Cells(y, 2).value
  351. sql = "insert into rt_ship_temp_1 (CARD,color1,work_no,thick,po_no,filename,serial,no,name,qty) values(N'" & xlSheet.Cells(y, 3).value & "',N'" & my_color & "',N'" & "',N'" & "',N'" & my_po & "',N'" & file_name & "','" & s1 & "','" & my_no & "',N'" & my_color & "','" & xlSheet.Cells(y, 6).value & "')"
  352. cmd.CommandText = sql
  353. cmd.ExecuteScalar()
  354. s1 = s1 + 1
  355. End If
  356. Next
  357. ElseIf OpenFileDialog1.SafeFileName Like "名扬发货明细*" Then '------------------------------------------------------------------
  358. sql = "select count(*) from rt_ship_temp_1 where filename=N'" & file_name & "'"
  359. cmd.CommandText = Sql
  360. Dim msg As String
  361. If cmd.ExecuteScalar > 0 Then
  362. msg = MsgBox("资料已经存在,是否要覆盖?", MsgBoxStyle.YesNo, "警告")
  363. If msg = vbNo Then
  364. Exit Sub
  365. End If
  366. End If
  367. If msg = vbYes Then
  368. sql = "delete from rt_ship_temp_1 where filename=N'" & file_name & "'"
  369. cmd.CommandText = sql
  370. cmd.ExecuteNonQuery()
  371. End If
  372. xlApp = CreateObject("Excel.Application")
  373. xlApp.Visible = True
  374. xlApp.DisplayAlerts = False
  375. xlBook = xlApp.Workbooks.Open(file_name,, True)
  376. xlBook.Activate()
  377. xlSheet = xlApp.Workbooks(1).Worksheets(1)
  378. Dim y As Integer = 0
  379. For y = 2 To xlApp.Workbooks(1).Worksheets(1).UsedRange.Rows.Count
  380. If IsDBNull(xlSheet.Cells(y, 2).value) Then
  381. Exit For
  382. End If
  383. Next y
  384. yy = y - 1
  385. 'xlApp.Range("A2:g" & yy).Select()
  386. 'xlApp.Selection.UnMerge
  387. 'xlApp.Selection.SpecialCells(Microsoft.Office.Interop.Excel.XlCellType.xlCellTypeBlanks).Select
  388. 'xlApp.CutCopyMode = False
  389. 'xlApp.Selection.FormulaR1C1 = "=R[-1]C"
  390. Dim my_card As String
  391. Dim my_no As String
  392. Dim my_nw As String
  393. Dim my_gw As String
  394. Dim my_name As String
  395. Dim thick As String
  396. Dim my_comment As String
  397. Dim my_po As String
  398. Dim my_price As String
  399. Dim s1 As String = 1
  400. Dim my_skuno As String
  401. Dim my_order_item As String
  402. Dim my_color As String
  403. For y = 2 To y - 1
  404. If xlSheet.Cells(y, 1).value Is Nothing Then
  405. Else
  406. my_no = xlSheet.Cells(y, 1).value
  407. 'my_comment = xlSheet.Cells(y, 7).value
  408. my_color = xlSheet.Cells(y, 2).value
  409. 'thick = xlSheet.Cells(y, 6).value
  410. my_po = xlSheet.Cells(y, 8).value
  411. sql = "insert into rt_ship_temp_1 (CARD,color1,work_no,po_no,filename,serial,no,name,qty) values(N'" & xlSheet.Cells(y, 4).value & "',N'" & my_color & "',N'" & xlSheet.Cells(y, 9).value & "',N'" & my_po & "',N'" & file_name & "','" & s1 & "','" & my_no & "',N'" & my_color & "','" & xlSheet.Cells(y, 3).value & "')"
  412. cmd.CommandText = sql
  413. cmd.ExecuteScalar()
  414. s1 = s1 + 1
  415. End If
  416. Next
  417. ElseIf OpenFileDialog1.SafeFileName Like "*上杰*" And Not (OpenFileDialog1.SafeFileName Like "*越南*") Then '----------------------------------------------------------------------------------上杰
  418. sql = "select count(*) from rt_ship_temp_1 where filename=N'" & file_name & "'"
  419. cmd.CommandText = Sql
  420. Dim msg As String
  421. If cmd.ExecuteScalar > 0 Then
  422. msg = MsgBox("资料已经存在,是否要覆盖?", MsgBoxStyle.YesNo, "警告")
  423. If msg = vbNo Then
  424. Exit Sub
  425. End If
  426. End If
  427. If msg = vbYes Then
  428. sql = "delete from rt_ship_temp_1 where filename=N'" & file_name & "'"
  429. cmd.CommandText = sql
  430. cmd.ExecuteNonQuery()
  431. End If
  432. xlApp = CreateObject("Excel.Application")
  433. xlApp.Visible = True
  434. xlApp.DisplayAlerts = False
  435. xlBook = xlApp.Workbooks.Open(file_name,, True)
  436. xlBook.Activate()
  437. xlSheet = xlApp.Workbooks(1).Worksheets(1)
  438. Dim y As Integer = 0
  439. For y = 14 To xlApp.Workbooks(1).Worksheets(1).UsedRange.Rows.Count
  440. If Len(xlSheet.Cells(y, 2).value) < 1 Then
  441. Exit For
  442. End If
  443. Next y
  444. xlApp.Range("A14:N" & y - 1).Select()
  445. ' If xlApp.Selection.mergecells = True Then
  446. xlApp.Selection.UnMerge
  447. 'xlApp.Selection.SpecialCells(Microsoft.Office.Interop.Excel.XlCellType.xlCellTypeBlanks).Select
  448. 'xlApp.CutCopyMode = False
  449. 'xlApp.Selection.FormulaR1C1 = "=R[-1]C"
  450. ' End If
  451. Dim my_no As String
  452. Dim my_nw As Double
  453. Dim my_gw As Double
  454. Dim my_sf As Double
  455. Dim my_price As Double
  456. Dim s1 As Integer = 1
  457. For y = 14 To y - 1
  458. 'If y = 14 Then
  459. ' my_nw = xlSheet.Cells(y, 6).value
  460. ' my_gw = xlSheet.Cells(y, 7).value
  461. ' my_no = xlSheet.Cells(y, 1).value
  462. 'End If
  463. If xlSheet.Cells(13, 11).value = "订单出货数量" Then
  464. If xlSheet.Cells(y, 11).value Is Nothing Then
  465. Else
  466. If xlSheet.Cells(y, 18).value Is Nothing Then
  467. sql = "insert into rt_ship_temp_1 (work_no,card,filename,serial,order_item,no,name,po_no,qty) values
  468. (N'" & xlSheet.Cells(y, 13).value & "','" & xlSheet.Cells(y, 4).value & "',N'" & file_name & "','" & s1 & "','" & xlSheet.Cells(y, 9).value & "','" & my_no & "',N'" & xlSheet.Cells(y, 2).value & "',N'" & xlSheet.Cells(y, 8).value & "'," & xlSheet.Cells(y, 11).value & ")"
  469. Else
  470. sql = "insert into rt_ship_temp_1 (comment,work_no,card,filename,serial,order_item,no,name,po_no,qty) values
  471. (N'" & xlSheet.Cells(y, 18).value & "','" & xlSheet.Cells(y, 13).value & "','" & xlSheet.Cells(y, 4).value & "',N'" & file_name & "','" & s1 & "','" & xlSheet.Cells(y, 9).value & "','" & my_no & "',N'" & xlSheet.Cells(y, 2).value & "',N'" & xlSheet.Cells(y, 8).value & "'," & xlSheet.Cells(y, 11).value & ")"
  472. End If
  473. cmd.CommandText = sql
  474. cmd.ExecuteScalar()
  475. s1 = s1 + 1
  476. End If
  477. ElseIf xlSheet.Cells(13, 10).value = "订单出货数量" Then
  478. If xlSheet.Cells(y, 10).value Is Nothing Then
  479. Else
  480. If xlSheet.Cells(y, 18).value Is Nothing Then
  481. sql = "insert into rt_ship_temp_1 (work_no,card,filename,serial,order_item,no,name,po_no,qty) values
  482. (N'" & xlSheet.Cells(y, 13).value & "','" & xlSheet.Cells(y, 4).value & "',N'" & file_name & "','" & s1 & "','" & xlSheet.Cells(y, 9).value & "','" & my_no & "',N'" & xlSheet.Cells(y, 2).value & "',N'" & xlSheet.Cells(y, 8).value & "'," & xlSheet.Cells(y, 10).value & ")"
  483. Else
  484. sql = "insert into rt_ship_temp_1 (comment,work_no,card,filename,serial,order_item,no,name,po_no,qty) values
  485. (N'" & xlSheet.Cells(y, 18).value.ToString.Replace("'", " ") & "','" & xlSheet.Cells(y, 13).value & "','" & xlSheet.Cells(y, 4).value & "',N'" & file_name & "','" & s1 & "','" & xlSheet.Cells(y, 9).value & "','" & my_no & "',N'" & xlSheet.Cells(y, 2).value & "',N'" & xlSheet.Cells(y, 8).value & "'," & xlSheet.Cells(y, 10).value & ")"
  486. End If
  487. cmd.CommandText = sql
  488. cmd.ExecuteScalar()
  489. s1 = s1 + 1
  490. End If
  491. ElseIf xlSheet.Cells(13, 9).value = "订单出货数量" Then
  492. If xlSheet.Cells(y, 9).value Is Nothing Then
  493. Else
  494. If xlSheet.Cells(y, 19).value Is Nothing Then
  495. sql = "insert into rt_ship_temp_1 (work_no,card,filename,serial,order_item,no,name,po_no,qty) values
  496. (N'" & xlSheet.Cells(y, 12).value & "','" & xlSheet.Cells(y, 4).value & "',N'" & file_name & "','" & s1 & "','" & xlSheet.Cells(y, 8).value & "','" & my_no & "',N'" & xlSheet.Cells(y, 2).value & "',N'" & xlSheet.Cells(y, 7).value & "'," & xlSheet.Cells(y, 9).value & ")"
  497. Else
  498. sql = "insert into rt_ship_temp_1 (comment,work_no,card,filename,serial,order_item,no,name,po_no,qty) values
  499. (N'" & xlSheet.Cells(y, 19).value.ToString.Replace("'", " ") & "','" & xlSheet.Cells(y, 12).value & "','" & xlSheet.Cells(y, 4).value & "',N'" & file_name & "','" & s1 & "','" & xlSheet.Cells(y, 8).value & "','" & my_no & "',N'" & xlSheet.Cells(y, 2).value & "',N'" & xlSheet.Cells(y, 7).value & "'," & xlSheet.Cells(y, 9).value & ")"
  500. End If
  501. cmd.CommandText = sql
  502. cmd.ExecuteScalar()
  503. s1 = s1 + 1
  504. End If
  505. End If
  506. 'If Not (xlSheet.Cells(y, 10).value Is Nothing) Then '尺数
  507. ' my_sf = xlSheet.Cells(y, 11).value
  508. ' my_price = xlSheet.Cells(y, 12).value
  509. ' If xlSheet.Cells(y, 10).value Is Nothing Then
  510. ' Else
  511. ' If xlSheet.Cells(y, 18).value Is Nothing Then
  512. ' If xlSheet.Cells(13, 10).value = "张数" Then
  513. ' sql = "insert into rt_ship_temp_1 (work_no,card,filename,serial,order_item,no,name,po_no,qty) values
  514. ' (N'" & xlSheet.Cells(y, 13).value & "','" & xlSheet.Cells(y, 5).value & "',N'" & file_name & "','" & s1 & "','" & xlSheet.Cells(y, 9).value & "','" & my_no & "',N'" & xlSheet.Cells(y, 2).value & "',N'" & xlSheet.Cells(y, 8).value & "'," & xlSheet.Cells(y, 11).value & ")"
  515. ' ElseIf xlSheet.Cells(13, 11).value = "张数" Then
  516. ' sql = "insert into rt_ship_temp_1 (work_no,card,filename,serial,order_item,no,name,po_no,qty) values
  517. ' (N'" & xlSheet.Cells(y, 13).value & "','" & xlSheet.Cells(y, 4).value & "',N'" & file_name & "','" & s1 & "','" & xlSheet.Cells(y, 9).value & "','" & my_no & "',N'" & xlSheet.Cells(y, 2).value & "',N'" & xlSheet.Cells(y, 8).value & "'," & xlSheet.Cells(y, 10).value & ")"
  518. ' End If
  519. ' Else
  520. ' If xlSheet.Cells(13, 10).value = "张数" Then
  521. ' sql = "insert into rt_ship_temp_1 (comment,work_no,card,filename,serial,order_item,no,name,po_no,qty) values
  522. ' (N'" & xlSheet.Cells(y, 18).value & "','" & xlSheet.Cells(y, 13).value & "','" & xlSheet.Cells(y, 5).value & "',N'" & file_name & "','" & s1 & "','" & xlSheet.Cells(y, 9).value & "','" & my_no & "',N'" & xlSheet.Cells(y, 2).value & "',N'" & xlSheet.Cells(y, 8).value & "'," & xlSheet.Cells(y, 11).value & ")"
  523. ' ElseIf xlSheet.Cells(13, 11).value = "张数" Then
  524. ' sql = "insert into rt_ship_temp_1 (comment,work_no,card,filename,serial,order_item,no,name,po_no,qty) values
  525. ' (N'" & xlSheet.Cells(y, 18).value & "','" & xlSheet.Cells(y, 14).value & "','" & xlSheet.Cells(y, 4).value & "',N'" & file_name & "','" & s1 & "','" & xlSheet.Cells(y, 9).value & "','" & my_no & "',N'" & xlSheet.Cells(y, 2).value & "',N'" & xlSheet.Cells(y, 8).value & "'," & xlSheet.Cells(y, 10).value & ")"
  526. ' End If
  527. ' End If
  528. ' cmd.CommandText = sql
  529. ' cmd.ExecuteScalar()
  530. ' s1 = s1 + 1
  531. ' End If
  532. 'End If
  533. Next
  534. ' sql = "select 品名,cast(sum(淨重) as numeric(10,1)) as 淨重 from (select case when 品名 like '%PU%' or 品名 like '%action%' or 品名 like N'%榔%' then 'pu' else '反毛' end as 品名,淨重 from (select name as 品名,sum(weight) as 淨重 from (SELECT no, name, qty_sf1, nw,qty_sf1/SUM(qty_sf1) OVER (PARTITION BY no) AS Ratio, cast(qty_sf1/SUM(qty_sf1) OVER (PARTITION BY no) *nw as numeric(10,3)) as weight FROM rt_ship_daily_sj) as p group by name) as q ) as qq group by 品名"
  535. ' cmd.CommandText = sql
  536. ' dt = New DataTable
  537. ' da.SelectCommand = cmd
  538. ' da.Fill(dt)
  539. ' dt.Columns.Add("尺数")
  540. ' dt.Columns.Add("货值")
  541. ' For rr As Integer = 0 To dt.Rows.Count - 1
  542. ' sql = "SELECT CAST(SUM(qty_sf1) AS numeric(10, 1)) AS 呎數 FROM (SELECT DISTINCT no, name, CASE WHEN name LIKE '%PU%' OR name LIKE '%action%' OR name LIKE N'%榔%' THEN 'pu' ELSE '反毛' END AS 品名, qty_sf, unit, nw, gw, po_no, po_serial, qty_sf1, sku_no, order_month, supplier, type, unit_price, cbm FROM rt_ship_daily_sj) AS p
  543. 'GROUP BY 品名 having 品名=N'" & dt.Rows(rr).Item("品名") & "'"
  544. ' cmd.CommandText = sql
  545. ' dt.Rows(rr).Item("尺数") = cmd.ExecuteScalar
  546. ' Next
  547. ' For rr As Integer = 0 To dt.Rows.Count - 1
  548. ' sql = "SELECT CAST(SUM(qty_sf1 * unit_price) AS numeric(10, 3)) AS 金額 FROM (SELECT DISTINCT no, name, CASE WHEN name LIKE '%PU%' OR name LIKE '%action%' OR name LIKE N'%榔%' THEN 'pu' ELSE '反毛' END AS 品名, qty_sf, unit, nw, gw, po_no, po_serial, qty_sf1, sku_no, order_month, supplier, type, unit_price, cbm FROM rt_ship_daily_sj) AS p
  549. 'GROUP BY 品名 having 品名=N'" & dt.Rows(rr).Item("品名") & "'"
  550. ' cmd.CommandText = sql
  551. ' dt.Rows(rr).Item("货值") = cmd.ExecuteScalar
  552. ' Next
  553. ' dgv1.DataSource = dt
  554. sql = "select 品名,po_no as 订购单号,厚度,cast(sum(qty_sf1) as numeric(10,1)) as 尺数,cast(sum(unit_price*qty_sf1)/sum(qty_sf1) as numeric(10,2)) as 单价,cast(sum(unit_price*qty_sf1) as numeric(10,2)) as 货值,sum(净重) as 净重 from
  555. (SELECT no, case when (name like '%PU%' or name like '%action%' or name like N'%榔%') AND name NOT LIKE '%tpu%' then N'贴膜' else '反毛' end as 品名, nw, gw, po_no, qty_sf1, unit_price,case when name like '%1.2%' then '1.24' when name like '%1.4%' then '1.46' else '1.24' end as 厚度,cast(qty_sf1/sum(qty_sf1) over (partition by no) *nw as numeric(10,1)) as 净重
  556. FROM rt_ship_daily_sj) as p group by 品名,po_no,厚度" '----旧
  557. Sql = "select name as 品名 ,po_no as 订单号,order_item as 项次号,cast(sum(qty_sf1) as numeric(10,1)) as 尺数,deli_no as 发货单号 from rt_ship_daily_sj group by name,po_no,order_item,deli_no "
  558. cmd.CommandText = Sql
  559. dt = New DataTable
  560. da.SelectCommand = cmd
  561. da.Fill(dt)
  562. dgv1.DataSource = dt
  563. dgv1.Columns("品名").Width = 300
  564. dgv1.Columns("订单号").Width = 180
  565. dgv1.Columns("项次号").Width = 80
  566. dgv1.Columns("尺数").Width = 120
  567. Sql = "select 品名,颜色,厚度,sum(尺数) as 尺数,sum(货值) as 货值,sum(净重) as 净重 from (select 品名,颜色,po_no as 订购单号,厚度,sum(qty_sf1) as 尺数,sum(unit_price*qty_sf1)/sum(qty_sf1) as 单价,sum(unit_price*qty_sf1) as 货值,sum(净重) as 净重 from
  568. (SELECT no, case when (name like '%PU%' or name like '%action%' or name like N'%榔%') and name not like '%tpu%' then N'贴膜' else '反毛' end as 品名, case when name like '%黑色%' then '黑色' else '其他' end as 颜色, nw, gw, po_no, qty_sf1, unit_price,case when name like '%1.2%' then '1.24' when name like '%1.4%' then '1.46' else '1.24' end as 厚度,cast(qty_sf1/sum(qty_sf1) over (partition by no) *nw as numeric(10,1)) as 净重
  569. FROM rt_ship_daily_sj) as p group by 品名,po_no,厚度,颜色) as q group by 品名,颜色,厚度 order by 品名"
  570. cmd.CommandText = Sql
  571. dt = New DataTable
  572. da.SelectCommand = cmd
  573. da.Fill(dt)
  574. dgv2.DataSource = dt
  575. Sql = "select 品名,颜色,sum(尺数) as 尺数,sum(货值) as 货值,sum(净重) as 净重 from (select 品名,颜色,po_no as 订购单号,厚度,cast(sum(qty_sf1) as numeric(10,1)) as 尺数,cast(sum(unit_price*qty_sf1)/sum(qty_sf1) as numeric(10,2)) as 单价,cast(sum(unit_price*qty_sf1) as numeric(10,2)) as 货值,sum(净重) as 净重 from
  576. (SELECT no, case when (name like '%PU%' or name like '%action%' or name like N'%榔%') and name not like '%tpu%' then N'贴膜' else '反毛' end as 品名, case when name like '%黑色%' then '黑色' else '其他' end as 颜色, nw, gw, po_no, qty_sf1, unit_price,case when name like '%1.2%' then '1.24' when name like '%1.4%' then '1.46' else '1.24' end as 厚度,cast(qty_sf1/sum(qty_sf1) over (partition by no) *nw as numeric(10,1)) as 净重
  577. FROM rt_ship_daily_sj) as p group by 品名,po_no,厚度,颜色) as q group by 品名,颜色 order by 品名"
  578. cmd.CommandText = Sql
  579. dt = New DataTable
  580. da.SelectCommand = cmd
  581. da.Fill(dt)
  582. dgv3.DataSource = dt
  583. ElseIf OpenFileDialog1.SafeFileName Like "*东家*" Or OpenFileDialog1.SafeFileName Like "*东治*" Then '----------------------------------------------------------------------------------东家
  584. sql = "select count(*) from rt_ship_temp_1 where filename=N'" & file_name & "'"
  585. cmd.CommandText = Sql
  586. Dim msg As String
  587. If cmd.ExecuteScalar > 0 Then
  588. msg = MsgBox("资料已经存在,是否要覆盖?", MsgBoxStyle.YesNo, "警告")
  589. If msg = vbNo Then
  590. Exit Sub
  591. End If
  592. End If
  593. If msg = vbYes Then
  594. sql = "delete from rt_ship_temp_1 where filename=N'" & file_name & "'"
  595. cmd.CommandText = sql
  596. cmd.ExecuteNonQuery()
  597. End If
  598. xlApp = CreateObject("Excel.Application")
  599. xlApp.Visible = True
  600. xlApp.DisplayAlerts = False
  601. xlBook = xlApp.Workbooks.Open(file_name,, True)
  602. xlBook.Activate()
  603. xlSheet = xlApp.Workbooks(1).Worksheets(1)
  604. Dim y As Integer = 0
  605. For y = 2 To xlApp.Workbooks(1).Worksheets(1).UsedRange.Rows.Count
  606. If Len(xlSheet.Cells(y, 2).value) < 1 Then
  607. Exit For
  608. End If
  609. Next y
  610. xlApp.Range("A2:L" & y - 1).Select()
  611. ' If xlApp.Selection.mergecells = True Then
  612. xlApp.Selection.UnMerge
  613. 'xlApp.Selection.SpecialCells(Microsoft.Office.Interop.Excel.XlCellType.xlCellTypeBlanks).Select
  614. 'xlApp.CutCopyMode = False
  615. 'xlApp.Selection.FormulaR1C1 = "=R[-1]C"
  616. ' End If
  617. Dim my_no As String
  618. Dim my_nw As Double
  619. Dim my_gw As Double
  620. Dim my_sf As Double
  621. Dim my_price As Double
  622. Dim s1 As Integer = 1
  623. For y = 2 To y - 1
  624. If y = 2 Then
  625. my_no = xlSheet.Cells(y, 1).value
  626. End If
  627. If xlSheet.Cells(y, 1).value Is Nothing Then
  628. Else
  629. my_no = xlSheet.Cells(y, 1).value
  630. End If
  631. sql = "insert into rt_ship_temp_1 (filename,serial,no,po_no,work_no,qty,name) values
  632. (N'" & file_name & "','" & s1 & "','" & my_no & "','" & xlSheet.Cells(y, 8).value & "',N'" & xlSheet.Cells(y, 9).value & "'," & xlSheet.Cells(y, 3).value & ",N'" & xlSheet.Cells(y, 2).value & "')"
  633. cmd.CommandText = sql
  634. cmd.ExecuteScalar()
  635. s1 = s1 + 1
  636. Next
  637. ElseIf OpenFileDialog1.SafeFileName Like "好兄弟*" And Not (OpenFileDialog1.SafeFileName Like "*样品*") And Not (OpenFileDialog1.SafeFileName Like "*手动*") Then '----------------------------------------------------------------------------------好兄弟
  638. sql = "select count(*) from rt_ship_temp_1 where filename=N'" & file_name & "'"
  639. cmd.CommandText = Sql
  640. Dim msg As String
  641. If cmd.ExecuteScalar > 0 Then
  642. msg = MsgBox("资料已经存在,是否要覆盖?", MsgBoxStyle.YesNo, "警告")
  643. If msg = vbNo Then
  644. Exit Sub
  645. End If
  646. End If
  647. If msg = vbYes Then
  648. sql = "delete from rt_ship_temp_1 where filename=N'" & file_name & "'"
  649. cmd.CommandText = sql
  650. cmd.ExecuteNonQuery()
  651. End If
  652. xlApp = CreateObject("Excel.Application")
  653. xlApp.Visible = True
  654. xlApp.DisplayAlerts = False
  655. xlBook = xlApp.Workbooks.Open(file_name,, True)
  656. xlBook.Activate()
  657. Dim my_name As String
  658. Dim my_qty As Double
  659. Dim my_po As String
  660. Dim my_po1 As String
  661. Dim my_name1() As String
  662. Dim my_po_1() As String
  663. For i = 1 To xlApp.Worksheets.Count
  664. xlSheet = xlApp.Worksheets(i)
  665. xlSheet.Activate()
  666. my_name = xlSheet.Cells(4, 1).value
  667. my_qty = xlSheet.Cells(38, 10).value
  668. my_po = xlSheet.Cells(3, 1).value
  669. my_po1 = xlSheet.Cells(3, 8).value
  670. my_name1 = Split(my_name, "材料名称:")
  671. my_po_1 = Split(my_po, "调料单号:")
  672. sql = "insert into rt_ship_temp_1 (filename,color1,serial,po_no,qty,name) values
  673. (N'" & file_name & "',N'" & my_name1(1) & "','" & i & "',N'" & my_po_1(1) & "/" & my_po1 & "'," & my_qty & ",N'" & my_name1(1) & "')"
  674. cmd.CommandText = sql
  675. cmd.ExecuteScalar()
  676. Next
  677. ElseIf OpenFileDialog1.SafeFileName Like "名创*" And Not (OpenFileDialog1.SafeFileName Like "名创发货明细*") And Not (OpenFileDialog1.SafeFileName Like "*手动*") Then '----------------------------------------------------------------------------------
  678. sql = "select count(*) from rt_ship_temp_1 where filename=N'" & file_name & "'"
  679. cmd.CommandText = Sql
  680. Dim msg As String
  681. If cmd.ExecuteScalar > 0 Then
  682. msg = MsgBox("资料已经存在,是否要覆盖?", MsgBoxStyle.YesNo, "警告")
  683. If msg = vbNo Then
  684. Exit Sub
  685. End If
  686. End If
  687. If msg = vbYes Then
  688. sql = "delete from rt_ship_temp_1 where filename=N'" & file_name & "'"
  689. cmd.CommandText = sql
  690. cmd.ExecuteNonQuery()
  691. End If
  692. xlApp = CreateObject("Excel.Application")
  693. xlApp.Visible = True
  694. xlApp.DisplayAlerts = False
  695. xlBook = xlApp.Workbooks.Open(file_name,, True)
  696. xlBook.Activate()
  697. Dim my_name As String
  698. Dim my_qty As Double
  699. Dim my_po As String
  700. Dim my_po1 As String
  701. Dim my_name1() As String
  702. Dim my_po_1() As String
  703. For i = 1 To xlApp.Worksheets.Count
  704. xlSheet = xlApp.Worksheets(i)
  705. xlSheet.Activate()
  706. my_name = xlSheet.Cells(4, 1).value
  707. my_qty = xlSheet.Cells(38, 10).value
  708. my_po = xlSheet.Cells(3, 1).value
  709. my_po1 = xlSheet.Cells(3, 8).value
  710. my_name1 = Split(my_name, "材料名称:")
  711. my_po_1 = Split(my_po, "调料单号:")
  712. sql = "insert into rt_ship_temp_1 (filename,color1,serial,po_no,qty,name) values
  713. (N'" & file_name & "',N'" & my_name1(1) & "','" & i & "',N'" & my_po_1(1) & "/" & my_po1 & "'," & my_qty & ",N'" & my_name1(1) & "')"
  714. cmd.CommandText = sql
  715. cmd.ExecuteScalar()
  716. Next
  717. ElseIf OpenFileDialog1.SafeFileName Like "名越*" And Not (OpenFileDialog1.SafeFileName Like "*名越发货明细*") And Not (OpenFileDialog1.SafeFileName Like "*手动*") Then '----------------------------------------------------------------------------------
  718. sql = "select count(*) from rt_ship_temp_1 where filename=N'" & file_name & "'"
  719. cmd.CommandText = Sql
  720. Dim msg As String
  721. If cmd.ExecuteScalar > 0 Then
  722. msg = MsgBox("资料已经存在,是否要覆盖?", MsgBoxStyle.YesNo, "警告")
  723. If msg = vbNo Then
  724. Exit Sub
  725. End If
  726. End If
  727. If msg = vbYes Then
  728. sql = "delete from rt_ship_temp_1 where filename=N'" & file_name & "'"
  729. cmd.CommandText = sql
  730. cmd.ExecuteNonQuery()
  731. End If
  732. xlApp = CreateObject("Excel.Application")
  733. xlApp.Visible = True
  734. xlApp.DisplayAlerts = False
  735. xlBook = xlApp.Workbooks.Open(file_name,, True)
  736. xlBook.Activate()
  737. Dim my_name As String
  738. Dim my_qty As Double
  739. Dim my_po As String
  740. Dim my_po1 As String
  741. Dim my_name1() As String
  742. Dim my_po_1() As String
  743. For i = 1 To xlApp.Worksheets.Count
  744. xlSheet = xlApp.Worksheets(i)
  745. xlSheet.Activate()
  746. my_name = xlSheet.Cells(4, 1).value
  747. my_qty = xlSheet.Cells(38, 10).value
  748. my_po = xlSheet.Cells(3, 1).value
  749. my_po1 = xlSheet.Cells(3, 8).value
  750. my_name1 = Split(my_name, "材料名称:")
  751. my_po_1 = Split(my_po, "调料单号:")
  752. sql = "insert into rt_ship_temp_1 (filename,color1,serial,po_no,qty,name) values
  753. (N'" & file_name & "',N'" & my_name1(1) & "','" & i & "',N'" & my_po_1(1) & "/" & my_po1 & "'," & my_qty & ",N'" & my_name1(1) & "')"
  754. cmd.CommandText = sql
  755. cmd.ExecuteScalar()
  756. Next
  757. ElseIf OpenFileDialog1.SafeFileName Like "名晋*" And Not (OpenFileDialog1.SafeFileName Like "*手动*") Then '----------------------------------------------------------------------------------
  758. sql = "select count(*) from rt_ship_temp_1 where filename=N'" & file_name & "'"
  759. cmd.CommandText = Sql
  760. Dim msg As String
  761. If cmd.ExecuteScalar > 0 Then
  762. msg = MsgBox("资料已经存在,是否要覆盖?", MsgBoxStyle.YesNo, "警告")
  763. If msg = vbNo Then
  764. Exit Sub
  765. End If
  766. End If
  767. If msg = vbYes Then
  768. sql = "delete from rt_ship_temp_1 where filename=N'" & file_name & "'"
  769. cmd.CommandText = sql
  770. cmd.ExecuteNonQuery()
  771. End If
  772. xlApp = CreateObject("Excel.Application")
  773. xlApp.Visible = True
  774. xlApp.DisplayAlerts = False
  775. xlBook = xlApp.Workbooks.Open(file_name,, True)
  776. xlBook.Activate()
  777. Dim my_name As String
  778. Dim my_qty As Double
  779. Dim my_po As String
  780. Dim my_po1 As String
  781. Dim my_name1() As String
  782. Dim my_po_1() As String
  783. For i = 1 To xlApp.Worksheets.Count
  784. xlSheet = xlApp.Worksheets(i)
  785. xlSheet.Activate()
  786. my_name = xlSheet.Cells(4, 1).value
  787. my_qty = xlSheet.Cells(38, 10).value
  788. my_po = xlSheet.Cells(3, 1).value
  789. my_po1 = xlSheet.Cells(3, 8).value
  790. my_name1 = Split(my_name, "材料名称:")
  791. my_po_1 = Split(my_po, "调料单号:")
  792. sql = "insert into rt_ship_temp_1 (filename,color1,serial,po_no,qty,name) values
  793. (N'" & file_name & "',N'" & Trim(my_name1(1)) & "','" & i & "',N'" & Trim(my_po_1(1)) & "/" & Trim(my_po1) & "'," & my_qty & ",N'" & Trim(my_name1(1)) & "')"
  794. cmd.CommandText = sql
  795. cmd.ExecuteScalar()
  796. Next
  797. ''sql = "insert into rt_ship_temp_1 (filename,serial,no,po_no,work_no,qty,name) values
  798. ' (N'" & file_name & "','" & s1 & "','" & my_no & "','" & xlSheet.Cells(y, 8).value & "',N'" & xlSheet.Cells(y, 9).value & "'," & xlSheet.Cells(y, 3).value & ",N'" & xlSheet.Cells(y, 2).value & "')"
  799. 'cmd.CommandText = sql
  800. 'cmd.ExecuteScalar()
  801. 's1 = s1 + 1
  802. ElseIf OpenFileDialog1.SafeFileName Like "顺泰盛*" And Not (OpenFileDialog1.SafeFileName Like "*手动*") Then '----------------------------------------------------------------------------------
  803. sql = "select count(*) from rt_ship_temp_1 where filename=N'" & file_name & "'"
  804. cmd.CommandText = Sql
  805. Dim msg As String
  806. If cmd.ExecuteScalar > 0 Then
  807. msg = MsgBox("资料已经存在,是否要覆盖?", MsgBoxStyle.YesNo, "警告")
  808. If msg = vbNo Then
  809. Exit Sub
  810. End If
  811. End If
  812. If msg = vbYes Then
  813. sql = "delete from rt_ship_temp_1 where filename=N'" & file_name & "'"
  814. cmd.CommandText = sql
  815. cmd.ExecuteNonQuery()
  816. End If
  817. xlApp = CreateObject("Excel.Application")
  818. xlApp.Visible = True
  819. xlApp.DisplayAlerts = False
  820. xlBook = xlApp.Workbooks.Open(file_name,, True)
  821. xlBook.Activate()
  822. Dim my_name As String
  823. Dim my_qty As Double
  824. Dim my_po As String
  825. Dim my_po1 As String
  826. Dim my_name1() As String
  827. Dim my_po_1() As String
  828. For i = 1 To xlApp.Worksheets.Count
  829. xlSheet = xlApp.Worksheets(i)
  830. xlSheet.Activate()
  831. my_name = xlSheet.Cells(4, 1).value
  832. my_qty = xlSheet.Cells(38, 10).value
  833. my_po = xlSheet.Cells(3, 1).value
  834. my_po1 = xlSheet.Cells(3, 8).value
  835. my_name1 = Split(my_name, "材料名称:")
  836. my_po_1 = Split(my_po, "调料单号:")
  837. sql = "insert into rt_ship_temp_1 (filename,color1,serial,po_no,qty,name) values
  838. (N'" & file_name & "',N'" & my_name1(1) & "','" & i & "',N'" & my_po_1(1) & "/" & my_po1 & "'," & my_qty & ",N'" & my_name1(1) & "')"
  839. cmd.CommandText = sql
  840. cmd.ExecuteScalar()
  841. Next
  842. ''sql = "insert into rt_ship_temp_1 (filename,serial,no,po_no,work_no,qty,name) values
  843. ' (N'" & file_name & "','" & s1 & "','" & my_no & "','" & xlSheet.Cells(y, 8).value & "',N'" & xlSheet.Cells(y, 9).value & "'," & xlSheet.Cells(y, 3).value & ",N'" & xlSheet.Cells(y, 2).value & "')"
  844. 'cmd.CommandText = sql
  845. 'cmd.ExecuteScalar()
  846. 's1 = s1 + 1
  847. ElseIf OpenFileDialog1.SafeFileName Like "*吉兴*" Then '----------------------------------------------------------------------------------吉兴
  848. sql = "select count(*) from rt_ship_temp_1 where filename=N'" & file_name & "'"
  849. cmd.CommandText = Sql
  850. Dim msg As String
  851. If cmd.ExecuteScalar > 0 Then
  852. msg = MsgBox("资料已经存在,是否要覆盖?", MsgBoxStyle.YesNo, "警告")
  853. If msg = vbNo Then
  854. Exit Sub
  855. End If
  856. End If
  857. If msg = vbYes Then
  858. sql = "delete from rt_ship_temp_1 where filename=N'" & file_name & "'"
  859. cmd.CommandText = sql
  860. cmd.ExecuteNonQuery()
  861. End If
  862. xlApp = CreateObject("Excel.Application")
  863. xlApp.Visible = True
  864. xlApp.DisplayAlerts = False
  865. xlBook = xlApp.Workbooks.Open(file_name,, True)
  866. xlBook.Activate()
  867. xlSheet = xlApp.Workbooks(1).Worksheets(1)
  868. Dim y As Integer = 0
  869. For y = 8 To xlApp.Workbooks(1).Worksheets(1).UsedRange.Rows.Count
  870. If Len(xlSheet.Cells(y, 1).value) < 1 Then
  871. Exit For
  872. End If
  873. Next y
  874. 'xlApp.Range("A2:L" & y - 1).Select()
  875. ' If xlApp.Selection.mergecells = True Then
  876. 'xlApp.Selection.UnMerge
  877. 'xlApp.Selection.SpecialCells(Microsoft.Office.Interop.Excel.XlCellType.xlCellTypeBlanks).Select
  878. 'xlApp.CutCopyMode = False
  879. 'xlApp.Selection.FormulaR1C1 = "=R[-1]C"
  880. ' End If
  881. Dim my_no As String
  882. Dim my_nw As Double
  883. Dim my_gw As Double
  884. Dim my_sf As Double
  885. Dim my_price As Double
  886. Dim s1 As Integer = 1
  887. For y = 8 To y - 1
  888. If y = 8 Then
  889. my_no = xlSheet.Cells(y, 1).value
  890. End If
  891. If xlSheet.Cells(y, 1).value Is Nothing Then
  892. Else
  893. my_no = xlSheet.Cells(y, 1).value
  894. End If
  895. sql = "insert into rt_ship_temp_1 (filename,serial,no,po_no,work_no,qty,name) values
  896. (N'" & file_name & "','" & s1 & "','" & my_no & "','" & xlSheet.Cells(y, 2).value & "',N'" & xlSheet.Cells(y, 1).value & "'," & xlSheet.Cells(y, 13).value & ",N'" & xlSheet.Cells(y, 8).value & "')"
  897. cmd.CommandText = sql
  898. cmd.ExecuteScalar()
  899. s1 = s1 + 1
  900. Next
  901. ElseIf OpenFileDialog1.SafeFileName Like "*松城*" And Not (OpenFileDialog1.SafeFileName Like "*手动*") Then '----------------------------------------------------------------------------------松城
  902. sql = "select count(*) from rt_ship_temp_1 where filename=N'" & file_name & "'"
  903. cmd.CommandText = Sql
  904. Dim msg As String
  905. If cmd.ExecuteScalar > 0 Then
  906. msg = MsgBox("资料已经存在,是否要覆盖?", MsgBoxStyle.YesNo, "警告")
  907. If msg = vbNo Then
  908. Exit Sub
  909. End If
  910. End If
  911. If msg = vbYes Then
  912. sql = "delete from rt_ship_temp_1 where filename=N'" & file_name & "'"
  913. cmd.CommandText = sql
  914. cmd.ExecuteNonQuery()
  915. End If
  916. xlApp = CreateObject("Excel.Application")
  917. xlApp.Visible = True
  918. xlApp.DisplayAlerts = False
  919. xlBook = xlApp.Workbooks.Open(file_name,, True)
  920. xlBook.Activate()
  921. xlSheet = xlApp.Workbooks(1).Worksheets(1)
  922. Dim y As Integer = 0
  923. For y = 3 To xlApp.Workbooks(1).Worksheets(1).UsedRange.Rows.Count
  924. If Len(xlSheet.Cells(y, 2).value) < 1 Then
  925. Exit For
  926. End If
  927. Next y
  928. 'xlApp.Range("A2:L" & y - 1).Select()
  929. ' If xlApp.Selection.mergecells = True Then
  930. 'xlApp.Selection.UnMerge
  931. 'xlApp.Selection.SpecialCells(Microsoft.Office.Interop.Excel.XlCellType.xlCellTypeBlanks).Select
  932. 'xlApp.CutCopyMode = False
  933. 'xlApp.Selection.FormulaR1C1 = "=R[-1]C"
  934. ' End If
  935. Dim my_no As String
  936. Dim my_nw As Double
  937. Dim my_gw As Double
  938. Dim my_sf As Double
  939. Dim my_price As Double
  940. Dim s1 As Integer = 1
  941. For y = 3 To y - 1
  942. If y = 3 Then
  943. my_no = xlSheet.Cells(y, 1).value
  944. End If
  945. If xlSheet.Cells(y, 1).value Is Nothing Then
  946. Else
  947. my_no = xlSheet.Cells(y, 1).value
  948. End If
  949. sql = "insert into rt_ship_temp_1 (filename,serial,no,po_no,work_no,qty,name,thick) values
  950. (N'" & file_name & "','" & s1 & "','" & my_no & "','" & xlSheet.Cells(y, 4).value & "',N'" & xlSheet.Cells(y, 7).value & "'," & xlSheet.Cells(y, 2).value & ",N'" & xlSheet.Cells(y, 5).value & "',N'" & xlSheet.Cells(y, 6).value & "')"
  951. cmd.CommandText = sql
  952. cmd.ExecuteScalar()
  953. s1 = s1 + 1
  954. Next
  955. 'Sql = "select name as 品名 ,po_no as 订单号,work_no as 指令号,cast(sum(qty_sf1) as numeric(10,1)) as 尺数,deli_no as 发货单号 from rt_ship_daily_dongjia group by name,po_no,work_no,deli_no "
  956. 'cmd.CommandText = Sql
  957. 'dt = New DataTable
  958. 'da.SelectCommand = cmd
  959. 'da.Fill(dt)
  960. 'dgv1.DataSource = dt
  961. 'dgv1.Columns("品名").Width = 300
  962. 'dgv1.Columns("订单号").Width = 180
  963. 'dgv1.Columns("指令号").Width = 80
  964. 'dgv1.Columns("尺数").Width = 120
  965. ElseIf OpenFileDialog1.SafeFileName Like "*宏福出货柜*" Then '----------------------------------------------------------------------------------上杰
  966. sql = "select count(*) from rt_ship_temp_1 where filename=N'" & file_name & "'"
  967. cmd.CommandText = Sql
  968. Dim msg As String
  969. If cmd.ExecuteScalar > 0 Then
  970. msg = MsgBox("资料已经存在,是否要覆盖?", MsgBoxStyle.YesNo, "警告")
  971. If msg = vbNo Then
  972. Exit Sub
  973. End If
  974. End If
  975. If msg = vbYes Then
  976. sql = "delete from rt_ship_temp_1 where filename=N'" & file_name & "'"
  977. cmd.CommandText = sql
  978. cmd.ExecuteNonQuery()
  979. End If
  980. xlApp = CreateObject("Excel.Application")
  981. xlApp.Visible = True
  982. xlApp.DisplayAlerts = False
  983. xlBook = xlApp.Workbooks.Open(file_name,, True)
  984. xlBook.Activate()
  985. xlSheet = xlApp.Workbooks(1).Worksheets(1)
  986. Dim y As Integer = 0
  987. For y = 14 To xlApp.Workbooks(1).Worksheets(1).UsedRange.Rows.Count
  988. If Len(xlSheet.Cells(y, 2).value) < 1 Then
  989. Exit For
  990. End If
  991. Next y
  992. xlApp.Range("A5:q" & y - 1).Select()
  993. ' If xlApp.Selection.mergecells = True Then
  994. xlApp.Selection.UnMerge
  995. 'xlApp.Selection.SpecialCells(Microsoft.Office.Interop.Excel.XlCellType.xlCellTypeBlanks).Select
  996. 'xlApp.CutCopyMode = False
  997. 'xlApp.Selection.FormulaR1C1 = "=R[-1]C"
  998. ' End If
  999. Dim my_no As String
  1000. Dim my_nw As Double
  1001. Dim my_gw As Double
  1002. Dim my_sf As Double
  1003. Dim my_price As Double
  1004. Dim s1 As Integer = 1
  1005. For y = 5 To y - 1
  1006. sql = "insert into rt_ship_temp_1 (card,serial,filename,name,qty,po_no,order_item,
  1007. work_no,order_month) values
  1008. ('" & xlSheet.Cells(y, 4).value & "',N'" & xlSheet.Cells(y, 1).value & "',N'" & file_name & "',N'" & xlSheet.Cells(y, 2).value & "','" & xlSheet.Cells(y, 3).value & "',N'" & xlSheet.Cells(y, 7).value & "','" & xlSheet.Cells(y, 8).value & "',N'" & xlSheet.Cells(y, 11).value & "','" & xlSheet.Cells(y, 12).value & "')"
  1009. cmd.CommandText = sql
  1010. cmd.ExecuteScalar()
  1011. Next
  1012. Sql = "select name as 品名 ,po_no as 订单号,order_item as 项次号,cast(sum(qty_sf1) as numeric(10,1)) as 尺数,deli_no as 发货单号 from rt_ship_daily_hongfu group by name,po_no,order_item,deli_no "
  1013. cmd.CommandText = Sql
  1014. dt = New DataTable
  1015. da.SelectCommand = cmd
  1016. da.Fill(dt)
  1017. dgv1.DataSource = dt
  1018. dgv1.Columns("品名").Width = 300
  1019. dgv1.Columns("订单号").Width = 180
  1020. dgv1.Columns("项次号").Width = 80
  1021. dgv1.Columns("尺数").Width = 120
  1022. ElseIf OpenFileDialog1.SafeFileName Like "*宏美发货柜*" Then '----------------------------------------------------------------------------------上杰
  1023. sql = "select count(*) from rt_ship_temp_1 where filename=N'" & file_name & "'"
  1024. cmd.CommandText = Sql
  1025. Dim msg As String
  1026. If cmd.ExecuteScalar > 0 Then
  1027. msg = MsgBox("资料已经存在,是否要覆盖?", MsgBoxStyle.YesNo, "警告")
  1028. If msg = vbNo Then
  1029. Exit Sub
  1030. End If
  1031. End If
  1032. If msg = vbYes Then
  1033. sql = "delete from rt_ship_temp_1 where filename=N'" & file_name & "'"
  1034. cmd.CommandText = sql
  1035. cmd.ExecuteNonQuery()
  1036. End If
  1037. xlApp = CreateObject("Excel.Application")
  1038. xlApp.Visible = True
  1039. xlApp.DisplayAlerts = False
  1040. xlBook = xlApp.Workbooks.Open(file_name,, True)
  1041. xlBook.Activate()
  1042. xlSheet = xlApp.Workbooks(1).Worksheets(1)
  1043. Dim y As Integer = 0
  1044. For y = 14 To xlApp.Workbooks(1).Worksheets(1).UsedRange.Rows.Count
  1045. If Len(xlSheet.Cells(y, 2).value) < 1 Then
  1046. Exit For
  1047. End If
  1048. Next y
  1049. xlApp.Range("A5:q" & y - 1).Select()
  1050. ' If xlApp.Selection.mergecells = True Then
  1051. xlApp.Selection.UnMerge
  1052. 'xlApp.Selection.SpecialCells(Microsoft.Office.Interop.Excel.XlCellType.xlCellTypeBlanks).Select
  1053. 'xlApp.CutCopyMode = False
  1054. 'xlApp.Selection.FormulaR1C1 = "=R[-1]C"
  1055. ' End If
  1056. Dim my_no As String
  1057. Dim my_nw As Double
  1058. Dim my_gw As Double
  1059. Dim my_sf As Double
  1060. Dim my_price As Double
  1061. Dim s1 As Integer = 1
  1062. For y = 6 To y - 1
  1063. sql = "insert into rt_ship_temp_1 (card,serial,filename,name,qty,po_no,order_item,
  1064. work_no,order_month) values
  1065. ('" & xlSheet.Cells(y, 4).value & "',N'" & xlSheet.Cells(y, 1).value & "',N'" & file_name & "',N'" & xlSheet.Cells(y, 2).value & "','" & xlSheet.Cells(y, 3).value & "',N'" & xlSheet.Cells(y, 7).value & "','" & xlSheet.Cells(y, 8).value & "',N'" & xlSheet.Cells(y, 11).value & "','" & xlSheet.Cells(y, 12).value & "')"
  1066. cmd.CommandText = sql
  1067. cmd.ExecuteScalar()
  1068. Next
  1069. sql = "select name as 品名 ,po_no as 订单号,order_item as 项次号,cast(sum(qty_sf1) as numeric(10,1)) as 尺数,deli_no as 发货单号 from rt_ship_daily_hongfu group by name,po_no,order_item,deli_no "
  1070. cmd.CommandText = Sql
  1071. dt = New DataTable
  1072. da.SelectCommand = cmd
  1073. da.Fill(dt)
  1074. dgv1.DataSource = dt
  1075. dgv1.Columns("品名").Width = 300
  1076. dgv1.Columns("订单号").Width = 180
  1077. dgv1.Columns("项次号").Width = 80
  1078. dgv1.Columns("尺数").Width = 120
  1079. ElseIf OpenFileDialog1.SafeFileName Like "*欣昌*" Then '----------------------------------------------------------------------------------上杰
  1080. sql = "select count(*) from rt_ship_temp_1 where filename=N'" & file_name & "'"
  1081. cmd.CommandText = Sql
  1082. Dim msg As String
  1083. If cmd.ExecuteScalar > 0 Then
  1084. msg = MsgBox("资料已经存在,是否要覆盖?", MsgBoxStyle.YesNo, "警告")
  1085. If msg = vbNo Then
  1086. Exit Sub
  1087. End If
  1088. End If
  1089. If msg = vbYes Then
  1090. sql = "delete from rt_ship_temp_1 where filename=N'" & file_name & "'"
  1091. cmd.CommandText = sql
  1092. cmd.ExecuteNonQuery()
  1093. End If
  1094. xlApp = CreateObject("Excel.Application")
  1095. xlApp.Visible = True
  1096. xlApp.DisplayAlerts = False
  1097. xlBook = xlApp.Workbooks.Open(file_name,, True)
  1098. xlBook.Activate()
  1099. xlSheet = xlApp.Workbooks(1).Worksheets("PKL")
  1100. Dim y As Integer = 0
  1101. For y = 16 To xlApp.Workbooks(1).Worksheets("PKL").UsedRange.Rows.Count
  1102. If Len(xlSheet.Cells(y, 2).value) < 1 Then
  1103. Exit For
  1104. End If
  1105. Next y
  1106. xlApp.Range("A5:q" & y - 1).Select()
  1107. ' If xlApp.Selection.mergecells = True Then
  1108. xlApp.Selection.UnMerge
  1109. 'xlApp.Selection.SpecialCells(Microsoft.Office.Interop.Excel.XlCellType.xlCellTypeBlanks).Select
  1110. 'xlApp.CutCopyMode = False
  1111. 'xlApp.Selection.FormulaR1C1 = "=R[-1]C"
  1112. ' End If
  1113. Dim my_no As String
  1114. Dim my_nw As Double
  1115. Dim my_gw As Double
  1116. Dim my_sf As Double
  1117. Dim my_price As Double
  1118. Dim s1 As Integer = 1
  1119. For y = 16 To y - 1
  1120. sql = "insert into rt_ship_temp_1 (serial,filename,name,qty,po_no,work_no,THICK) values
  1121. (N'" & s1 & "',N'" & file_name & "',N'" & xlSheet.Cells(y, 3).value & "','" & xlSheet.Cells(y, 6).value & "',N'" & xlSheet.Cells(y, 2).value & "',N'" & xlSheet.Cells(y, 4).value & "',N'" & xlSheet.Cells(y, 5).value & "')"
  1122. cmd.CommandText = sql
  1123. cmd.ExecuteScalar()
  1124. s1 = s1 + 1
  1125. Next
  1126. ElseIf OpenFileDialog1.SafeFileName Like "*ruitai inv*" Then '----------------------------------------------------------------------------------大田
  1127. Dim filename1 As String
  1128. filename1 = file_name & "大田"
  1129. sql = "select count(*) from rt_ship_temp_1 where filename=N'" & filename1 & "'"
  1130. cmd.CommandText = Sql
  1131. Dim msg As String
  1132. If cmd.ExecuteScalar > 0 Then
  1133. msg = MsgBox("资料已经存在,是否要覆盖?", MsgBoxStyle.YesNo, "警告")
  1134. If msg = vbNo Then
  1135. Exit Sub
  1136. End If
  1137. End If
  1138. If msg = vbYes Then
  1139. sql = "delete from rt_ship_temp_1 where filename=N'" & filename1 & "'"
  1140. cmd.CommandText = sql
  1141. cmd.ExecuteNonQuery()
  1142. End If
  1143. xlApp = CreateObject("Excel.Application")
  1144. xlApp.Visible = True
  1145. xlApp.DisplayAlerts = False
  1146. xlBook = xlApp.Workbooks.Open(file_name,, True)
  1147. xlBook.Activate()
  1148. xlSheet = xlApp.Workbooks(1).Worksheets("P&L")
  1149. Dim s1 As Integer = 1
  1150. Dim y As Integer = 0
  1151. For y = 29 To xlApp.Workbooks(1).Worksheets(1).UsedRange.Rows.Count
  1152. If Len(xlSheet.Cells(y, 3).value) < 1 Then
  1153. Exit For
  1154. End If
  1155. Next y
  1156. file_name = file_name & "大田"
  1157. For y = 29 To y - 1
  1158. sql = "insert into rt_ship_temp_1 (serial,filename,name,qty,po_no) values (N'" & s1 & "',N'" & file_name & "',N'" & xlSheet.Cells(y, 3).value & "','" & xlSheet.Cells(y, 7).value & "',N'" & xlSheet.Cells(y, 2).value & "')"
  1159. cmd.CommandText = sql
  1160. cmd.ExecuteScalar()
  1161. s1 += 1
  1162. Next
  1163. ElseIf OpenFileDialog1.SafeFileName Like "*三元*" Then '----------------------------------------------------------------------------------大田
  1164. sql = "select count(*) from rt_ship_temp_1 where filename=N'" & file_name & "'"
  1165. cmd.CommandText = Sql
  1166. Dim msg As String
  1167. If cmd.ExecuteScalar > 0 Then
  1168. msg = MsgBox("资料已经存在,是否要覆盖?", MsgBoxStyle.YesNo, "警告")
  1169. If msg = vbNo Then
  1170. Exit Sub
  1171. End If
  1172. End If
  1173. If msg = vbYes Then
  1174. sql = "delete from rt_ship_temp_1 where filename=N'" & file_name & "'"
  1175. cmd.CommandText = sql
  1176. cmd.ExecuteNonQuery()
  1177. End If
  1178. xlApp = CreateObject("Excel.Application")
  1179. xlApp.Visible = True
  1180. xlApp.DisplayAlerts = False
  1181. xlBook = xlApp.Workbooks.Open(file_name,, True)
  1182. xlBook.Activate()
  1183. xlSheet = xlApp.Workbooks(1).Worksheets("1")
  1184. Dim s1 As Integer = 1
  1185. Dim y As Integer = 0
  1186. For y = 2 To xlApp.Workbooks(1).Worksheets(1).UsedRange.Rows.Count
  1187. If Len(xlSheet.Cells(y, 2).value) < 1 Then
  1188. Exit For
  1189. End If
  1190. Next y
  1191. For y = 2 To y - 1
  1192. sql = "insert into rt_ship_temp_1 (serial,filename,name,qty,po_no,card) values (N'" & s1 & "',N'" & file_name & "',N'" & xlSheet.Cells(y, 2).value & "','" & xlSheet.Cells(y, 3).value & "',N'" & xlSheet.Cells(y, 9).value & "',N'" & xlSheet.Cells(y, 4).value & "')"
  1193. cmd.CommandText = sql
  1194. cmd.ExecuteScalar()
  1195. s1 += 1
  1196. Next
  1197. ElseIf OpenFileDialog1.SafeFileName Like "*宏福出货*" Then '----------------------------------------------------------------------------------
  1198. sql = "select count(*) from rt_ship_temp_1 where filename=N'" & file_name & "'"
  1199. cmd.CommandText = Sql
  1200. Dim msg As String
  1201. If cmd.ExecuteScalar > 0 Then
  1202. msg = MsgBox("资料已经存在,是否要覆盖?", MsgBoxStyle.YesNo, "警告")
  1203. If msg = vbNo Then
  1204. Exit Sub
  1205. End If
  1206. End If
  1207. If msg = vbYes Then
  1208. sql = "delete from rt_ship_temp_1 where filename=N'" & file_name & "'"
  1209. cmd.CommandText = sql
  1210. cmd.ExecuteNonQuery()
  1211. End If
  1212. xlApp = CreateObject("Excel.Application")
  1213. xlApp.Visible = True
  1214. xlApp.DisplayAlerts = False
  1215. xlBook = xlApp.Workbooks.Open(file_name,, True)
  1216. xlBook.Activate()
  1217. xlSheet = xlApp.Workbooks(1).Worksheets("1")
  1218. Dim yyy As Integer = 0
  1219. Dim y As Integer = 0
  1220. For y = 4 To xlApp.Workbooks(1).Worksheets("1").UsedRange.Rows.Count
  1221. If Len(xlSheet.Cells(y, 2).value) < 1 Then
  1222. Exit For
  1223. End If
  1224. Next y
  1225. xlApp.Range("A4:w" & y - 1).Select()
  1226. ' If xlApp.Selection.mergecells = True Then
  1227. xlApp.Selection.UnMerge
  1228. 'xlApp.Selection.SpecialCells(Microsoft.Office.Interop.Excel.XlCellType.xlCellTypeBlanks).Select
  1229. 'xlApp.CutCopyMode = False
  1230. 'xlApp.Selection.FormulaR1C1 = "=R[-1]C"
  1231. ' End If
  1232. Dim my_no As String
  1233. Dim my_nw As Double
  1234. Dim my_gw As Double
  1235. Dim my_sf As Double
  1236. Dim my_price As Double
  1237. Dim s1 As Integer = 1
  1238. For y = 4 To y - 1
  1239. sql = "insert into rt_ship_temp_1 (card,serial,filename,name,qty,po_no,order_item,
  1240. work_no,color1) values ('" & xlSheet.Cells(y, 7).value & "','" & s1 & "',N'" & file_name & "',N'" & xlSheet.Cells(y, 2).value & "'," & xlSheet.Cells(y, 5).value & ",N'" & xlSheet.Cells(y, 15).value & "','" & xlSheet.Cells(y, 14).value & "',N'" & xlSheet.Cells(y, 17).value & "',N'" & xlSheet.Cells(y, 4).value & "')"
  1241. cmd.CommandText = sql
  1242. cmd.ExecuteScalar()
  1243. s1 += 1
  1244. Next
  1245. ElseIf OpenFileDialog1.SafeFileName Like "*永丰*" Then '----------------------------------------------------------------------------------永丰
  1246. sql = "select count(*) from rt_ship_temp_1 where filename=N'" & file_name & "'"
  1247. cmd.CommandText = Sql
  1248. Dim msg As String
  1249. If cmd.ExecuteScalar > 0 Then
  1250. msg = MsgBox("资料已经存在,是否要覆盖?", MsgBoxStyle.YesNo, "警告")
  1251. If msg = vbNo Then
  1252. Exit Sub
  1253. End If
  1254. End If
  1255. If msg = vbYes Then
  1256. sql = "delete from rt_ship_temp_1 where filename=N'" & file_name & "'"
  1257. cmd.CommandText = sql
  1258. cmd.ExecuteNonQuery()
  1259. End If
  1260. xlApp = CreateObject("Excel.Application")
  1261. xlApp.Visible = True
  1262. xlApp.DisplayAlerts = False
  1263. xlBook = xlApp.Workbooks.Open(file_name,, True)
  1264. xlBook.Activate()
  1265. Dim my_total_weight As Double = 0
  1266. Dim s1 As Integer = 1
  1267. Dim s11 As Integer = 1001
  1268. For i = 1 To xlApp.Worksheets.Count
  1269. xlSheet = xlApp.Worksheets(i)
  1270. xlSheet.Activate()
  1271. Dim y As Integer
  1272. For y = xlApp.Workbooks(1).Worksheets(i).UsedRange.Rows.Count To 3 Step -1
  1273. If xlSheet.Cells(y, 1).value = Nothing Then
  1274. If xlSheet.Cells(y, 2).value = "重量" Then
  1275. End If
  1276. GoTo OK5
  1277. End If
  1278. If xlSheet.Cells(y, 1).value.ToString = "数量合计" Then
  1279. Exit For
  1280. End If
  1281. OK5:
  1282. Next y
  1283. Dim yyy As Integer
  1284. For yyy = 3 To xlApp.Workbooks(1).Worksheets(i).UsedRange.Rows.Count
  1285. If xlSheet.Cells(yyy, 14).value = "制 表" Then
  1286. Exit For
  1287. End If
  1288. Next yyy
  1289. If xlSheet.Cells(y + 2, 2).value Like "重量*" Then
  1290. Dim q() As String
  1291. Dim r() As String
  1292. q = Split(xlSheet.Cells(y + 2, 2).value, "重量")
  1293. r = Split(q(1), "KG")
  1294. If IsNumeric(r(0)) Then
  1295. Else
  1296. r = Split(q(1), "kg")
  1297. If IsNumeric(r(0)) Then
  1298. Else
  1299. r = Split(q(1), "Kg")
  1300. End If
  1301. End If
  1302. 'my_total_weight = r(0)
  1303. End If
  1304. xlSheet.Range("A3:A" & y - 1).Select()
  1305. xlApp.Selection.UnMerge
  1306. 'xlApp.Selection.SpecialCells(Microsoft.Office.Interop.Excel.XlCellType.xlCellTypeBlanks).Select
  1307. 'xlApp.CutCopyMode = False
  1308. 'xlApp.Selection.FormulaR1C1 = "=R[-1]C"
  1309. xlSheet.Range("c3:g" & y - 1).Select()
  1310. xlApp.Selection.UnMerge
  1311. 'xlApp.Selection.SpecialCells(Microsoft.Office.Interop.Excel.XlCellType.xlCellTypeBlanks).Select
  1312. 'xlApp.CutCopyMode = False
  1313. 'xlApp.Selection.FormulaR1C1 = "=R[-1]C"
  1314. xlSheet.Range("N3:Q" & yyy - 1).Select()
  1315. xlApp.Selection.UnMerge
  1316. 'xlApp.Selection.SpecialCells(Microsoft.Office.Interop.Excel.XlCellType.xlCellTypeBlanks).Select
  1317. 'xlApp.CutCopyMode = False
  1318. 'xlApp.Selection.FormulaR1C1 = "=R[-1]C"
  1319. If xlSheet.Range("K3:L" & yyy - 1).MergeCells.ToString <> "False" Then
  1320. xlSheet.Range("K3:L" & yyy - 1).Select()
  1321. xlApp.Selection.UnMerge
  1322. 'xlApp.Selection.SpecialCells(Microsoft.Office.Interop.Excel.XlCellType.xlCellTypeBlanks).Select
  1323. 'xlApp.CutCopyMode = False
  1324. 'xlApp.Selection.FormulaR1C1 = "=R[-1]C"
  1325. End If
  1326. Dim my_card As String
  1327. Dim my_no As String
  1328. Dim my_po As String
  1329. Dim my_work As String
  1330. Dim my_color As String
  1331. Dim my_thick As String
  1332. Dim my_no1 As String
  1333. Dim my_po1 As String
  1334. Dim my_work1 As String
  1335. Dim my_color1 As String
  1336. Dim my_thick1 As String
  1337. For y = 3 To y - 1
  1338. If y = 3 Then
  1339. my_no = 3
  1340. my_no1 = xlSheet.Cells(y, 11).value
  1341. my_po = xlSheet.Cells(y, 4).value
  1342. my_work = xlSheet.Cells(y, 5).value
  1343. my_color = xlSheet.Cells(y, 6).value
  1344. my_thick = xlSheet.Cells(y, 7).value
  1345. my_po1 = xlSheet.Cells(y, 14).value
  1346. my_work1 = xlSheet.Cells(y, 15).value
  1347. my_color1 = xlSheet.Cells(y, 16).value
  1348. my_thick1 = xlSheet.Cells(y, 17).value
  1349. End If
  1350. If xlSheet.Cells(y, 2).value = Nothing And xlSheet.Cells(y, 4).value = Nothing And xlSheet.Cells(y, 5).value = Nothing And xlSheet.Cells(y, 6).value = Nothing And xlSheet.Cells(y, 7).value = Nothing Then
  1351. ' Exit For
  1352. Else
  1353. If xlSheet.Cells(y, 2).value Is Nothing Then
  1354. Else
  1355. If xlSheet.Cells(y, 4).VALUE Is Nothing Then
  1356. If xlSheet.Cells(y, 1).value Is Nothing Then
  1357. Else
  1358. my_no = xlSheet.Cells(y, 1).value
  1359. End If
  1360. sql = "insert into rt_ship_temp_1 (filename,card,serial,no,qty,po_no,work_no,color,thick) values(N'" & file_name & "','" & xlSheet.Cells(y, 3).value & "','" & s1 & "','" & my_no & "'," & xlSheet.Cells(y, 2).value & ",N'" & my_po & "',N'" & my_work & "',N'" & my_color & "','" & my_thick & "')"
  1361. cmd.CommandText = sql
  1362. cmd.ExecuteScalar()
  1363. s1 = s1 + 1
  1364. Else
  1365. If xlSheet.Cells(y, 1).value Is Nothing Then
  1366. Else
  1367. my_no = xlSheet.Cells(y, 1).value
  1368. End If
  1369. my_po = xlSheet.Cells(y, 4).value
  1370. my_work = xlSheet.Cells(y, 5).value
  1371. my_color = xlSheet.Cells(y, 6).value
  1372. my_thick = xlSheet.Cells(y, 7).value
  1373. Sql = "insert into rt_ship_daily_yongfong (filename,card,serial,no,qty_sf,po_no,work_no,color,thick) values(N'" & file_name & "','" & xlSheet.Cells(y, 3).value & "','" & s1 & "','" & my_no & "'," & xlSheet.Cells(y, 2).value & ",N'" & xlSheet.Ce & "',N'" & my_work & "',N'" & my_color & "','" & my_thick & "')"
  1374. cmd.CommandText = sql
  1375. cmd.ExecuteScalar()
  1376. sql = "insert into rt_ship_temp_1 (filename,card,serial,no,qty_sf,po_no,work_no,color,thick) values(N'" & file_name & "','" & xlSheet.Cells(y, 3).value & "','" & s1 & "','" & my_no & "'," & xlSheet.Cells(y, 2).value & ",N'" & xlSheet.Ce & "',N'" & my_work & "',N'" & my_color & "','" & my_thick & "')"
  1377. cmd.CommandText = sql
  1378. cmd.ExecuteScalar()
  1379. s1 = s1 + 1
  1380. End If
  1381. End If
  1382. End If
  1383. If xlSheet.Cells(y, 12).value = Nothing And xlSheet.Cells(y, 14).value = Nothing And xlSheet.Cells(y, 15).value = Nothing And xlSheet.Cells(y, 16).value = Nothing And xlSheet.Cells(y, 17).value = Nothing Then
  1384. ' Exit For
  1385. Else
  1386. If xlSheet.Cells(y, 12).value Is Nothing Then
  1387. Else
  1388. If xlSheet.Cells(y, 14).VALUE Is Nothing Then
  1389. If xlSheet.Cells(y, 11).value Is Nothing Then
  1390. Else
  1391. my_no1 = xlSheet.Cells(y, 11).value
  1392. End If
  1393. Sql = "insert into rt_ship_daily_yongfong (filename,card,serial,no,qty_sf,po_no,work_no,color,thick) values(N'" & file_name & "','" & xlSheet.Cells(y, 13).value & "','" & s11 & "','" & my_no1 & "'," & xlSheet.Cells(y, 12).value & ",N'" & my_po1 & "',N'" & my_work1 & "',N'" & my_color1 & "','" & my_thick1 & "')"
  1394. cmd.CommandText = sql
  1395. cmd.ExecuteScalar()
  1396. sql = "insert into rt_ship_temp_1 (filename,card,serial,no,qty_sf,po_no,work_no,color,thick) values(N'" & file_name & "','" & xlSheet.Cells(y, 13).value & "','" & s11 & "','" & my_no1 & "'," & xlSheet.Cells(y, 12).value & ",N'" & my_po1 & "',N'" & my_work1 & "',N'" & my_color1 & "','" & my_thick1 & "')"
  1397. cmd.CommandText = sql
  1398. cmd.ExecuteScalar()
  1399. s11 = s11 + 1
  1400. Else
  1401. If xlSheet.Cells(y, 11).value Is Nothing Then
  1402. Else
  1403. my_no1 = xlSheet.Cells(y, 11).value
  1404. End If
  1405. my_po1 = xlSheet.Cells(y, 14).value
  1406. my_work1 = xlSheet.Cells(y, 15).value
  1407. my_color1 = xlSheet.Cells(y, 16).value
  1408. my_thick1 = xlSheet.Cells(y, 17).value
  1409. Sql = "insert into rt_ship_daily_yongfong (filename,card,serial,no,qty_sf,po_no,work_no,color,thick) values(N'" & file_name & "','" & xlSheet.Cells(y, 13).value & "','" & s11 & "','" & my_no1 & "'," & xlSheet.Cells(y, 12).value & ",N'" & my_po1 & "',N'" & my_work1 & "',N'" & my_color1 & "','" & my_thick1 & "')"
  1410. cmd.CommandText = sql
  1411. cmd.ExecuteScalar()
  1412. sql = "insert into rt_ship_temp_1 (filename,card,serial,no,qty_sf,po_no,work_no,color,thick) values(N'" & file_name & "','" & xlSheet.Cells(y, 13).value & "','" & s11 & "','" & my_no1 & "'," & xlSheet.Cells(y, 12).value & ",N'" & my_po1 & "',N'" & my_work1 & "',N'" & my_color1 & "','" & my_thick1 & "')"
  1413. cmd.CommandText = sql
  1414. cmd.ExecuteScalar()
  1415. s11 = s11 + 1
  1416. End If
  1417. End If
  1418. 'sql = "insert into rt_ship_076_1 (no,sf,order_no,i_no,color,thick) values('" & my_no1 & "'," & xlSheet.Cells(y, 10).value & ",N'" & my_po1 & "',N'" & my_work1 & "',N'" & my_color1 & "','" & my_thick1 & "')"
  1419. 'cmd.CommandText = sql
  1420. 'cmd.ExecuteScalar()
  1421. End If
  1422. Next
  1423. Next
  1424. 'Sql = "SELECT * FROM rt_ship_daily_yongfong" '--------------------------
  1425. 'cmd.CommandText = Sql
  1426. 'dt = New DataTable
  1427. 'da.SelectCommand = cmd
  1428. 'da.Fill(dt)
  1429. 'For x As Integer = 0 To dt.Rows.Count - 1
  1430. ' Sql = "update rt_ship_daily_yongfong set size='"
  1431. ' mysplit = Split(dt.Rows(x).Item("color"), "/")
  1432. ' If UBound(mysplit) > 1 Then
  1433. ' Sql = "update rt_ship_daily_yongfong set color1=N'" & mysplit(UBound(mysplit)) & "' where COLOR=N'" & dt.Rows(x).Item("COLOR") & "' and deli_no='" & dt.Rows(x).Item("deli_no") & "' and serial='" & dt.Rows(x).Item("serial") & "' AND FILENAME=N'" & dt.Rows(x).Item("serial") & "'"
  1434. ' cmd.CommandText = sql
  1435. ' cmd.ExecuteScalar()
  1436. ' sql = "update rt_ship_temp_1 set color1=N'" & mysplit(UBound(mysplit)) & "' where COLOR=N'" & dt.Rows(x).Item("COLOR") & "' and deli_no='" & dt.Rows(x).Item("deli_no") & "' and serial='" & dt.Rows(x).Item("serial") & "' AND FILENAME=N'" & dt.Rows(x).Item("serial") & "'"
  1437. ' cmd.CommandText = sql
  1438. ' cmd.ExecuteScalar()
  1439. ' Else
  1440. ' sql = "update rt_ship_daily_yongfong set color1=N'" & dt.Rows(x).Item("color") & "' where COLOR=N'" & dt.Rows(x).Item("COLOR") & "' and deli_no='" & dt.Rows(x).Item("deli_no") & "' and serial='" & dt.Rows(x).Item("serial") & "' AND FILENAME=N'" & dt.Rows(x).Item("serial") & "'"
  1441. ' cmd.CommandText = sql
  1442. ' cmd.ExecuteScalar()
  1443. ' sql = "update rt_ship_daily_temp_1 set color1=N'" & dt.Rows(x).Item("color") & "' where COLOR=N'" & dt.Rows(x).Item("COLOR") & "' and deli_no='" & dt.Rows(x).Item("deli_no") & "' and serial='" & dt.Rows(x).Item("serial") & "' AND FILENAME=N'" & dt.Rows(x).Item("serial") & "'"
  1444. ' cmd.CommandText = sql
  1445. ' cmd.ExecuteScalar()
  1446. ' End If
  1447. 'Next
  1448. sql = "SELECT po_no AS 订单号, work_no AS 指令号, color AS 颜色, thick AS 厚度, cast(SUM(qty_sf) as numeric(10,1)) AS 尺数,deli as 发货单号 FROM RT_ship_daily_yongfong GROUP BY po_no, work_no, color,thick,deli ORDER BY 订单号, 指令号, 颜色"
  1449. cmd.CommandText = Sql
  1450. dt = New DataTable
  1451. da.SelectCommand = cmd
  1452. da.Fill(dt)
  1453. dgv1.DataSource = dt
  1454. 'dt.Columns.Add("货值")
  1455. ElseIf OpenFileDialog1.SafeFileName Like "*永正货柜*" Then '--------------------------------------------------------------------------永正货柜
  1456. sql = "select count(*) from rt_ship_temp_1 where filename=N'" & file_name & "'"
  1457. cmd.CommandText = sql
  1458. Dim msg As String
  1459. If cmd.ExecuteScalar > 0 Then
  1460. msg = MsgBox("资料已经存在,是否要覆盖?", MsgBoxStyle.YesNo, "警告")
  1461. If msg = vbNo Then
  1462. Exit Sub
  1463. End If
  1464. End If
  1465. If msg = vbYes Then
  1466. sql = "delete from rt_ship_temp_1 where filename=N'" & file_name & "'"
  1467. cmd.CommandText = sql
  1468. cmd.ExecuteNonQuery()
  1469. End If
  1470. xlApp = CreateObject("Excel.Application")
  1471. xlApp.Visible = True
  1472. xlApp.DisplayAlerts = False
  1473. xlBook = xlApp.Workbooks.Open(file_name,, True)
  1474. xlBook.Activate()
  1475. xlSheet = xlApp.Workbooks(1).Worksheets(1)
  1476. Dim y As Integer = 0
  1477. For y = 14 To xlApp.Workbooks(1).Worksheets(1).UsedRange.Rows.Count
  1478. If Len(xlSheet.Cells(y, 2).value) < 1 Then
  1479. Exit For
  1480. End If
  1481. Next y
  1482. xlApp.Range("A14:N" & y - 1).Select()
  1483. ' If xlApp.Selection.mergecells = True Then
  1484. xlApp.Selection.UnMerge
  1485. 'xlApp.Selection.SpecialCells(Microsoft.Office.Interop.Excel.XlCellType.xlCellTypeBlanks).Select
  1486. 'xlApp.CutCopyMode = False
  1487. 'xlApp.Selection.FormulaR1C1 = "=R[-1]C"
  1488. ' End If
  1489. Dim mc As Integer = 1
  1490. For y = 14 To y - 1
  1491. sql = "insert into rt_ship_temp_1 (filename,work_no,order_item,card,no,name,qty,po_no,serial) values(N'" & file_name & "',N'" & xlSheet.Cells(y, 10).value &
  1492. "',N'" & xlSheet.Cells(y, 8).value & "',N'" & xlSheet.Cells(y, 4).value & "',N'" &
  1493. xlSheet.Cells(y, 1).value & "',N'" & xlSheet.Cells(y, 2).value & "'," & xlSheet.Cells(y, 3).value & ",N'" & xlSheet.Cells(y, 7).value & "'," & mc & ")"
  1494. cmd.CommandText = sql
  1495. cmd.ExecuteScalar()
  1496. mc = mc + 1
  1497. Next
  1498. ElseIf OpenFileDialog1.SafeFileName Like "*永弘出货*" Then '--------------------------------------------------------------------------永正货柜
  1499. sql = "select count(*) from rt_ship_temp_1 where filename=N'" & file_name & "'"
  1500. cmd.CommandText = sql
  1501. Dim msg As String
  1502. If cmd.ExecuteScalar > 0 Then
  1503. msg = MsgBox("资料已经存在,是否要覆盖?", MsgBoxStyle.YesNo, "警告")
  1504. If msg = vbNo Then
  1505. Exit Sub
  1506. End If
  1507. End If
  1508. If msg = vbYes Then
  1509. sql = "delete from rt_ship_temp_1 where filename=N'" & file_name & "'"
  1510. cmd.CommandText = sql
  1511. cmd.ExecuteNonQuery()
  1512. End If
  1513. xlApp = CreateObject("Excel.Application")
  1514. xlApp.Visible = True
  1515. xlApp.DisplayAlerts = False
  1516. xlBook = xlApp.Workbooks.Open(file_name,, True)
  1517. xlBook.Activate()
  1518. xlSheet = xlApp.Workbooks(1).Worksheets(1)
  1519. Dim y As Integer = 0
  1520. For y = 4 To xlApp.Workbooks(1).Worksheets(1).UsedRange.Rows.Count
  1521. If Len(xlSheet.Cells(y, 2).value) < 1 Then
  1522. Exit For
  1523. End If
  1524. Next y
  1525. xlApp.Range("A14:N" & y - 1).Select()
  1526. ' If xlApp.Selection.mergecells = True Then
  1527. xlApp.Selection.UnMerge
  1528. 'xlApp.Selection.SpecialCells(Microsoft.Office.Interop.Excel.XlCellType.xlCellTypeBlanks).Select
  1529. 'xlApp.CutCopyMode = False
  1530. 'xlApp.Selection.FormulaR1C1 = "=R[-1]C"
  1531. ' End If
  1532. Dim mc As Integer = 1
  1533. For y = 4 To y - 1
  1534. sql = "insert into rt_ship_temp_1 (filename,order_item,name,qty,po_no,serial) values(N'" & file_name & "',N'" & xlSheet.Cells(y, 12).value & "',N'" & xlSheet.Cells(y, 2).value & "'," & xlSheet.Cells(y, 4).value & ",N'" & xlSheet.Cells(y, 13).value & "'," & mc & ")"
  1535. cmd.CommandText = sql
  1536. cmd.ExecuteScalar()
  1537. mc = mc + 1
  1538. Next
  1539. ElseIf OpenFileDialog1.SafeFileName Like "*永弘*" And Not (OpenFileDialog1.SafeFileName Like "*手动*") Then '--------------------------------------------------------------------------永正货柜
  1540. sql = "select count(*) from rt_ship_temp_1 where filename=N'" & file_name & "'"
  1541. cmd.CommandText = sql
  1542. Dim msg As String
  1543. If cmd.ExecuteScalar > 0 Then
  1544. msg = MsgBox("资料已经存在,是否要覆盖?", MsgBoxStyle.YesNo, "警告")
  1545. If msg = vbNo Then
  1546. Exit Sub
  1547. End If
  1548. End If
  1549. If msg = vbYes Then
  1550. sql = "delete from rt_ship_temp_1 where filename=N'" & file_name & "'"
  1551. cmd.CommandText = sql
  1552. cmd.ExecuteNonQuery()
  1553. End If
  1554. xlApp = CreateObject("Excel.Application")
  1555. xlApp.Visible = True
  1556. xlApp.DisplayAlerts = False
  1557. xlBook = xlApp.Workbooks.Open(file_name,, True)
  1558. xlBook.Activate()
  1559. xlSheet = xlApp.Workbooks(1).Worksheets(1)
  1560. Dim y As Integer = 0
  1561. For y = 14 To xlApp.Workbooks(1).Worksheets(1).UsedRange.Rows.Count
  1562. If Len(xlSheet.Cells(y, 2).value) < 1 Then
  1563. Exit For
  1564. End If
  1565. Next y
  1566. xlApp.Range("A14:N" & y - 1).Select()
  1567. ' If xlApp.Selection.mergecells = True Then
  1568. xlApp.Selection.UnMerge
  1569. 'xlApp.Selection.SpecialCells(Microsoft.Office.Interop.Excel.XlCellType.xlCellTypeBlanks).Select
  1570. 'xlApp.CutCopyMode = False
  1571. 'xlApp.Selection.FormulaR1C1 = "=R[-1]C"
  1572. ' End If
  1573. Dim mc As Integer = 1
  1574. For y = 13 To y - 1
  1575. sql = "insert into rt_ship_temp_1 (filename,work_no,order_item,name,qty,po_no,serial) values(N'" & file_name & "',N'" & xlSheet.Cells(y, 11).value & "',N'" & xlSheet.Cells(y, 7).value & "',N'" & xlSheet.Cells(y, 2).value & "'," & xlSheet.Cells(y, 3).value & ",N'" & xlSheet.Cells(y, 6).value & "'," & mc & ")"
  1576. cmd.CommandText = sql
  1577. cmd.ExecuteScalar()
  1578. mc = mc + 1
  1579. Next
  1580. ' sql = "select 品名,厚度,cast(sum(淨重) as numeric(10,1)) as 淨重 from (select case when 品名 like '%PU%' or 品名 like '%action%' or 品名 like N'%榔%' then 'pu' else '反毛' end as 品名,淨重,厚度 from (select name as 品名, thick as 厚度,sum(weight) as 淨重 from (SELECT no, name,CASE WHEN name LIKE '%1.2%' THEN 1.24 ELSE 1.46 END AS thick, qty_sf1, nw,qty_sf1/SUM(qty_sf1) OVER (PARTITION BY no) AS Ratio, cast(qty_sf1/SUM(qty_sf1) OVER (PARTITION BY no) *nw as numeric(10,3)) as weight FROM RT_Ship_UZ_HG) as p group by name,thick) as q ) as qq group by 品名,厚度"
  1581. ' cmd.CommandText = sql
  1582. ' dt = New DataTable
  1583. ' da.SelectCommand = cmd
  1584. ' da.Fill(dt)
  1585. ' dt.Columns.Add("尺数")
  1586. ' dt.Columns.Add("货值")
  1587. ' For rr As Integer = 0 To dt.Rows.Count - 1
  1588. ' sql = "SELECT CAST(SUM(qty_sf1) AS numeric(10, 1)) AS 呎數 FROM (SELECT DISTINCT no, name, CASE WHEN name LIKE '%PU%' OR name LIKE '%action%' OR name LIKE N'%榔%' THEN 'pu' ELSE '反毛' END AS 品名, qty_sf, nw, gw, po_no, qty_sf1, unit_price FROM RT_Ship_UZ_HG) AS p
  1589. 'GROUP BY 品名 having 品名=N'" & dt.Rows(rr).Item("品名") & "'"
  1590. ' cmd.CommandText = sql
  1591. ' dt.Rows(rr).Item("尺数") = cmd.ExecuteScalar
  1592. ' Next
  1593. ' For rr As Integer = 0 To dt.Rows.Count - 1
  1594. ' sql = "SELECT CAST(SUM(qty_sf1 * unit_price) AS numeric(10, 3)) AS 金額 FROM (SELECT DISTINCT no, name, CASE WHEN name LIKE '%PU%' OR name LIKE '%action%' OR name LIKE N'%榔%' THEN 'pu' ELSE '反毛' END AS 品名, qty_sf, nw, po_no, qty_sf1,unit_price FROM RT_Ship_UZ_HG) AS p
  1595. 'GROUP BY 品名 having 品名=N'" & dt.Rows(rr).Item("品名") & "'"
  1596. ' cmd.CommandText = sql
  1597. ' dt.Rows(rr).Item("货值") = cmd.ExecuteScalar
  1598. ' Next
  1599. ' dgv1.DataSource = dt
  1600. ' Sql = "select po_no as 订单号,品名 as 类别, 颜色,sum(qty_sf1) as 尺数,cast(sum(qty_sf1*单价)/sum(qty_sf1) as numeric(10,2)) as 单价 from (SELECT rt_ship_uz_hg.po_no, case when name like '%PU%' or name like '%action%' or name like N'%榔%' then '貼膜' else '反毛' end as 品名,case when name like '%黑色%' then '黑色' else '其他' end as 颜色,name,CASE WHEN name LIKE '%1.2%' THEN 1.24 ELSE 1.46 END AS thick,
  1601. 'unit_price as 单价, qty_sf1, nw,qty_sf1/SUM(qty_sf1) OVER (PARTITION BY no) AS Ratio, cast(qty_sf1/SUM(qty_sf1) OVER (PARTITION BY no) *nw as numeric(10,3)) as weight FROM RT_Ship_UZ_HG) as p group by po_no,品名,颜色"
  1602. ' sql = "select po_no as 订单号,name as 品名,work_no as 指令号 ,sum(qty_sf1) as 尺数,deli_no as 发货单号 FROM RT_Ship_UZ_HG group by po_no,name,work_no,deli_no"
  1603. ' cmd.CommandText = Sql
  1604. ' dt = New DataTable
  1605. ' da.SelectCommand = cmd
  1606. ' da.Fill(dt)
  1607. ' dgv1.DataSource = dt
  1608. ' dgv1.Columns(0).Width = 200
  1609. ' dgv1.Columns(1).Width = 80
  1610. ' dgv1.Columns(2).Width = 80
  1611. ' sql = "select 类别,颜色,sum(尺数) as 尺数,cast(sum(货值)/sum(尺数) as numeric(10,2)) as 单价,cast(sum(货值) as numeric(10,2)) as 货值,sum(毛重) as 毛重,sum(净重) as 净重,sum(件数) as 件数 from
  1612. '( select po_no as 订单号,类别,sum(nw) as 净重,sum(gw) as 毛重, 颜色,sum(qty_sf1) as 尺数,sum(qty_sf1*单价)as 货值,count(*) as 件数 from
  1613. '(SELECT rt_ship_uz_hg.po_no, case when name like '%PU%' or name like '%action%' or name like N'%榔%' then '貼膜' else '反毛' end as 类别,case when name like '%黑色%' then '黑色' else '其他' end as 颜色,name,
  1614. 'unit_price as 单价, qty_sf1, nw, gw,qty_sf1/SUM(qty_sf1) OVER (PARTITION BY no) AS Ratio, cast(qty_sf1/SUM(qty_sf1) OVER (PARTITION BY no) *nw as numeric(10,3)) as weight FROM RT_Ship_UZ_HG) as p group by po_no,类别,颜色) as q group by 类别,颜色 order by 类别"
  1615. ' cmd.CommandText = Sql
  1616. ' dt = New DataTable
  1617. ' da.SelectCommand = cmd
  1618. ' da.Fill(dt)
  1619. ' dgv2.DataSource = dt
  1620. ' dgv2.Columns(0).Width = 70
  1621. ' dgv2.Columns(1).Width = 70
  1622. ' dgv2.Columns(2).Width = 120
  1623. ' dgv2.Columns(3).Width = 70
  1624. ' dgv2.Columns(4).Width = 120
  1625. ' dgv2.Columns(5).Width = 120
  1626. ' With dgv2.Columns("尺数").DefaultCellStyle
  1627. ' .Format = "n2"
  1628. ' .Alignment = DataGridViewContentAlignment.MiddleRight
  1629. ' End With
  1630. ' With dgv2.Columns("货值").DefaultCellStyle
  1631. ' .Format = "n2"
  1632. ' .Alignment = DataGridViewContentAlignment.MiddleRight
  1633. ' End With
  1634. ' With dgv2.Columns("净重").DefaultCellStyle
  1635. ' .Format = "n2"
  1636. ' .Alignment = DataGridViewContentAlignment.MiddleRight
  1637. ' End With
  1638. ' With dgv2.Columns("毛重").DefaultCellStyle
  1639. ' .Format = "n2"
  1640. ' .Alignment = DataGridViewContentAlignment.MiddleRight
  1641. ' End With
  1642. ElseIf OpenFileDialog1.SafeFileName Like "永正发货*" Then '-----------永正发货
  1643. sql = "select count(*) from rt_ship_temp_1 where filename=N'" & file_name & "'"
  1644. cmd.CommandText = Sql
  1645. Dim msg As String
  1646. If cmd.ExecuteScalar > 0 Then
  1647. msg = MsgBox("资料已经存在,是否要覆盖?", MsgBoxStyle.YesNo, "警告")
  1648. If msg = vbNo Then
  1649. Exit Sub
  1650. End If
  1651. End If
  1652. If msg = vbYes Then
  1653. sql = "delete from rt_ship_temp_1 where filename=N'" & file_name & "'"
  1654. cmd.CommandText = sql
  1655. cmd.ExecuteNonQuery()
  1656. End If
  1657. xlApp = CreateObject("Excel.Application")
  1658. xlApp.Visible = True
  1659. xlApp.DisplayAlerts = False
  1660. xlBook = xlApp.Workbooks.Open(file_name,, True)
  1661. xlBook.Activate()
  1662. xlSheet = xlApp.Workbooks(1).Worksheets(1)
  1663. Dim y As Integer = 0
  1664. For y = 14 To xlApp.Workbooks(1).Worksheets(1).UsedRange.Rows.Count
  1665. If Len(xlSheet.Cells(y, 2).value) < 1 Then
  1666. Exit For
  1667. End If
  1668. Next y
  1669. yy = y - 1
  1670. xlApp.Range("A14:q" & yy).Select()
  1671. 'If xlApp.Selection.mergecells = True Then
  1672. xlApp.Selection.UnMerge
  1673. 'xlApp.Selection.SpecialCells(Microsoft.Office.Interop.Excel.XlCellType.xlCellTypeBlanks).Select
  1674. 'xlApp.CutCopyMode = False
  1675. 'xlApp.Selection.FormulaR1C1 = "=R[-1]C"
  1676. 'End If
  1677. Dim my_card As String
  1678. Dim my_no As String
  1679. Dim my_nw As String
  1680. Dim my_gw As String
  1681. Dim my_name As String
  1682. Dim my_po As String
  1683. Dim my_price As String
  1684. Dim s1 As String = 1
  1685. Dim my_skuno As String
  1686. Dim my_order_item As String
  1687. For y = 14 To y - 1
  1688. If y = 14 Then
  1689. my_no = xlSheet.Cells(y, 1).value
  1690. my_order_item = xlSheet.Cells(y, 1).value
  1691. my_name = xlSheet.Cells(y, 2).value
  1692. my_card = xlSheet.Cells(y, 4).value
  1693. my_po = xlSheet.Cells(y, 7).value
  1694. my_skuno = xlSheet.Cells(y, 11).value
  1695. End If
  1696. If xlSheet.Cells(y, 1).value Is Nothing And xlSheet.Cells(y, 3).value Is Nothing And xlSheet.Cells(y, 7).value Is Nothing And xlSheet.Cells(y, 10).value Is Nothing Then
  1697. Else
  1698. If xlSheet.Cells(y, 10).value Is Nothing Then
  1699. Else
  1700. If xlSheet.Cells(y, 3).value Is Nothing And xlSheet.Cells(y, 8).value Is Nothing And xlSheet.Cells(y, 9).value Is Nothing Then
  1701. Else
  1702. my_name = xlSheet.Cells(y, 2).value
  1703. my_po = xlSheet.Cells(y, 7).value
  1704. my_skuno = xlSheet.Cells(y, 11).value
  1705. End If
  1706. sql = "insert into rt_ship_temp_1 (order_item,filename,work_no,serial,card,no,name,po_no,qty) values('" & xlSheet.Cells(y, 8).value & "',N'" & file_name & "',N'" & my_skuno & "','" & s1 & "','" & xlSheet.Cells(y, 4).value & "','" & my_no & "',N'" & my_name & "',N'" & my_po & "'," & xlSheet.Cells(y, 10).value & ")"
  1707. cmd.CommandText = sql
  1708. cmd.ExecuteScalar()
  1709. s1 = s1 + 1
  1710. End If
  1711. End If
  1712. Next
  1713. Sql = "select 品名,po_no as 订购单号,厚度,cast(sum(qty_sf1) as numeric(10,1)) as 尺数,cast(sum(unit_price*qty_sf1)/sum(qty_sf1) as numeric(10,2)) as 单价,cast(sum(unit_price*qty_sf1) as numeric(10,2)) as 货值,sum(净重) as 净重 from
  1714. (SELECT no, case when name like '%PU%' or name like '%action%' or name like N'%榔%' then N'贴膜' else '反毛' end as 品名, nw, gw, po_no, qty_sf1, unit_price,case when name like '%1.2%' then '1.24' when name like '%1.4%' then '1.46' else '1.24' end as 厚度,cast(qty_sf1/sum(qty_sf1) over (partition by no) *nw as numeric(10,1)) as 净重
  1715. FROM RT_SHIP_DAILY_UZ_1) as p group by 品名,po_no,厚度" '----旧
  1716. Sql = "select name as 品名,po_no as 订单号,order_item as 项次号,cast(sum(qty_sf1) as numeric(10,1)) as 尺数 from rt_ship_daily_uz_1 group by name,po_no,order_item"
  1717. cmd.CommandText = Sql
  1718. dt = New DataTable
  1719. da.SelectCommand = cmd
  1720. da.Fill(dt)
  1721. dt.Columns.Add("发货单号")
  1722. dgv1.DataSource = dt
  1723. dgv1.Columns("品名").Width = 300
  1724. dgv1.Columns("订单号").Width = 120
  1725. dgv1.Columns("项次号").Width = 80
  1726. dgv1.Columns("尺数").Width = 120
  1727. Sql = "select 品名,厚度,sum(尺数) as 尺数,sum(货值) as 货值,sum(净重) as 净重 from (select 品名,po_no as 订购单号,厚度,cast(sum(qty_sf1) as numeric(10,1)) as 尺数,cast(sum(unit_price*qty_sf1)/sum(qty_sf1) as numeric(10,2)) as 单价,cast(sum(unit_price*qty_sf1) as numeric(10,2)) as 货值,sum(净重) as 净重 from
  1728. (SELECT no, case when name like '%PU%' or name like '%action%' or name like N'%榔%' then N'贴膜' else '反毛' end as 品名, nw, gw, po_no, qty_sf1, unit_price,case when name like '%1.2%' then '1.24' when name like '%1.4%' then '1.46' else '1.24' end as 厚度,cast(qty_sf1/sum(qty_sf1) over (partition by no) *nw as numeric(10,1)) as 净重
  1729. FROM RT_SHIP_DAILY_UZ_1) as p group by 品名,po_no,厚度) as q group by 品名,厚度 order by 品名"
  1730. cmd.CommandText = Sql
  1731. dt = New DataTable
  1732. da.SelectCommand = cmd
  1733. da.Fill(dt)
  1734. dgv2.DataSource = dt
  1735. Sql = "select 品名,sum(尺数) as 尺数,sum(货值) as 货值,sum(净重) as 净重 from (select 品名,po_no as 订购单号,厚度,cast(sum(qty_sf1) as numeric(10,1)) as 尺数,cast(sum(unit_price*qty_sf1)/sum(qty_sf1) as numeric(10,2)) as 单价,cast(sum(unit_price*qty_sf1) as numeric(10,2)) as 货值,sum(净重) as 净重 from
  1736. (SELECT no, case when name like '%PU%' or name like '%action%' or name like N'%榔%' then N'贴膜' else '反毛' end as 品名, nw, gw, po_no, qty_sf1, unit_price,case when name like '%1.2%' then '1.24' when name like '%1.4%' then '1.46' else '1.24' end as 厚度,cast(qty_sf1/sum(qty_sf1) over (partition by no) *nw as numeric(10,1)) as 净重
  1737. FROM RT_SHIP_DAILY_UZ_1) as p group by 品名,po_no,厚度) as q group by 品名 order by 品名"
  1738. cmd.CommandText = Sql
  1739. dt = New DataTable
  1740. da.SelectCommand = cmd
  1741. da.Fill(dt)
  1742. dgv3.DataSource = dt
  1743. ElseIf OpenFileDialog1.SafeFileName Like "*亿博样*" And Not (OpenFileDialog1.SafeFileName Like "*华盛*") And Not (OpenFileDialog1.SafeFileName Like "*NK*") Then '-----------------------------
  1744. sql = "select count(*) from rt_ship_temp_1 where filename=N'" & file_name & "'"
  1745. cmd.CommandText = Sql
  1746. Dim msg As String
  1747. If cmd.ExecuteScalar > 0 Then
  1748. msg = MsgBox("资料已经存在,是否要覆盖?", MsgBoxStyle.YesNo, "警告")
  1749. If msg = vbNo Then
  1750. Exit Sub
  1751. End If
  1752. End If
  1753. If msg = vbYes Then
  1754. sql = "delete from rt_ship_temp_1 where filename=N'" & file_name & "'"
  1755. cmd.CommandText = sql
  1756. cmd.ExecuteNonQuery()
  1757. End If
  1758. xlApp = CreateObject("Excel.Application")
  1759. xlApp.Visible = True
  1760. xlApp.DisplayAlerts = False
  1761. xlBook = xlApp.Workbooks.Open(file_name,, True)
  1762. xlBook.Activate()
  1763. Dim s1 As Integer = 0
  1764. Dim my_no As Integer
  1765. For i = 1 To xlApp.Worksheets.Count
  1766. If xlApp.Workbooks(1).Worksheets(i).name = "1" Then
  1767. xlSheet = xlApp.Workbooks(1).Worksheets(i)
  1768. xlSheet.Activate()
  1769. Exit For
  1770. End If
  1771. Next
  1772. Dim y As Integer = 0
  1773. For y = 2 To xlApp.ActiveSheet.UsedRange.Rows.Count
  1774. If xlSheet.Cells(y, 2).value = "合计:" Then
  1775. Exit For
  1776. End If
  1777. Next y
  1778. xlApp.Range("A2:i" & y - 1).Select()
  1779. ' If xlApp.Selection.mergecells = True Then
  1780. xlApp.Selection.UnMerge
  1781. 'xlApp.Selection.SpecialCells(Microsoft.Office.Interop.Excel.XlCellType.xlCellTypeBlanks).Select
  1782. 'xlApp.CutCopyMode = False
  1783. 'xlApp.Selection.FormulaR1C1 = "=R[-1]C"
  1784. 'End If
  1785. s1 = 1
  1786. For y = 2 To y - 1
  1787. If xlSheet.Cells(y, 1).value Is Nothing Then
  1788. Else
  1789. my_no = xlSheet.Cells(y, 1).value
  1790. End If
  1791. sql = "insert into rt_ship_temp_1 (serial,filename,no,name,qty,nw,gw,po_no) values('" & s1 & "',N'" & file_name & "','" & my_no & "',N'" & xlSheet.Cells(y, 2).value & "'," & xlSheet.Cells(y, 3).value & "," & xlSheet.Cells(y, 5).value & "," & xlSheet.Cells(y, 6).value & ",'" & xlSheet.Cells(y, 7).value & "')"
  1792. cmd.CommandText = sql
  1793. cmd.ExecuteScalar()
  1794. s1 = s1 + 1
  1795. Next
  1796. Sql = "select 订单号,cast(sum(数量) as numeric(10,1)) as 尺数,sum(重量) as 净重,厚度 from (SELECT po_no as 订单号,name as 品名, qty as 数量,cast(qty/SUM(qty) OVER (PARTITION BY no) *nw as numeric(10,1)) as 重量,case when left(ltrim(name),3)='1.2' then left(ltrim(name),3) +'4' else '1.46' end as 厚度
  1797. FROM RT_SHIP_DAILY_YB ) as p group by 订单号,厚度" '旧
  1798. Sql = "SELECT name as 品名,po_no as 订单号, cast(sum(qty) as numeric(10,1)) as 尺数,deli_no as 发货单号 from RT_SHIP_DAILY_YBy group by po_no,name,deli_no"
  1799. cmd.CommandText = Sql
  1800. dt = New DataTable
  1801. da.SelectCommand = cmd
  1802. da.Fill(dt)
  1803. dgv1.DataSource = dt
  1804. dgv1.Columns("品名").Width = 350
  1805. dgv1.Columns("订单号").Width = 150
  1806. ElseIf OpenFileDialog1.SafeFileName Like "*亿博样*" And (OpenFileDialog1.SafeFileName Like "*NK*") Then '-----------------------------
  1807. Sql = "select count(*) from rt_ship_daily_yby where filename=N'" & file_name & "'"
  1808. cmd.CommandText = Sql
  1809. Dim msg As String
  1810. If cmd.ExecuteScalar > 0 Then
  1811. msg = MsgBox("资料已经存在,是否要覆盖?", MsgBoxStyle.YesNo, "警告")
  1812. If msg = vbNo Then
  1813. Exit Sub
  1814. End If
  1815. End If
  1816. If msg = vbYes Then
  1817. Sql = "delete from rt_ship_daily_yby where filename=N'" & file_name & "'"
  1818. cmd.CommandText = sql
  1819. cmd.ExecuteNonQuery()
  1820. sql = "delete from rt_ship_temp_1 where filename=N'" & file_name & "'"
  1821. cmd.CommandText = sql
  1822. cmd.ExecuteNonQuery()
  1823. End If
  1824. xlApp = CreateObject("Excel.Application")
  1825. xlApp.Visible = True
  1826. xlApp.DisplayAlerts = False
  1827. xlBook = xlApp.Workbooks.Open(file_name,, True)
  1828. xlBook.Activate()
  1829. Dim s1 As Integer = 0
  1830. Dim my_no As Integer
  1831. For i = 1 To xlApp.Worksheets.Count
  1832. If xlApp.Workbooks(1).Worksheets(i).name = "明细" Then
  1833. xlSheet = xlApp.Workbooks(1).Worksheets(i)
  1834. xlSheet.Activate()
  1835. Exit For
  1836. End If
  1837. Next
  1838. Dim y As Integer = 0
  1839. For y = 2 To xlApp.ActiveSheet.UsedRange.Rows.Count
  1840. If xlSheet.Cells(y, 2).value = "合计:" Then
  1841. Exit For
  1842. End If
  1843. Next y
  1844. xlApp.Range("A2:i" & y - 1).Select()
  1845. ' If xlApp.Selection.mergecells = True Then
  1846. xlApp.Selection.UnMerge
  1847. 'xlApp.Selection.SpecialCells(Microsoft.Office.Interop.Excel.XlCellType.xlCellTypeBlanks).Select
  1848. 'xlApp.CutCopyMode = False
  1849. 'xlApp.Selection.FormulaR1C1 = "=R[-1]C"
  1850. 'End If
  1851. s1 = 1
  1852. For y = 2 To y - 1
  1853. If xlSheet.Cells(y, 1).value Is Nothing Then
  1854. Else
  1855. my_no = xlSheet.Cells(y, 1).value
  1856. End If
  1857. sql = "insert into rt_ship_temp_1 (thick,serial,filename,no,qty,name,po_no) values('" & xlSheet.Cells(y, 3).value & "',N'" & s1 & "',N'" & file_name & "','" & my_no &
  1858. "'," & xlSheet.Cells(y, 4).value & ",N'" & xlSheet.Cells(y, 2).value & "',N'" & xlSheet.Cells(y, 9).value & "')"
  1859. cmd.CommandText = sql
  1860. cmd.ExecuteScalar()
  1861. s1 = s1 + 1
  1862. Next
  1863. Sql = "select 订单号,cast(sum(数量) as numeric(10,1)) as 尺数,sum(重量) as 净重,厚度 from (SELECT po_no as 订单号,name as 品名, qty as 数量,cast(qty/SUM(qty) OVER (PARTITION BY no) *nw as numeric(10,1)) as 重量,case when left(ltrim(name),3)='1.2' then left(ltrim(name),3) +'4' else '1.46' end as 厚度
  1864. FROM RT_SHIP_DAILY_YB ) as p group by 订单号,厚度" '旧
  1865. Sql = "SELECT name as 品名,po_no as 订单号, cast(sum(qty) as numeric(10,1)) as 尺数,deli_no as 发货单号 from RT_SHIP_DAILY_YBy group by po_no,name,deli_no"
  1866. cmd.CommandText = Sql
  1867. dt = New DataTable
  1868. da.SelectCommand = cmd
  1869. da.Fill(dt)
  1870. dgv1.DataSource = dt
  1871. dgv1.Columns("品名").Width = 350
  1872. dgv1.Columns("订单号").Width = 150
  1873. ElseIf OpenFileDialog1.SafeFileName Like "亿博发货*" Then '--------------------------------------- 亿博发货明细
  1874. sql = "select count(*) from rt_ship_temp_1 where filename=N'" & file_name & "'"
  1875. cmd.CommandText = Sql
  1876. Dim msg As String
  1877. If cmd.ExecuteScalar > 0 Then
  1878. msg = MsgBox("资料已经存在,是否要覆盖?", MsgBoxStyle.YesNo, "警告")
  1879. If msg = vbNo Then
  1880. Exit Sub
  1881. End If
  1882. End If
  1883. If msg = vbYes Then
  1884. sql = "delete from rt_ship_temp_1 where filename=N'" & file_name & "'"
  1885. cmd.CommandText = sql
  1886. cmd.ExecuteNonQuery()
  1887. End If
  1888. xlApp = CreateObject("Excel.Application")
  1889. xlApp.Visible = True
  1890. xlApp.DisplayAlerts = False
  1891. xlBook = xlApp.Workbooks.Open(file_name,, True)
  1892. xlBook.Activate()
  1893. Dim s1 As Integer = 0
  1894. Dim my_no As Integer
  1895. For i = 1 To xlApp.Worksheets.Count
  1896. If xlApp.Workbooks(1).Worksheets(i).name = "1" Then
  1897. xlSheet = xlApp.Workbooks(1).Worksheets(i)
  1898. xlSheet.Activate()
  1899. Exit For
  1900. End If
  1901. Next
  1902. Dim y As Integer = 0
  1903. For y = 2 To xlApp.ActiveSheet.UsedRange.Rows.Count
  1904. If xlSheet.Cells(y, 2).value = "合计:" Then
  1905. Exit For
  1906. End If
  1907. Next y
  1908. xlApp.Range("A2:i" & y - 1).Select()
  1909. ' If xlApp.Selection.mergecells = True Then
  1910. xlApp.Selection.UnMerge
  1911. 'xlApp.Selection.SpecialCells(Microsoft.Office.Interop.Excel.XlCellType.xlCellTypeBlanks).Select
  1912. 'xlApp.CutCopyMode = False
  1913. 'xlApp.Selection.FormulaR1C1 = "=R[-1]C"
  1914. 'End If
  1915. s1 = 1
  1916. For y = 2 To y - 1
  1917. If xlSheet.Cells(y, 1).value Is Nothing Then
  1918. Else
  1919. my_no = xlSheet.Cells(y, 1).value
  1920. End If
  1921. sql = "insert into rt_ship_temp_1 (CARD,serial,filename,no,name,qty,po_no) values('" & xlSheet.Cells(y, 4).value & "','" & s1 & "',N'" & file_name & "','" & my_no & "',N'" & xlSheet.Cells(y, 2).value & "'," & xlSheet.Cells(y, 3).value & ",N'" & xlSheet.Cells(y, 8).value & "')"
  1922. cmd.CommandText = sql
  1923. cmd.ExecuteScalar()
  1924. s1 = s1 + 1
  1925. Next
  1926. ' sql = "select 订单号,类别,cast(sum(数量) as numeric(10,1)) as 尺数,sum(重量) as 净重,厚度 from (SELECT po_no as 订单号,name as 品名,case when name like '%PU%' or name like '%action%' or name like N'%榔%' or name like N'%virgin%' then 'PU' else '反毛' end as 类别, qty as 数量,cast(qty/SUM(qty) OVER (PARTITION BY no) *nw as numeric(10,1)) as 重量,case when left(ltrim(name),3)='1.2' then left(ltrim(name),3) +'4' else '1.46' end as 厚度
  1927. 'FROM RT_SHIP_DAILY_YB) as p group by 订单号,类别,厚度"
  1928. ' cmd.CommandText = sql
  1929. ' dt = New DataTable
  1930. ' da.SelectCommand = cmd
  1931. ' da.Fill(dt)
  1932. ' dgv2.DataSource = dt
  1933. ' sql = "select 类别,sum(尺数),sum(净重) from (select 订单号,类别,cast(sum(数量) as numeric(10,1)) as 尺数,sum(重量) as 净重,厚度 from (SELECT po_no as 订单号,name as 品名,case when name like '%PU%' or name like '%action%' or name like N'%榔%' or name like N'%virgin%' then 'PU' else '反毛' end as 类别, case when name like '%black%' then '黑色' else '其他' end as 颜色, qty as 数量,cast(qty/SUM(qty) OVER (PARTITION BY no) *nw as numeric(10,1)) as 重量,case when left(ltrim(name),3)='1.2' then left(ltrim(name),3) +'4' else '1.46' end as 厚度
  1934. 'FROM RT_SHIP_DAILY_YB) as p group by 订单号,类别,厚度) as q group by 类别"
  1935. ' cmd.CommandText = sql
  1936. ' dt = New DataTable
  1937. ' da.SelectCommand = cmd
  1938. ' da.Fill(dt)
  1939. ' dgv3.DataSource = dt
  1940. ' sql = "select name as 品名,cast(sum(qty_sf) as numeric(10,1)) as 尺数,cast(sum(qty_sf*unit_price) as numeric(10,1)) as 总价,sum(weight) as 淨重 from (SELECT no, name, color, qty_sf, gw1, po_no, unit_price, cast(qty_sf/SUM(qty_sf) OVER (PARTITION BY no) *gw1 as numeric(10,1)) as weight
  1941. 'FROM RT_SHIP_DAILY_PUMA) as p group by name"
  1942. ' cmd.CommandText = sql
  1943. ' dt = New DataTable
  1944. ' da.SelectCommand = cmd
  1945. ' da.Fill(dt)
  1946. 'sql = ""
  1947. 'cmd.CommandText = sql
  1948. 'dt = New DataTable
  1949. 'da.SelectCommand = cmd
  1950. 'da.Fill(dt)
  1951. 'dgv2.DataSource = dt
  1952. ElseIf OpenFileDialog1.SafeFileName Like "宏美*" Then '------------------------------------------------------------------
  1953. sql = "select count(*) from rt_ship_temp_1 where filename=N'" & file_name & "'"
  1954. cmd.CommandText = Sql
  1955. Dim msg As String
  1956. If cmd.ExecuteScalar > 0 Then
  1957. msg = MsgBox("资料已经存在,是否要覆盖?", MsgBoxStyle.YesNo, "警告")
  1958. If msg = vbNo Then
  1959. Exit Sub
  1960. End If
  1961. End If
  1962. If msg = vbYes Then
  1963. sql = "delete from rt_ship_temp_1 where filename=N'" & file_name & "'"
  1964. cmd.CommandText = sql
  1965. cmd.ExecuteNonQuery()
  1966. End If
  1967. xlApp = CreateObject("Excel.Application")
  1968. xlApp.Visible = True
  1969. xlApp.DisplayAlerts = False
  1970. xlBook = xlApp.Workbooks.Open(file_name,, True)
  1971. xlBook.Activate()
  1972. xlSheet = xlApp.Workbooks(1).Worksheets(1)
  1973. Dim y As Integer = 0
  1974. For y = 4 To xlApp.Workbooks(1).Worksheets(1).UsedRange.Rows.Count
  1975. If xlSheet.Cells(y, 3).value = "合 计" Then
  1976. Exit For
  1977. End If
  1978. Next y
  1979. yy = y - 1
  1980. xlApp.Range("A4:w" & yy).Select()
  1981. 'If xlApp.Selection.mergecells = True Then
  1982. xlApp.Selection.UnMerge
  1983. 'xlApp.Selection.SpecialCells(Microsoft.Office.Interop.Excel.XlCellType.xlCellTypeBlanks).Select
  1984. 'xlApp.CutCopyMode = False
  1985. 'xlApp.Selection.FormulaR1C1 = "=R[-1]C"
  1986. 'End If
  1987. Dim my_card As String
  1988. Dim my_no As String
  1989. Dim my_nw As String
  1990. Dim my_gw As String
  1991. Dim my_name As String
  1992. Dim my_po As String
  1993. Dim my_price As String
  1994. Dim s1 As String = 1
  1995. Dim my_skuno As String
  1996. Dim my_order_item As String
  1997. Dim my_color As String
  1998. For y = 4 To y - 1
  1999. If y = 4 Then
  2000. my_no = xlSheet.Cells(y, 1).value
  2001. 'my_order_item = xlSheet.Cells(y, 1).value
  2002. my_name = xlSheet.Cells(y, 2).value
  2003. my_color = xlSheet.Cells(y, 4).value
  2004. ' my_card = xlSheet.Cells(y, 5).value
  2005. ' my_nw = xlSheet.Cells(y, 6).value
  2006. 'my_gw = xlSheet.Cells(y, 7).value
  2007. 'my_po = xlSheet.Cells(y, 8).value
  2008. 'my_skuno = xlSheet.Cells(y, 12).value
  2009. End If
  2010. If xlSheet.Cells(y, 1).value Is Nothing Then
  2011. Else
  2012. my_no = xlSheet.Cells(y, 1).value
  2013. End If
  2014. sql = "insert into rt_ship_temp_1 (color,po_no,work_no,filename,serial,no,name,qty) values(N'" & xlSheet.Cells(y, 4).value & "',N'" & xlSheet.Cells(y, 14).value & "',N'" & xlSheet.Cells(y, 17).value & "',N'" & file_name & "','" & s1 & "','" & my_no & "',N'" & xlSheet.Cells(y, 2).value & "','" & xlSheet.Cells(y, 5).value & "')"
  2015. cmd.CommandText = sql
  2016. cmd.ExecuteScalar()
  2017. s1 = s1 + 1
  2018. Next
  2019. Sql = "select 品名,po_no as 订购单号,厚度,cast(sum(qty_sf1) as numeric(10,1)) as 尺数,cast(sum(unit_price*qty_sf1)/sum(qty_sf1) as numeric(10,2)) as 单价,cast(sum(unit_price*qty_sf1) as numeric(10,2)) as 货值,sum(净重) as 净重 from
  2020. (SELECT no, case when name like '%PU%' or name like '%action%' or name like N'%榔%' then N'贴膜' else '反毛' end as 品名, nw, gw, po_no, qty_sf1, unit_price,case when name like '%1.2%' then '1.24' when name like '%1.4%' then '1.46' else '1.24' end as 厚度,cast(qty_sf1/sum(qty_sf1) over (partition by no) *nw as numeric(10,1)) as 净重
  2021. FROM RT_SHIP_DAILY_UZ_1) as p group by 品名,po_no,厚度" '----旧
  2022. Sql = "select po_no as 订单号,name as 品名,color as 颜色,cast(sum(qty) as numeric(10,1)) as 尺数,deli_no as 发货单号 from rt_ship_daily_hongmei group by name,po_no,name,color,deli_no"
  2023. cmd.CommandText = Sql
  2024. dt = New DataTable
  2025. da.SelectCommand = cmd
  2026. da.Fill(dt)
  2027. dgv1.DataSource = dt
  2028. dgv1.Columns("品名").Width = 350
  2029. dgv1.Columns("订单号").Width = 120
  2030. dgv1.Columns("颜色").Width = 100
  2031. dgv1.Columns("尺数").Width = 120
  2032. ElseIf OpenFileDialog1.SafeFileName Like "志捷*" Then '------------------------------------------------------------------
  2033. sql = "select count(*) from rt_ship_temp_1 where filename=N'" & file_name & "'"
  2034. cmd.CommandText = Sql
  2035. Dim msg As String
  2036. If cmd.ExecuteScalar > 0 Then
  2037. msg = MsgBox("资料已经存在,是否要覆盖?", MsgBoxStyle.YesNo, "警告")
  2038. If msg = vbNo Then
  2039. Exit Sub
  2040. End If
  2041. End If
  2042. If msg = vbYes Then
  2043. sql = "delete from rt_ship_temp_1 where filename=N'" & file_name & "'"
  2044. cmd.CommandText = sql
  2045. cmd.ExecuteNonQuery()
  2046. End If
  2047. xlApp = CreateObject("Excel.Application")
  2048. xlApp.Visible = True
  2049. xlApp.DisplayAlerts = False
  2050. xlBook = xlApp.Workbooks.Open(file_name,, True)
  2051. xlBook.Activate()
  2052. xlSheet = xlApp.Workbooks(1).Worksheets(1)
  2053. Dim y As Integer = 0
  2054. For y = 3 To xlApp.Workbooks(1).Worksheets(1).UsedRange.Rows.Count
  2055. If xlSheet.Cells(y, 2).value Is Nothing Then
  2056. Exit For
  2057. End If
  2058. Next y
  2059. yy = y - 1
  2060. 'xlApp.Range("A2:g" & yy).Select()
  2061. 'xlApp.Selection.UnMerge
  2062. 'xlApp.Selection.SpecialCells(Microsoft.Office.Interop.Excel.XlCellType.xlCellTypeBlanks).Select
  2063. 'xlApp.CutCopyMode = False
  2064. 'xlApp.Selection.FormulaR1C1 = "=R[-1]C"
  2065. Dim my_card As String
  2066. Dim my_no As String
  2067. Dim my_nw As String
  2068. Dim my_gw As String
  2069. Dim my_name As String
  2070. Dim thick As String
  2071. Dim my_comment As String
  2072. Dim my_po As String
  2073. Dim my_price As String
  2074. Dim s1 As String = 1
  2075. Dim my_skuno As String
  2076. Dim my_order_item As String
  2077. Dim my_color As String
  2078. For y = 3 To y - 1
  2079. If y = 3 Then
  2080. my_no = xlSheet.Cells(y, 1).value
  2081. my_comment = xlSheet.Cells(y, 7).value
  2082. my_color = xlSheet.Cells(y, 5).value
  2083. thick = xlSheet.Cells(y, 6).value
  2084. my_po = xlSheet.Cells(y, 4).value
  2085. End If
  2086. If xlSheet.Cells(y, 1).value Is Nothing Then
  2087. Else
  2088. my_no = xlSheet.Cells(y, 1).value
  2089. End If
  2090. If Not (xlSheet.Cells(y, 2).value Is Nothing) Then
  2091. If xlSheet.Cells(y, 4).value Is Nothing Then
  2092. Else
  2093. my_comment = xlSheet.Cells(y, 7).value
  2094. my_color = xlSheet.Cells(y, 5).value
  2095. thick = xlSheet.Cells(y, 6).value
  2096. my_po = xlSheet.Cells(y, 4).value
  2097. End If
  2098. End If
  2099. If my_comment Is Nothing Then
  2100. sql = "insert into rt_ship_temp_1 (CARD,color1,work_no,thick,po_no,filename,serial,no,name,qty) values(N'" & xlSheet.Cells(y, 3).value & "',N'" & my_color & "',N'" & my_comment & "',N'" & thick & "',N'" & my_po & "',N'" & file_name & "','" & s1 & "','" & my_no & "',N'" & my_color & "','" & xlSheet.Cells(y, 2).value & "')"
  2101. Else
  2102. sql = "insert into rt_ship_temp_1 (CARD,color1,work_no,thick,po_no,filename,serial,no,name,qty) values(N'" & xlSheet.Cells(y, 3).value & "',N'" & my_color & "',N'" & my_comment.ToString.Replace("'", "''") & "',N'" & thick & "',N'" & my_po & "',N'" & file_name & "','" & s1 & "','" & my_no & "',N'" & my_color & "','" & xlSheet.Cells(y, 2).value & "')"
  2103. End If
  2104. cmd.CommandText = sql
  2105. cmd.ExecuteScalar()
  2106. s1 = s1 + 1
  2107. Next
  2108. ElseIf OpenFileDialog1.SafeFileName Like "金帝样品*" Then '------------------------------------------------------------------
  2109. sql = "select count(*) from rt_ship_temp_1 where filename=N'" & file_name & "'"
  2110. cmd.CommandText = Sql
  2111. Dim msg As String
  2112. If cmd.ExecuteScalar > 0 Then
  2113. msg = MsgBox("资料已经存在,是否要覆盖?", MsgBoxStyle.YesNo, "警告")
  2114. If msg = vbNo Then
  2115. Exit Sub
  2116. End If
  2117. End If
  2118. If msg = vbYes Then
  2119. sql = "delete from rt_ship_temp_1 where filename=N'" & file_name & "'"
  2120. cmd.CommandText = sql
  2121. cmd.ExecuteNonQuery()
  2122. End If
  2123. xlApp = CreateObject("Excel.Application")
  2124. xlApp.Visible = True
  2125. xlApp.DisplayAlerts = False
  2126. xlBook = xlApp.Workbooks.Open(file_name,, True)
  2127. xlBook.Activate()
  2128. xlSheet = xlApp.Workbooks(1).Worksheets(1)
  2129. Dim y As Integer = 0
  2130. For y = 3 To xlApp.Workbooks(1).Worksheets(1).UsedRange.Rows.Count
  2131. If xlSheet.Cells(y, 2).value Is Nothing Then
  2132. Exit For
  2133. End If
  2134. Next y
  2135. yy = y - 1
  2136. 'xlApp.Range("A2:g" & yy).Select()
  2137. 'xlApp.Selection.UnMerge
  2138. 'xlApp.Selection.SpecialCells(Microsoft.Office.Interop.Excel.XlCellType.xlCellTypeBlanks).Select
  2139. 'xlApp.CutCopyMode = False
  2140. 'xlApp.Selection.FormulaR1C1 = "=R[-1]C"
  2141. Dim my_card As String
  2142. Dim my_no As String
  2143. Dim my_nw As String
  2144. Dim my_gw As String
  2145. Dim my_name As String
  2146. Dim thick As String
  2147. Dim my_comment As String
  2148. Dim my_po As String
  2149. Dim my_price As String
  2150. Dim s1 As String = 1
  2151. Dim my_skuno As String
  2152. Dim my_order_item As String
  2153. Dim my_color As String
  2154. For y = 3 To y - 1
  2155. my_no = xlSheet.Cells(y, 4).value
  2156. ' my_comment = xlSheet.Cells(y, 7).value
  2157. my_color = xlSheet.Cells(y, 5).value
  2158. ' thick = xlSheet.Cells(y, 6).value
  2159. my_po = xlSheet.Cells(y, 4).value
  2160. sql = "insert into rt_ship_temp_1 (CARD,color1,work_no,thick,po_no,filename,serial,no,name,qty) values(N'" & xlSheet.Cells(y, 3).value & "',N'" & my_color & "',N'" & my_comment & "',N'" & thick & "',N'" & my_po & "',N'" & file_name & "','" & s1 & "','',N'" & my_color & "','" & xlSheet.Cells(y, 2).value & "')"
  2161. cmd.CommandText = sql
  2162. cmd.ExecuteScalar()
  2163. s1 = s1 + 1
  2164. Next
  2165. ElseIf OpenFileDialog1.SafeFileName Like "名越发货明细*" Then '------------------------------------------------------------------
  2166. sql = "select count(*) from rt_ship_temp_1 where filename=N'" & file_name & "'"
  2167. cmd.CommandText = Sql
  2168. Dim msg As String
  2169. If cmd.ExecuteScalar > 0 Then
  2170. msg = MsgBox("资料已经存在,是否要覆盖?", MsgBoxStyle.YesNo, "警告")
  2171. If msg = vbNo Then
  2172. Exit Sub
  2173. End If
  2174. End If
  2175. If msg = vbYes Then
  2176. sql = "delete from rt_ship_temp_1 where filename=N'" & file_name & "'"
  2177. cmd.CommandText = sql
  2178. cmd.ExecuteNonQuery()
  2179. End If
  2180. xlApp = CreateObject("Excel.Application")
  2181. xlApp.Visible = True
  2182. xlApp.DisplayAlerts = False
  2183. xlBook = xlApp.Workbooks.Open(file_name,, True)
  2184. xlBook.Activate()
  2185. xlSheet = xlApp.Workbooks(1).Worksheets(1)
  2186. Dim y As Integer = 0
  2187. For y = 2 To xlApp.Workbooks(1).Worksheets(1).UsedRange.Rows.Count
  2188. If xlSheet.Cells(y, 2).value Is Nothing Then
  2189. Exit For
  2190. End If
  2191. Next y
  2192. yy = y - 1
  2193. 'xlApp.Range("A2:g" & yy).Select()
  2194. 'xlApp.Selection.UnMerge
  2195. 'xlApp.Selection.SpecialCells(Microsoft.Office.Interop.Excel.XlCellType.xlCellTypeBlanks).Select
  2196. 'xlApp.CutCopyMode = False
  2197. 'xlApp.Selection.FormulaR1C1 = "=R[-1]C"
  2198. Dim my_card As String
  2199. Dim my_no As String
  2200. Dim my_nw As String
  2201. Dim my_gw As String
  2202. Dim my_name As String
  2203. Dim thick As String
  2204. Dim my_comment As String
  2205. Dim my_po As String
  2206. Dim my_price As String
  2207. Dim s1 As String = 1
  2208. Dim my_skuno As String
  2209. Dim my_order_item As String
  2210. Dim my_color As String
  2211. For y = 2 To y - 1
  2212. my_no = xlSheet.Cells(y, 4).value
  2213. my_comment = ""
  2214. my_color = xlSheet.Cells(y, 2).value
  2215. thick = ""
  2216. my_po = xlSheet.Cells(y, 8).value
  2217. sql = "insert into rt_ship_temp_1 (CARD,color1,work_no,thick,po_no,filename,serial,no,name,qty) values(N'" & xlSheet.Cells(y, 4).value & "',N'" & my_color & "',N'" & xlSheet.Cells(y, 9).value & "',N'" & thick & "',N'" & my_po & "',N'" & file_name & "','" & s1 & "','',N'" & my_color & "','" & xlSheet.Cells(y, 3).value & "')"
  2218. cmd.CommandText = sql
  2219. cmd.ExecuteScalar()
  2220. s1 = s1 + 1
  2221. Next
  2222. ElseIf OpenFileDialog1.SafeFileName Like "名创发货明细*" Then '------------------------------------------------------------------
  2223. sql = "select count(*) from rt_ship_temp_1 where filename=N'" & file_name & "'"
  2224. cmd.CommandText = Sql
  2225. Dim msg As String
  2226. If cmd.ExecuteScalar > 0 Then
  2227. msg = MsgBox("资料已经存在,是否要覆盖?", MsgBoxStyle.YesNo, "警告")
  2228. If msg = vbNo Then
  2229. Exit Sub
  2230. End If
  2231. End If
  2232. If msg = vbYes Then
  2233. sql = "delete from rt_ship_temp_1 where filename=N'" & file_name & "'"
  2234. cmd.CommandText = sql
  2235. cmd.ExecuteNonQuery()
  2236. End If
  2237. xlApp = CreateObject("Excel.Application")
  2238. xlApp.Visible = True
  2239. xlApp.DisplayAlerts = False
  2240. xlBook = xlApp.Workbooks.Open(file_name,, True)
  2241. xlBook.Activate()
  2242. xlSheet = xlApp.Workbooks(1).Worksheets(1)
  2243. Dim y As Integer = 0
  2244. For y = 2 To xlApp.Workbooks(1).Worksheets(1).UsedRange.Rows.Count
  2245. If xlSheet.Cells(y, 2).value Is Nothing Then
  2246. Exit For
  2247. End If
  2248. Next y
  2249. yy = y - 1
  2250. 'xlApp.Range("A2:g" & yy).Select()
  2251. 'xlApp.Selection.UnMerge
  2252. 'xlApp.Selection.SpecialCells(Microsoft.Office.Interop.Excel.XlCellType.xlCellTypeBlanks).Select
  2253. 'xlApp.CutCopyMode = False
  2254. 'xlApp.Selection.FormulaR1C1 = "=R[-1]C"
  2255. Dim my_card As String
  2256. Dim my_no As String
  2257. Dim my_nw As String
  2258. Dim my_gw As String
  2259. Dim my_name As String
  2260. Dim thick As String
  2261. Dim my_comment As String
  2262. Dim my_po As String
  2263. Dim my_price As String
  2264. Dim s1 As String = 1
  2265. Dim my_skuno As String
  2266. Dim my_order_item As String
  2267. Dim my_color As String
  2268. For y = 2 To y - 1
  2269. my_no = xlSheet.Cells(y, 4).value
  2270. my_comment = ""
  2271. my_color = xlSheet.Cells(y, 2).value
  2272. thick = ""
  2273. my_po = xlSheet.Cells(y, 8).value
  2274. sql = "insert into rt_ship_temp_1 (CARD,color1,work_no,thick,po_no,filename,serial,no,name,qty) values(N'" & xlSheet.Cells(y, 4).value & "',N'" & my_color & "',N'" & xlSheet.Cells(y, 7).value & "',N'" & thick & "',N'" & xlSheet.Cells(y, 7).value & "',N'" & file_name & "','" & s1 & "','',N'" & my_color & "','" & xlSheet.Cells(y, 3).value & "')"
  2275. cmd.CommandText = sql
  2276. cmd.ExecuteScalar()
  2277. s1 = s1 + 1
  2278. Next
  2279. ElseIf OpenFileDialog1.SafeFileName Like "好兄弟样品*" Then '------------------------------------------------------------------
  2280. sql = "select count(*) from rt_ship_temp_1 where filename=N'" & file_name & "'"
  2281. cmd.CommandText = Sql
  2282. Dim msg As String
  2283. If cmd.ExecuteScalar > 0 Then
  2284. msg = MsgBox("资料已经存在,是否要覆盖?", MsgBoxStyle.YesNo, "警告")
  2285. If msg = vbNo Then
  2286. Exit Sub
  2287. End If
  2288. End If
  2289. If msg = vbYes Then
  2290. sql = "delete from rt_ship_temp_1 where filename=N'" & file_name & "'"
  2291. cmd.CommandText = sql
  2292. cmd.ExecuteNonQuery()
  2293. End If
  2294. xlApp = CreateObject("Excel.Application")
  2295. xlApp.Visible = True
  2296. xlApp.DisplayAlerts = False
  2297. xlBook = xlApp.Workbooks.Open(file_name,, True)
  2298. xlBook.Activate()
  2299. xlSheet = xlApp.Workbooks(1).Worksheets(1)
  2300. Dim y As Integer = 0
  2301. For y = 3 To xlApp.Workbooks(1).Worksheets(1).UsedRange.Rows.Count
  2302. If xlSheet.Cells(y, 2).value Is Nothing Then
  2303. Exit For
  2304. End If
  2305. Next y
  2306. yy = y - 1
  2307. Dim my_card As String
  2308. Dim my_no As String
  2309. Dim my_nw As String
  2310. Dim my_gw As String
  2311. Dim my_name As String
  2312. Dim thick As String
  2313. Dim my_comment As String
  2314. Dim my_po As String
  2315. Dim my_price As String
  2316. Dim s1 As String = 1
  2317. Dim my_skuno As String
  2318. Dim my_order_item As String
  2319. Dim my_color As String
  2320. For y = 3 To y - 1
  2321. my_no = xlSheet.Cells(y, 4).value
  2322. ' my_comment = xlSheet.Cells(y, 7).value
  2323. my_color = xlSheet.Cells(y, 5).value
  2324. thick = xlSheet.Cells(y, 6).value
  2325. my_po = xlSheet.Cells(y, 4).value
  2326. sql = "insert into rt_ship_temp_1 (CARD,color1,work_no,thick,po_no,filename,serial,no,name,qty) values(N'" & xlSheet.Cells(y, 3).value & "',N'" & my_color & "',N'" & my_comment & "',N'" & thick & "',N'" & my_po & "',N'" & file_name & "','" & s1 & "','',N'" & my_color & "','" & xlSheet.Cells(y, 2).value & "')"
  2327. cmd.CommandText = sql
  2328. cmd.ExecuteScalar()
  2329. s1 = s1 + 1
  2330. Next
  2331. ElseIf OpenFileDialog1.SafeFileName Like "*THANG*" Then '------------------------------------------------------------------
  2332. sql = "select count(*) from rt_ship_temp_1 where filename=N'" & file_name & "'"
  2333. cmd.CommandText = Sql
  2334. Dim msg As String
  2335. If cmd.ExecuteScalar > 0 Then
  2336. msg = MsgBox("资料已经存在,是否要覆盖?", MsgBoxStyle.YesNo, "警告")
  2337. If msg = vbNo Then
  2338. Exit Sub
  2339. End If
  2340. End If
  2341. If msg = vbYes Then
  2342. sql = "delete from rt_ship_temp_1 where filename=N'" & file_name & "'"
  2343. cmd.CommandText = sql
  2344. cmd.ExecuteNonQuery()
  2345. End If
  2346. xlApp = CreateObject("Excel.Application")
  2347. xlApp.Visible = True
  2348. xlApp.DisplayAlerts = False
  2349. xlBook = xlApp.Workbooks.Open(file_name,, True)
  2350. xlBook.Activate()
  2351. xlSheet = xlApp.Workbooks(1).Worksheets(1)
  2352. Dim y As Integer = 0
  2353. For y = 3 To xlApp.Workbooks(1).Worksheets(1).UsedRange.Rows.Count
  2354. If xlSheet.Cells(y, 2).value Is Nothing Then
  2355. Exit For
  2356. End If
  2357. Next y
  2358. yy = y - 1
  2359. xlApp.Range("A2:j" & yy).Select()
  2360. xlApp.Selection.UnMerge
  2361. Dim my_card As String
  2362. Dim my_no As String
  2363. Dim my_nw As String
  2364. Dim my_gw As String
  2365. Dim my_name As String
  2366. Dim my_po As String
  2367. Dim my_price As String
  2368. Dim s1 As String = 1
  2369. Dim my_skuno As String
  2370. Dim my_order_item As String
  2371. Dim my_color As String
  2372. s1 = 1
  2373. For y = 2 To y - 1
  2374. If y = 2 Then
  2375. my_no = xlSheet.Cells(y, 1).value
  2376. my_name = xlSheet.Cells(y, 2).value
  2377. my_po = xlSheet.Cells(y, 9).value
  2378. End If
  2379. If xlSheet.Cells(y, 1).value Is Nothing Then
  2380. Else
  2381. my_no = xlSheet.Cells(y, 1).value
  2382. End If
  2383. If xlSheet.Cells(y, 2).value Is Nothing Then
  2384. Else
  2385. my_name = xlSheet.Cells(y, 2).value.Replace("'", "''")
  2386. my_po = xlSheet.Cells(y, 9).value
  2387. End If
  2388. sql = "insert into rt_ship_temp_1 (po_no,filename,serial,no,name,qty,card) values(N'" & my_po & "',N'" & file_name & "','" & s1 & "','" & my_no & "',N'" & my_name & "','" & xlSheet.Cells(y, 3).value & "','" & xlSheet.Cells(y, 4).value & "')"
  2389. cmd.CommandText = sql
  2390. cmd.ExecuteScalar()
  2391. s1 = s1 + 1
  2392. Next
  2393. ElseIf OpenFileDialog1.SafeFileName Like "076样品*" Then '------------------------------------------------------------------
  2394. sql = "select count(*) from rt_ship_temp_1 where filename=N'" & file_name & "'"
  2395. cmd.CommandText = Sql
  2396. Dim msg As String
  2397. If cmd.ExecuteScalar > 0 Then
  2398. msg = MsgBox("资料已经存在,是否要覆盖?", MsgBoxStyle.YesNo, "警告")
  2399. If msg = vbNo Then
  2400. Exit Sub
  2401. End If
  2402. End If
  2403. If msg = vbYes Then
  2404. sql = "delete from rt_ship_temp_1 where filename=N'" & file_name & "'"
  2405. cmd.CommandText = sql
  2406. cmd.ExecuteNonQuery()
  2407. End If
  2408. xlApp = CreateObject("Excel.Application")
  2409. xlApp.Visible = True
  2410. xlApp.DisplayAlerts = False
  2411. xlBook = xlApp.Workbooks.Open(file_name,, True)
  2412. xlBook.Activate()
  2413. xlSheet = xlApp.Workbooks(1).Worksheets(1)
  2414. Dim y As Integer = 0
  2415. For y = 3 To xlApp.Workbooks(1).Worksheets(1).UsedRange.Rows.Count
  2416. If xlSheet.Cells(y, 2).value Is Nothing Then
  2417. Exit For
  2418. End If
  2419. Next y
  2420. yy = y - 1
  2421. xlApp.Range("A3:h" & yy).Select()
  2422. 'If xlApp.Selection.mergecells = True Then
  2423. xlApp.Selection.UnMerge
  2424. 'xlApp.Selection.SpecialCells(Microsoft.Office.Interop.Excel.XlCellType.xlCellTypeBlanks).Select
  2425. 'xlApp.CutCopyMode = False
  2426. 'xlApp.Selection.FormulaR1C1 = "=R[-1]C"
  2427. 'End If
  2428. Dim my_card As String
  2429. Dim my_no As String
  2430. Dim my_nw As String
  2431. Dim my_gw As String
  2432. Dim my_name As String
  2433. Dim my_po As String
  2434. Dim my_price As String
  2435. Dim s1 As String = 1
  2436. Dim my_skuno As String
  2437. Dim my_order_item As String
  2438. Dim my_color As String
  2439. Dim my_thick As String
  2440. For y = 3 To y - 1
  2441. If y = 3 Then
  2442. my_no = xlSheet.Cells(y, 1).value
  2443. 'my_order_item = xlSheet.Cells(y, 1).value
  2444. my_po = xlSheet.Cells(y, 4).value
  2445. my_skuno = xlSheet.Cells(y, 5).value
  2446. my_color = xlSheet.Cells(y, 6).value
  2447. my_thick = xlSheet.Cells(y, 7).value
  2448. my_card = xlSheet.Cells(y, 3).value
  2449. End If
  2450. If xlSheet.Cells(y, 5).value Is Nothing Then
  2451. Else
  2452. my_no = xlSheet.Cells(y, 1).value
  2453. my_po = xlSheet.Cells(y, 4).value
  2454. my_skuno = xlSheet.Cells(y, 5).value
  2455. my_color = xlSheet.Cells(y, 6).value
  2456. my_thick = xlSheet.Cells(y, 7).value
  2457. my_card = xlSheet.Cells(y, 3).value
  2458. End If
  2459. sql = "insert into rt_ship_temp_1 (card,comment,work_no,thick,po_no,filename,serial,no,color1,qty) values(N'" & my_card & "',N'" & xlSheet.Cells(y, 8).value & "',N'" & my_skuno & "',N'" & my_thick & "',N'" & my_po & "',N'" & file_name & "','" & s1 & "','" & my_no & "',N'" & my_color & "','" & xlSheet.Cells(y, 2).value & "')"
  2460. cmd.CommandText = sql
  2461. cmd.ExecuteScalar()
  2462. s1 = s1 + 1
  2463. Next
  2464. Sql = "select 品名,po_no as 订购单号,厚度,cast(sum(qty_sf1) as numeric(10,1)) as 尺数,cast(sum(unit_price*qty_sf1)/sum(qty_sf1) as numeric(10,2)) as 单价,cast(sum(unit_price*qty_sf1) as numeric(10,2)) as 货值,sum(净重) as 净重 from
  2465. (SELECT no, case when name like '%PU%' or name like '%action%' or name like N'%榔%' then N'贴膜' else '反毛' end as 品名, nw, gw, po_no, qty_sf1, unit_price,case when name like '%1.2%' then '1.24' when name like '%1.4%' then '1.46' else '1.24' end as 厚度,cast(qty_sf1/sum(qty_sf1) over (partition by no) *nw as numeric(10,1)) as 净重
  2466. FROM RT_SHIP_DAILY_UZ_1) as p group by 品名,po_no,厚度" '----旧
  2467. Sql = "select po_no as 订单号,name as 品名,work_no as 指令号,cast(sum(qty) as numeric(10,1)) as 尺数,deli_no as 发货单号 from rt_ship_daily_076_sample group by name,po_no,name,work_no,deli_no"
  2468. cmd.CommandText = Sql
  2469. dt = New DataTable
  2470. da.SelectCommand = cmd
  2471. da.Fill(dt)
  2472. dgv1.DataSource = dt
  2473. dgv1.Columns("品名").Width = 350
  2474. dgv1.Columns("订单号").Width = 120
  2475. dgv1.Columns("指令号").Width = 150
  2476. dgv1.Columns("尺数").Width = 120
  2477. ElseIf OpenFileDialog1.SafeFileName Like "加和*" And Not (OpenFileDialog1.SafeFileName Like "*sample*") Then
  2478. sql = "select count(*) from rt_ship_TEMP_1 where filename=N'" & file_name & "'"
  2479. cmd.CommandText = Sql
  2480. Dim msg As String
  2481. If cmd.ExecuteScalar > 0 Then
  2482. msg = MsgBox("资料已经存在,是否要覆盖?", MsgBoxStyle.YesNo, "警告")
  2483. If msg = vbNo Then
  2484. Exit Sub
  2485. End If
  2486. End If
  2487. If msg = vbYes Then
  2488. sql = "delete from rt_ship_temp_1 where filename=N'" & file_name & "'"
  2489. cmd.CommandText = sql
  2490. cmd.ExecuteNonQuery()
  2491. End If
  2492. xlApp = CreateObject("Excel.Application")
  2493. xlApp.Visible = True
  2494. xlApp.DisplayAlerts = False
  2495. xlBook = xlApp.Workbooks.Open(file_name,, True)
  2496. xlBook.Activate()
  2497. For i = 1 To xlApp.Worksheets.Count
  2498. If xlApp.Workbooks(1).Worksheets(i).name = "加和" Or xlApp.Workbooks(1).Worksheets(i).name = "1" Then
  2499. xlSheet = xlApp.Workbooks(1).Worksheets(i)
  2500. xlSheet.Activate()
  2501. Exit For
  2502. End If
  2503. Next
  2504. Dim y As Integer = 0
  2505. For y = 3 To xlApp.ActiveSheet.UsedRange.Rows.Count
  2506. If Len(xlSheet.Cells(y, 7).value) < 1 Then
  2507. Exit For
  2508. End If
  2509. Next y
  2510. 'xlApp.Range("A4:m" & y - 1).Select()
  2511. '' If xlApp.Selection.mergecells = True Then
  2512. 'xlApp.Selection.UnMerge
  2513. 'xlApp.Selection.SpecialCells(Microsoft.Office.Interop.Excel.XlCellType.xlCellTypeBlanks).Select
  2514. 'xlApp.CutCopyMode = False
  2515. 'xlApp.Selection.FormulaR1C1 = "=R[-1]C"
  2516. '' End If
  2517. Dim my_no As String
  2518. Dim s1 As Integer = 0
  2519. For y = 4 To y - 1
  2520. If y = 4 Then
  2521. my_no = xlSheet.Cells(4, 1).value
  2522. End If
  2523. If xlSheet.Cells(y, 1).value Is Nothing Then
  2524. Else
  2525. my_no = xlSheet.Cells(y, 1).value
  2526. End If
  2527. sql = "insert into rt_ship_temp_1 (CARD,serial,filename,no,po_no,work_no,material_no,name,thick,
  2528. color1,qty) values('" & xlSheet.Cells(y, 9).value & "','" & s1 & "',N'" & file_name & "','" &
  2529. my_no & "',N'" & xlSheet.Cells(y, 2).value & "','" & xlSheet.Cells(y, 3).value & "','" & xlSheet.Cells(y, 4).value & "',N'" & xlSheet.Cells(y, 5).value & "','" & xlSheet.Cells(y, 6).value &
  2530. "',N'" & xlSheet.Cells(y, 5).value & "','" & xlSheet.Cells(y, 8).value & "')"
  2531. cmd.CommandText = sql
  2532. cmd.ExecuteScalar()
  2533. s1 = s1 + 1
  2534. Next
  2535. ElseIf OpenFileDialog1.SafeFileName Like "吉兴*" Then
  2536. Sql = "delete from rt_ship_daily_JX"
  2537. cmd.CommandText = sql
  2538. cmd.ExecuteNonQuery()
  2539. sql = "delete from rt_ship_temp_1 where filename=N'" & file_name & "'"
  2540. cmd.CommandText = sql
  2541. cmd.ExecuteNonQuery()
  2542. 'For i = 1 To xlApp.Worksheets.Count
  2543. ' If xlApp.Workbooks(1).Worksheets(i).name = "0" Then
  2544. ' Exit For
  2545. ' End If
  2546. 'Next
  2547. xlSheet = xlApp.Workbooks(1).Worksheets(1)
  2548. xlSheet.Activate()
  2549. Dim y As Integer = 0
  2550. For y = 8 To xlApp.ActiveSheet.UsedRange.Rows.Count
  2551. If Len(xlSheet.Cells(y, 2).value) < 1 Then
  2552. Exit For
  2553. End If
  2554. Next y
  2555. xlApp.Range("A2:u" & y - 1).Select()
  2556. xlApp.Selection.UnMerge
  2557. xlApp.Selection.SpecialCells(Microsoft.Office.Interop.Excel.XlCellType.xlCellTypeBlanks).Select
  2558. xlApp.CutCopyMode = False
  2559. xlApp.Selection.FormulaR1C1 = "=R[-1]C"
  2560. For y = 8 To y - 1
  2561. Sql = "insert into rt_ship_daily_jx (no,name,color,qty,nw,gw,po_no) values('" & xlSheet.Cells(y, 4).value & "',N'" & xlSheet.Cells(y, 8).value & "',N'" & xlSheet.Cells(y, 10).value & "'," & xlSheet.Cells(y, 13).value & "," & xlSheet.Cells(y, 17).value & "," & xlSheet.Cells(y, 20).value & ",N'" & xlSheet.Cells(y, 2).value & "')"
  2562. cmd.CommandText = sql
  2563. cmd.ExecuteScalar()
  2564. sql = "insert into rt_ship_temp_1 (no,name,color,qty,nw,gw,po_no) values('" & xlSheet.Cells(y, 4).value & "',N'" & xlSheet.Cells(y, 8).value & "',N'" & xlSheet.Cells(y, 10).value & "'," & xlSheet.Cells(y, 13).value & "," & xlSheet.Cells(y, 17).value & "," & xlSheet.Cells(y, 20).value & ",N'" & xlSheet.Cells(y, 2).value & "')"
  2565. cmd.CommandText = sql
  2566. cmd.ExecuteScalar()
  2567. Next
  2568. Sql = "select 订单号,类别,cast(sum(数量) as numeric(10,1)) as 尺数,cast(sum(数量*单价) as numeric(10,3)) as 货值,sum(重量) as 净重,厚度 from
  2569. (SELECT po_no as 订单号,name as 品名,case when name like '%PU %' or name like '%action%' or name like N'%榔%' or name like N'%virgin%' then 'PU' else '反毛' end as 类别, qty as 数量,
  2570. cast(qty/SUM(qty) OVER (PARTITION BY no) *nw as numeric(10,1)) as 重量,case when left(ltrim(name),3)='1.2' then left(ltrim(name),3) +'4' else '1.46' end as 厚度,unit_price as 单价
  2571. FROM RT_SHIP_DAILY_jx) as p group by 订单号,类别,厚度"
  2572. cmd.CommandText = Sql
  2573. dt = New DataTable
  2574. da.SelectCommand = cmd
  2575. da.Fill(dt)
  2576. dgv1.DataSource = dt
  2577. Sql = "select 类别,sum(尺数),sum(净重),sum(货值) from(select 订单号,类别,cast(sum(数量) as numeric(10,1)) as 尺数,cast(sum(数量*单价) as numeric(10,3)) as 货值,sum(重量) as 净重,厚度 from (SELECT po_no as 订单号,name as 品名,case when name like '%PU %' or name like '% action %' or name like N'%榔%' or name like N'% virgin %' then 'PU' else '反毛' end as 类别, qty as 数量,cast(qty/SUM(qty) OVER (PARTITION BY no) *nw as numeric(10,1)) as 重量,case when left(ltrim(name),3)='1.2' then left(ltrim(name),3) +'4' else '1.46' end as 厚度,unit_price as 单价 FROM RT_SHIP_DAILY_jx) as p group by 订单号,类别,厚度) as q group by 类别"
  2578. cmd.CommandText = Sql
  2579. dt = New DataTable
  2580. da.SelectCommand = cmd
  2581. da.Fill(dt)
  2582. dgv2.DataSource = dt
  2583. ElseIf OpenFileDialog1.SafeFileName Like "*PEI HAI*" Then '-----------------------------------------
  2584. sql = "select count(*) from rt_ship_temp_1 where filename=N'" & file_name & "'"
  2585. cmd.CommandText = Sql
  2586. Dim msg As String
  2587. If cmd.ExecuteScalar > 0 Then
  2588. msg = MsgBox("资料已经存在,是否要覆盖?", MsgBoxStyle.YesNo, "警告")
  2589. If msg = vbNo Then
  2590. Exit Sub
  2591. End If
  2592. End If
  2593. If msg = vbYes Then
  2594. sql = "delete from rt_ship_temp_1 where filename=N'" & file_name & "'"
  2595. cmd.CommandText = sql
  2596. cmd.ExecuteNonQuery()
  2597. End If
  2598. xlApp = CreateObject("Excel.Application")
  2599. xlApp.Visible = True
  2600. xlApp.DisplayAlerts = False
  2601. xlBook = xlApp.Workbooks.Open(file_name,, True)
  2602. xlBook.Activate()
  2603. Dim s1 As Integer = 0
  2604. Dim my_no As Integer
  2605. For i = 1 To xlApp.Worksheets.Count
  2606. If xlApp.Workbooks(1).Worksheets(i).name = "1" Then
  2607. xlSheet = xlApp.Workbooks(1).Worksheets(i)
  2608. xlSheet.Activate()
  2609. Exit For
  2610. End If
  2611. Next
  2612. Dim y As Integer = 0
  2613. For y = 2 To xlApp.ActiveSheet.UsedRange.Rows.Count
  2614. If xlSheet.Cells(y, 2).value Is Nothing Then
  2615. Exit For
  2616. End If
  2617. Next y
  2618. xlApp.Range("A2:J" & y - 1).Select()
  2619. ' If xlApp.Selection.mergecells = True Then
  2620. xlApp.Selection.UnMerge
  2621. 'xlApp.Selection.SpecialCells(Microsoft.Office.Interop.Excel.XlCellType.xlCellTypeBlanks).Select
  2622. 'xlApp.CutCopyMode = False
  2623. 'xlApp.Selection.FormulaR1C1 = "=R[-1]C"
  2624. 'End If
  2625. s1 = 1
  2626. For y = 2 To y - 1
  2627. If xlSheet.Cells(y, 1).value Is Nothing Then
  2628. Else
  2629. my_no = xlSheet.Cells(y, 1).value
  2630. End If
  2631. sql = "insert into rt_ship_temp_1 (serial,filename,no,name,qty,po_no) values('" & s1 & "',N'" & file_name & "','" & my_no & "',N'" & xlSheet.Cells(y, 2).value & "'," & xlSheet.Cells(y, 3).value & ",N'" & xlSheet.Cells(y, 8).value & "')"
  2632. cmd.CommandText = sql
  2633. cmd.ExecuteScalar()
  2634. s1 = s1 + 1
  2635. Next
  2636. ElseIf OpenFileDialog1.SafeFileName Like "加和*" And Not (OpenFileDialog1.SafeFileName Like "*sample*") Then
  2637. sql = "select count(*) from rt_ship_TEMP_1 where filename=N'" & file_name & "'"
  2638. cmd.CommandText = Sql
  2639. Dim msg As String
  2640. If cmd.ExecuteScalar > 0 Then
  2641. msg = MsgBox("资料已经存在,是否要覆盖?", MsgBoxStyle.YesNo, "警告")
  2642. If msg = vbNo Then
  2643. Exit Sub
  2644. End If
  2645. End If
  2646. If msg = vbYes Then
  2647. sql = "delete from rt_ship_temp_1 where filename=N'" & file_name & "'"
  2648. cmd.CommandText = sql
  2649. cmd.ExecuteNonQuery()
  2650. End If
  2651. xlApp = CreateObject("Excel.Application")
  2652. xlApp.Visible = True
  2653. xlApp.DisplayAlerts = False
  2654. xlBook = xlApp.Workbooks.Open(file_name,, True)
  2655. xlBook.Activate()
  2656. For i = 1 To xlApp.Worksheets.Count
  2657. If xlApp.Workbooks(1).Worksheets(i).name = "加和" Then
  2658. xlSheet = xlApp.Workbooks(1).Worksheets(i)
  2659. xlSheet.Activate()
  2660. Exit For
  2661. End If
  2662. Next
  2663. Dim y As Integer = 0
  2664. For y = 4 To xlApp.ActiveSheet.UsedRange.Rows.Count
  2665. If Len(xlSheet.Cells(y, 7).value) < 1 Then
  2666. Exit For
  2667. End If
  2668. Next y
  2669. xlApp.Range("A4:m" & y - 1).Select()
  2670. ' If xlApp.Selection.mergecells = True Then
  2671. xlApp.Selection.UnMerge
  2672. xlApp.Selection.SpecialCells(Microsoft.Office.Interop.Excel.XlCellType.xlCellTypeBlanks).Select
  2673. xlApp.CutCopyMode = False
  2674. xlApp.Selection.FormulaR1C1 = "=R[-1]C"
  2675. ' End If
  2676. Dim my_no As String
  2677. Dim s1 As Integer = 0
  2678. For y = 4 To y - 1
  2679. If y = 4 Then
  2680. my_no = xlSheet.Cells(4, 1).value
  2681. End If
  2682. If xlSheet.Cells(y, 1).value Is Nothing Then
  2683. Else
  2684. my_no = xlSheet.Cells(y, 1).value
  2685. End If
  2686. sql = "insert into rt_ship_temp_1 (CARD,serial,filename,no,po_no,work_no,material_no,name,thick,
  2687. color1,qty) values('" & xlSheet.Cells(y, 9).value & "','" & s1 & "',N'" & file_name & "','" &
  2688. my_no & "',N'" & xlSheet.Cells(y, 2).value & "','" & xlSheet.Cells(y, 3).value & "','" & xlSheet.Cells(y, 4).value & "',N'" & xlSheet.Cells(y, 5).value & "','" & xlSheet.Cells(y, 6).value &
  2689. "',N'" & xlSheet.Cells(y, 5).value & "','" & xlSheet.Cells(y, 8).value & "')"
  2690. cmd.CommandText = sql
  2691. cmd.ExecuteScalar()
  2692. s1 = s1 + 1
  2693. Next
  2694. ElseIf OpenFileDialog1.SafeFileName Like "吉兴*" Then
  2695. Sql = "delete from rt_ship_daily_JX"
  2696. cmd.CommandText = sql
  2697. cmd.ExecuteNonQuery()
  2698. sql = "delete from rt_ship_temp_1 where filename=N'" & file_name & "'"
  2699. cmd.CommandText = sql
  2700. cmd.ExecuteNonQuery()
  2701. 'For i = 1 To xlApp.Worksheets.Count
  2702. ' If xlApp.Workbooks(1).Worksheets(i).name = "0" Then
  2703. ' Exit For
  2704. ' End If
  2705. 'Next
  2706. xlSheet = xlApp.Workbooks(1).Worksheets(1)
  2707. xlSheet.Activate()
  2708. Dim y As Integer = 0
  2709. For y = 8 To xlApp.ActiveSheet.UsedRange.Rows.Count
  2710. If Len(xlSheet.Cells(y, 2).value) < 1 Then
  2711. Exit For
  2712. End If
  2713. Next y
  2714. xlApp.Range("A2:u" & y - 1).Select()
  2715. xlApp.Selection.UnMerge
  2716. xlApp.Selection.SpecialCells(Microsoft.Office.Interop.Excel.XlCellType.xlCellTypeBlanks).Select
  2717. xlApp.CutCopyMode = False
  2718. xlApp.Selection.FormulaR1C1 = "=R[-1]C"
  2719. For y = 8 To y - 1
  2720. Sql = "insert into rt_ship_daily_jx (no,name,color,qty,nw,gw,po_no) values('" & xlSheet.Cells(y, 4).value & "',N'" & xlSheet.Cells(y, 8).value & "',N'" & xlSheet.Cells(y, 10).value & "'," & xlSheet.Cells(y, 13).value & "," & xlSheet.Cells(y, 17).value & "," & xlSheet.Cells(y, 20).value & ",N'" & xlSheet.Cells(y, 2).value & "')"
  2721. cmd.CommandText = sql
  2722. cmd.ExecuteScalar()
  2723. sql = "insert into rt_ship_temp_1 (no,name,color,qty,nw,gw,po_no) values('" & xlSheet.Cells(y, 4).value & "',N'" & xlSheet.Cells(y, 8).value & "',N'" & xlSheet.Cells(y, 10).value & "'," & xlSheet.Cells(y, 13).value & "," & xlSheet.Cells(y, 17).value & "," & xlSheet.Cells(y, 20).value & ",N'" & xlSheet.Cells(y, 2).value & "')"
  2724. cmd.CommandText = sql
  2725. cmd.ExecuteScalar()
  2726. Next
  2727. Sql = "select 订单号,类别,cast(sum(数量) as numeric(10,1)) as 尺数,cast(sum(数量*单价) as numeric(10,3)) as 货值,sum(重量) as 净重,厚度 from
  2728. (SELECT po_no as 订单号,name as 品名,case when name like '%PU %' or name like '%action%' or name like N'%榔%' or name like N'%virgin%' then 'PU' else '反毛' end as 类别, qty as 数量,
  2729. cast(qty/SUM(qty) OVER (PARTITION BY no) *nw as numeric(10,1)) as 重量,case when left(ltrim(name),3)='1.2' then left(ltrim(name),3) +'4' else '1.46' end as 厚度,unit_price as 单价
  2730. FROM RT_SHIP_DAILY_jx) as p group by 订单号,类别,厚度"
  2731. cmd.CommandText = Sql
  2732. dt = New DataTable
  2733. da.SelectCommand = cmd
  2734. da.Fill(dt)
  2735. dgv1.DataSource = dt
  2736. Sql = "select 类别,sum(尺数),sum(净重),sum(货值) from(select 订单号,类别,cast(sum(数量) as numeric(10,1)) as 尺数,cast(sum(数量*单价) as numeric(10,3)) as 货值,sum(重量) as 净重,厚度 from (SELECT po_no as 订单号,name as 品名,case when name like '%PU %' or name like '% action %' or name like N'%榔%' or name like N'% virgin %' then 'PU' else '反毛' end as 类别, qty as 数量,cast(qty/SUM(qty) OVER (PARTITION BY no) *nw as numeric(10,1)) as 重量,case when left(ltrim(name),3)='1.2' then left(ltrim(name),3) +'4' else '1.46' end as 厚度,unit_price as 单价 FROM RT_SHIP_DAILY_jx) as p group by 订单号,类别,厚度) as q group by 类别"
  2737. cmd.CommandText = Sql
  2738. dt = New DataTable
  2739. da.SelectCommand = cmd
  2740. da.Fill(dt)
  2741. dgv2.DataSource = dt
  2742. ElseIf OpenFileDialog1.SafeFileName Like "*coach*" Then '-----------------------------------------
  2743. sql = "select count(*) from rt_ship_temp_1 where filename=N'" & file_name & "'"
  2744. cmd.CommandText = Sql
  2745. Dim msg As String
  2746. If cmd.ExecuteScalar > 0 Then
  2747. msg = MsgBox("资料已经存在,是否要覆盖?", MsgBoxStyle.YesNo, "警告")
  2748. If msg = vbNo Then
  2749. Exit Sub
  2750. End If
  2751. End If
  2752. If msg = vbYes Then
  2753. sql = "delete from rt_ship_temp_1 where filename=N'" & file_name & "'"
  2754. cmd.CommandText = sql
  2755. cmd.ExecuteNonQuery()
  2756. End If
  2757. xlApp = CreateObject("Excel.Application")
  2758. xlApp.Visible = True
  2759. xlApp.DisplayAlerts = False
  2760. xlBook = xlApp.Workbooks.Open(file_name,, True)
  2761. xlBook.Activate()
  2762. Dim s1 As Integer = 0
  2763. Dim my_no As Integer
  2764. For i = 1 To xlApp.Worksheets.Count
  2765. If xlApp.Workbooks(1).Worksheets(i).name = "1" Then
  2766. xlSheet = xlApp.Workbooks(1).Worksheets(i)
  2767. xlSheet.Activate()
  2768. Exit For
  2769. End If
  2770. Next
  2771. Dim y As Integer = 0
  2772. For y = 2 To xlApp.ActiveSheet.UsedRange.Rows.Count
  2773. If xlSheet.Cells(y, 2).value Is Nothing Then
  2774. Exit For
  2775. End If
  2776. Next y
  2777. xlApp.Range("A2:J" & y - 1).Select()
  2778. ' If xlApp.Selection.mergecells = True Then
  2779. xlApp.Selection.UnMerge
  2780. 'xlApp.Selection.SpecialCells(Microsoft.Office.Interop.Excel.XlCellType.xlCellTypeBlanks).Select
  2781. 'xlApp.CutCopyMode = False
  2782. 'xlApp.Selection.FormulaR1C1 = "=R[-1]C"
  2783. 'End If
  2784. s1 = 1
  2785. For y = 2 To y - 1
  2786. If xlSheet.Cells(y, 1).value Is Nothing Then
  2787. Else
  2788. my_no = xlSheet.Cells(y, 1).value
  2789. End If
  2790. sql = "insert into rt_ship_temp_1 (serial,filename,no,name,qty,po_no) values('" & s1 & "',N'" & file_name & "','" & my_no & "',N'" & xlSheet.Cells(y, 2).value & "'," & xlSheet.Cells(y, 3).value & ",N'" & xlSheet.Cells(y, 7).value & "')"
  2791. cmd.CommandText = sql
  2792. cmd.ExecuteScalar()
  2793. s1 = s1 + 1
  2794. Next
  2795. ElseIf OpenFileDialog1.SafeFileName Like "锐奇*" Then '---------------------
  2796. sql = "select count(*) from rt_ship_TEMP_1 where filename=N'" & file_name & "'"
  2797. cmd.CommandText = Sql
  2798. Dim msg As String
  2799. If cmd.ExecuteScalar > 0 Then
  2800. msg = MsgBox("资料已经存在,是否要覆盖?", MsgBoxStyle.YesNo, "警告")
  2801. If msg = vbNo Then
  2802. Exit Sub
  2803. End If
  2804. End If
  2805. If msg = vbYes Then
  2806. sql = "delete from rt_ship_temp_1 where filename=N'" & file_name & "'"
  2807. cmd.CommandText = sql
  2808. cmd.ExecuteNonQuery()
  2809. End If
  2810. xlApp = CreateObject("Excel.Application")
  2811. xlApp.Visible = True
  2812. xlApp.DisplayAlerts = False
  2813. xlBook = xlApp.Workbooks.Open(file_name,, True)
  2814. xlBook.Activate()
  2815. xlApp = CreateObject("Excel.Application")
  2816. xlApp.Visible = True
  2817. xlApp.DisplayAlerts = False
  2818. xlBook = xlApp.Workbooks.Open(file_name,, True)
  2819. xlBook.Activate()
  2820. Dim s1 As Integer = 0
  2821. Dim my_no As Integer
  2822. For i = 1 To xlApp.Worksheets.Count
  2823. If xlApp.Workbooks(1).Worksheets(i).name = "1" Then
  2824. xlSheet = xlApp.Workbooks(1).Worksheets(i)
  2825. xlSheet.Activate()
  2826. Exit For
  2827. End If
  2828. Next
  2829. Dim y As Integer = 0
  2830. For y = 2 To xlApp.ActiveSheet.UsedRange.Rows.Count
  2831. If xlSheet.Cells(y, 2).value Is Nothing Then
  2832. Exit For
  2833. End If
  2834. Next y
  2835. xlApp.Range("A2:h" & y - 1).Select()
  2836. ' If xlApp.Selection.mergecells = True Then
  2837. xlApp.Selection.UnMerge
  2838. 'End If
  2839. s1 = 1
  2840. For y = 2 To y - 1
  2841. If xlSheet.Cells(y, 1).value Is Nothing Then
  2842. Else
  2843. my_no = xlSheet.Cells(y, 1).value
  2844. End If
  2845. sql = "insert into rt_ship_temp_1 (serial,filename,no,name,qty,po_no,work_no,card) values('" & s1 & "',N'" & file_name & "','" & my_no & "',N'" & xlSheet.Cells(y, 2).value & "','" & xlSheet.Cells(y, 3).value & "',N'" & xlSheet.Cells(y, 6).value & "',N'" & xlSheet.Cells(y, 7).value & "',N'" & xlSheet.Cells(y, 4).value & "')"
  2846. cmd.CommandText = sql
  2847. cmd.ExecuteScalar()
  2848. s1 = s1 + 1
  2849. Next
  2850. Sql = "select 订单号,cast(sum(数量) as numeric(10,1)) as 尺数,sum(重量) as 净重,厚度 from (SELECT po_no as 订单号,name as 品名, qty as 数量,cast(qty/SUM(qty) OVER (PARTITION BY no) *nw as numeric(10,1)) as 重量,case when left(ltrim(name),3)='1.2' then left(ltrim(name),3) +'4' else '1.46' end as 厚度
  2851. FROM RT_SHIP_DAILY_YB ) as p group by 订单号,厚度" '旧
  2852. Sql = "SELECT name as 品名,po_no as 采购号,work_no as 订单号, cast(sum(qty) as numeric(10,1)) as 尺数,deli_no as 发货单号 from RT_SHIP_DAILY_ruiqi group by po_no,name,work_no,deli_no"
  2853. cmd.CommandText = Sql
  2854. dt = New DataTable
  2855. da.SelectCommand = cmd
  2856. da.Fill(dt)
  2857. dgv1.DataSource = dt
  2858. dgv1.Columns("品名").Width = 300
  2859. dgv1.Columns("采购号").Width = 150
  2860. dgv1.Columns("订单号").Width = 200
  2861. ElseIf OpenFileDialog1.SafeFileName Like "鑫龙*" Then '---------------------
  2862. sql = "select count(*) from rt_ship_TEMP_1 where filename=N'" & file_name & "'"
  2863. cmd.CommandText = Sql
  2864. Dim msg As String
  2865. If cmd.ExecuteScalar > 0 Then
  2866. msg = MsgBox("资料已经存在,是否要覆盖?", MsgBoxStyle.YesNo, "警告")
  2867. If msg = vbNo Then
  2868. Exit Sub
  2869. End If
  2870. End If
  2871. If msg = vbYes Then
  2872. sql = "delete from rt_ship_temp_1 where filename=N'" & file_name & "'"
  2873. cmd.CommandText = sql
  2874. cmd.ExecuteNonQuery()
  2875. End If
  2876. xlApp = CreateObject("Excel.Application")
  2877. xlApp.Visible = True
  2878. xlApp.DisplayAlerts = False
  2879. xlBook = xlApp.Workbooks.Open(file_name,, True)
  2880. xlBook.Activate()
  2881. xlApp = CreateObject("Excel.Application")
  2882. xlApp.Visible = True
  2883. xlApp.DisplayAlerts = False
  2884. xlBook = xlApp.Workbooks.Open(file_name,, True)
  2885. xlBook.Activate()
  2886. Dim s1 As Integer = 0
  2887. Dim my_no As Integer
  2888. For i = 1 To xlApp.Worksheets.Count
  2889. If xlApp.Workbooks(1).Worksheets(i).name = "1" Then
  2890. xlSheet = xlApp.Workbooks(1).Worksheets(i)
  2891. xlSheet.Activate()
  2892. Exit For
  2893. End If
  2894. Next
  2895. Dim y As Integer = 0
  2896. For y = 2 To xlApp.ActiveSheet.UsedRange.Rows.Count
  2897. If xlSheet.Cells(y, 2).value Is Nothing Then
  2898. Exit For
  2899. End If
  2900. Next y
  2901. 'xlApp.Range("A2:h" & y - 1).Select()
  2902. '' If xlApp.Selection.mergecells = True Then
  2903. 'xlApp.Selection.UnMerge
  2904. 'End If
  2905. s1 = 1
  2906. For y = 2 To y - 1
  2907. If xlSheet.Cells(y, 1).value Is Nothing Then
  2908. Else
  2909. my_no = xlSheet.Cells(y, 1).value
  2910. End If
  2911. sql = "insert into rt_ship_temp_1 (serial,filename,no,name,qty,po_no) values('" & s1 & "',N'" & file_name & "','" & my_no & "',N'" & xlSheet.Cells(y, 2).value & "','" & xlSheet.Cells(y, 3).value & "','" & xlSheet.Cells(y, 6).value & "')"
  2912. cmd.CommandText = sql
  2913. cmd.ExecuteScalar()
  2914. s1 = s1 + 1
  2915. Next
  2916. Dim mysplit() As String
  2917. dt = New DataTable
  2918. sql = "select * from rt_ship_temp_1 where color1 is null and filename like N'%鑫龙%'"
  2919. cmd.CommandText = sql
  2920. da.Fill(dt)
  2921. For d As Integer = 0 To dt.Rows.Count - 1
  2922. mysplit = Split(dt.Rows(d).Item("name"), " ")
  2923. If UBound(mysplit) > 0 Then
  2924. sql = "update rt_ship_temp_1 set color1='" & mysplit(0) & "' where po_no='" & dt.Rows(d).Item("po_no") & "' and name='" & dt.Rows(d).Item("name") & "' and qty='" & dt.Rows(d).Item("qty") & "' and serial='" & dt.Rows(d).Item("serial") & "'"
  2925. cmd.CommandText = sql
  2926. cmd.ExecuteScalar()
  2927. End If
  2928. Next
  2929. ElseIf OpenFileDialog1.SafeFileName Like "*鑫茂*" Then '---------------------
  2930. sql = "select count(*) from rt_ship_TEMP_1 where filename=N'" & file_name & "'"
  2931. cmd.CommandText = Sql
  2932. Dim msg As String
  2933. If cmd.ExecuteScalar > 0 Then
  2934. msg = MsgBox("资料已经存在,是否要覆盖?", MsgBoxStyle.YesNo, "警告")
  2935. If msg = vbNo Then
  2936. Exit Sub
  2937. End If
  2938. End If
  2939. If msg = vbYes Then
  2940. sql = "delete from rt_ship_temp_1 where filename=N'" & file_name & "'"
  2941. cmd.CommandText = sql
  2942. cmd.ExecuteNonQuery()
  2943. End If
  2944. xlApp = CreateObject("Excel.Application")
  2945. xlApp.Visible = True
  2946. xlApp.DisplayAlerts = False
  2947. xlBook = xlApp.Workbooks.Open(file_name,, True)
  2948. xlBook.Activate()
  2949. xlApp = CreateObject("Excel.Application")
  2950. xlApp.Visible = True
  2951. xlApp.DisplayAlerts = False
  2952. xlBook = xlApp.Workbooks.Open(file_name,, True)
  2953. xlBook.Activate()
  2954. Dim s1 As Integer = 0
  2955. Dim my_no As Integer
  2956. For i = 1 To xlApp.Worksheets.Count
  2957. If xlApp.Workbooks(1).Worksheets(i).name = "1" Then
  2958. xlSheet = xlApp.Workbooks(1).Worksheets(i)
  2959. xlSheet.Activate()
  2960. Exit For
  2961. End If
  2962. Next
  2963. Dim y As Integer = 0
  2964. For y = 2 To xlApp.ActiveSheet.UsedRange.Rows.Count
  2965. If xlSheet.Cells(y, 2).value Is Nothing Then
  2966. Exit For
  2967. End If
  2968. Next y
  2969. 'xlApp.Range("A2:h" & y - 1).Select()
  2970. '' If xlApp.Selection.mergecells = True Then
  2971. 'xlApp.Selection.UnMerge
  2972. 'End If
  2973. s1 = 1
  2974. For y = 2 To y - 1
  2975. If xlSheet.Cells(y, 1).value Is Nothing Then
  2976. Else
  2977. my_no = xlSheet.Cells(y, 1).value
  2978. End If
  2979. sql = "insert into rt_ship_temp_1 (serial,filename,no,name,qty,po_no) values('" & s1 & "',N'" & file_name & "','" & my_no & "',N'" & xlSheet.Cells(y, 2).value & "','" & xlSheet.Cells(y, 4).value & "','" & xlSheet.Cells(y, 6).value & "')"
  2980. cmd.CommandText = sql
  2981. cmd.ExecuteScalar()
  2982. s1 = s1 + 1
  2983. Next
  2984. Dim mysplit() As String
  2985. dt = New DataTable
  2986. sql = "select * from rt_ship_temp_1 where color1 is null and filename like N'%鑫龙%'"
  2987. cmd.CommandText = sql
  2988. da.Fill(dt)
  2989. For d As Integer = 0 To dt.Rows.Count - 1
  2990. mysplit = Split(dt.Rows(d).Item("name"), " ")
  2991. If UBound(mysplit) > 0 Then
  2992. sql = "update rt_ship_temp_1 set color1='" & mysplit(0) & "' where po_no='" & dt.Rows(d).Item("po_no") & "' and name='" & dt.Rows(d).Item("name") & "' and qty='" & dt.Rows(d).Item("qty") & "' and serial='" & dt.Rows(d).Item("serial") & "'"
  2993. cmd.CommandText = sql
  2994. cmd.ExecuteScalar()
  2995. End If
  2996. Next
  2997. ElseIf OpenFileDialog1.SafeFileName Like "*亿博*" And (OpenFileDialog1.SafeFileName Like "*华盛*" Or OpenFileDialog1.SafeFileName Like "*NK*") Then '-----------------------------------
  2998. sql = "select count(*) from rt_ship_temp_1 where filename=N'" & file_name & "'"
  2999. cmd.CommandText = Sql
  3000. Dim msg As String
  3001. If cmd.ExecuteScalar > 0 Then
  3002. msg = MsgBox("资料已经存在,是否要覆盖?", MsgBoxStyle.YesNo, "警告")
  3003. If msg = vbNo Then
  3004. Exit Sub
  3005. End If
  3006. End If
  3007. If msg = vbYes Then
  3008. sql = "delete from rt_ship_temp_1 where filename=N'" & file_name & "'"
  3009. cmd.CommandText = sql
  3010. cmd.ExecuteNonQuery()
  3011. End If
  3012. xlApp = CreateObject("Excel.Application")
  3013. xlApp.Visible = True
  3014. xlApp.DisplayAlerts = False
  3015. xlBook = xlApp.Workbooks.Open(file_name,, True)
  3016. xlBook.Activate()
  3017. Dim s1 As Integer = 0
  3018. Dim my_no As Integer
  3019. For i = 1 To xlApp.Worksheets.Count
  3020. If xlApp.Workbooks(1).Worksheets(i).name = "明细" Then
  3021. xlSheet = xlApp.Workbooks(1).Worksheets(i)
  3022. xlSheet.Activate()
  3023. Exit For
  3024. End If
  3025. Next
  3026. Dim y As Integer = 0
  3027. For y = 2 To xlApp.ActiveSheet.UsedRange.Rows.Count
  3028. If xlSheet.Cells(y, 2).value = "合计:" Then
  3029. Exit For
  3030. End If
  3031. Next y
  3032. xlApp.Range("A2:i" & y - 1).Select()
  3033. ' If xlApp.Selection.mergecells = True Then
  3034. xlApp.Selection.UnMerge
  3035. 'xlApp.Selection.SpecialCells(Microsoft.Office.Interop.Excel.XlCellType.xlCellTypeBlanks).Select
  3036. 'xlApp.CutCopyMode = False
  3037. 'xlApp.Selection.FormulaR1C1 = "=R[-1]C"
  3038. 'End If
  3039. s1 = 1
  3040. For y = 2 To y - 1
  3041. If xlSheet.Cells(y, 1).value Is Nothing Then
  3042. Else
  3043. my_no = xlSheet.Cells(y, 1).value
  3044. End If
  3045. sql = "insert into rt_ship_temp_1 (serial,filename,no,name,qty,po_no,thick) values('" & s1 & "',N'" & file_name & "','" & my_no & "',N'" & xlSheet.Cells(y, 2).value & "'," & xlSheet.Cells(y, 4).value & ",N'" & xlSheet.Cells(y, 9).value & "','" & xlSheet.Cells(y, 3).value & "')"
  3046. cmd.CommandText = sql
  3047. cmd.ExecuteScalar()
  3048. s1 = s1 + 1
  3049. Next
  3050. Sql = "select 订单号,cast(sum(数量) as numeric(10,1)) as 尺数,sum(重量) as 净重,厚度 from (SELECT po_no as 订单号,name as 品名, qty as 数量,cast(qty/SUM(qty) OVER (PARTITION BY no) *nw as numeric(10,1)) as 重量,case when left(ltrim(name),3)='1.2' then left(ltrim(name),3) +'4' else '1.46' end as 厚度
  3051. FROM RT_SHIP_DAILY_YB ) as p group by 订单号,厚度" '旧
  3052. Sql = "SELECT name as 品名,po_no as 订单号, cast(sum(qty) as numeric(10,1)) as 尺数,deli_no as 发货单号 from rt_ship_daily_yby_huasheng group by po_no,name,deli_no"
  3053. cmd.CommandText = Sql
  3054. dt = New DataTable
  3055. da.SelectCommand = cmd
  3056. da.Fill(dt)
  3057. dgv1.DataSource = dt
  3058. dgv1.Columns("品名").Width = 350
  3059. dgv1.Columns("订单号").Width = 150
  3060. ElseIf OpenFileDialog1.SafeFileName Like "EVERGREE*" Then '------------------------------------
  3061. Sql = "select count(*) from rt_ship_daily_evergree where filename=N'" & file_name & "'"
  3062. cmd.CommandText = Sql
  3063. Dim msg As String
  3064. If cmd.ExecuteScalar > 0 Then
  3065. msg = MsgBox("资料已经存在,是否要覆盖?", MsgBoxStyle.YesNo, "警告")
  3066. If msg = vbNo Then
  3067. Exit Sub
  3068. End If
  3069. End If
  3070. If msg = vbYes Then
  3071. Sql = "delete from rt_ship_daily_evergree where filename=N'" & file_name & "'"
  3072. cmd.CommandText = sql
  3073. cmd.ExecuteNonQuery()
  3074. sql = "delete from rt_ship_temp_1 where filename=N'" & file_name & "'"
  3075. cmd.CommandText = sql
  3076. cmd.ExecuteNonQuery()
  3077. End If
  3078. xlApp = CreateObject("Excel.Application")
  3079. xlApp.Visible = True
  3080. xlApp.DisplayAlerts = False
  3081. xlBook = xlApp.Workbooks.Open(file_name,, True)
  3082. xlBook.Activate()
  3083. Dim s1 As Integer = 0
  3084. Dim my_no As Integer
  3085. For i = 1 To xlApp.Worksheets.Count
  3086. If xlApp.Workbooks(1).Worksheets(i).name = "1" Then
  3087. xlSheet = xlApp.Workbooks(1).Worksheets(i)
  3088. xlSheet.Activate()
  3089. Exit For
  3090. End If
  3091. Next
  3092. Dim y As Integer = 0
  3093. For y = 2 To xlApp.ActiveSheet.UsedRange.Rows.Count
  3094. If xlSheet.Cells(y, 2).value Is Nothing Then
  3095. Exit For
  3096. End If
  3097. Next y
  3098. xlApp.Range("A2:J" & y - 1).Select()
  3099. ' If xlApp.Selection.mergecells = True Then
  3100. xlApp.Selection.UnMerge
  3101. xlApp.Selection.SpecialCells(Microsoft.Office.Interop.Excel.XlCellType.xlCellTypeBlanks).Select
  3102. xlApp.CutCopyMode = False
  3103. xlApp.Selection.FormulaR1C1 = "=R[-1]C"
  3104. 'End If
  3105. s1 = 1
  3106. For y = 2 To y - 1
  3107. If xlSheet.Cells(y, 1).value Is Nothing Then
  3108. Else
  3109. my_no = xlSheet.Cells(y, 1).value
  3110. End If
  3111. sql = "insert into rt_ship_temp_1 (serial,filename,no,name,qty,po_no) values('" & s1 & "',N'" & file_name & "','" & my_no & "',N'" & xlSheet.Cells(y, 2).value & "'," & xlSheet.Cells(y, 3).value & "," & "N'" & xlSheet.Cells(y, 7).value & "')"
  3112. cmd.CommandText = sql
  3113. cmd.ExecuteScalar()
  3114. s1 = s1 + 1
  3115. Next
  3116. ElseIf OpenFileDialog1.SafeFileName Like "*THANH*" Then '------------------------------------------------------------------------
  3117. sql = "select count(*) from rt_ship_temp_1 where filename=N'" & file_name & "'"
  3118. cmd.CommandText = Sql
  3119. Dim msg As String
  3120. If cmd.ExecuteScalar > 0 Then
  3121. msg = MsgBox("资料已经存在,是否要覆盖?", MsgBoxStyle.YesNo, "警告")
  3122. If msg = vbNo Then
  3123. Exit Sub
  3124. End If
  3125. End If
  3126. If msg = vbYes Then
  3127. sql = "delete from rt_ship_temp_1 where filename=N'" & file_name & "'"
  3128. cmd.CommandText = sql
  3129. cmd.ExecuteNonQuery()
  3130. End If
  3131. xlApp = CreateObject("Excel.Application")
  3132. xlApp.Visible = True
  3133. xlApp.DisplayAlerts = False
  3134. xlBook = xlApp.Workbooks.Open(file_name,, True)
  3135. xlBook.Activate()
  3136. Dim s1 As Integer = 0
  3137. Dim my_no As Integer
  3138. For i = 1 To xlApp.Worksheets.Count
  3139. If xlApp.Workbooks(1).Worksheets(i).name = "1" Then
  3140. xlSheet = xlApp.Workbooks(1).Worksheets(i)
  3141. xlSheet.Activate()
  3142. Exit For
  3143. End If
  3144. Next
  3145. Dim y As Integer = 0
  3146. For y = 2 To xlApp.ActiveSheet.UsedRange.Rows.Count
  3147. If xlSheet.Cells(y, 2).value Is Nothing Then
  3148. Exit For
  3149. End If
  3150. Next y
  3151. xlApp.Range("A2:J" & y - 1).Select()
  3152. ' If xlApp.Selection.mergecells = True Then
  3153. xlApp.Selection.UnMerge
  3154. 'xlApp.Selection.SpecialCells(Microsoft.Office.Interop.Excel.XlCellType.xlCellTypeBlanks).Select
  3155. 'xlApp.CutCopyMode = False
  3156. 'xlApp.Selection.FormulaR1C1 = "=R[-1]C"
  3157. 'End If
  3158. s1 = 1
  3159. For y = 2 To y - 1
  3160. If xlSheet.Cells(y, 1).value Is Nothing Then
  3161. Else
  3162. my_no = xlSheet.Cells(y, 1).value
  3163. End If
  3164. sql = "insert into rt_ship_temp_1 (serial,filename,no,name,qty,nw,gw,po_no) values('" & s1 & "',N'" & file_name & "','" & my_no & "',N'" & xlSheet.Cells(y, 2).value & "'," & xlSheet.Cells(y, 3).value & "," & xlSheet.Cells(y, 6).value & "," & xlSheet.Cells(y, 7).value & ",N'" & xlSheet.Cells(y, 8).value & "')"
  3165. cmd.CommandText = sql
  3166. cmd.ExecuteScalar()
  3167. s1 = s1 + 1
  3168. Next
  3169. Sql = "select 订单号,cast(sum(数量) as numeric(10,1)) as 尺数,sum(重量) as 净重,厚度 from (SELECT po_no as 订单号,name as 品名, qty as 数量,cast(qty/SUM(qty) OVER (PARTITION BY no) *nw as numeric(10,1)) as 重量,case when left(ltrim(name),3)='1.2' then left(ltrim(name),3) +'4' else '1.46' end as 厚度
  3170. FROM RT_SHIP_DAILY_YB ) as p group by 订单号,厚度" '旧
  3171. Sql = "SELECT name as 品名,po_no as 订单号, cast(sum(qty) as numeric(10,1)) as 尺数,deli_no as 发货单号 from RT_SHIP_DAILY_thanhhu group by po_no,name,deli_no"
  3172. cmd.CommandText = Sql
  3173. dt = New DataTable
  3174. da.SelectCommand = cmd
  3175. da.Fill(dt)
  3176. dgv1.DataSource = dt
  3177. dgv1.Columns("品名").Width = 400
  3178. dgv1.Columns("订单号").Width = 150
  3179. ElseIf OpenFileDialog1.SafeFileName Like "PROPERWELL*" Then '------------------------------------------------------
  3180. Sql = "select count(*) from rt_ship_daily_PROPERWELL where filename=N'" & file_name & "'"
  3181. cmd.CommandText = Sql
  3182. Dim msg As String
  3183. If cmd.ExecuteScalar > 0 Then
  3184. msg = MsgBox("资料已经存在,是否要覆盖?", MsgBoxStyle.YesNo, "警告")
  3185. If msg = vbNo Then
  3186. Exit Sub
  3187. End If
  3188. End If
  3189. If msg = vbYes Then
  3190. Sql = "delete from rt_ship_daily_PROPERWELL where filename=N'" & file_name & "'"
  3191. cmd.CommandText = sql
  3192. cmd.ExecuteNonQuery()
  3193. sql = "delete from rt_ship_temp_1 where filename=N'" & file_name & "'"
  3194. cmd.CommandText = sql
  3195. cmd.ExecuteNonQuery()
  3196. End If
  3197. xlApp = CreateObject("Excel.Application")
  3198. xlApp.Visible = True
  3199. xlApp.DisplayAlerts = False
  3200. xlBook = xlApp.Workbooks.Open(file_name,, True)
  3201. xlBook.Activate()
  3202. Dim s1 As Integer = 0
  3203. Dim my_no As Integer
  3204. For i = 1 To xlApp.Worksheets.Count
  3205. If xlApp.Workbooks(1).Worksheets(i).name = "1" Then
  3206. xlSheet = xlApp.Workbooks(1).Worksheets(i)
  3207. xlSheet.Activate()
  3208. Exit For
  3209. End If
  3210. Next
  3211. Dim y As Integer = 0
  3212. For y = 2 To xlApp.ActiveSheet.UsedRange.Rows.Count
  3213. If xlSheet.Cells(y, 2).value Is Nothing Then
  3214. Exit For
  3215. End If
  3216. Next y
  3217. xlApp.Range("A2:J" & y - 1).Select()
  3218. ' If xlApp.Selection.mergecells = True Then
  3219. xlApp.Selection.UnMerge
  3220. xlApp.Selection.SpecialCells(Microsoft.Office.Interop.Excel.XlCellType.xlCellTypeBlanks).Select
  3221. xlApp.CutCopyMode = False
  3222. xlApp.Selection.FormulaR1C1 = "=R[-1]C"
  3223. 'End If
  3224. s1 = 1
  3225. For y = 2 To y - 1
  3226. If xlSheet.Cells(y, 1).value Is Nothing Then
  3227. Else
  3228. my_no = xlSheet.Cells(y, 1).value
  3229. End If
  3230. Sql = "insert into rt_ship_daily_PROPERWELL (serial,filename,no,name,qty,nw,gw,po_no) values('" & s1 & "',N'" & file_name & "','" & my_no & "',N'" & xlSheet.Cells(y, 2).value & "'," & xlSheet.Cells(y, 3).value & "," & xlSheet.Cells(y, 5).value & "," & xlSheet.Cells(y, 6).value & ",N'" & xlSheet.Cells(y, 7).value & "')"
  3231. cmd.CommandText = sql
  3232. cmd.ExecuteScalar()
  3233. sql = "insert into rt_ship_temp_1 (serial,filename,no,name,qty,nw,gw,po_no) values('" & s1 & "',N'" & file_name & "','" & my_no & "',N'" & xlSheet.Cells(y, 2).value & "'," & xlSheet.Cells(y, 3).value & "," & xlSheet.Cells(y, 5).value & "," & xlSheet.Cells(y, 6).value & ",N'" & xlSheet.Cells(y, 7).value & "')"
  3234. cmd.CommandText = sql
  3235. cmd.ExecuteScalar()
  3236. s1 = s1 + 1
  3237. Next
  3238. Sql = "select 订单号,cast(sum(数量) as numeric(10,1)) as 尺数,sum(重量) as 净重,厚度 from (SELECT po_no as 订单号,name as 品名, qty as 数量,cast(qty/SUM(qty) OVER (PARTITION BY no) *nw as numeric(10,1)) as 重量,case when left(ltrim(name),3)='1.2' then left(ltrim(name),3) +'4' else '1.46' end as 厚度
  3239. FROM RT_SHIP_DAILY_YB ) as p group by 订单号,厚度" '旧
  3240. Sql = "SELECT name as 品名,po_no as 订单号, cast(sum(qty) as numeric(10,1)) as 尺数,deli_no as 发货单号 from RT_SHIP_DAILY_PROPERWELL group by po_no,name,deli_no"
  3241. cmd.CommandText = Sql
  3242. dt = New DataTable
  3243. da.SelectCommand = cmd
  3244. da.Fill(dt)
  3245. dgv1.DataSource = dt
  3246. dgv1.Columns("品名").Width = 400
  3247. dgv1.Columns("订单号").Width = 150
  3248. ElseIf OpenFileDialog1.SafeFileName Like "STELLA*" Or OpenFileDialog1.SafeFileName Like "INDIA*" Or OpenFileDialog1.SafeFileName Like "RAMARIM*" Or OpenFileDialog1.SafeFileName Like "KHE *" Or OpenFileDialog1.SafeFileName Like "PONTUS*" Or OpenFileDialog1.SafeFileName Like "BRANCH *" Then '--------------------------------
  3249. sql = "select count(*) from rt_ship_temp_1 where filename=N'" & file_name & "'"
  3250. cmd.CommandText = Sql
  3251. Dim msg As String
  3252. If cmd.ExecuteScalar > 0 Then
  3253. msg = MsgBox("资料已经存在,是否要覆盖?", MsgBoxStyle.YesNo, "警告")
  3254. If msg = vbNo Then
  3255. Exit Sub
  3256. End If
  3257. End If
  3258. If msg = vbYes Then
  3259. sql = "delete from rt_ship_temp_1 where filename=N'" & file_name & "'"
  3260. cmd.CommandText = sql
  3261. cmd.ExecuteNonQuery()
  3262. End If
  3263. xlApp = CreateObject("Excel.Application")
  3264. xlApp.Visible = True
  3265. xlApp.DisplayAlerts = False
  3266. xlBook = xlApp.Workbooks.Open(file_name,, True)
  3267. xlBook.Activate()
  3268. Dim s1 As Integer = 0
  3269. Dim my_no As Integer
  3270. For i = 1 To xlApp.Worksheets.Count
  3271. If xlApp.Workbooks(1).Worksheets(i).name = "1" Then
  3272. xlSheet = xlApp.Workbooks(1).Worksheets(i)
  3273. xlSheet.Activate()
  3274. Exit For
  3275. End If
  3276. Next
  3277. Dim y As Integer = 0
  3278. For y = 2 To xlApp.ActiveSheet.UsedRange.Rows.Count
  3279. If xlSheet.Cells(y, 2).value Is Nothing Then
  3280. Exit For
  3281. End If
  3282. Next y
  3283. xlApp.Range("A2:J" & y - 1).Select()
  3284. ' If xlApp.Selection.mergecells = True Then
  3285. xlApp.Selection.UnMerge
  3286. xlApp.Selection.SpecialCells(Microsoft.Office.Interop.Excel.XlCellType.xlCellTypeBlanks).Select
  3287. xlApp.CutCopyMode = False
  3288. xlApp.Selection.FormulaR1C1 = "=R[-1]C"
  3289. 'End If
  3290. s1 = 1
  3291. For y = 2 To y - 1
  3292. If xlSheet.Cells(y, 1).value Is Nothing Then
  3293. Else
  3294. my_no = xlSheet.Cells(y, 1).value
  3295. End If
  3296. sql = "insert into rt_ship_temp_1 (thick,serial,filename,no,name,qty,po_no) values('1.24','" & s1 & "',N'" & file_name & "','" & my_no & "',N'" & xlSheet.Cells(y, 2).value & " " & xlSheet.Cells(y, 3).value & "'," & xlSheet.Cells(y, 4).value & ",N'" & xlSheet.Cells(y, 8).value & "')"
  3297. cmd.CommandText = sql
  3298. cmd.ExecuteScalar()
  3299. s1 = s1 + 1
  3300. Next
  3301. ElseIf OpenFileDialog1.SafeFileName Like "*HATAY*" And Not (OpenFileDialog1.SafeFileName Like "*手动*") Then '-----------------------------------------
  3302. sql = "select count(*) from rt_ship_temp_1 where filename=N'" & file_name & "'"
  3303. cmd.CommandText = sql
  3304. Dim msg As String
  3305. If cmd.ExecuteScalar > 0 Then
  3306. msg = MsgBox("资料已经存在,是否要覆盖?", MsgBoxStyle.YesNo, "警告")
  3307. If msg = vbNo Then
  3308. Exit Sub
  3309. End If
  3310. End If
  3311. If msg = vbYes Then
  3312. sql = "delete from rt_ship_temp_1 where filename=N'" & file_name & "'"
  3313. cmd.CommandText = sql
  3314. cmd.ExecuteNonQuery()
  3315. End If
  3316. xlApp = CreateObject("Excel.Application")
  3317. xlApp.Visible = True
  3318. xlApp.DisplayAlerts = False
  3319. xlBook = xlApp.Workbooks.Open(file_name,, True)
  3320. xlBook.Activate()
  3321. xlSheet = xlApp.Workbooks(1).Worksheets(1)
  3322. Dim y As Integer = 0
  3323. For y = 3 To xlApp.Workbooks(1).Worksheets(1).UsedRange.Rows.Count
  3324. If xlSheet.Cells(y, 2).value Is Nothing Then
  3325. Exit For
  3326. End If
  3327. Next y
  3328. yy = y - 1
  3329. xlApp.Range("A2:j" & yy).Select()
  3330. xlApp.Selection.UnMerge
  3331. Dim my_card As String
  3332. Dim my_no As String
  3333. Dim my_nw As String
  3334. Dim my_gw As String
  3335. Dim my_name As String
  3336. Dim my_po As String
  3337. Dim my_price As String
  3338. Dim s1 As String = 1
  3339. Dim my_skuno As String
  3340. Dim my_order_item As String
  3341. Dim my_color As String
  3342. s1 = 1
  3343. For y = 2 To y - 1
  3344. If y = 2 Then
  3345. my_no = xlSheet.Cells(y, 1).value
  3346. my_name = xlSheet.Cells(y, 2).value
  3347. my_po = xlSheet.Cells(y, 8).value
  3348. End If
  3349. If xlSheet.Cells(y, 1).value Is Nothing Then
  3350. Else
  3351. my_no = xlSheet.Cells(y, 1).value
  3352. End If
  3353. If xlSheet.Cells(y, 2).value Is Nothing Then
  3354. Else
  3355. my_name = xlSheet.Cells(y, 2).value
  3356. my_po = xlSheet.Cells(y, 8).value
  3357. End If
  3358. 'sql = "insert into rt_ship_daily_jj (color,work_no,thick,po_no,filename,serial,no,name,qty) values(N'" & xlSheet.Cells(y, 4).value & "',N'" & xlSheet.Cells(y, 6).Value.ToString.Replace("'", "''") & "',N'" & xlSheet.Cells(y, 5).value & "',N'" & xlSheet.Cells(y, 3).value & "',N'" & file_name & "','" & s1 & "','" & my_no & "',N'" & xlSheet.Cells(y, 4).value & "','" & xlSheet.Cells(y, 2).value & "')"
  3359. 'cmd.CommandText = sql
  3360. 'cmd.ExecuteScalar()
  3361. sql = "insert into rt_ship_temp_1 (card,po_no,filename,serial,no,name,qty) values(N'" & xlSheet.Cells(y, 4).value & "',N'" & my_po & "',N'" & file_name & "','" & s1 & "','" & my_no & "',N'" & my_name.ToString.Replace("'", "''") & "',N'" & xlSheet.Cells(y, 3).value & "')"
  3362. cmd.CommandText = sql & "','" & xlSheet.Cells(y, 3).value & "')"
  3363. cmd.CommandText = sql
  3364. cmd.ExecuteScalar()
  3365. s1 = s1 + 1
  3366. Next
  3367. sql = "update rt_ship_temp_1 set thick=1.24 where name like '%1.2%' and name like '%1.4%' and filename like N'%hatay%' "
  3368. cmd.CommandText = sql
  3369. cmd.ExecuteScalar()
  3370. sql = "update rt_ship_temp_1 set thick=1.46 where name like '%1.4%' and name like '%1.6%' and filename like N'%hatay%' "
  3371. cmd.CommandText = sql
  3372. cmd.ExecuteScalar()
  3373. ElseIf OpenFileDialog1.SafeFileName Like "*许宝贝*" Then '-----------------------------------------
  3374. sql = "select count(*) from rt_ship_temp_1 where filename=N'" & file_name & "'"
  3375. cmd.CommandText = sql
  3376. Dim msg As String
  3377. If cmd.ExecuteScalar > 0 Then
  3378. msg = MsgBox("资料已经存在,是否要覆盖?", MsgBoxStyle.YesNo, "警告")
  3379. If msg = vbNo Then
  3380. Exit Sub
  3381. End If
  3382. End If
  3383. If msg = vbYes Then
  3384. sql = "delete from rt_ship_temp_1 where filename=N'" & file_name & "'"
  3385. cmd.CommandText = sql
  3386. cmd.ExecuteNonQuery()
  3387. End If
  3388. xlApp = CreateObject("Excel.Application")
  3389. xlApp.Visible = True
  3390. xlApp.DisplayAlerts = False
  3391. xlBook = xlApp.Workbooks.Open(file_name,, True)
  3392. xlBook.Activate()
  3393. xlSheet = xlApp.Workbooks(1).Worksheets(1)
  3394. Dim my_card As String
  3395. Dim my_no As String
  3396. Dim my_nw As String
  3397. Dim my_gw As String
  3398. Dim my_name As String
  3399. Dim my_po As String
  3400. Dim my_price As String
  3401. Dim s1 As String = 1
  3402. Dim my_skuno As String
  3403. Dim my_order_item As String
  3404. Dim my_color As String
  3405. s1 = 1
  3406. For y = 3 To 100
  3407. If xlSheet.Cells(y, 3).value Is Nothing Then
  3408. Exit For
  3409. End If
  3410. sql = "insert into rt_ship_temp_1 (color1,thick,card,deli_no,deli,
  3411. po_no,filename,serial,no,name,qty) values(N'" & xlSheet.Cells(y, 4).value & "','" & xlSheet.Cells(y, 5).value & "','" & xlSheet.Cells(y, 7).value & "',N'" & xlSheet.Cells(y, 9).value & "',N'" & "尤珊荣" & "',N'" & xlSheet.Cells(y, 8).value & "',N'" & file_name & "','" & s1 & "','" & my_no & "',N'" & xlSheet.Cells(y, 4).value & "',N'" & xlSheet.Cells(y, 6).value & "')"
  3412. cmd.CommandText = sql
  3413. cmd.ExecuteScalar()
  3414. s1 = s1 + 1
  3415. Next
  3416. ElseIf OpenFileDialog1.SafeFileName Like "*手动*" Then '-----------------------------------------
  3417. sql = "select count(*) from rt_ship_temp_1 where filename=N'" & file_name & "'"
  3418. cmd.CommandText = sql
  3419. Dim msg As String
  3420. If cmd.ExecuteScalar > 0 Then
  3421. msg = MsgBox("资料已经存在,是否要覆盖?", MsgBoxStyle.YesNo, "警告")
  3422. If msg = vbNo Then
  3423. Exit Sub
  3424. End If
  3425. End If
  3426. If msg = vbYes Then
  3427. sql = "delete from rt_ship_temp_1 where filename=N'" & file_name & "'"
  3428. cmd.CommandText = sql
  3429. cmd.ExecuteNonQuery()
  3430. End If
  3431. xlApp = CreateObject("Excel.Application")
  3432. xlApp.Visible = True
  3433. xlApp.DisplayAlerts = False
  3434. xlBook = xlApp.Workbooks.Open(file_name,, True)
  3435. xlBook.Activate()
  3436. xlSheet = xlApp.Workbooks(1).Worksheets(1)
  3437. Dim my_card As String
  3438. Dim my_no As String
  3439. Dim my_nw As String
  3440. Dim my_gw As String
  3441. Dim my_name As String
  3442. Dim my_po As String
  3443. Dim my_price As String
  3444. Dim s1 As String = 1
  3445. Dim my_skuno As String
  3446. Dim my_order_item As String
  3447. Dim my_color As String
  3448. s1 = 1
  3449. For y = 3 To 100
  3450. If xlSheet.Cells(y, 3).value Is Nothing Then
  3451. Exit For
  3452. End If
  3453. sql = "insert into rt_ship_temp_1 (color1,thick,card,deli_no,deli,
  3454. po_no,work_no,filename,serial,no,name,qty) values(N'" & xlSheet.Cells(y, 4).value & "','" & xlSheet.Cells(y, 5).value & "','" & xlSheet.Cells(y, 7).value & "',N'" & xlSheet.Cells(y, 9).value & "',N'" & xlSheet.Cells(y, 10).value & "',N'" & xlSheet.Cells(y, 8).value & "',N'" & xlSheet.Cells(y, 11).value & "',N'" & file_name & "','" & s1 & "','" & my_no & "',N'" & xlSheet.Cells(y, 4).value & "',N'" & xlSheet.Cells(y, 6).value & "')"
  3455. cmd.CommandText = sql
  3456. cmd.ExecuteScalar()
  3457. s1 = s1 + 1
  3458. Next
  3459. ElseIf OpenFileDialog1.SafeFileName Like "*许宝贝*" Then '-----------------------------------------
  3460. sql = "select count(*) from rt_ship_temp_1 where filename=N'" & file_name & "'"
  3461. cmd.CommandText = sql
  3462. Dim msg As String
  3463. If cmd.ExecuteScalar > 0 Then
  3464. msg = MsgBox("资料已经存在,是否要覆盖?", MsgBoxStyle.YesNo, "警告")
  3465. If msg = vbNo Then
  3466. Exit Sub
  3467. End If
  3468. End If
  3469. If msg = vbYes Then
  3470. sql = "delete from rt_ship_temp_1 where filename=N'" & file_name & "'"
  3471. cmd.CommandText = sql
  3472. cmd.ExecuteNonQuery()
  3473. End If
  3474. xlApp = CreateObject("Excel.Application")
  3475. xlApp.Visible = True
  3476. xlApp.DisplayAlerts = False
  3477. xlBook = xlApp.Workbooks.Open(file_name,, True)
  3478. xlBook.Activate()
  3479. xlSheet = xlApp.Workbooks(1).Worksheets(1)
  3480. Dim my_card As String
  3481. Dim my_no As String
  3482. Dim my_nw As String
  3483. Dim my_gw As String
  3484. Dim my_name As String
  3485. Dim my_po As String
  3486. Dim my_price As String
  3487. Dim s1 As String = 1
  3488. Dim my_skuno As String
  3489. Dim my_order_item As String
  3490. Dim my_color As String
  3491. s1 = 1
  3492. For y = 3 To 100
  3493. If xlSheet.Cells(y, 3).value Is Nothing Then
  3494. Exit For
  3495. End If
  3496. sql = "insert into rt_ship_temp_1 (color1,thick,card,deli_no,deli,
  3497. po_no,filename,serial,no,name,qty) values(N'" & xlSheet.Cells(y, 4).value & "','" & xlSheet.Cells(y, 5).value & "','" & xlSheet.Cells(y, 7).value & "',N'" & xlSheet.Cells(y, 9).value & "',N'" & "尤珊荣" & "',N'" & xlSheet.Cells(y, 8).value & "',N'" & file_name & "','" & s1 & "','" & my_no & "',N'" & xlSheet.Cells(y, 4).value & "',N'" & xlSheet.Cells(y, 6).value & "')"
  3498. cmd.CommandText = sql
  3499. cmd.ExecuteScalar()
  3500. s1 = s1 + 1
  3501. Next
  3502. ElseIf OpenFileDialog1.SafeFileName Like "*手动锐奇*" Then '-----------------------------------------
  3503. sql = "select count(*) from rt_ship_temp_1 where filename=N'" & file_name & "'"
  3504. cmd.CommandText = sql
  3505. Dim msg As String
  3506. If cmd.ExecuteScalar > 0 Then
  3507. msg = MsgBox("资料已经存在,是否要覆盖?", MsgBoxStyle.YesNo, "警告")
  3508. If msg = vbNo Then
  3509. Exit Sub
  3510. End If
  3511. End If
  3512. If msg = vbYes Then
  3513. sql = "delete from rt_ship_temp_1 where filename=N'" & file_name & "'"
  3514. cmd.CommandText = sql
  3515. cmd.ExecuteNonQuery()
  3516. End If
  3517. xlApp = CreateObject("Excel.Application")
  3518. xlApp.Visible = True
  3519. xlApp.DisplayAlerts = False
  3520. xlBook = xlApp.Workbooks.Open(file_name,, True)
  3521. xlBook.Activate()
  3522. xlSheet = xlApp.Workbooks(1).Worksheets(1)
  3523. Dim my_card As String
  3524. Dim my_no As String
  3525. Dim my_nw As String
  3526. Dim my_gw As String
  3527. Dim my_name As String
  3528. Dim my_po As String
  3529. Dim my_price As String
  3530. Dim s1 As String = 1
  3531. Dim my_skuno As String
  3532. Dim my_order_item As String
  3533. Dim my_color As String
  3534. s1 = 1
  3535. For y = 3 To 100
  3536. If xlSheet.Cells(y, 3).value Is Nothing Then
  3537. Exit For
  3538. End If
  3539. sql = "insert into rt_ship_temp_1 (color1,thick,card,deli_no,deli,
  3540. po_no,work_no,filename,serial,no,name,qty) values(N'" & xlSheet.Cells(y, 4).value & "','" & xlSheet.Cells(y, 5).value & "','" & xlSheet.Cells(y, 7).value & "',N'" & xlSheet.Cells(y, 9).value & "',N'" & "陈立雄" & "',N'" & xlSheet.Cells(y, 8).value & "',N'" & xlSheet.Cells(y, 11).value & "',N'" & file_name & "','" & s1 & "','" & my_no & "',N'" & xlSheet.Cells(y, 4).value & "',N'" & xlSheet.Cells(y, 6).value & "')"
  3541. cmd.CommandText = sql
  3542. cmd.ExecuteScalar()
  3543. s1 = s1 + 1
  3544. Next
  3545. ElseIf OpenFileDialog1.SafeFileName Like "*手动加和*" Then '-----------------------------------------
  3546. sql = "select count(*) from rt_ship_temp_1 where filename=N'" & file_name & "'"
  3547. cmd.CommandText = sql
  3548. Dim msg As String
  3549. If cmd.ExecuteScalar > 0 Then
  3550. msg = MsgBox("资料已经存在,是否要覆盖?", MsgBoxStyle.YesNo, "警告")
  3551. If msg = vbNo Then
  3552. Exit Sub
  3553. End If
  3554. End If
  3555. If msg = vbYes Then
  3556. sql = "delete from rt_ship_temp_1 where filename=N'" & file_name & "'"
  3557. cmd.CommandText = sql
  3558. cmd.ExecuteNonQuery()
  3559. End If
  3560. xlApp = CreateObject("Excel.Application")
  3561. xlApp.Visible = True
  3562. xlApp.DisplayAlerts = False
  3563. xlBook = xlApp.Workbooks.Open(file_name,, True)
  3564. xlBook.Activate()
  3565. xlSheet = xlApp.Workbooks(1).Worksheets(1)
  3566. Dim my_card As String
  3567. Dim my_no As String
  3568. Dim my_nw As String
  3569. Dim my_gw As String
  3570. Dim my_name As String
  3571. Dim my_po As String
  3572. Dim my_price As String
  3573. Dim s1 As String = 1
  3574. Dim my_skuno As String
  3575. Dim my_order_item As String
  3576. Dim my_color As String
  3577. s1 = 1
  3578. For y = 3 To 100
  3579. If xlSheet.Cells(y, 3).value Is Nothing Then
  3580. Exit For
  3581. End If
  3582. sql = "insert into rt_ship_temp_1 (color1,thick,card,deli_no,deli,
  3583. po_no,work_no,filename,serial,no,name,qty) values(N'" & xlSheet.Cells(y, 4).value & "','" & xlSheet.Cells(y, 5).value & "','" & xlSheet.Cells(y, 7).value & "',N'" & xlSheet.Cells(y, 9).value & "',N'" & "尤珊荣" & "',N'" & xlSheet.Cells(y, 8).value & "',N'" & xlSheet.Cells(y, 11).value & "',N'" & file_name & "','" & s1 & "','" & my_no & "',N'" & xlSheet.Cells(y, 4).value & "',N'" & xlSheet.Cells(y, 6).value & "')"
  3584. cmd.CommandText = sql
  3585. cmd.ExecuteScalar()
  3586. s1 = s1 + 1
  3587. Next
  3588. 'ElseIf OpenFileDialog1.SafeFileName Like "*好兄弟*" Then '-----------------------------------------
  3589. ' sql = "select count(*) from rt_ship_temp_1 where filename=N'" & file_name & "'"
  3590. ' cmd.CommandText = sql
  3591. ' Dim msg As String
  3592. ' If cmd.ExecuteScalar > 0 Then
  3593. ' msg = MsgBox("资料已经存在,是否要覆盖?", MsgBoxStyle.YesNo, "警告")
  3594. ' If msg = vbNo Then
  3595. ' Exit Sub
  3596. ' End If
  3597. ' End If
  3598. ' If msg = vbYes Then
  3599. ' sql = "delete from rt_ship_temp_1 where filename=N'" & file_name & "'"
  3600. ' cmd.CommandText = sql
  3601. ' cmd.ExecuteNonQuery()
  3602. ' End If
  3603. ' xlApp = CreateObject("Excel.Application")
  3604. ' xlApp.Visible = True
  3605. ' xlApp.DisplayAlerts = False
  3606. ' Dim my_name As String
  3607. ' Dim my_qty As Double
  3608. ' Dim my_po As String
  3609. ' Dim my_po1 As String
  3610. ' xlSheet = xlApp.Workbooks(1).Worksheets(1)
  3611. ' Dim s1 As Integer
  3612. ' s1 = 1
  3613. ' For y = 3 To 100
  3614. ' If xlSheet.Cells(y, 3).value Is Nothing Then
  3615. ' Exit For
  3616. ' End If
  3617. ' sql = "insert into rt_ship_temp_1 (SIZE,COMMENT,color1,thick,card,deli_no,deli,
  3618. ' po_no,filename,serial,no,name,qty) values(N'" & xlSheet.Cells(y, 12).value & "',N'" & xlSheet.Cells(y, 3).value & "',N'" & xlSheet.Cells(y, 4).value & "','" & xlSheet.Cells(y, 5).value & "','" & xlSheet.Cells(y, 7).value & "',N'" & xlSheet.Cells(y, 9).value & "',N'" & xlSheet.Cells(y, 10).value & "',N'" & xlSheet.Cells(y, 8).value & "',N'" & file_name & "','" & s1 & "','" & my_no & "',N'" & xlSheet.Cells(y, 4).value & "',N'" & xlSheet.Cells(y, 6).value & "')"
  3619. ' cmd.CommandText = sql
  3620. ' cmd.ExecuteScalar()
  3621. ' s1 = s1 + 1
  3622. ' Next
  3623. ElseIf OpenFileDialog1.SafeFileName Like "*利亚*" Then '-----------------------------------------
  3624. sql = "select count(*) from rt_ship_temp_1 where filename=N'" & file_name & "'"
  3625. cmd.CommandText = sql
  3626. Dim msg As String
  3627. If cmd.ExecuteScalar > 0 Then
  3628. msg = MsgBox("资料已经存在,是否要覆盖?", MsgBoxStyle.YesNo, "警告")
  3629. If msg = vbNo Then
  3630. Exit Sub
  3631. End If
  3632. End If
  3633. If msg = vbYes Then
  3634. sql = "delete from rt_ship_temp_1 where filename=N'" & file_name & "'"
  3635. cmd.CommandText = sql
  3636. cmd.ExecuteNonQuery()
  3637. End If
  3638. xlApp = CreateObject("Excel.Application")
  3639. xlApp.Visible = True
  3640. xlApp.DisplayAlerts = False
  3641. xlBook = xlApp.Workbooks.Open(file_name,, True)
  3642. xlBook.Activate()
  3643. xlSheet = xlApp.Workbooks(1).Worksheets(1)
  3644. Dim my_card As String
  3645. Dim my_no As String
  3646. Dim my_nw As String
  3647. Dim my_gw As String
  3648. Dim my_name As String
  3649. Dim my_po As String
  3650. Dim my_price As String
  3651. Dim s1 As String = 1
  3652. Dim my_skuno As String
  3653. Dim my_order_item As String
  3654. Dim my_color As String
  3655. s1 = 1
  3656. For y = 3 To 100
  3657. If xlSheet.Cells(y, 3).value Is Nothing Then
  3658. Exit For
  3659. End If
  3660. sql = "insert into rt_ship_temp_1 (color1,thick,card,deli_no,deli,
  3661. po_no,filename,serial,no,name,qty) values(N'" & xlSheet.Cells(y, 4).value & "','" & xlSheet.Cells(y, 5).value & "','" & xlSheet.Cells(y, 7).value & "',N'" & xlSheet.Cells(y, 9).value & "',N'" & xlSheet.Cells(y, 10).value & "',N'" & xlSheet.Cells(y, 3).value & xlSheet.Cells(y, 8).value & "',N'" & file_name & "','" & s1 & "','" & my_no & "',N'" & xlSheet.Cells(y, 4).value & "',N'" & xlSheet.Cells(y, 6).value & "')"
  3662. cmd.CommandText = sql
  3663. cmd.ExecuteScalar()
  3664. s1 = s1 + 1
  3665. Next
  3666. ElseIf OpenFileDialog1.SafeFileName Like "*名创鞋业*" Then '-----------------------------------------
  3667. sql = "select count(*) from rt_ship_temp_1 where filename=N'" & file_name & "'"
  3668. cmd.CommandText = sql
  3669. Dim msg As String
  3670. If cmd.ExecuteScalar > 0 Then
  3671. msg = MsgBox("资料已经存在,是否要覆盖?", MsgBoxStyle.YesNo, "警告")
  3672. If msg = vbNo Then
  3673. Exit Sub
  3674. End If
  3675. End If
  3676. If msg = vbYes Then
  3677. sql = "delete from rt_ship_temp_1 where filename=N'" & file_name & "'"
  3678. cmd.CommandText = sql
  3679. cmd.ExecuteNonQuery()
  3680. End If
  3681. xlApp = CreateObject("Excel.Application")
  3682. xlApp.Visible = True
  3683. xlApp.DisplayAlerts = False
  3684. xlBook = xlApp.Workbooks.Open(file_name,, True)
  3685. xlBook.Activate()
  3686. xlSheet = xlApp.Workbooks(1).Worksheets(1)
  3687. Dim my_card As String
  3688. Dim my_no As String
  3689. Dim my_nw As String
  3690. Dim my_gw As String
  3691. Dim my_name As String
  3692. Dim my_po As String
  3693. Dim my_price As String
  3694. Dim s1 As String = 1
  3695. Dim my_skuno As String
  3696. Dim my_order_item As String
  3697. Dim my_color As String
  3698. s1 = 1
  3699. For y = 3 To 100
  3700. If xlSheet.Cells(y, 3).value Is Nothing Then
  3701. Exit For
  3702. End If
  3703. sql = "insert into rt_ship_temp_1 (WORK_NO,color1,thick,card,deli_no,deli,
  3704. po_no,filename,serial,no,name,qty) values(N'" & xlSheet.Cells(y, 11).value & "','" & xlSheet.Cells(y, 4).value & "','" & xlSheet.Cells(y, 5).value & "','" & xlSheet.Cells(y, 7).value & "',N'" & xlSheet.Cells(y, 9).value & "',N'" & xlSheet.Cells(y, 10).value & "',N'" & xlSheet.Cells(y, 8).value & "',N'" & file_name & "','" & s1 & "','" & my_no & "',N'" & xlSheet.Cells(y, 4).value & "',N'" & xlSheet.Cells(y, 6).value & "')"
  3705. cmd.CommandText = sql
  3706. cmd.ExecuteScalar()
  3707. s1 = s1 + 1
  3708. Next
  3709. ElseIf OpenFileDialog1.SafeFileName Like "*聚兴*" Then '-----------------------------------------
  3710. sql = "select count(*) from rt_ship_temp_1 where filename=N'" & file_name & "'"
  3711. cmd.CommandText = sql
  3712. Dim msg As String
  3713. If cmd.ExecuteScalar > 0 Then
  3714. msg = MsgBox("资料已经存在,是否要覆盖?", MsgBoxStyle.YesNo, "警告")
  3715. If msg = vbNo Then
  3716. Exit Sub
  3717. End If
  3718. End If
  3719. If msg = vbYes Then
  3720. sql = "delete from rt_ship_temp_1 where filename=N'" & file_name & "'"
  3721. cmd.CommandText = sql
  3722. cmd.ExecuteNonQuery()
  3723. End If
  3724. xlApp = CreateObject("Excel.Application")
  3725. xlApp.Visible = True
  3726. xlApp.DisplayAlerts = False
  3727. xlBook = xlApp.Workbooks.Open(file_name,, True)
  3728. xlBook.Activate()
  3729. xlSheet = xlApp.Workbooks(1).Worksheets(1)
  3730. Dim my_card As String
  3731. Dim my_no As String
  3732. Dim my_nw As String
  3733. Dim my_gw As String
  3734. Dim my_name As String
  3735. Dim my_po As String
  3736. Dim my_price As String
  3737. Dim s1 As String = 1
  3738. Dim my_skuno As String
  3739. Dim my_order_item As String
  3740. Dim my_color As String
  3741. s1 = 1
  3742. For y = 3 To 100
  3743. If xlSheet.Cells(y, 3).value Is Nothing Then
  3744. Exit For
  3745. End If
  3746. sql = "insert into rt_ship_temp_1 (color1,thick,card,deli_no,deli,
  3747. po_no,filename,serial,no,name,qty) values(N'" & xlSheet.Cells(y, 4).value & "','" & xlSheet.Cells(y, 5).value & "','" & xlSheet.Cells(y, 7).value & "',N'" & xlSheet.Cells(y, 9).value & "',N'" & "尤珊荣" & "',N'" & xlSheet.Cells(y, 8).value & "',N'" & file_name & "','" & s1 & "','" & my_no & "',N'" & xlSheet.Cells(y, 4).value & "',N'" & xlSheet.Cells(y, 6).value & "')"
  3748. cmd.CommandText = sql
  3749. cmd.ExecuteScalar()
  3750. s1 = s1 + 1
  3751. Next
  3752. ElseIf OpenFileDialog1.SafeFileName Like "*加和sample*" Then '-----------------------------------------
  3753. sql = "select count(*) from rt_ship_temp_1 where filename=N'" & file_name & "'"
  3754. cmd.CommandText = sql
  3755. Dim msg As String
  3756. If cmd.ExecuteScalar > 0 Then
  3757. msg = MsgBox("资料已经存在,是否要覆盖?", MsgBoxStyle.YesNo, "警告")
  3758. If msg = vbNo Then
  3759. Exit Sub
  3760. End If
  3761. End If
  3762. If msg = vbYes Then
  3763. sql = "delete from rt_ship_temp_1 where filename=N'" & file_name & "'"
  3764. cmd.CommandText = sql
  3765. cmd.ExecuteNonQuery()
  3766. End If
  3767. xlApp = CreateObject("Excel.Application")
  3768. xlApp.Visible = True
  3769. xlApp.DisplayAlerts = False
  3770. xlBook = xlApp.Workbooks.Open(file_name,, True)
  3771. xlBook.Activate()
  3772. xlSheet = xlApp.Workbooks(1).Worksheets(1)
  3773. Dim my_card As String
  3774. Dim my_no As String
  3775. Dim my_nw As String
  3776. Dim my_gw As String
  3777. Dim my_name As String
  3778. Dim my_po As String
  3779. Dim my_price As String
  3780. Dim s1 As String = 1
  3781. Dim my_skuno As String
  3782. Dim my_order_item As String
  3783. Dim my_color As String
  3784. s1 = 1
  3785. For y = 3 To 100
  3786. If xlSheet.Cells(y, 3).value Is Nothing Then
  3787. Exit For
  3788. End If
  3789. sql = "insert into rt_ship_temp_1 (work_no,color,thick,card,deli_no,deli,
  3790. po_no,filename,serial,no,name,qty) values(N'" & xlSheet.Cells(y, 9).value & "',N'" & xlSheet.Cells(y, 4).value & "','" & xlSheet.Cells(y, 5).value & "','" & xlSheet.Cells(y, 7).value & "',N'" & xlSheet.Cells(y, 10).value & "',N'" & xlSheet.Cells(y, 11).value & "',N'" & xlSheet.Cells(y, 8).value & "',N'" & file_name & "','" & s1 & "','" & my_no & "',N'" & xlSheet.Cells(y, 4).value & "',N'" & xlSheet.Cells(y, 6).value & "')"
  3791. cmd.CommandText = sql
  3792. cmd.ExecuteScalar()
  3793. s1 = s1 + 1
  3794. Next
  3795. ElseIf OpenFileDialog1.SafeFileName Like "11111" Then '-----------------------------------------
  3796. ElseIf OpenFileDialog1.SafeFileName Like "11111" Then '---------------------------------------------------
  3797. xlApp = CreateObject("Excel.Application")
  3798. xlApp.Visible = True
  3799. xlApp.DisplayAlerts = False
  3800. xlBook = xlApp.Workbooks.Open(file_name,, True)
  3801. xlBook.Activate()
  3802. Sql = "delete from rt_ship_daily_dj"
  3803. cmd.CommandText = sql
  3804. cmd.ExecuteNonQuery()
  3805. For i = 1 To xlApp.Worksheets.Count
  3806. If xlApp.Workbooks(1).Worksheets(i).name = "0" Then
  3807. xlSheet = xlApp.Workbooks(1).Worksheets(i)
  3808. xlSheet.Activate()
  3809. Exit For
  3810. End If
  3811. Next
  3812. Dim y As Integer = 0
  3813. For y = 2 To xlApp.ActiveSheet.UsedRange.Rows.Count
  3814. If Len(xlSheet.Cells(y, 7).value) < 1 Then
  3815. Exit For
  3816. End If
  3817. Next y
  3818. xlApp.Range("A2:K" & y - 1).Select()
  3819. xlApp.Selection.UnMerge
  3820. xlApp.Selection.SpecialCells(Microsoft.Office.Interop.Excel.XlCellType.xlCellTypeBlanks).Select
  3821. xlApp.CutCopyMode = False
  3822. xlApp.Selection.FormulaR1C1 = "=R[-1]C"
  3823. For y = 2 To y - 1
  3824. Sql = "insert into rt_ship_daily_dj (no,name,qty,nw,gw,po_no,unit_price) values('" & xlSheet.Cells(y, 1).value & "',N'" & xlSheet.Cells(y, 2).value & "'," & xlSheet.Cells(y, 3).value & "," & xlSheet.Cells(y, 5).value & "," & xlSheet.Cells(y, 6).value & ",N'" & xlSheet.Cells(y, 7).value & "'," & xlSheet.Cells(y, 10).value & ")"
  3825. cmd.CommandText = sql
  3826. cmd.ExecuteScalar()
  3827. sql = "insert into rt_ship_temp_1 (no,name,qty,nw,gw,po_no,unit_price) values('" & xlSheet.Cells(y, 1).value & "',N'" & xlSheet.Cells(y, 2).value & "'," & xlSheet.Cells(y, 3).value & "," & xlSheet.Cells(y, 5).value & "," & xlSheet.Cells(y, 6).value & ",N'" & xlSheet.Cells(y, 7).value & "'," & xlSheet.Cells(y, 10).value & ")"
  3828. cmd.CommandText = sql
  3829. cmd.ExecuteScalar()
  3830. Next
  3831. Sql = "select 订单号,类别,cast(sum(数量) as numeric(10,1)) as 尺数,cast(sum(数量*单价) as numeric(10,3)) as 货值,sum(重量) as 净重,厚度 from
  3832. (SELECT po_no as 订单号,name as 品名,case when name like '%PU%' or name like '%action%' or name like N'%榔%' or name like N'%virgin%' then 'PU' else '反毛' end as 类别, qty as 数量,
  3833. cast(qty/SUM(qty) OVER (PARTITION BY no) *nw as numeric(10,1)) as 重量,case when left(ltrim(name),3)='1.2' then left(ltrim(name),3) +'4' else '1.46' end as 厚度,unit_price as 单价
  3834. FROM RT_SHIP_DAILY_dj) as p group by 订单号,类别,厚度"
  3835. cmd.CommandText = Sql
  3836. dt = New DataTable
  3837. da.SelectCommand = cmd
  3838. da.Fill(dt)
  3839. dgv1.DataSource = dt
  3840. Sql = "select 类别,sum(尺数),sum(净重),sum(货值) from(select 订单号,类别,cast(sum(数量) as numeric(10,1)) as 尺数,cast(sum(数量*单价) as numeric(10,3)) as 货值,sum(重量) as 净重,厚度 from (SELECT po_no as 订单号,name as 品名,case when name like '%PU%' or name like '%action%' or name like N'%榔%' or name like N'%virgin%' then 'PU' else '反毛' end as 类别, qty as 数量,cast(qty/SUM(qty) OVER (PARTITION BY no) *nw as numeric(10,1)) as 重量,case when left(ltrim(name),3)='1.2' then left(ltrim(name),3) +'4' else '1.46' end as 厚度,unit_price as 单价 FROM RT_SHIP_DAILY_dj) as p group by 订单号,类别,厚度) as q group by 类别"
  3841. cmd.CommandText = Sql
  3842. dt = New DataTable
  3843. da.SelectCommand = cmd
  3844. da.Fill(dt)
  3845. dgv2.DataSource = dt
  3846. ElseIf OpenFileDialog1.SafeFileName Like "*威弘*" Then '------------------------------------
  3847. sql = "select count(*) from rt_ship_temp_1 where filename=N'" & file_name & "'"
  3848. cmd.CommandText = Sql
  3849. Dim msg As String
  3850. If cmd.ExecuteScalar > 0 Then
  3851. msg = MsgBox("资料已经存在,是否要覆盖?", MsgBoxStyle.YesNo, "警告")
  3852. If msg = vbNo Then
  3853. Exit Sub
  3854. End If
  3855. End If
  3856. If msg = vbYes Then
  3857. sql = "delete from rt_ship_temp_1 where filename=N'" & file_name & "'"
  3858. cmd.CommandText = sql
  3859. cmd.ExecuteNonQuery()
  3860. End If
  3861. xlApp = CreateObject("Excel.Application")
  3862. xlApp.Visible = True
  3863. xlApp.DisplayAlerts = False
  3864. xlBook = xlApp.Workbooks.Open(file_name,, True)
  3865. xlBook.Activate()
  3866. xlApp = CreateObject("Excel.Application")
  3867. xlApp.Visible = True
  3868. xlApp.DisplayAlerts = False
  3869. xlBook = xlApp.Workbooks.Open(file_name,, True)
  3870. xlBook.Activate()
  3871. Dim s1 As Integer = 1
  3872. Dim s11 As Integer = 1001
  3873. For i = 1 To xlApp.Worksheets.Count
  3874. xlSheet = xlApp.Worksheets(i)
  3875. xlSheet.Activate()
  3876. Dim y As Integer
  3877. For y = xlApp.Workbooks(1).Worksheets(i).UsedRange.Rows.Count To 3 Step -1
  3878. If xlSheet.Cells(y, 1).value = Nothing Then
  3879. GoTo OK2
  3880. End If
  3881. If xlSheet.Cells(y, 1).value.ToString = "数量合计" Then
  3882. Exit For
  3883. End If
  3884. OK2:
  3885. Next y
  3886. Dim yyy As Integer
  3887. For yyy = 3 To xlApp.Workbooks(1).Worksheets(i).UsedRange.Rows.Count
  3888. If xlSheet.Cells(yyy, 14).value = "制 表" Then
  3889. Exit For
  3890. End If
  3891. Next yyy
  3892. xlSheet.Range("A3:A" & y - 1).Select()
  3893. xlApp.Selection.UnMerge
  3894. 'xlApp.Selection.SpecialCells(Microsoft.Office.Interop.Excel.XlCellType.xlCellTypeBlanks).Select
  3895. 'xlApp.CutCopyMode = False
  3896. 'xlApp.Selection.FormulaR1C1 = "=R[-1]C"
  3897. xlSheet.Range("c4:g" & y - 1).Select()
  3898. xlApp.Selection.UnMerge
  3899. 'xlApp.Selection.SpecialCells(Microsoft.Office.Interop.Excel.XlCellType.xlCellTypeBlanks).Select
  3900. 'xlApp.CutCopyMode = False
  3901. 'xlApp.Selection.FormulaR1C1 = "=R[-1]C"
  3902. xlSheet.Range("k3:k" & yyy - 1).Select()
  3903. xlApp.Selection.UnMerge
  3904. 'xlApp.Selection.SpecialCells(Microsoft.Office.Interop.Excel.XlCellType.xlCellTypeBlanks).Select
  3905. 'xlApp.CutCopyMode = False
  3906. 'xlApp.Selection.FormulaR1C1 = "=R[-1]C"
  3907. If xlSheet.Range("N3:Q" & yyy - 1).MergeCells.ToString <> "False" Then
  3908. xlSheet.Range("N3:Q" & yyy - 1).Select()
  3909. xlApp.Selection.UnMerge
  3910. 'xlApp.Selection.SpecialCells(Microsoft.Office.Interop.Excel.XlCellType.xlCellTypeBlanks).Select
  3911. 'xlApp.CutCopyMode = False
  3912. 'xlApp.Selection.FormulaR1C1 = "=R[-1]C"
  3913. End If
  3914. Dim my_no As String
  3915. Dim my_po As String
  3916. Dim my_work As String
  3917. Dim my_color As String
  3918. Dim my_thick As String
  3919. Dim my_no1 As String
  3920. Dim my_po1 As String
  3921. Dim my_work1 As String
  3922. Dim my_color1 As String
  3923. Dim my_thick1 As String
  3924. Dim my_card As String
  3925. For y = 3 To y - 1
  3926. If y = 3 Then
  3927. my_po = xlSheet.Cells(3, 4).value
  3928. my_work = xlSheet.Cells(3, 5).value
  3929. my_color = xlSheet.Cells(3, 6).value
  3930. my_thick = xlSheet.Cells(3, 7).value
  3931. my_po1 = xlSheet.Cells(3, 14).value
  3932. my_work1 = xlSheet.Cells(3, 15).value
  3933. my_color1 = xlSheet.Cells(3, 16).value
  3934. my_thick1 = xlSheet.Cells(3, 17).value
  3935. End If
  3936. If xlSheet.Cells(y, 2).value = Nothing And xlSheet.Cells(y, 4).value = Nothing And xlSheet.Cells(y, 5).value = Nothing And xlSheet.Cells(y, 6).value = Nothing And xlSheet.Cells(y, 7).value = Nothing Then
  3937. ' Exit For
  3938. Else
  3939. If xlSheet.Cells(y, 2).value Is Nothing Then
  3940. Else
  3941. If xlSheet.Cells(y, 4).VALUE Is Nothing Then
  3942. If xlSheet.Cells(y, 1).value Is Nothing Then
  3943. Else
  3944. my_no = xlSheet.Cells(y, 1).value
  3945. End If
  3946. sql = "insert into rt_ship_temp_1 (filename,card,serial,no,qty,po_no,work_no,color1,thick) values(N'" & file_name & "','" & xlSheet.Cells(y, 3).value & "','" & s1 & "','" & my_no & "'," & xlSheet.Cells(y, 2).value & ",N'" & my_po & "',N'" & my_work & "',N'" & my_color & "','" & my_thick & "')"
  3947. cmd.CommandText = sql
  3948. cmd.ExecuteScalar()
  3949. s1 = s1 + 1
  3950. Else
  3951. If xlSheet.Cells(y, 1).value Is Nothing Then
  3952. Else
  3953. my_no = xlSheet.Cells(y, 1).value
  3954. End If
  3955. my_po = xlSheet.Cells(y, 4).value
  3956. my_work = xlSheet.Cells(y, 5).value
  3957. my_color = xlSheet.Cells(y, 6).value
  3958. my_thick = xlSheet.Cells(y, 7).value
  3959. sql = "insert into rt_ship_temp_1 (filename,card,serial,no,qty,po_no,work_no,color1,thick) values(N'" & file_name & "','" & xlSheet.Cells(y, 3).value & "','" & s1 & "','" & my_no & "'," & xlSheet.Cells(y, 2).value & ",N'" & my_po & "',N'" & my_work & "',N'" & my_color & "','" & my_thick & "')"
  3960. cmd.CommandText = sql
  3961. cmd.ExecuteScalar()
  3962. s1 = s1 + 1
  3963. End If
  3964. End If
  3965. End If
  3966. If xlSheet.Cells(y, 12).value = Nothing And xlSheet.Cells(y, 14).value = Nothing And xlSheet.Cells(y, 15).value = Nothing And xlSheet.Cells(y, 16).value = Nothing And xlSheet.Cells(y, 17).value = Nothing Then
  3967. ' Exit For
  3968. Else
  3969. If xlSheet.Cells(y, 12).value Is Nothing Then
  3970. Else
  3971. If xlSheet.Cells(y, 14).VALUE Is Nothing Then
  3972. If xlSheet.Cells(y, 11).value Is Nothing Then
  3973. Else
  3974. my_no1 = xlSheet.Cells(y, 11).value
  3975. End If
  3976. sql = "insert into rt_ship_temp_1 (filename,card,serial,no,qty,po_no,work_no,color1,thick) values(N'" & file_name & "','" & xlSheet.Cells(y, 13).value & "','" & s11 & "','" & my_no1 & "'," & xlSheet.Cells(y, 12).value & ",N'" & my_po1 & "',N'" & my_work1 & "',N'" & my_color1 & "','" & my_thick1 & "')"
  3977. cmd.CommandText = sql
  3978. cmd.ExecuteScalar()
  3979. s11 = s11 + 1
  3980. Else
  3981. If xlSheet.Cells(y, 11).value Is Nothing Then
  3982. Else
  3983. my_no1 = xlSheet.Cells(y, 11).value
  3984. End If
  3985. my_po1 = xlSheet.Cells(y, 14).value
  3986. my_work1 = xlSheet.Cells(y, 15).value
  3987. my_color1 = xlSheet.Cells(y, 16).value
  3988. my_thick1 = xlSheet.Cells(y, 17).value
  3989. sql = "insert into rt_ship_temp_1 (filename,card,serial,no,qty,po_no,work_no,color1,thick) values(N'" & file_name & "','" & xlSheet.Cells(y, 13).value & "','" & s11 & "','" & my_no1 & "'," & xlSheet.Cells(y, 12).value & ",N'" & my_po1 & "',N'" & my_work1 & "',N'" & my_color1 & "','" & my_thick1 & "')"
  3990. cmd.CommandText = sql
  3991. cmd.ExecuteScalar()
  3992. s11 = s11 + 1
  3993. End If
  3994. End If
  3995. 'sql = "insert into rt_ship_076_1 (no,sf,order_no,i_no,color,thick) values('" & my_no1 & "'," & xlSheet.Cells(y, 10).value & ",N'" & my_po1 & "',N'" & my_work1 & "',N'" & my_color1 & "','" & my_thick1 & "')"
  3996. 'cmd.CommandText = sql
  3997. 'cmd.ExecuteScalar()
  3998. End If
  3999. Next
  4000. Next
  4001. Sql = "SELECT order_no AS 订单号, i_no AS 指令号, color AS 颜色, thick AS 厚度, cast(SUM(sf) as numeric(10,1)) AS 尺数,deli_no as 发货单号 FROM RT_ship_daily_wh GROUP BY order_no, i_no, color, thick,deli_no ORDER BY 订单号, 指令号, 颜色"
  4002. cmd.CommandText = Sql
  4003. dt = New DataTable
  4004. da.SelectCommand = cmd
  4005. da.Fill(dt)
  4006. dgv1.DataSource = dt
  4007. dgv1.Columns("颜色").Width = 350
  4008. dgv1.Columns("订单号").Width = 120
  4009. 'dt.Columns.Add("尺数")
  4010. 'dt.Columns.Add("货值")
  4011. Sql = "SELECT 订单类别, 厚度, SUM(尺数) AS 尺数, 类别
  4012. FROM (SELECT CASE WHEN LEFT(order_no, 2)
  4013. = 'RT' THEN N'人民币' WHEN order_no LIKE 'SX%' THEN '美元' ELSE order_no END AS 订单类别,
  4014. i_no AS 指令号, color AS 颜色, thick AS 厚度, CAST(SUM(sf) AS numeric(10, 1)) AS 尺数,
  4015. CASE WHEN color LIKE '%pu%' OR
  4016. color LIKE '%action%' OR
  4017. color LIKE N'%纹%' THEN 'PU' ELSE '反毛' END AS 类别
  4018. FROM RT_ship_daily_wh
  4019. GROUP BY order_no, i_no, color, thick) AS p
  4020. GROUP BY 订单类别, 厚度, 类别
  4021. ORDER BY 订单类别"
  4022. cmd.CommandText = Sql
  4023. dt = New DataTable
  4024. da.SelectCommand = cmd
  4025. da.Fill(dt)
  4026. dgv2.DataSource = dt
  4027. Sql = "SELECT 订单类别, SUM(尺数) AS 尺数, 类别
  4028. FROM (SELECT CASE WHEN LEFT(order_no, 2)
  4029. = 'RT' THEN N'人民币' WHEN order_no LIKE 'SX%' THEN '美元' ELSE order_no END AS 订单类别,
  4030. i_no AS 指令号, color AS 颜色, thick AS 厚度, CAST(SUM(sf) AS numeric(10, 1)) AS 尺数,
  4031. CASE WHEN color LIKE '%pu%' OR
  4032. color LIKE '%action%' OR
  4033. color LIKE N'%纹%' THEN 'PU' ELSE '反毛' END AS 类别
  4034. FROM RT_ship_daily_wh
  4035. GROUP BY order_no, i_no, color, thick) AS p
  4036. GROUP BY 订单类别, 类别 ORDER BY 订单类别"
  4037. cmd.CommandText = Sql
  4038. dt = New DataTable
  4039. da.SelectCommand = cmd
  4040. da.Fill(dt)
  4041. dgv3.DataSource = dt
  4042. ElseIf OpenFileDialog1.SafeFileName Like "SAMIL*" Then '--------------------------------
  4043. sql = "select count(*) from rt_ship_temp_1 where filename=N'" & file_name & "'"
  4044. cmd.CommandText = Sql
  4045. Dim msg As String
  4046. If cmd.ExecuteScalar > 0 Then
  4047. msg = MsgBox("资料已经存在,是否要覆盖?", MsgBoxStyle.YesNo, "警告")
  4048. If msg = vbNo Then
  4049. Exit Sub
  4050. End If
  4051. End If
  4052. If msg = vbYes Then
  4053. sql = "delete from rt_ship_temp_1 where filename=N'" & file_name & "'"
  4054. cmd.CommandText = sql
  4055. cmd.ExecuteNonQuery()
  4056. End If
  4057. xlApp = CreateObject("Excel.Application")
  4058. xlApp.Visible = True
  4059. xlApp.DisplayAlerts = False
  4060. xlBook = xlApp.Workbooks.Open(file_name,, True)
  4061. xlBook.Activate()
  4062. Dim s1 As Integer = 1
  4063. 'For i = 1 To xlApp.Worksheets.Count
  4064. ' If xlApp.Workbooks(1).Worksheets(i).name = "0" Then
  4065. ' Exit For
  4066. ' End If
  4067. 'Next
  4068. xlSheet = xlApp.Workbooks(1).Worksheets(1)
  4069. xlSheet.Activate()
  4070. Dim y As Integer = 0
  4071. For y = 2 To xlApp.ActiveSheet.UsedRange.Rows.Count
  4072. If Len(xlSheet.Cells(y, 2).value) < 1 Then
  4073. Exit For
  4074. End If
  4075. Next y
  4076. xlApp.Range("A2:j" & y - 1).Select()
  4077. xlApp.Selection.UnMerge
  4078. 'xlApp.Selection.SpecialCells(Microsoft.Office.Interop.Excel.XlCellType.xlCellTypeBlanks).Select
  4079. 'xlApp.CutCopyMode = False
  4080. 'xlApp.Selection.FormulaR1C1 = "=R[-1]C"
  4081. s1 = 1
  4082. For y = 2 To y - 1
  4083. sql = "insert into rt_ship_temp_1 (comment,serial,filename,card,name,qty,po_no) values(N'" & xlSheet.Cells(y, 13).value & "','" & s1 & "',N'" & file_name & "','" & xlSheet.Cells(y, 4).value & "',N'" & xlSheet.Cells(y, 2).value & "'," & xlSheet.Cells(y, 3).value & ",N'" & xlSheet.Cells(y, 9).value.ToString.Replace("'", " ") & "')"
  4084. cmd.CommandText = sql
  4085. cmd.ExecuteScalar()
  4086. s1 = s1 + 1
  4087. Next
  4088. Sql = "select 订单号,类别,cast(sum(数量) as numeric(10,1)) as 尺数,cast(sum(数量*单价) as numeric(10,3)) as 货值,sum(重量) as 净重,厚度 from
  4089. (SELECT po_no as 订单号,name as 品名,case when name like '%PU %' or name like '%action%' or name like N'%榔%' or name like N'%virgin%' then 'PU' else '反毛' end as 类别, qty as 数量,
  4090. cast(qty/SUM(qty) OVER (PARTITION BY no) *nw as numeric(10,1)) as 重量,case when left(ltrim(name),3)='1.2' then left(ltrim(name),3) +'4' else '1.46' end as 厚度,unit_price as 单价
  4091. FROM RT_SHIP_DAILY_samil) as p group by 订单号,类别,厚度" '旧
  4092. Sql = "select name as 品名,po_no as 订单号,cast(sum(qty) as numeric(10,1)) as 尺数,deli_no as 发货单号 from rt_ship_daily_samil group by name,po_no,deli_no"
  4093. cmd.CommandText = Sql
  4094. dt = New DataTable
  4095. da.SelectCommand = cmd
  4096. da.Fill(dt)
  4097. dgv1.DataSource = dt
  4098. dgv1.Columns("品名").Width = 350
  4099. dgv1.Columns("订单号").Width = 180
  4100. Sql = "select 类别,sum(尺数),sum(净重),sum(货值) from(select 订单号,类别,cast(sum(数量) as numeric(10,1)) as 尺数,cast(sum(数量*单价) as numeric(10,3)) as 货值,sum(重量) as 净重,厚度 from (SELECT po_no as 订单号,name as 品名,case when name like '%PU %' or name like '% action %' or name like N'%榔%' or name like N'% virgin %' then 'PU' else '反毛' end as 类别, qty as 数量,cast(qty/SUM(qty) OVER (PARTITION BY no) *nw as numeric(10,1)) as 重量,case when left(ltrim(name),3)='1.2' then left(ltrim(name),3) +'4' else '1.46' end as 厚度,unit_price as 单价 FROM RT_SHIP_DAILY_samil) as p group by 订单号,类别,厚度) as q group by 类别"
  4101. cmd.CommandText = Sql
  4102. dt = New DataTable
  4103. da.SelectCommand = cmd
  4104. da.Fill(dt)
  4105. dgv2.DataSource = dt
  4106. ElseIf OpenFileDialog1.SafeFileName Like "宏福1111*" Then '-----------------宏福-----------------PUMA
  4107. Sql = "select count(*) from rt_ship_daily_hongfu where filename=N'" & file_name & "'"
  4108. cmd.CommandText = Sql
  4109. Dim msg As String
  4110. If cmd.ExecuteScalar > 0 Then
  4111. msg = MsgBox("资料已经存在,是否要覆盖?", MsgBoxStyle.YesNo, "警告")
  4112. If msg = vbNo Then
  4113. Exit Sub
  4114. End If
  4115. End If
  4116. If msg = vbYes Then
  4117. Sql = "delete from rt_ship_daily_hongfu where filename=N'" & file_name & "'"
  4118. cmd.CommandText = sql
  4119. cmd.ExecuteNonQuery()
  4120. sql = "delete from rt_ship_temp_1 where filename=N'" & file_name & "'"
  4121. cmd.CommandText = sql
  4122. cmd.ExecuteNonQuery()
  4123. End If
  4124. xlApp = CreateObject("Excel.Application")
  4125. xlApp.Visible = True
  4126. xlApp.DisplayAlerts = False
  4127. xlBook = xlApp.Workbooks.Open(file_name,, True)
  4128. xlBook.Activate()
  4129. Dim conn1 As New SqlConnection
  4130. conn1.ConnectionString = connstring
  4131. conn1.Open()
  4132. Dim cmd1 As New SqlCommand
  4133. cmd1.Connection = conn1
  4134. Dim dr As SqlDataReader
  4135. For i = 1 To xlApp.Worksheets.Count
  4136. If xlApp.Workbooks(1).Worksheets(i).name = "1" Then
  4137. xlSheet = xlApp.Workbooks(1).Worksheets(i)
  4138. xlSheet.Activate()
  4139. Exit For
  4140. End If
  4141. Next
  4142. Dim y As Integer = 0
  4143. For y = 4 To xlApp.ActiveSheet.UsedRange.Rows.Count
  4144. If Len(xlSheet.Cells(y, 2).value) < 1 Then
  4145. Exit For
  4146. End If
  4147. Next y
  4148. xlApp.Range("A4:v" & y - 1).Select()
  4149. 'If xlApp.Selection.mergecells = True Then
  4150. xlApp.Selection.UnMerge
  4151. xlApp.Selection.SpecialCells(Microsoft.Office.Interop.Excel.XlCellType.xlCellTypeBlanks).Select
  4152. xlApp.CutCopyMode = False
  4153. xlApp.Selection.FormulaR1C1 = "=R[-1]C"
  4154. ' End If
  4155. For y = 4 To y - 1
  4156. Sql = "insert into rt_ship_daily_puma (no,name,color,qty_sf,gw1,po_no,unit_price) values('" & xlSheet.Cells(y, 1).value & "',N'" & xlSheet.Cells(y, 2).value & "',N'" & xlSheet.Cells(y, 4).value & "'," & xlSheet.Cells(y, 5).value & "," & xlSheet.Cells(y, 12).value & ",N'" & xlSheet.Cells(y, 14).value & "',N'" & xlSheet.Cells(y, 20).value & "')"
  4157. cmd.CommandText = sql
  4158. cmd.ExecuteScalar()
  4159. sql = "insert into rt_ship_temp_1 (no,name,color,qty_sf,gw1,po_no,unit_price) values('" & xlSheet.Cells(y, 1).value & "',N'" & xlSheet.Cells(y, 2).value & "',N'" & xlSheet.Cells(y, 4).value & "'," & xlSheet.Cells(y, 5).value & "," & xlSheet.Cells(y, 12).value & ",N'" & xlSheet.Cells(y, 14).value & "',N'" & xlSheet.Cells(y, 20).value & "')"
  4160. cmd.CommandText = sql
  4161. cmd.ExecuteScalar()
  4162. Next
  4163. Sql = "select name as 品名,cast(sum(qty_sf) as numeric(10,1)) as 尺数,cast(sum(qty_sf*unit_price) as numeric(10,2)) as 货值,po_no as 订单号,sum(重量) as 毛重, sum(袋重) as 袋重,sum(重量)-sum(袋重) as 净重 from
  4164. (select no,name,qty_sf,unit_price,po_no,gw1,cast(qty_sf/SUM(qty_sf) OVER (PARTITION BY no) *gw1 as numeric(10,2)) as 重量,cast(pa/SUM(pa) OVER (PARTITION BY no)*0.1 as numeric(10,2)) as 袋重 from
  4165. (select no,name,color,qty_sf,unit_price,po_no,gw1,cast(count as numeric(10,1)) as pa from
  4166. (SELECT no, name,case when name<>'' then 1 end as count, color, qty_sf, gw1, po_no, unit_price, cast(qty_sf/SUM(qty_sf) OVER (PARTITION BY no) *gw1 as numeric(10,1)) as weight
  4167. FROM RT_SHIP_DAILY_PUMA) as r) as s) as t group by name,po_no order by 品名,po_no"
  4168. cmd.CommandText = Sql
  4169. dt = New DataTable
  4170. da.SelectCommand = cmd
  4171. da.Fill(dt)
  4172. dgv1.DataSource = dt
  4173. Sql = "select 品名,sum(尺数) as 尺数,cast(sum(净重) as numeric(10,1)) as 淨重 from(select case when (品名 like '%PU%' or 品名 like '%action%' or 品名 like N'%榔%') and 品名 not like '%puma%' then 'pu' else '反毛' end as 品名,尺数,净重 from
  4174. (select name as 品名,cast(sum(qty_sf) as numeric(10,1)) as 尺数,cast(sum(qty_sf*unit_price) as numeric(10,2)) as 货值,po_no as 订单号,sum(重量) as 毛重, sum(袋重) as 袋重,sum(重量)-sum(袋重) as 净重 from
  4175. (select no,name,qty_sf,unit_price,po_no,gw1,cast(qty_sf/SUM(qty_sf) OVER (PARTITION BY no) *gw1 as numeric(10,2)) as 重量,cast(pa/SUM(pa) OVER (PARTITION BY no)*0.1 as numeric(10,3)) as 袋重 from
  4176. (select no,name,color,qty_sf,unit_price,po_no,gw1,cast(count as numeric(10,2)) as pa from
  4177. (SELECT no, name,case when name<>'' then 1 end as count, color, qty_sf, gw1, po_no, unit_price, cast(qty_sf/SUM(qty_sf) OVER (PARTITION BY no) *gw1 as numeric(10,2)) as weight
  4178. FROM RT_SHIP_DAILY_PUMA) as r) as s) as t group by name,po_no) as u) as v group by 品名"
  4179. cmd.CommandText = Sql
  4180. dt = New DataTable
  4181. da.SelectCommand = cmd
  4182. da.Fill(dt)
  4183. dgv2.DataSource = dt
  4184. ' sql = "select name as 品名,cast(sum(qty_sf) as numeric(10,1)) as 尺数,cast(sum(qty_sf*unit_price) as numeric(10,1)) as 总价,sum(weight) as 淨重 from (SELECT no, name, color, qty_sf, gw1, po_no, unit_price, cast(qty_sf/SUM(qty_sf) OVER (PARTITION BY no) *gw1 as numeric(10,1)) as weight
  4185. 'FROM RT_SHIP_DAILY_PUMA) as p group by name"
  4186. ' cmd.CommandText = sql
  4187. ' dt = New DataTable
  4188. ' da.SelectCommand = cmd
  4189. ' da.Fill(dt)
  4190. 'sql = ""
  4191. 'cmd.CommandText = sql
  4192. 'dt = New DataTable
  4193. 'da.SelectCommand = cmd
  4194. 'da.Fill(dt)
  4195. 'dgv2.DataSource = dt
  4196. ElseIf OpenFileDialog1.SafeFileName Like "穎億*" Then '-------------------------
  4197. sql = "select count(*) from rt_ship_temp_1 where filename=N'" & file_name & "'"
  4198. cmd.CommandText = Sql
  4199. Dim msg As String
  4200. If cmd.ExecuteScalar > 0 Then
  4201. msg = MsgBox("资料已经存在,是否要覆盖?", MsgBoxStyle.YesNo, "警告")
  4202. If msg = vbNo Then
  4203. Exit Sub
  4204. End If
  4205. End If
  4206. If msg = vbYes Then
  4207. sql = "delete from rt_ship_temp_1 where filename=N'" & file_name & "'"
  4208. cmd.CommandText = sql
  4209. cmd.ExecuteNonQuery()
  4210. End If
  4211. xlApp = CreateObject("Excel.Application")
  4212. xlApp.Visible = True
  4213. xlApp.DisplayAlerts = False
  4214. xlBook = xlApp.Workbooks.Open(file_name,, True)
  4215. xlBook.Activate()
  4216. xlApp = CreateObject("Excel.Application")
  4217. xlApp.Visible = True
  4218. xlApp.DisplayAlerts = False
  4219. xlBook = xlApp.Workbooks.Open(file_name,, True)
  4220. xlBook.Activate()
  4221. For i = 1 To xlApp.Worksheets.Count
  4222. If xlApp.Workbooks(1).Worksheets(i).name = "0" Then
  4223. xlSheet = xlApp.Workbooks(1).Worksheets(i)
  4224. xlSheet.Activate()
  4225. Exit For
  4226. End If
  4227. Next
  4228. Dim y As Integer = 0
  4229. For y = 2 To xlApp.ActiveSheet.UsedRange.Rows.Count
  4230. If Len(xlSheet.Cells(y, 2).value) < 1 Then
  4231. Exit For
  4232. End If
  4233. Next y
  4234. 'xlApp.Range("A2:k" & y - 1).Select()
  4235. ''If xlApp.Selection.mergecells = True Then
  4236. 'xlApp.Selection.UnMerge
  4237. 'xlApp.Selection.SpecialCells(Microsoft.Office.Interop.Excel.XlCellType.xlCellTypeBlanks).Select
  4238. 'xlApp.CutCopyMode = False
  4239. 'xlApp.Selection.FormulaR1C1 = "=R[-1]C"
  4240. For y = 2 To y - 1
  4241. sql = "insert into rt_ship_temp_1 (filename,no,name,qty,
  4242. po_no,work_no) values(N'" & file_name & "','" & xlSheet.Cells(y, 1).value & "',N'" & xlSheet.Cells(y, 2).value & "','" & xlSheet.Cells(y, 3).value & "',N'" &
  4243. xlSheet.Cells(y, 8).value & "',N'" & xlSheet.Cells(y, 9).value & "')"
  4244. cmd.CommandText = sql
  4245. cmd.ExecuteScalar()
  4246. Next
  4247. ElseIf OpenFileDialog1.SafeFileName Like "澳孚*" Then '------------------------------------
  4248. sql = "select count(*) from rt_ship_temp_1 where filename=N'" & file_name & "'"
  4249. cmd.CommandText = Sql
  4250. Dim msg As String
  4251. If cmd.ExecuteScalar > 0 Then
  4252. msg = MsgBox("资料已经存在,是否要覆盖?", MsgBoxStyle.YesNo, "警告")
  4253. If msg = vbNo Then
  4254. Exit Sub
  4255. End If
  4256. End If
  4257. If msg = vbYes Then
  4258. sql = "delete from rt_ship_temp_1 where filename=N'" & file_name & "'"
  4259. cmd.CommandText = sql
  4260. cmd.ExecuteNonQuery()
  4261. End If
  4262. xlApp = CreateObject("Excel.Application")
  4263. xlApp.Visible = True
  4264. xlApp.DisplayAlerts = False
  4265. xlBook = xlApp.Workbooks.Open(file_name,, True)
  4266. xlBook.Activate()
  4267. xlApp = CreateObject("Excel.Application")
  4268. xlApp.Visible = True
  4269. xlApp.DisplayAlerts = False
  4270. xlBook = xlApp.Workbooks.Open(file_name,, True)
  4271. xlBook.Activate()
  4272. xlSheet = xlApp.Workbooks(1).Worksheets(1)
  4273. Dim y As Integer = 0
  4274. For y = 2 To xlApp.Workbooks(1).Worksheets(1).UsedRange.Rows.Count
  4275. If Len(xlSheet.Cells(y, 2).value) < 1 Then
  4276. Exit For
  4277. End If
  4278. Next y
  4279. xlApp.Range("A2:l" & y - 1).Select()
  4280. ' If xlApp.Selection.mergecells = True Then
  4281. xlApp.Selection.UnMerge
  4282. 'xlApp.Selection.SpecialCells(Microsoft.Office.Interop.Excel.XlCellType.xlCellTypeBlanks).Select
  4283. 'xlApp.CutCopyMode = False
  4284. 'xlApp.Selection.FormulaR1C1 = "=R[-1]C"
  4285. ' End If
  4286. Dim my_no As String
  4287. Dim my_nw As Double
  4288. Dim my_gw As Double
  4289. Dim my_sf As Double
  4290. Dim my_price As Double
  4291. Dim s1 As Integer = 0
  4292. For y = 2 To y - 1
  4293. 'If Not (xlSheet.Cells(y, 9).value Is Nothing) Then
  4294. 'If (xlSheet.Cells(y, 5).value Is Nothing) And (xlSheet.Cells(y, 6).value Is Nothing) Then
  4295. ' my_nw = xlSheet.Cells(y - 1, 5).value
  4296. ' my_gw = xlSheet.Cells(y - 1, 6).value
  4297. ' my_no = xlSheet.Cells(y - 1, 1).value
  4298. 'Else
  4299. ' my_nw = xlSheet.Cells(y, 5).value
  4300. ' my_gw = xlSheet.Cells(y, 6).value
  4301. ' my_no = xlSheet.Cells(y, 1).value
  4302. 'End If
  4303. my_sf = xlSheet.Cells(y, 4).value
  4304. sql = "insert into rt_ship_temp_1 (filename,serial,no,name,qty,
  4305. po_no,work_no) values(N'" & file_name & "','" & s1 & "','" &
  4306. my_no & "',N'" & xlSheet.Cells(y, 2).value & "'," & xlSheet.Cells(y, 3).value & ",N'" & xlSheet.Cells(y, 8).value & "','" & xlSheet.Cells(y, 9).value & "')"
  4307. cmd.CommandText = sql
  4308. cmd.ExecuteScalar()
  4309. s1 = s1 + 1
  4310. ' End If
  4311. Next
  4312. ElseIf OpenFileDialog1.SafeFileName Like "极路客*" Then '--------------------------------------------极路客
  4313. sql = "select count(*) from rt_ship_temp_1 where filename=N'" & file_name & "'"
  4314. cmd.CommandText = Sql
  4315. Dim msg As String
  4316. If cmd.ExecuteScalar > 0 Then
  4317. msg = MsgBox("资料已经存在,是否要覆盖?", MsgBoxStyle.YesNo, "警告")
  4318. If msg = vbNo Then
  4319. Exit Sub
  4320. End If
  4321. End If
  4322. If msg = vbYes Then
  4323. sql = "delete from rt_ship_temp_1 where filename=N'" & file_name & "'"
  4324. cmd.CommandText = sql
  4325. cmd.ExecuteNonQuery()
  4326. End If
  4327. xlApp = CreateObject("Excel.Application")
  4328. xlApp.Visible = True
  4329. xlApp.DisplayAlerts = False
  4330. xlBook = xlApp.Workbooks.Open(file_name,, True)
  4331. xlBook.Activate()
  4332. Dim s1 As Integer = 1
  4333. Dim s11 As Integer = 1001
  4334. For i = 1 To xlApp.Worksheets.Count
  4335. xlSheet = xlApp.Worksheets(i)
  4336. xlSheet.Activate()
  4337. Dim y As Integer
  4338. For y = xlApp.Workbooks(1).Worksheets(i).UsedRange.Rows.Count To 3 Step -1
  4339. If xlSheet.Cells(y, 1).value = Nothing Then
  4340. GoTo OK3
  4341. End If
  4342. If xlSheet.Cells(y, 5).value.ToString = "重量总计:" Then
  4343. Exit For
  4344. End If
  4345. Next y
  4346. OK3:
  4347. Dim yyy As Integer
  4348. For yyy = 3 To xlApp.Workbooks(1).Worksheets(i).UsedRange.Rows.Count
  4349. If xlSheet.Cells(yyy, 7).value Is Nothing And xlSheet.Cells(yyy, 8).value Is Nothing Then
  4350. Exit For
  4351. End If
  4352. Next yyy
  4353. 'xlSheet.Range("A3:A" & y - 1).Select()
  4354. 'xlApp.Selection.UnMerge
  4355. ''xlApp.Selection.SpecialCells(Microsoft.Office.Interop.Excel.XlCellType.xlCellTypeBlanks).Select
  4356. ''xlApp.CutCopyMode = False
  4357. ''xlApp.Selection.FormulaR1C1 = "=R[-1]C"
  4358. 'xlSheet.Range("d3:e" & y - 1).Select()
  4359. 'xlApp.Selection.UnMerge
  4360. ''xlApp.Selection.SpecialCells(Microsoft.Office.Interop.Excel.XlCellType.xlCellTypeBlanks).Select
  4361. ''xlApp.CutCopyMode = False
  4362. ''xlApp.Selection.FormulaR1C1 = "=R[-1]C"
  4363. 'xlSheet.Range("j3:M" & yyy - 1).Select()
  4364. 'xlApp.Selection.UnMerge
  4365. 'xlApp.Selection.SpecialCells(Microsoft.Office.Interop.Excel.XlCellType.xlCellTypeBlanks).Select
  4366. 'xlApp.CutCopyMode = False
  4367. 'xlApp.Selection.FormulaR1C1 = "=R[-1]C"
  4368. 'If xlSheet.Range("N3:Q" & yyy - 1).MergeCells.ToString <> "False" Then
  4369. ' xlSheet.Range("N3:Q" & yyy - 1).Select()
  4370. ' xlApp.Selection.UnMerge
  4371. ' 'xlApp.Selection.SpecialCells(Microsoft.Office.Interop.Excel.XlCellType.xlCellTypeBlanks).Select
  4372. ' 'xlApp.CutCopyMode = False
  4373. ' 'xlApp.Selection.FormulaR1C1 = "=R[-1]C"
  4374. 'End If
  4375. Dim my_no As String
  4376. Dim my_po As String
  4377. Dim my_work As String
  4378. Dim my_color As String
  4379. Dim my_thick As String
  4380. Dim my_no1 As String
  4381. Dim my_po1 As String
  4382. Dim my_work1 As String
  4383. Dim my_color1 As String
  4384. Dim my_thick1 As String
  4385. Dim my_card As String
  4386. For y = 3 To y - 1
  4387. If y = 3 Then
  4388. my_no = xlSheet.Cells(y, 1).value
  4389. my_color = xlSheet.Cells(y, 5).value
  4390. my_thick = xlSheet.Cells(y, 6).value
  4391. my_card = xlSheet.Cells(y, 3).value
  4392. my_no1 = xlSheet.Cells(y, 7).value
  4393. my_color1 = xlSheet.Cells(y, 12).value
  4394. my_thick1 = xlSheet.Cells(y, 13).value
  4395. End If
  4396. If xlSheet.Cells(y, 2).value = Nothing And xlSheet.Cells(y, 5).value = Nothing And xlSheet.Cells(y, 6).value = Nothing Then
  4397. ' Exit For
  4398. Else
  4399. If xlSheet.Cells(y, 2).value Is Nothing Then
  4400. Else
  4401. If xlSheet.Cells(y, 5).value Is Nothing And xlSheet.Cells(y, 6).value Is Nothing Then
  4402. Else
  4403. my_card = xlSheet.Cells(y, 3).value
  4404. my_color = xlSheet.Cells(y, 5).value
  4405. my_thick = xlSheet.Cells(y, 6).value
  4406. End If
  4407. sql = "insert into rt_ship_temp_1 (filename,card,serial,qty,color1,thick,PO_NO) values(N'" &
  4408. file_name & "','" & my_card & "','" & s1 & "','" & xlSheet.Cells(y, 2).value & "',N'" & my_color & "','" & my_thick & "','" & xlSheet.Cells(y, 4).value & "')"
  4409. cmd.CommandText = sql
  4410. cmd.ExecuteScalar()
  4411. s1 = s1 + 1
  4412. End If
  4413. End If
  4414. If xlSheet.Cells(y, 9).value = Nothing And xlSheet.Cells(y, 12).value = Nothing And xlSheet.Cells(y, 13).value = Nothing Then
  4415. ' Exit For
  4416. Else
  4417. If xlSheet.Cells(y, 9).value Is Nothing Then
  4418. Else
  4419. If xlSheet.Cells(y, 12).value Is Nothing And xlSheet.Cells(y, 13).value Is Nothing Then
  4420. Else
  4421. my_color1 = xlSheet.Cells(y, 12).value
  4422. my_thick1 = xlSheet.Cells(y, 13).value
  4423. End If
  4424. sql = "insert into rt_ship_temp_1 (filename,card,serial,no,qty,color1,thick,PO_NO) values(N'" &
  4425. file_name & "','" & xlSheet.Cells(y, 10).value & "','" & s11 & "','" & my_no1 & "','" & xlSheet.Cells(y, 9).value & "',N'" & my_color1 & "','" & my_thick1 & "','" & xlSheet.Cells(y, 11).value & "')"
  4426. cmd.CommandText = sql
  4427. cmd.ExecuteScalar()
  4428. s11 = s11 + 1
  4429. End If
  4430. End If
  4431. Next
  4432. Next
  4433. Sql = "SELECT color as 颜色,thick as 厚度,sum(qty) as 尺数,deli_no as 发货单号 from rt_ship_daily_jlk group by color,thick,deli_no "
  4434. cmd.CommandText = Sql
  4435. dt = New DataTable
  4436. da.SelectCommand = cmd
  4437. da.Fill(dt)
  4438. dgv1.DataSource = dt
  4439. 'dt.Columns.Add("尺数")
  4440. 'dt.Columns.Add("货值")
  4441. ' sql = "SELECT 订单类别, 厚度, SUM(尺数) AS 尺数, 类别
  4442. 'FROM (SELECT CASE WHEN LEFT(order_no, 2)
  4443. ' = 'RT' THEN N'人民币' WHEN order_no LIKE 'SX%' THEN '美元' ELSE order_no END AS 订单类别,
  4444. ' i_no AS 指令号, color AS 颜色, thick AS 厚度, CAST(SUM(sf) AS numeric(10, 1)) AS 尺数,
  4445. ' CASE WHEN color LIKE '%pu%' OR
  4446. ' color LIKE '%action%' OR
  4447. ' color LIKE N'%纹%' THEN 'PU' ELSE '反毛' END AS 类别
  4448. ' FROM RT_ship_daily_wh
  4449. ' GROUP BY order_no, i_no, color, thick) AS p
  4450. 'GROUP BY 订单类别, 厚度, 类别
  4451. 'ORDER BY 订单类别"
  4452. ' cmd.CommandText = sql
  4453. ' dt = New DataTable
  4454. ' da.SelectCommand = cmd
  4455. ' da.Fill(dt)
  4456. ' dgv2.DataSource = dt
  4457. ' sql = "SELECT 订单类别, SUM(尺数) AS 尺数, 类别
  4458. 'FROM (SELECT CASE WHEN LEFT(order_no, 2)
  4459. ' = 'RT' THEN N'人民币' WHEN order_no LIKE 'SX%' THEN '美元' ELSE order_no END AS 订单类别,
  4460. ' i_no AS 指令号, color AS 颜色, thick AS 厚度, CAST(SUM(sf) AS numeric(10, 1)) AS 尺数,
  4461. ' CASE WHEN color LIKE '%pu%' OR
  4462. ' color LIKE '%action%' OR
  4463. ' color LIKE N'%纹%' THEN 'PU' ELSE '反毛' END AS 类别
  4464. ' FROM RT_ship_daily_wh
  4465. ' GROUP BY order_no, i_no, color, thick) AS p
  4466. 'GROUP BY 订单类别, 类别 ORDER BY 订单类别"
  4467. ' cmd.CommandText = sql
  4468. ' dt = New DataTable
  4469. ' da.SelectCommand = cmd
  4470. ' da.Fill(dt)
  4471. ' dgv3.DataSource = dt
  4472. ElseIf OpenFileDialog1.SafeFileName Like "*永驰*" Then '------------------------------------------------
  4473. sql = "select count(*) from rt_ship_temp_1 where filename=N'" & file_name & "'"
  4474. cmd.CommandText = Sql
  4475. Dim msg As String
  4476. If cmd.ExecuteScalar > 0 Then
  4477. msg = MsgBox("资料已经存在,是否要覆盖?", MsgBoxStyle.YesNo, "警告")
  4478. If msg = vbNo Then
  4479. Exit Sub
  4480. End If
  4481. End If
  4482. If msg = vbYes Then
  4483. sql = "delete from rt_ship_temp_1 where filename=N'" & file_name & "'"
  4484. cmd.CommandText = sql
  4485. cmd.ExecuteNonQuery()
  4486. End If
  4487. xlApp = CreateObject("Excel.Application")
  4488. xlApp.Visible = True
  4489. xlApp.DisplayAlerts = False
  4490. xlBook = xlApp.Workbooks.Open(file_name,, True)
  4491. xlBook.Activate()
  4492. Dim my_total_weight As Double = 0
  4493. Dim s1 As Integer = 1
  4494. Dim s11 As Integer = 1001
  4495. For i = 1 To xlApp.Worksheets.Count
  4496. xlSheet = xlApp.Worksheets(i)
  4497. xlSheet.Activate()
  4498. Dim y As Integer
  4499. For y = xlApp.Workbooks(1).Worksheets(i).UsedRange.Rows.Count To 3 Step -1
  4500. If xlSheet.Cells(y, 1).value = Nothing Then
  4501. If xlSheet.Cells(y, 2).value = "数量合计" Then
  4502. End If
  4503. GoTo OK
  4504. End If
  4505. If xlSheet.Cells(y, 1).value.ToString = "数量合计" Then
  4506. Exit For
  4507. End If
  4508. OK:
  4509. Next y
  4510. Dim yyy As Integer
  4511. For yyy = 3 To xlApp.Workbooks(1).Worksheets(i).UsedRange.Rows.Count
  4512. If xlSheet.Cells(yyy, 14).value = "制 表" Then
  4513. Exit For
  4514. End If
  4515. Next yyy
  4516. If xlSheet.Cells(y + 2, 2).value Like "重量*" Then
  4517. Dim q() As String
  4518. Dim r() As String
  4519. q = Split(xlSheet.Cells(y + 2, 2).value, "重量")
  4520. r = Split(q(1), "KG")
  4521. If IsNumeric(r(0)) Then
  4522. Else
  4523. r = Split(q(1), "kg")
  4524. If IsNumeric(r(0)) Then
  4525. Else
  4526. r = Split(q(1), "Kg")
  4527. End If
  4528. End If
  4529. 'my_total_weight = r(0)
  4530. End If
  4531. xlSheet.Range("A3:A" & y - 1).Select()
  4532. xlApp.Selection.UnMerge
  4533. 'xlApp.Selection.SpecialCells(Microsoft.Office.Interop.Excel.XlCellType.xlCellTypeBlanks).Select
  4534. 'xlApp.CutCopyMode = False
  4535. 'xlApp.Selection.FormulaR1C1 = "=R[-1]C"
  4536. 'xlSheet.Range("c3:c" & y - 1).Select()
  4537. 'xlApp.Selection.UnMerge
  4538. 'xlApp.Selection.SpecialCells(Microsoft.Office.Interop.Excel.XlCellType.xlCellTypeBlanks).Select
  4539. 'xlApp.CutCopyMode = False
  4540. 'xlApp.Selection.FormulaR1C1 = "=R[-1]C"
  4541. xlSheet.Range("d3:g" & y - 1).Select()
  4542. xlApp.Selection.UnMerge
  4543. 'xlApp.Selection.SpecialCells(Microsoft.Office.Interop.Excel.XlCellType.xlCellTypeBlanks).Select
  4544. 'xlApp.CutCopyMode = False
  4545. 'xlApp.Selection.FormulaR1C1 = "=R[-1]C"
  4546. xlSheet.Range("N3:Q" & yyy - 1).Select()
  4547. xlApp.Selection.UnMerge
  4548. 'xlApp.Selection.SpecialCells(Microsoft.Office.Interop.Excel.XlCellType.xlCellTypeBlanks).Select
  4549. 'xlApp.CutCopyMode = False
  4550. 'xlApp.Selection.FormulaR1C1 = "=R[-1]C"
  4551. If xlSheet.Range("K3:s" & yyy - 1).MergeCells.ToString <> "False" Then
  4552. xlSheet.Range("K3:s" & yyy - 1).Select()
  4553. xlApp.Selection.UnMerge
  4554. 'xlApp.Selection.SpecialCells(Microsoft.Office.Interop.Excel.XlCellType.xlCellTypeBlanks).Select
  4555. 'xlApp.CutCopyMode = False
  4556. 'xlApp.Selection.FormulaR1C1 = "=R[-1]C"
  4557. End If
  4558. Dim my_card1 As String
  4559. Dim my_card As String
  4560. Dim my_no As String
  4561. Dim my_po As String
  4562. Dim my_work As String
  4563. Dim my_color As String
  4564. Dim my_thick As String
  4565. Dim my_no1 As String
  4566. Dim my_po1 As String
  4567. Dim my_work1 As String
  4568. Dim my_color1 As String
  4569. Dim my_thick1 As String
  4570. For y = 3 To y - 1
  4571. If y = 3 Then
  4572. my_card = xlSheet.Cells(3, 3).value
  4573. my_po = xlSheet.Cells(3, 4).value
  4574. my_work = xlSheet.Cells(3, 5).value
  4575. my_color = xlSheet.Cells(3, 6).value
  4576. my_thick = xlSheet.Cells(3, 7).value
  4577. my_card1 = xlSheet.Cells(3, 13).value
  4578. my_po1 = xlSheet.Cells(3, 14).value
  4579. my_work1 = xlSheet.Cells(3, 15).value
  4580. my_color1 = xlSheet.Cells(3, 16).value
  4581. my_thick1 = xlSheet.Cells(3, 17).value
  4582. End If
  4583. If xlSheet.Cells(y, 2).value Is Nothing Then
  4584. Else
  4585. If xlSheet.Cells(y, 6).VALUE Is Nothing Then '颜色为空
  4586. If xlSheet.Cells(y, 1).value Is Nothing Then
  4587. Else
  4588. my_no = xlSheet.Cells(y, 1).value
  4589. End If
  4590. sql = "insert into rt_ship_temp_1 (filename,card,serial,no,qty,order_no,work_no,color1,thick) values(N'" & file_name & "','" & xlSheet.Cells(y, 3).value & "','" & s1 & "','" & my_no & "'," & xlSheet.Cells(y, 2).value & ",N'" & my_po & "',N'" & my_work & "',N'" & my_color & "','" & my_thick & "')"
  4591. cmd.CommandText = sql
  4592. cmd.ExecuteScalar()
  4593. s1 = s1 + 1
  4594. Else
  4595. If xlSheet.Cells(y, 1).value Is Nothing Then
  4596. Else
  4597. my_no = xlSheet.Cells(y, 1).value
  4598. End If
  4599. my_po = xlSheet.Cells(y, 4).value
  4600. my_work = xlSheet.Cells(y, 5).value
  4601. my_color = xlSheet.Cells(y, 6).value
  4602. my_thick = xlSheet.Cells(y, 7).value
  4603. sql = "insert into rt_ship_temp_1 (filename,card,serial,no,qty,order_no,work_no,color1,thick) values(N'" & file_name & "','" & xlSheet.Cells(y, 3).value & "','" & s1 & "','" & my_no & "'," & xlSheet.Cells(y, 2).value & ",N'" & my_po & "',N'" & my_work & "',N'" & my_color & "','" & my_thick & "')"
  4604. cmd.CommandText = sql
  4605. cmd.ExecuteScalar()
  4606. s1 = s1 + 1
  4607. End If
  4608. End If
  4609. If xlSheet.Cells(y, 12).value Is Nothing Then
  4610. Else
  4611. If xlSheet.Cells(y, 16).VALUE Is Nothing Then '颜色为空
  4612. If xlSheet.Cells(y, 11).value Is Nothing Then
  4613. Else
  4614. my_no1 = xlSheet.Cells(y, 11).value
  4615. End If
  4616. sql = "insert into rt_ship_temp_1 (filename,card,serial,no,qty,order_no,work_no,color1,thick) values(N'" & file_name & "','" & xlSheet.Cells(y, 13).value & "','" & s11 & "','" & my_no1 & "'," & xlSheet.Cells(y, 12).value & ",N'" & my_po1 & "',N'" & my_work1 & "',N'" & my_color1 & "','" & my_thick1 & "')"
  4617. cmd.CommandText = sql
  4618. cmd.ExecuteScalar()
  4619. s11 = s11 + 1
  4620. Else
  4621. If xlSheet.Cells(y, 11).value Is Nothing Then
  4622. Else
  4623. my_no1 = xlSheet.Cells(y, 11).value
  4624. End If
  4625. my_po1 = xlSheet.Cells(y, 14).value
  4626. my_work1 = xlSheet.Cells(y, 15).value
  4627. my_color1 = xlSheet.Cells(y, 16).value
  4628. my_thick1 = xlSheet.Cells(y, 17).value
  4629. sql = "insert into rt_ship_temp_1 (filename,card,serial,no,qty,order_no,work_no,color1,thick) values(N'" & file_name & "','" & xlSheet.Cells(y, 13).value & "','" & s11 & "','" & my_no1 & "'," & xlSheet.Cells(y, 12).value & ",N'" & my_po1 & "',N'" & my_work1 & "',N'" & my_color1 & "','" & my_thick1 & "')"
  4630. cmd.CommandText = sql
  4631. cmd.ExecuteScalar()
  4632. s11 = s11 + 1
  4633. End If
  4634. End If
  4635. 'sql = "insert into rt_ship_076_1 (no,sf,order_no,i_no,color,thick) values('" & my_no1 & "'," & xlSheet.Cells(y, 10).value & ",N'" & my_po1 & "',N'" & my_work1 & "',N'" & my_color1 & "','" & my_thick1 & "')"
  4636. 'cmd.CommandText = sql
  4637. 'cmd.ExecuteScalar()
  4638. Next
  4639. Next
  4640. Sql = "SELECT order_no AS 订单号, i_no AS 指令号, color AS 颜色, thick AS 厚度, cast(SUM(sf) as numeric(10,1)) AS 尺数 FROM rt_ship_daily_yongchi GROUP BY order_no, i_no, color, thick ORDER BY 订单号, 指令号, 颜色"
  4641. cmd.CommandText = Sql
  4642. dt = New DataTable
  4643. da.SelectCommand = cmd
  4644. da.Fill(dt)
  4645. dt.Columns.Add("发货单号")
  4646. dgv1.DataSource = dt
  4647. 'dt.Columns.Add("货值")
  4648. Sql = "SELECT 订单类别, 厚度, SUM(尺数) AS 尺数, 类别
  4649. FROM (SELECT CASE WHEN LEFT(order_no, 2)
  4650. = 'RT' THEN N'人民币' WHEN order_no LIKE 'SX%' THEN '美元' ELSE order_no END AS 订单类别,
  4651. i_no AS 指令号, color AS 颜色, thick AS 厚度, CAST(SUM(sf) AS numeric(10, 1)) AS 尺数,
  4652. CASE WHEN color LIKE '%pu%' OR
  4653. color LIKE '%action%' OR
  4654. color LIKE N'%纹%' THEN 'PU' ELSE '反毛' END AS 类别
  4655. FROM rt_ship_daily_yongchi
  4656. GROUP BY order_no, i_no, color, thick) AS p
  4657. GROUP BY 订单类别, 厚度, 类别
  4658. ORDER BY 订单类别"
  4659. cmd.CommandText = Sql
  4660. dt = New DataTable
  4661. da.SelectCommand = cmd
  4662. da.Fill(dt)
  4663. dgv2.DataSource = dt
  4664. Sql = "SELECT 订单类别, SUM(尺数) AS 尺数, 类别
  4665. FROM (SELECT CASE WHEN LEFT(order_no, 2)
  4666. = 'RT' THEN N'人民币' WHEN order_no LIKE 'SX%' THEN '美元' ELSE order_no END AS 订单类别,
  4667. i_no AS 指令号, color AS 颜色, thick AS 厚度, CAST(SUM(sf) AS numeric(10, 1)) AS 尺数,
  4668. CASE WHEN color LIKE '%pu%' OR
  4669. color LIKE '%action%' OR
  4670. color LIKE N'%纹%' THEN 'PU' ELSE '反毛' END AS 类别
  4671. FROM rt_ship_daily_yongchi
  4672. GROUP BY order_no, i_no, color, thick) AS p
  4673. GROUP BY 订单类别, 类别 ORDER BY 订单类别"
  4674. cmd.CommandText = Sql
  4675. dt = New DataTable
  4676. da.SelectCommand = cmd
  4677. da.Fill(dt)
  4678. dgv3.DataSource = dt
  4679. sql = "update rt_ship_temp_1 set name=color where filename like N'%永驰%'"
  4680. cmd.CommandText = sql
  4681. cmd.ExecuteScalar()
  4682. ElseIf OpenFileDialog1.SafeFileName Like "*铭鑫*" Then '------------------------------------------------
  4683. sql = "select count(*) from rt_ship_temp_1 where filename=N'" & file_name & "'"
  4684. cmd.CommandText = Sql
  4685. Dim msg As String
  4686. If cmd.ExecuteScalar > 0 Then
  4687. msg = MsgBox("资料已经存在,是否要覆盖?", MsgBoxStyle.YesNo, "警告")
  4688. If msg = vbNo Then
  4689. Exit Sub
  4690. End If
  4691. End If
  4692. If msg = vbYes Then
  4693. sql = "delete from rt_ship_temp_1 where filename=N'" & file_name & "'"
  4694. cmd.CommandText = sql
  4695. cmd.ExecuteNonQuery()
  4696. End If
  4697. xlApp = CreateObject("Excel.Application")
  4698. xlApp.Visible = True
  4699. xlApp.DisplayAlerts = False
  4700. xlBook = xlApp.Workbooks.Open(file_name,, True)
  4701. xlBook.Activate()
  4702. Dim my_total_weight As Double = 0
  4703. Dim s1 As Integer = 1
  4704. Dim s11 As Integer = 1001
  4705. For i = 1 To xlApp.Worksheets.Count
  4706. xlSheet = xlApp.Worksheets(i)
  4707. xlSheet.Activate()
  4708. Dim my_card1 As String
  4709. Dim my_card As String
  4710. Dim my_no As String
  4711. Dim my_po As String
  4712. Dim my_work As String
  4713. Dim my_color As String
  4714. Dim my_thick As String
  4715. Dim my_no1 As String
  4716. Dim my_po1 As String
  4717. Dim my_work1 As String
  4718. Dim my_color1 As String
  4719. Dim my_thick1 As String
  4720. For y = 2 To xlApp.Workbooks(1).Worksheets(i).UsedRange.Rows.Count
  4721. If y = 2 Then
  4722. ' my_card = xlSheet.Cells(3, 3).value
  4723. my_po = xlSheet.Cells(y, 5).value
  4724. ' my_work = xlSheet.Cells(3, 5).value
  4725. my_color = xlSheet.Cells(y, 2).value
  4726. my_thick = xlSheet.Cells(y, 3).value
  4727. ' my_card1 = xlSheet.Cells(y, 13).value
  4728. my_po1 = xlSheet.Cells(y, 10).value
  4729. ' my_work1 = xlSheet.Cells(y, 15).value
  4730. my_color1 = xlSheet.Cells(y, 7).value
  4731. my_thick1 = xlSheet.Cells(y, 8).value
  4732. End If
  4733. If xlSheet.Cells(y, 2).value Is Nothing Then
  4734. Else
  4735. sql = "insert into rt_ship_temp_1 (filename,serial,no,qty,order_no,work_no,color,thick) values(N'" & file_name & "','" & s1 & "','" & my_no & "'," & xlSheet.Cells(y, 4).value & ",N'" & my_po & "',N'" & my_work & "',N'" & my_color & "','" & my_thick & "')"
  4736. cmd.CommandText = sql
  4737. cmd.ExecuteScalar()
  4738. s1 = s1 + 1
  4739. End If
  4740. If xlSheet.Cells(y, 7).value Is Nothing Then
  4741. Else
  4742. sql = "insert into rt_ship_temp_1 (filename,serial,no,sf,order_no,work_no,color,thick) values(N'" & file_name & "','" & s11 & "','" & my_no1 & "'," & xlSheet.Cells(y, 9).value & ",N'" & my_po1 & "',N'" & my_work1 & "',N'" & my_color1 & "','" & my_thick1 & "')"
  4743. cmd.CommandText = sql
  4744. cmd.ExecuteScalar()
  4745. s11 = s11 + 1
  4746. End If
  4747. 'sql = "insert into rt_ship_076_1 (no,sf,order_no,i_no,color,thick) values('" & my_no1 & "'," & xlSheet.Cells(y, 10).value & ",N'" & my_po1 & "',N'" & my_work1 & "',N'" & my_color1 & "','" & my_thick1 & "')"
  4748. 'cmd.CommandText = sql
  4749. 'cmd.ExecuteScalar()
  4750. Next
  4751. Next
  4752. Sql = "SELECT order_no AS 订单号, i_no AS 指令号, color AS 颜色, thick AS 厚度, cast(SUM(sf) as numeric(10,1)) AS 尺数 FROM rt_ship_daily_yongchi GROUP BY order_no, i_no, color, thick ORDER BY 订单号, 指令号, 颜色"
  4753. cmd.CommandText = Sql
  4754. dt = New DataTable
  4755. da.SelectCommand = cmd
  4756. da.Fill(dt)
  4757. dt.Columns.Add("发货单号")
  4758. dgv1.DataSource = dt
  4759. 'dt.Columns.Add("货值")
  4760. Sql = "SELECT 订单类别, 厚度, SUM(尺数) AS 尺数, 类别
  4761. FROM (SELECT CASE WHEN LEFT(order_no, 2)
  4762. = 'RT' THEN N'人民币' WHEN order_no LIKE 'SX%' THEN '美元' ELSE order_no END AS 订单类别,
  4763. i_no AS 指令号, color AS 颜色, thick AS 厚度, CAST(SUM(sf) AS numeric(10, 1)) AS 尺数,
  4764. CASE WHEN color LIKE '%pu%' OR
  4765. color LIKE '%action%' OR
  4766. color LIKE N'%纹%' THEN 'PU' ELSE '反毛' END AS 类别
  4767. FROM rt_ship_daily_yongchi
  4768. GROUP BY order_no, i_no, color, thick) AS p
  4769. GROUP BY 订单类别, 厚度, 类别
  4770. ORDER BY 订单类别"
  4771. cmd.CommandText = Sql
  4772. dt = New DataTable
  4773. da.SelectCommand = cmd
  4774. da.Fill(dt)
  4775. dgv2.DataSource = dt
  4776. Sql = "SELECT 订单类别, SUM(尺数) AS 尺数, 类别
  4777. FROM (SELECT CASE WHEN LEFT(order_no, 2)
  4778. = 'RT' THEN N'人民币' WHEN order_no LIKE 'SX%' THEN '美元' ELSE order_no END AS 订单类别,
  4779. i_no AS 指令号, color AS 颜色, thick AS 厚度, CAST(SUM(sf) AS numeric(10, 1)) AS 尺数,
  4780. CASE WHEN color LIKE '%pu%' OR
  4781. color LIKE '%action%' OR
  4782. color LIKE N'%纹%' THEN 'PU' ELSE '反毛' END AS 类别
  4783. FROM rt_ship_daily_yongchi
  4784. GROUP BY order_no, i_no, color, thick) AS p
  4785. GROUP BY 订单类别, 类别 ORDER BY 订单类别"
  4786. cmd.CommandText = Sql
  4787. dt = New DataTable
  4788. da.SelectCommand = cmd
  4789. da.Fill(dt)
  4790. dgv3.DataSource = dt
  4791. sql = "update rt_ship_temp_1 set name=color where filename like N'%永驰%'"
  4792. cmd.CommandText = sql
  4793. cmd.ExecuteScalar()
  4794. ElseIf OpenFileDialog1.SafeFileName Like "076*" Then '------------------------076
  4795. sql = "select count(*) from rt_ship_temp_1 where filename=N'" & file_name & "'"
  4796. cmd.CommandText = Sql
  4797. Dim msg As String
  4798. If cmd.ExecuteScalar > 0 Then
  4799. msg = MsgBox("资料已经存在,是否要覆盖?", MsgBoxStyle.YesNo, "警告")
  4800. If msg = vbNo Then
  4801. Exit Sub
  4802. End If
  4803. End If
  4804. If msg = vbYes Then
  4805. sql = "delete from rt_ship_temp_1 where filename=N'" & file_name & "'"
  4806. cmd.CommandText = sql
  4807. cmd.ExecuteNonQuery()
  4808. End If
  4809. xlApp = CreateObject("Excel.Application")
  4810. xlApp.Visible = True
  4811. xlApp.DisplayAlerts = False
  4812. xlBook = xlApp.Workbooks.Open(file_name,, True)
  4813. xlBook.Activate()
  4814. Dim my_total_weight As Double = 0
  4815. Dim s1 As Integer = 1
  4816. Dim s11 As Integer = 1001
  4817. For i = 1 To xlApp.Worksheets.Count
  4818. xlSheet = xlApp.Worksheets(i)
  4819. xlSheet.Activate()
  4820. Dim y As Integer
  4821. For y = xlApp.Workbooks(1).Worksheets(i).UsedRange.Rows.Count To 3 Step -1
  4822. If xlSheet.Cells(y, 1).value = Nothing Then
  4823. If xlSheet.Cells(y, 2).value = "重量" Then
  4824. End If
  4825. GoTo OK6
  4826. End If
  4827. If xlSheet.Cells(y, 1).value.ToString = "数量合计" Then
  4828. Exit For
  4829. End If
  4830. OK6:
  4831. Next y
  4832. Dim yyy As Integer
  4833. For yyy = 3 To xlApp.Workbooks(1).Worksheets(i).UsedRange.Rows.Count
  4834. If xlSheet.Cells(yyy, 14).value = "制 表" Then
  4835. Exit For
  4836. End If
  4837. Next yyy
  4838. If xlSheet.Cells(y + 2, 2).value Like "重量*" Then
  4839. Dim q() As String
  4840. Dim r() As String
  4841. q = Split(xlSheet.Cells(y + 2, 2).value, "重量")
  4842. r = Split(q(1), "KG")
  4843. If IsNumeric(r(0)) Then
  4844. Else
  4845. r = Split(q(1), "kg")
  4846. If IsNumeric(r(0)) Then
  4847. Else
  4848. r = Split(q(1), "Kg")
  4849. End If
  4850. End If
  4851. 'my_total_weight = r(0)
  4852. End If
  4853. xlSheet.Range("A3:A" & y - 1).Select()
  4854. xlApp.Selection.UnMerge
  4855. 'xlApp.Selection.SpecialCells(Microsoft.Office.Interop.Excel.XlCellType.xlCellTypeBlanks).Select
  4856. 'xlApp.CutCopyMode = False
  4857. 'xlApp.Selection.FormulaR1C1 = "=R[-1]C"
  4858. xlSheet.Range("c3:g" & y - 1).Select()
  4859. xlApp.Selection.UnMerge
  4860. 'xlApp.Selection.SpecialCells(Microsoft.Office.Interop.Excel.XlCellType.xlCellTypeBlanks).Select
  4861. 'xlApp.CutCopyMode = False
  4862. 'xlApp.Selection.FormulaR1C1 = "=R[-1]C"
  4863. xlSheet.Range("N3:Q" & yyy - 1).Select()
  4864. xlApp.Selection.UnMerge
  4865. 'xlApp.Selection.SpecialCells(Microsoft.Office.Interop.Excel.XlCellType.xlCellTypeBlanks).Select
  4866. 'xlApp.CutCopyMode = False
  4867. 'xlApp.Selection.FormulaR1C1 = "=R[-1]C"
  4868. If xlSheet.Range("K3:L" & yyy - 1).MergeCells.ToString <> "False" Then
  4869. xlSheet.Range("K3:L" & yyy - 1).Select()
  4870. xlApp.Selection.UnMerge
  4871. 'xlApp.Selection.SpecialCells(Microsoft.Office.Interop.Excel.XlCellType.xlCellTypeBlanks).Select
  4872. 'xlApp.CutCopyMode = False
  4873. 'xlApp.Selection.FormulaR1C1 = "=R[-1]C"
  4874. End If
  4875. Dim my_card As String
  4876. Dim my_no As String
  4877. Dim my_po As String
  4878. Dim my_work As String
  4879. Dim my_color As String
  4880. Dim my_thick As String
  4881. Dim my_no1 As String
  4882. Dim my_po1 As String
  4883. Dim my_work1 As String
  4884. Dim my_color1 As String
  4885. Dim my_thick1 As String
  4886. For y = 3 To y - 1
  4887. If y = 3 Then
  4888. my_po = xlSheet.Cells(y, 4).value
  4889. my_work = xlSheet.Cells(y, 5).value
  4890. my_color = xlSheet.Cells(y, 6).value
  4891. my_thick = xlSheet.Cells(y, 7).value
  4892. my_po1 = xlSheet.Cells(y, 14).value
  4893. my_work1 = xlSheet.Cells(y, 15).value
  4894. my_color1 = xlSheet.Cells(y, 16).value
  4895. my_thick1 = xlSheet.Cells(y, 17).value
  4896. End If
  4897. If xlSheet.Cells(y, 2).value = Nothing And xlSheet.Cells(y, 4).value = Nothing And xlSheet.Cells(y, 5).value = Nothing And xlSheet.Cells(y, 6).value = Nothing And xlSheet.Cells(y, 7).value = Nothing Then
  4898. ' Exit For
  4899. Else
  4900. If xlSheet.Cells(y, 2).value Is Nothing Then
  4901. Else
  4902. If xlSheet.Cells(y, 4).VALUE Is Nothing Then
  4903. If xlSheet.Cells(y, 1).value Is Nothing Then
  4904. Else
  4905. my_no = xlSheet.Cells(y, 1).value
  4906. End If
  4907. sql = "insert into rt_ship_temp_1 (filename,card,serial,no,qty,po_no,work_no,color1,thick) values(N'" & file_name & "','" & xlSheet.Cells(y, 3).value & "','" & s1 & "','" & my_no & "'," & xlSheet.Cells(y, 2).value & ",N'" & my_po & "',N'" & my_work & "',N'" & my_color & "','" & my_thick & "')"
  4908. cmd.CommandText = sql
  4909. cmd.ExecuteScalar()
  4910. s1 = s1 + 1
  4911. Else
  4912. If xlSheet.Cells(y, 1).value Is Nothing Then
  4913. Else
  4914. my_no = xlSheet.Cells(y, 1).value
  4915. End If
  4916. my_po = xlSheet.Cells(y, 4).value
  4917. my_work = xlSheet.Cells(y, 5).value
  4918. my_color = xlSheet.Cells(y, 6).value
  4919. my_thick = xlSheet.Cells(y, 7).value
  4920. sql = "insert into rt_ship_temp_1 (filename,card,serial,no,qty,po_no,work_no,color1,thick) values(N'" & file_name & "','" & xlSheet.Cells(y, 3).value & "','" & s1 & "','" & my_no & "'," & xlSheet.Cells(y, 2).value & ",N'" & my_po & "',N'" & my_work & "',N'" & my_color & "','" & my_thick & "')"
  4921. cmd.CommandText = sql
  4922. cmd.ExecuteScalar()
  4923. s1 = s1 + 1
  4924. End If
  4925. End If
  4926. End If
  4927. If xlSheet.Cells(y, 12).value = Nothing And xlSheet.Cells(y, 14).value = Nothing And xlSheet.Cells(y, 15).value = Nothing And xlSheet.Cells(y, 16).value = Nothing And xlSheet.Cells(y, 17).value = Nothing Then
  4928. ' Exit For
  4929. Else
  4930. If xlSheet.Cells(y, 12).value Is Nothing Then
  4931. Else
  4932. If xlSheet.Cells(y, 14).VALUE Is Nothing Then
  4933. If xlSheet.Cells(y, 11).value Is Nothing Then
  4934. Else
  4935. my_no1 = xlSheet.Cells(y, 11).value
  4936. End If
  4937. sql = "insert into rt_ship_temp_1 (filename,card,serial,no,qty,po_no,work_no,color1,thick) values(N'" & file_name & "','" & xlSheet.Cells(y, 13).value & "','" & s11 & "','" & my_no1 & "'," & xlSheet.Cells(y, 12).value & ",N'" & my_po1 & "',N'" & my_work1 & "',N'" & my_color1 & "','" & my_thick1 & "')"
  4938. cmd.CommandText = sql
  4939. cmd.ExecuteScalar()
  4940. s11 = s11 + 1
  4941. Else
  4942. If xlSheet.Cells(y, 11).value Is Nothing Then
  4943. Else
  4944. my_no1 = xlSheet.Cells(y, 11).value
  4945. End If
  4946. my_po1 = xlSheet.Cells(y, 14).value
  4947. my_work1 = xlSheet.Cells(y, 15).value
  4948. my_color1 = xlSheet.Cells(y, 16).value
  4949. my_thick1 = xlSheet.Cells(y, 17).value
  4950. sql = "insert into rt_ship_temp_1 (filename,card,serial,no,qty,po_no,work_no,color1,thick) values(N'" & file_name & "','" & xlSheet.Cells(y, 13).value & "','" & s11 & "','" & my_no1 & "'," & xlSheet.Cells(y, 12).value & ",N'" & my_po1 & "',N'" & my_work1 & "',N'" & my_color1 & "','" & my_thick1 & "')"
  4951. cmd.CommandText = sql
  4952. cmd.ExecuteScalar()
  4953. s11 = s11 + 1
  4954. End If
  4955. End If
  4956. 'sql = "insert into rt_ship_076_1 (no,sf,order_no,i_no,color,thick) values('" & my_no1 & "'," & xlSheet.Cells(y, 10).value & ",N'" & my_po1 & "',N'" & my_work1 & "',N'" & my_color1 & "','" & my_thick1 & "')"
  4957. 'cmd.CommandText = sql
  4958. 'cmd.ExecuteScalar()
  4959. End If
  4960. Next
  4961. Next
  4962. Sql = "SELECT order_no AS 订单号, i_no AS 指令号, color AS 颜色, thick AS 厚度, cast(SUM(sf) as numeric(10,1)) AS 尺数 FROM RT_ship_076_1 GROUP BY order_no, i_no, color, thick ORDER BY 订单号, 指令号, 颜色"
  4963. cmd.CommandText = Sql
  4964. dt = New DataTable
  4965. da.SelectCommand = cmd
  4966. da.Fill(dt)
  4967. dt.Columns.Add("发货单号")
  4968. dgv1.DataSource = dt
  4969. 'dt.Columns.Add("货值")
  4970. Sql = "SELECT 订单类别, 厚度, SUM(尺数) AS 尺数, 类别
  4971. FROM (SELECT CASE WHEN LEFT(order_no, 2)
  4972. = 'RT' THEN N'人民币' WHEN order_no LIKE 'SX%' THEN '美元' ELSE order_no END AS 订单类别,
  4973. i_no AS 指令号, color AS 颜色, thick AS 厚度, CAST(SUM(sf) AS numeric(10, 1)) AS 尺数,
  4974. CASE WHEN color LIKE '%pu%' OR
  4975. color LIKE '%action%' OR
  4976. color LIKE N'%纹%' THEN 'PU' ELSE '反毛' END AS 类别
  4977. FROM RT_ship_076_1
  4978. GROUP BY order_no, i_no, color, thick) AS p
  4979. GROUP BY 订单类别, 厚度, 类别
  4980. ORDER BY 订单类别"
  4981. cmd.CommandText = Sql
  4982. dt = New DataTable
  4983. da.SelectCommand = cmd
  4984. da.Fill(dt)
  4985. dgv2.DataSource = dt
  4986. Sql = "SELECT 订单类别, SUM(尺数) AS 尺数, 类别
  4987. FROM (SELECT CASE WHEN LEFT(order_no, 2)
  4988. = 'RT' THEN N'人民币' WHEN order_no LIKE 'SX%' THEN '美元' ELSE order_no END AS 订单类别,
  4989. i_no AS 指令号, color AS 颜色, thick AS 厚度, CAST(SUM(sf) AS numeric(10, 1)) AS 尺数,
  4990. CASE WHEN color LIKE '%pu%' OR
  4991. color LIKE '%action%' OR
  4992. color LIKE N'%纹%' THEN 'PU' ELSE '反毛' END AS 类别
  4993. FROM RT_ship_076_1
  4994. GROUP BY order_no, i_no, color, thick) AS p
  4995. GROUP BY 订单类别, 类别 ORDER BY 订单类别"
  4996. cmd.CommandText = Sql
  4997. dt = New DataTable
  4998. da.SelectCommand = cmd
  4999. da.Fill(dt)
  5000. dgv3.DataSource = dt
  5001. For rr As Integer = 0 To dt.Rows.Count - 1
  5002. 'sql = ""
  5003. 'cmd.CommandText = sql
  5004. 'dt.Rows(rr).Item("尺数") = cmd.ExecuteScalar
  5005. Next
  5006. For rr As Integer = 0 To dt.Rows.Count - 1
  5007. 'sql = ""
  5008. 'cmd.CommandText = sql
  5009. 'dt.Rows(rr).Item("货值") = cmd.ExecuteScalar
  5010. Next
  5011. 'DataGridView1.DataSource = dt
  5012. Else
  5013. MsgBox("找不到相对应的模组")
  5014. Exit Sub
  5015. End If
  5016. sql = "update rt_ship_temp_1 set comment='' where comment is null"
  5017. cmd.CommandText = sql
  5018. cmd.ExecuteScalar()
  5019. xlApp.Visible = True
  5020. xlApp.Quit()
  5021. xlSheet = Nothing '釋放sheet物件
  5022. ' xlApp.Quit() '關閉Excel
  5023. KillExcel(xlApp)
  5024. update() '更新资料
  5025. 'Button3.PerformClick()
  5026. 'Button6.PerformClick()
  5027. sql = "update rt_ship_temp_1 set thick=1.24 where name like '%1.2-%' and thick is null "
  5028. cmd.CommandText = sql
  5029. cmd.ExecuteScalar()
  5030. sql = "update rt_ship_temp_1 set thick=1.46 where name like '%1.4-%' and thick is null "
  5031. cmd.CommandText = sql
  5032. cmd.ExecuteScalar()
  5033. sql = "update rt_ship_temp_1 set name=color1 where name is null "
  5034. cmd.CommandText = sql
  5035. cmd.ExecuteScalar()
  5036. sql = "select filename,cast(sum(qty) as numeric(10,1)) as 尺数 from rt_ship_temp_1 group by filename,update_date order by update_date desc"
  5037. cmd.CommandText = sql
  5038. da.SelectCommand = cmd
  5039. dt1 = New DataTable
  5040. da.Fill(dt1)
  5041. DataGridView1.DataSource = Nothing
  5042. DataGridView1.DataSource = dt1
  5043. MsgBox("作业完成")
  5044. End Sub
  5045. Private Sub KillExcel(ByVal objExcel As Object)
  5046. Try
  5047. If objExcel IsNot Nothing Then
  5048. Dim lProcessIdAddr As Integer
  5049. Dim iPID As Integer
  5050. iPID = GetWindowThreadProcessId(objExcel.Hwnd, lProcessIdAddr)
  5051. System.Diagnostics.Process.GetProcessById(lProcessIdAddr).Kill()
  5052. End If
  5053. Catch ex As Exception
  5054. End Try
  5055. End Sub
  5056. Private Sub Frm_Ship_daily_1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
  5057. dgv_edit.SelectionMode = DataGridViewSelectionMode.FullRowSelect
  5058. dgv1.AllowUserToAddRows = False
  5059. DataGridView2.AllowUserToAddRows = False
  5060. DataGridView2.SelectionMode = DataGridViewSelectionMode.FullRowSelect
  5061. chkZhiDan.Items.Add("陈立雄")
  5062. chkZhiDan.Items.Add("尤珊荣")
  5063. chkZhiDan.Items.Add("郑春玉")
  5064. chkZhiDan.Items.Add("陈建超")
  5065. chkZhiDan.Items.Add("蔡春燕")
  5066. chkZhiDan.Items.Add("叶以")
  5067. chkZhiDan.Items.Add("蔡青山")
  5068. chkZhiDan.Items.Add("许燕江")
  5069. chkZhiDan.SelectionMode = SelectionMode.One
  5070. chkSongHuo.Items.Add("许智富")
  5071. chkSongHuo.Items.Add("蔡青山")
  5072. chkSongHuo.SelectionMode = SelectionMode.One
  5073. conn.ConnectionString = connstring
  5074. conn.Open()
  5075. cmd.Connection = conn
  5076. '---------------------------------------------------------------------------更新
  5077. sql = "update rt_ship_temp_1 set update_date=getdate() where date is null"
  5078. cmd.CommandText = sql
  5079. cmd.ExecuteScalar()
  5080. sql = "update rt_ship_temp_1 set work_no='' where work_no is null"
  5081. cmd.CommandText = sql
  5082. cmd.ExecuteScalar()
  5083. sql = "update rt_ship_temp_1 set color1=name where len(color1)<2 "
  5084. cmd.CommandText = sql
  5085. cmd.ExecuteScalar()
  5086. sql = "UPDATE rt_ship_temp_1
  5087. SET source1 = p.Expr1
  5088. FROM (SELECT card1, source AS Expr1
  5089. FROM RT_RETAN_RECORD
  5090. ) AS p INNER JOIN
  5091. rt_ship_temp_1 ON p.card1 = rt_ship_temp_1.card"
  5092. cmd.CommandText = sql
  5093. cmd.ExecuteScalar()
  5094. sql = "update rt_ship_temp_1 set source1=N'信德' where right(card,2)= 'WB'"
  5095. cmd.CommandText = sql
  5096. cmd.ExecuteScalar()
  5097. sql = "update rt_ship_temp_1 set source1=N'外购小皮' where right(card,1)= 'W'"
  5098. cmd.CommandText = sql
  5099. cmd.ExecuteScalar()
  5100. sql = "select top(1) date from rt_ship_temp_1 order by date desc"
  5101. cmd.CommandText = sql
  5102. TextBox8.Text = cmd.ExecuteScalar
  5103. sql = "select top(1) date from rt_measure_daily order by date desc"
  5104. cmd.CommandText = sql
  5105. TextBox7.Text = cmd.ExecuteScalar
  5106. sql = "SELECT rt_ship_temp_1.date, rt_ship_temp_1.custname, rt_ship_temp_1.name, rt_ship_temp_1.card AS 卡号,
  5107. CAST(SUM(rt_ship_temp_1.qty) AS numeric(10, 1)) AS 销售数量, CAST(AVG(rt_finish_stock.sf) AS numeric(10, 1))
  5108. AS 即时库存, CAST(AVG(rt_finish_stock.sf) AS numeric(10, 1)) - CAST(SUM(rt_ship_temp_1.qty) AS numeric(10, 1)) AS 结存,
  5109. rt_finish_stock.code AS 代码, rt_finish_stock.name AS 品名
  5110. FROM rt_ship_temp_1 LEFT OUTER JOIN
  5111. rt_finish_stock ON rt_ship_temp_1.card = rt_finish_stock.lot
  5112. WHERE (rt_ship_temp_1.date BETWEEN '2024/6/18' AND '2024/6/30')
  5113. GROUP BY rt_ship_temp_1.card, rt_finish_stock.code, rt_finish_stock.name, rt_ship_temp_1.date, rt_ship_temp_1.custname,
  5114. rt_ship_temp_1.name
  5115. ORDER BY 结存"
  5116. DateTimePicker3.Value = "2024/6/18"
  5117. cmd.CommandText = sql
  5118. cmd.ExecuteScalar()
  5119. cmd.CommandText = sql
  5120. da.SelectCommand = cmd
  5121. dt1 = New DataTable
  5122. da.Fill(dt1)
  5123. dgv_bal.DataSource = dt1
  5124. sql = "update rt_ship_temp_1 set comment='' where comment is null"
  5125. cmd.CommandText = sql
  5126. cmd.ExecuteScalar()
  5127. sql = "update rt_ship_temp_1 set comment='' where comment is null"
  5128. cmd.CommandText = sql
  5129. cmd.ExecuteScalar()
  5130. update()
  5131. End Sub
  5132. Private Sub DataGridView1_CellContentClick(sender As Object, e As DataGridViewCellEventArgs) Handles DataGridView1.CellContentClick
  5133. If DataGridView1.Rows(DataGridView1.CurrentCell.RowIndex).Cells("filename").Value Like "*上杰*" Or DataGridView1.Rows(DataGridView1.CurrentCell.RowIndex).Cells("filename").Value Like "*宏美发*" Or DataGridView1.Rows(DataGridView1.CurrentCell.RowIndex).Cells("filename").Value Like "*永正*" Or DataGridView1.Rows(DataGridView1.CurrentCell.RowIndex).Cells("filename").Value Like "*宏福*" Then '---加order_item
  5134. sql = "select name as 品名,color1 as 颜色,thick as 厚度,card as 卡号,po_no as 订单号,work_no as 指令号,order_item as 项次号, cast(sum(qty) as numeric(10,1)) as 尺数,deli as 发货人,deli_no as 发货单号 from rt_ship_temp_1 where filename=N'" & DataGridView1.Rows(DataGridView1.CurrentCell.RowIndex).Cells("filename").Value & "' group by name,color1,thick,card,po_no,work_no,order_item,deli,deli_no"
  5135. sql = "SELECT rt_ship_temp_1.name AS 品名, rt_ship_temp_1.color1 AS 颜色, rt_ship_temp_1.thick AS 厚度,
  5136. rt_ship_temp_1.card AS 卡号, RT_RETAN_RECORD.source AS 皮源, rt_ship_temp_1.po_no AS 订单号,
  5137. rt_ship_temp_1.work_no AS 指令号,order_item as 项次号,CAST(SUM(rt_ship_temp_1.qty) AS numeric(10, 1)) AS 尺数,
  5138. rt_ship_temp_1.deli AS 发货人, rt_ship_temp_1.deli_no AS 发货单号
  5139. FROM rt_ship_temp_1 LEFT OUTER JOIN
  5140. RT_RETAN_RECORD ON rt_ship_temp_1.card = RT_RETAN_RECORD.card
  5141. WHERE (rt_ship_temp_1.filename=N'" & DataGridView1.Rows(DataGridView1.CurrentCell.RowIndex).Cells("filename").Value & "')
  5142. GROUP BY rt_ship_temp_1.name, rt_ship_temp_1.color1, rt_ship_temp_1.thick, rt_ship_temp_1.card, rt_ship_temp_1.po_no,
  5143. rt_ship_temp_1.work_no, rt_ship_temp_1.deli_no,rt_ship_temp_1.order_item, rt_ship_temp_1.deli, RT_RETAN_RECORD.source"
  5144. sql = "SELECT rt_ship_temp_1.name AS 品名, rt_ship_temp_1.color1 AS 颜色, rt_ship_temp_1.thick AS 厚度,
  5145. rt_ship_temp_1.card AS 卡号, rt_finish_stock.name, rt_ship_temp_1.po_no AS 订单号, rt_ship_temp_1.work_no AS 指令号,
  5146. rt_ship_temp_1.order_item AS 项次号, CAST(SUM(rt_ship_temp_1.qty) AS numeric(10, 1)) AS 尺数,
  5147. rt_ship_temp_1.deli AS 发货人, rt_ship_temp_1.deli_no AS 发货单号
  5148. FROM rt_ship_temp_1 LEFT OUTER JOIN
  5149. rt_finish_stock ON rt_ship_temp_1.card = rt_finish_stock.lot
  5150. WHERE (rt_ship_temp_1.filename = N'" & DataGridView1.Rows(DataGridView1.CurrentCell.RowIndex).Cells("filename").Value & "')
  5151. GROUP BY rt_ship_temp_1.name, rt_ship_temp_1.color1, rt_ship_temp_1.thick, rt_ship_temp_1.card, rt_ship_temp_1.po_no,
  5152. rt_ship_temp_1.work_no, rt_ship_temp_1.deli_no, rt_ship_temp_1.order_item, rt_ship_temp_1.deli, rt_finish_stock.name"
  5153. If DataGridView1.Rows(DataGridView1.CurrentCell.RowIndex).Cells("filename").Value Like "*上杰*" Then
  5154. sql = "select name as 品名,color1 as 颜色,thick as 厚度,card as 卡号,po_no as 订单号,work_no as 指令号,order_item as 项次号, cast(sum(qty) as numeric(10,1)) as 尺数,comment as 备注,deli as 发货人,deli_no as 发货单号 from rt_ship_temp_1 where filename=N'" & DataGridView1.Rows(DataGridView1.CurrentCell.RowIndex).Cells("filename").Value & "' group by name,color1,thick,card,po_no,work_no,order_item,comment,deli,deli_no"
  5155. sql = "SELECT rt_ship_temp_1.name AS 品名, rt_ship_temp_1.color1 AS 颜色, rt_ship_temp_1.thick AS 厚度,
  5156. rt_ship_temp_1.card AS 卡号, RT_RETAN_RECORD.source AS 皮源, rt_ship_temp_1.po_no AS 订单号,
  5157. rt_ship_temp_1.work_no AS 指令号,order_item as 项次号,CAST(SUM(rt_ship_temp_1.qty) AS numeric(10, 1)) AS 尺数, rt_ship_temp_1.comment as 备注,
  5158. rt_ship_temp_1.deli AS 发货人, rt_ship_temp_1.deli_no AS 发货单号
  5159. FROM rt_ship_temp_1 LEFT OUTER JOIN
  5160. RT_RETAN_RECORD ON rt_ship_temp_1.card = RT_RETAN_RECORD.card
  5161. WHERE (rt_ship_temp_1.filename=N'" & DataGridView1.Rows(DataGridView1.CurrentCell.RowIndex).Cells("filename").Value & "')
  5162. GROUP BY rt_ship_temp_1.name, rt_ship_temp_1.color1, rt_ship_temp_1.thick, rt_ship_temp_1.card, rt_ship_temp_1.po_no,
  5163. rt_ship_temp_1.work_no, rt_ship_temp_1.deli_no,rt_ship_temp_1.comment,rt_ship_temp_1.order_item, rt_ship_temp_1.deli, RT_RETAN_RECORD.source"
  5164. sql = "SELECT rt_ship_temp_1.name AS 品名, rt_ship_temp_1.color1 AS 颜色, rt_ship_temp_1.thick AS 厚度,
  5165. rt_ship_temp_1.card AS 卡号, rt_finish_stock.name, rt_ship_temp_1.po_no AS 订单号, rt_ship_temp_1.work_no AS 指令号,
  5166. rt_ship_temp_1.order_item AS 项次号, CAST(SUM(rt_ship_temp_1.qty) AS numeric(10, 1)) AS 尺数,
  5167. rt_ship_temp_1.deli AS 发货人, rt_ship_temp_1.deli_no AS 发货单号
  5168. FROM rt_ship_temp_1 LEFT OUTER JOIN
  5169. rt_finish_stock ON rt_ship_temp_1.card = rt_finish_stock.lot
  5170. WHERE (rt_ship_temp_1.filename = N'" & DataGridView1.Rows(DataGridView1.CurrentCell.RowIndex).Cells("filename").Value & "')
  5171. GROUP BY rt_ship_temp_1.name, rt_ship_temp_1.color1, rt_ship_temp_1.thick, rt_ship_temp_1.card, rt_ship_temp_1.po_no,
  5172. rt_ship_temp_1.work_no, rt_ship_temp_1.deli_no, rt_ship_temp_1.order_item, rt_ship_temp_1.deli, rt_finish_stock.name"
  5173. End If
  5174. ElseIf DataGridView1.Rows(DataGridView1.CurrentCell.RowIndex).Cells("filename").Value Like "*076样*" Or DataGridView1.Rows(DataGridView1.CurrentCell.RowIndex).Cells("filename").Value Like "*好兄弟*" Then '-----加comment
  5175. sql = "select name as 品名,color1 as 颜色,thick as 厚度,card as 卡号,po_no as 订单号,work_no as 指令号,comment as 备注, cast(sum(qty) as numeric(10,1)) as 尺数,deli as 发货人,deli_no as 发货单号 from rt_ship_temp_1 where filename=N'" & DataGridView1.Rows(DataGridView1.CurrentCell.RowIndex).Cells("filename").Value & "' group by name,color1,thick,card,po_no,work_no,comment,deli_no,deli"
  5176. sql = "SELECT rt_ship_temp_1.name AS 品名, rt_ship_temp_1.color1 AS 颜色, rt_ship_temp_1.thick AS 厚度,
  5177. rt_ship_temp_1.card AS 卡号, RT_RETAN_RECORD.source AS 皮源, rt_ship_temp_1.po_no AS 订单号,
  5178. rt_ship_temp_1.work_no AS 指令号,comment as 备注, CAST(SUM(rt_ship_temp_1.qty) AS numeric(10, 1)) AS 尺数,
  5179. rt_ship_temp_1.deli AS 发货人, rt_ship_temp_1.deli_no AS 发货单号
  5180. FROM rt_ship_temp_1 LEFT OUTER JOIN
  5181. RT_RETAN_RECORD ON rt_ship_temp_1.card = RT_RETAN_RECORD.card
  5182. WHERE (rt_ship_temp_1.filename=N'" & DataGridView1.Rows(DataGridView1.CurrentCell.RowIndex).Cells("filename").Value & "')
  5183. GROUP BY rt_ship_temp_1.name, rt_ship_temp_1.color1, rt_ship_temp_1.thick, rt_ship_temp_1.card, rt_ship_temp_1.po_no,
  5184. rt_ship_temp_1.work_no, rt_ship_temp_1.deli_no,rt_ship_temp_1.comment, rt_ship_temp_1.deli, RT_RETAN_RECORD.source"
  5185. sql = "SELECT rt_ship_temp_1.name AS 品名, rt_ship_temp_1.color1 AS 颜色, rt_ship_temp_1.thick AS 厚度,
  5186. rt_ship_temp_1.card AS 卡号, rt_finish_stock.name, rt_ship_temp_1.po_no AS 订单号, rt_ship_temp_1.work_no AS 指令号,comment as 备注,
  5187. CAST(SUM(rt_ship_temp_1.qty) AS numeric(10, 1)) AS 尺数,
  5188. rt_ship_temp_1.deli AS 发货人, rt_ship_temp_1.deli_no AS 发货单号
  5189. FROM rt_ship_temp_1 LEFT OUTER JOIN
  5190. rt_finish_stock ON rt_ship_temp_1.card = rt_finish_stock.lot
  5191. WHERE (rt_ship_temp_1.filename = N'" & DataGridView1.Rows(DataGridView1.CurrentCell.RowIndex).Cells("filename").Value & "')
  5192. GROUP BY rt_ship_temp_1.name, rt_ship_temp_1.color1, rt_ship_temp_1.thick, rt_ship_temp_1.card, rt_ship_temp_1.po_no,
  5193. rt_ship_temp_1.work_no, rt_ship_temp_1.deli_no, rt_ship_temp_1.comment, rt_ship_temp_1.deli, rt_finish_stock.name"
  5194. Else '---其他
  5195. sql = "select name as 品名,color1 as 颜色,thick as 厚度,card as 卡号,po_no as 订单号,work_no as 指令号, cast(sum(qty) as numeric(10,1)) as 尺数,deli as 发货人,deli_no as 发货单号 from rt_ship_temp_1 where filename=N'" & DataGridView1.Rows(DataGridView1.CurrentCell.RowIndex).Cells("filename").Value & "' group by name,color1,thick,card,po_no,work_no,deli_no,deli"
  5196. sql = "SELECT rt_ship_temp_1.name AS 品名, rt_ship_temp_1.color1 AS 颜色, rt_ship_temp_1.thick AS 厚度,
  5197. rt_ship_temp_1.card AS 卡号, RT_RETAN_RECORD.source AS 皮源, rt_ship_temp_1.po_no AS 订单号,
  5198. rt_ship_temp_1.work_no AS 指令号, CAST(SUM(rt_ship_temp_1.qty) AS numeric(10, 1)) AS 尺数,
  5199. rt_ship_temp_1.deli AS 发货人, rt_ship_temp_1.deli_no AS 发货单号
  5200. FROM rt_ship_temp_1 LEFT OUTER JOIN
  5201. RT_RETAN_RECORD ON rt_ship_temp_1.card = RT_RETAN_RECORD.card
  5202. WHERE (rt_ship_temp_1.filename=N'" & DataGridView1.Rows(DataGridView1.CurrentCell.RowIndex).Cells("filename").Value & "')
  5203. GROUP BY rt_ship_temp_1.name, rt_ship_temp_1.color1, rt_ship_temp_1.thick, rt_ship_temp_1.card, rt_ship_temp_1.po_no,
  5204. rt_ship_temp_1.work_no, rt_ship_temp_1.deli_no, rt_ship_temp_1.deli, RT_RETAN_RECORD.source"
  5205. sql = "SELECT rt_ship_temp_1.name AS 品名, rt_ship_temp_1.color1 AS 颜色, rt_ship_temp_1.thick AS 厚度,
  5206. rt_ship_temp_1.card AS 卡号, rt_finish_stock.name, rt_ship_temp_1.po_no AS 订单号, rt_ship_temp_1.work_no AS 指令号,
  5207. CAST(SUM(rt_ship_temp_1.qty) AS numeric(10, 1)) AS 尺数,
  5208. rt_ship_temp_1.deli AS 发货人, rt_ship_temp_1.deli_no AS 发货单号
  5209. FROM rt_ship_temp_1 LEFT OUTER JOIN
  5210. rt_finish_stock ON rt_ship_temp_1.card = rt_finish_stock.lot
  5211. WHERE (rt_ship_temp_1.filename = N'" & DataGridView1.Rows(DataGridView1.CurrentCell.RowIndex).Cells("filename").Value & "')
  5212. GROUP BY rt_ship_temp_1.name, rt_ship_temp_1.color1, rt_ship_temp_1.thick, rt_ship_temp_1.card, rt_ship_temp_1.po_no,
  5213. rt_ship_temp_1.work_no, rt_ship_temp_1.deli_no, rt_ship_temp_1.deli, rt_finish_stock.name"
  5214. End If
  5215. cmd.CommandText = sql
  5216. da.SelectCommand = cmd
  5217. dt1 = New DataTable
  5218. da.Fill(dt1)
  5219. DataGridView2.DataSource = Nothing
  5220. DataGridView2.DataSource = dt1
  5221. DataGridView2.Columns(0).Width = 550
  5222. DataGridView2.Columns(1).Width = 100
  5223. DataGridView2.Columns(2).Width = 70
  5224. DataGridView2.Columns(3).Width = 150
  5225. DataGridView2.Columns(5).Width = 150
  5226. ' If DataGridView1.Rows(DataGridView1.CurrentCell.RowIndex).Cells("filename").Value Like "*上杰*" Or DataGridView1.Rows(DataGridView1.CurrentCell.RowIndex).Cells("filename").Value Like "*宏美发*" Or DataGridView1.Rows(DataGridView1.CurrentCell.RowIndex).Cells("filename").Value Like "*永正*" Or DataGridView1.Rows(DataGridView1.CurrentCell.RowIndex).Cells("filename").Value Like "*宏福*" Then '---加order_item
  5227. ' sql = "select name as 品名,color1 as 颜色,thick as 厚度,card as 卡号,po_no as 订单号,work_no as 指令号,order_item as 项次号, cast(sum(qty) as numeric(10,1)) as 尺数,deli as 发货人,deli_no as 发货单号 from rt_ship_temp_1 where filename=N'" & DataGridView1.Rows(DataGridView1.CurrentCell.RowIndex).Cells("filename").Value & "' group by name,color1,thick,card,po_no,work_no,order_item,deli,deli_no"
  5228. ' sql = "SELECT rt_ship_temp_1.name AS 品名, rt_ship_temp_1.color1 AS 颜色, rt_ship_temp_1.thick AS 厚度,
  5229. ' rt_ship_temp_1.card AS 卡号, RT_RETAN_RECORD.source AS 皮源, rt_ship_temp_1.po_no AS 订单号,
  5230. ' rt_ship_temp_1.work_no AS 指令号,order_item as 项次号,CAST(SUM(rt_ship_temp_1.qty) AS numeric(10, 1)) AS 尺数,
  5231. ' rt_ship_temp_1.deli AS 发货人, rt_ship_temp_1.deli_no AS 发货单号
  5232. 'FROM rt_ship_temp_1 LEFT OUTER JOIN
  5233. ' RT_RETAN_RECORD ON rt_ship_temp_1.card = RT_RETAN_RECORD.card
  5234. 'WHERE (rt_ship_temp_1.filename=N'" & DataGridView1.Rows(DataGridView1.CurrentCell.RowIndex).Cells("filename").Value & "')
  5235. 'GROUP BY rt_ship_temp_1.name, rt_ship_temp_1.color1, rt_ship_temp_1.thick, rt_ship_temp_1.card, rt_ship_temp_1.po_no,
  5236. ' rt_ship_temp_1.work_no, rt_ship_temp_1.deli_no,rt_ship_temp_1.order_item, rt_ship_temp_1.deli, RT_RETAN_RECORD.source"
  5237. ' sql = "SELECT rt_ship_temp_1.name AS 品名, rt_ship_temp_1.color1 AS 颜色, rt_ship_temp_1.thick AS 厚度,
  5238. ' rt_ship_temp_1.card AS 卡号, rt_finish_stock.name, rt_ship_temp_1.po_no AS 订单号, rt_ship_temp_1.work_no AS 指令号,
  5239. ' rt_ship_temp_1.order_item AS 项次号, CAST(SUM(rt_ship_temp_1.qty) AS numeric(10, 1)) AS 尺数,
  5240. ' rt_ship_temp_1.deli AS 发货人, rt_ship_temp_1.deli_no AS 发货单号
  5241. 'FROM rt_ship_temp_1 LEFT OUTER JOIN
  5242. ' rt_finish_stock ON rt_ship_temp_1.card = rt_finish_stock.lot
  5243. 'WHERE (rt_ship_temp_1.filename = N'" & DataGridView1.Rows(DataGridView1.CurrentCell.RowIndex).Cells("filename").Value & "')
  5244. 'GROUP BY rt_ship_temp_1.name, rt_ship_temp_1.color1, rt_ship_temp_1.thick, rt_ship_temp_1.card, rt_ship_temp_1.po_no,
  5245. ' rt_ship_temp_1.work_no, rt_ship_temp_1.deli_no, rt_ship_temp_1.order_item, rt_ship_temp_1.deli, rt_finish_stock.name"
  5246. ' If DataGridView1.Rows(DataGridView1.CurrentCell.RowIndex).Cells("filename").Value Like "*上杰*" Then
  5247. ' sql = "select name as 品名,color1 as 颜色,thick as 厚度,card as 卡号,po_no as 订单号,work_no as 指令号,order_item as 项次号, cast(sum(qty) as numeric(10,1)) as 尺数,comment as 备注,deli as 发货人,deli_no as 发货单号 from rt_ship_temp_1 where filename=N'" & DataGridView1.Rows(DataGridView1.CurrentCell.RowIndex).Cells("filename").Value & "' group by name,color1,thick,card,po_no,work_no,order_item,comment,deli,deli_no"
  5248. ' sql = "SELECT rt_ship_temp_1.name AS 品名, rt_ship_temp_1.color1 AS 颜色, rt_ship_temp_1.thick AS 厚度,
  5249. ' rt_ship_temp_1.card AS 卡号, RT_RETAN_RECORD.source AS 皮源, rt_ship_temp_1.po_no AS 订单号,
  5250. ' rt_ship_temp_1.work_no AS 指令号,order_item as 项次号,CAST(SUM(rt_ship_temp_1.qty) AS numeric(10, 1)) AS 尺数, rt_ship_temp_1.comment as 备注,
  5251. ' rt_ship_temp_1.deli AS 发货人, rt_ship_temp_1.deli_no AS 发货单号
  5252. 'FROM rt_ship_temp_1 LEFT OUTER JOIN
  5253. ' RT_RETAN_RECORD ON rt_ship_temp_1.card = RT_RETAN_RECORD.card
  5254. 'WHERE (rt_ship_temp_1.filename=N'" & DataGridView1.Rows(DataGridView1.CurrentCell.RowIndex).Cells("filename").Value & "')
  5255. 'GROUP BY rt_ship_temp_1.name, rt_ship_temp_1.color1, rt_ship_temp_1.thick, rt_ship_temp_1.card, rt_ship_temp_1.po_no,
  5256. ' rt_ship_temp_1.work_no, rt_ship_temp_1.deli_no,rt_ship_temp_1.comment,rt_ship_temp_1.order_item, rt_ship_temp_1.deli, RT_RETAN_RECORD.source"
  5257. ' sql = "SELECT rt_ship_temp_1.name AS 品名, rt_ship_temp_1.color1 AS 颜色, rt_ship_temp_1.thick AS 厚度,
  5258. ' rt_ship_temp_1.card AS 卡号, rt_finish_stock.name, rt_ship_temp_1.po_no AS 订单号, rt_ship_temp_1.work_no AS 指令号,
  5259. ' rt_ship_temp_1.order_item AS 项次号, CAST(SUM(rt_ship_temp_1.qty) AS numeric(10, 1)) AS 尺数,
  5260. ' rt_ship_temp_1.deli AS 发货人, rt_ship_temp_1.deli_no AS 发货单号
  5261. 'FROM rt_ship_temp_1 LEFT OUTER JOIN
  5262. ' rt_finish_stock ON rt_ship_temp_1.card = rt_finish_stock.lot
  5263. 'WHERE (rt_ship_temp_1.filename = N'" & DataGridView1.Rows(DataGridView1.CurrentCell.RowIndex).Cells("filename").Value & "')
  5264. 'GROUP BY rt_ship_temp_1.name, rt_ship_temp_1.color1, rt_ship_temp_1.thick, rt_ship_temp_1.card, rt_ship_temp_1.po_no,
  5265. ' rt_ship_temp_1.work_no, rt_ship_temp_1.deli_no, rt_ship_temp_1.order_item, rt_ship_temp_1.deli, rt_finish_stock.name"
  5266. ' End If
  5267. ' ElseIf DataGridView1.Rows(DataGridView1.CurrentCell.RowIndex).Cells("filename").Value Like "*076样*" Or DataGridView1.Rows(DataGridView1.CurrentCell.RowIndex).Cells("filename").Value Like "*好兄弟*" Then '-----加comment
  5268. ' sql = "select name as 品名,color1 as 颜色,thick as 厚度,card as 卡号,po_no as 订单号,work_no as 指令号,comment as 备注, cast(sum(qty) as numeric(10,1)) as 尺数,deli as 发货人,deli_no as 发货单号 from rt_ship_temp_1 where filename=N'" & DataGridView1.Rows(DataGridView1.CurrentCell.RowIndex).Cells("filename").Value & "' group by name,color1,thick,card,po_no,work_no,comment,deli_no,deli"
  5269. ' sql = "SELECT rt_ship_temp_1.name AS 品名, rt_ship_temp_1.color1 AS 颜色, rt_ship_temp_1.thick AS 厚度,
  5270. ' rt_ship_temp_1.card AS 卡号, RT_RETAN_RECORD.source AS 皮源, rt_ship_temp_1.po_no AS 订单号,
  5271. ' rt_ship_temp_1.work_no AS 指令号,comment as 备注, CAST(SUM(rt_ship_temp_1.qty) AS numeric(10, 1)) AS 尺数,
  5272. ' rt_ship_temp_1.deli AS 发货人, rt_ship_temp_1.deli_no AS 发货单号
  5273. 'FROM rt_ship_temp_1 LEFT OUTER JOIN
  5274. ' RT_RETAN_RECORD ON rt_ship_temp_1.card = RT_RETAN_RECORD.card
  5275. 'WHERE (rt_ship_temp_1.filename=N'" & DataGridView1.Rows(DataGridView1.CurrentCell.RowIndex).Cells("filename").Value & "')
  5276. 'GROUP BY rt_ship_temp_1.name, rt_ship_temp_1.color1, rt_ship_temp_1.thick, rt_ship_temp_1.card, rt_ship_temp_1.po_no,
  5277. ' rt_ship_temp_1.work_no, rt_ship_temp_1.deli_no,rt_ship_temp_1.comment, rt_ship_temp_1.deli, RT_RETAN_RECORD.source"
  5278. ' sql = "SELECT rt_ship_temp_1.name AS 品名, rt_ship_temp_1.color1 AS 颜色, rt_ship_temp_1.thick AS 厚度,
  5279. ' rt_ship_temp_1.card AS 卡号, rt_finish_stock.name, rt_ship_temp_1.po_no AS 订单号, rt_ship_temp_1.work_no AS 指令号,comment as 备注,
  5280. ' CAST(SUM(rt_ship_temp_1.qty) AS numeric(10, 1)) AS 尺数,
  5281. ' rt_ship_temp_1.deli AS 发货人, rt_ship_temp_1.deli_no AS 发货单号
  5282. 'FROM rt_ship_temp_1 LEFT OUTER JOIN
  5283. ' rt_finish_stock ON rt_ship_temp_1.card = rt_finish_stock.lot
  5284. 'WHERE (rt_ship_temp_1.filename = N'" & DataGridView1.Rows(DataGridView1.CurrentCell.RowIndex).Cells("filename").Value & "')
  5285. 'GROUP BY rt_ship_temp_1.name, rt_ship_temp_1.color1, rt_ship_temp_1.thick, rt_ship_temp_1.card, rt_ship_temp_1.po_no,
  5286. ' rt_ship_temp_1.work_no, rt_ship_temp_1.deli_no, rt_ship_temp_1.comment, rt_ship_temp_1.deli, rt_finish_stock.name"
  5287. ' Else '---其他
  5288. ' sql = "select name as 品名,color1 as 颜色,thick as 厚度,card as 卡号,po_no as 订单号,work_no as 指令号, cast(sum(qty) as numeric(10,1)) as 尺数,deli as 发货人,deli_no as 发货单号 from rt_ship_temp_1 where filename=N'" & DataGridView1.Rows(DataGridView1.CurrentCell.RowIndex).Cells("filename").Value & "' group by name,color1,thick,card,po_no,work_no,deli_no,deli"
  5289. ' sql = "SELECT rt_ship_temp_1.name AS 品名, rt_ship_temp_1.color1 AS 颜色, rt_ship_temp_1.thick AS 厚度,
  5290. ' rt_ship_temp_1.card AS 卡号, RT_RETAN_RECORD.source AS 皮源, rt_ship_temp_1.po_no AS 订单号,
  5291. ' rt_ship_temp_1.work_no AS 指令号, CAST(SUM(rt_ship_temp_1.qty) AS numeric(10, 1)) AS 尺数,
  5292. ' rt_ship_temp_1.deli AS 发货人, rt_ship_temp_1.deli_no AS 发货单号
  5293. 'FROM rt_ship_temp_1 LEFT OUTER JOIN
  5294. ' RT_RETAN_RECORD ON rt_ship_temp_1.card = RT_RETAN_RECORD.card
  5295. 'WHERE (rt_ship_temp_1.filename=N'" & DataGridView1.Rows(DataGridView1.CurrentCell.RowIndex).Cells("filename").Value & "')
  5296. 'GROUP BY rt_ship_temp_1.name, rt_ship_temp_1.color1, rt_ship_temp_1.thick, rt_ship_temp_1.card, rt_ship_temp_1.po_no,
  5297. ' rt_ship_temp_1.work_no, rt_ship_temp_1.deli_no, rt_ship_temp_1.deli, RT_RETAN_RECORD.source"
  5298. ' sql = "SELECT rt_ship_temp_1.name AS 品名, rt_ship_temp_1.color1 AS 颜色, rt_ship_temp_1.thick AS 厚度,
  5299. ' rt_ship_temp_1.card AS 卡号, rt_finish_stock.name, rt_ship_temp_1.po_no AS 订单号, rt_ship_temp_1.work_no AS 指令号,
  5300. ' CAST(SUM(rt_ship_temp_1.qty) AS numeric(10, 1)) AS 尺数,
  5301. ' rt_ship_temp_1.deli AS 发货人, rt_ship_temp_1.deli_no AS 发货单号
  5302. 'FROM rt_ship_temp_1 LEFT OUTER JOIN
  5303. ' rt_finish_stock ON rt_ship_temp_1.card = rt_finish_stock.lot
  5304. 'WHERE (rt_ship_temp_1.filename = N'" & DataGridView1.Rows(DataGridView1.CurrentCell.RowIndex).Cells("filename").Value & "')
  5305. 'GROUP BY rt_ship_temp_1.name, rt_ship_temp_1.color1, rt_ship_temp_1.thick, rt_ship_temp_1.card, rt_ship_temp_1.po_no,
  5306. ' rt_ship_temp_1.work_no, rt_ship_temp_1.deli_no, rt_ship_temp_1.deli, rt_finish_stock.name"
  5307. ' End If
  5308. ' cmd.CommandText = sql
  5309. ' da.SelectCommand = cmd
  5310. ' dt1 = New DataTable
  5311. ' da.Fill(dt1)
  5312. ' DataGridView2.DataSource = Nothing
  5313. ' DataGridView2.DataSource = dt1
  5314. ' DataGridView2.Columns(0).Width = 400
  5315. ' DataGridView2.Columns(1).Width = 200
  5316. ' DataGridView2.Columns(3).Width = 200
  5317. End Sub
  5318. Private Sub update()
  5319. sql = "update rt_ship_temp_1 set name=color1 where name is null"
  5320. cmd.CommandText = sql
  5321. cmd.ExecuteScalar()
  5322. sql = "update rt_ship_temp_1 set work_no='' where work_no is null"
  5323. cmd.CommandText = sql
  5324. cmd.ExecuteScalar()
  5325. sql = "select filename,cast(sum(qty) as numeric(10,1)) as 尺数 from rt_ship_temp_1 group by filename,update_date order by update_date desc"
  5326. cmd.CommandText = sql
  5327. da.SelectCommand = cmd
  5328. dt1 = New DataTable
  5329. da.Fill(dt1)
  5330. DataGridView1.DataSource = Nothing
  5331. DataGridView1.DataSource = dt1
  5332. DataGridView1.Columns(0).Width = 350
  5333. DataGridView1.RowHeadersWidth = 25
  5334. DataGridView1.Rows(0).Selected = False
  5335. End Sub
  5336. Private Sub Button10_Click(sender As Object, e As EventArgs) Handles Button10.Click
  5337. xlApp = CreateObject("Excel.Application")
  5338. xlBook = xlApp.Workbooks.Add
  5339. xlApp.Visible = True
  5340. 'xlApp.DisplayAlerts = False
  5341. xlBook.Activate()
  5342. xlBook.Parent.Windows(1).Visible = True
  5343. xlSheet = xlBook.Worksheets(1)
  5344. xlSheet.Name = "反毛皮"
  5345. xlApp.DisplayAlerts = False
  5346. sql = "select date as 日期,custname as 客户,deli_no as 发货单号,replace(color1,char(10),'') as 颜色,cast(sum(qty) as numeric(10,1)) as 尺数,deli as 发货人 from rt_ship_temp_1
  5347. where DATE BETWEEN '" & String.Format("{0:d}", DateTimePicker1.Value) & "' AND '" & String.Format("{0:d}", DateTimePicker2.Value) & "' and pattern is null group by date,custname,deli_no,color1,deli"
  5348. cmd.CommandText = sql
  5349. da.SelectCommand = cmd
  5350. dt1 = New DataTable
  5351. da.Fill(dt1)
  5352. dgv_1.DataSource = dt1
  5353. dgv_1.SelectAll()
  5354. Me.dgv_1.ClipboardCopyMode = DataGridViewClipboardCopyMode.EnableAlwaysIncludeHeaderText
  5355. Me.dgv_1.RowHeadersVisible = False
  5356. Clipboard.SetDataObject(dgv_1.GetClipboardContent())
  5357. xlSheet.Cells(4, 2).PasteSpecial()
  5358. Clipboard.SetDataObject(DBNull.Value)
  5359. xlApp.ActiveSheet.ListObjects.Add(Microsoft.Office.Interop.Excel.XlListObjectSourceType.xlSrcRange, xlApp.Range("B4:g" & dt1.Rows.Count + 3 + 1), , Microsoft.Office.Interop.Excel.XlYesNoGuess.xlYes).Name = "表1"
  5360. sql = "select deli as 发货人,cast(sum(qty) as numeric(10,1)) as 尺数 from rt_ship_temp_1 where DATE BETWEEN '" & String.Format("{0:d}", DateTimePicker1.Value) & "' AND '" & String.Format("{0:d}", DateTimePicker2.Value) & "' and pattern is null group by deli "
  5361. cmd.CommandText = sql
  5362. da.SelectCommand = cmd
  5363. dt1 = New DataTable
  5364. da.Fill(dt1)
  5365. dgv_2.DataSource = dt1
  5366. dgv_2.SelectAll()
  5367. Me.dgv_2.ClipboardCopyMode = DataGridViewClipboardCopyMode.EnableAlwaysIncludeHeaderText
  5368. Me.dgv_2.RowHeadersVisible = False
  5369. Clipboard.SetDataObject(dgv_2.GetClipboardContent())
  5370. xlApp.Cells(4, 10).Select()
  5371. xlSheet.PasteSpecial()
  5372. Clipboard.SetDataObject(DBNull.Value)
  5373. xlApp.ActiveSheet.ListObjects.Add(Microsoft.Office.Interop.Excel.XlListObjectSourceType.xlSrcRange, xlApp.Range("J4:K" & dt1.Rows.Count + 3 + 1), , Microsoft.Office.Interop.Excel.XlYesNoGuess.xlYes).Name = "表2"
  5374. xlSheet.Columns("b:b").ColumnWidth = 22
  5375. xlSheet.Columns("c:c").ColumnWidth = 25
  5376. xlSheet.Columns("d:d").ColumnWidth = 25
  5377. xlSheet.Columns("e:e").ColumnWidth = 40
  5378. ' xlApp.Columns("f:k").NumberFormatLocal = "#,###.0_ ;[红色]-0.0 "
  5379. xlApp.Columns("b:k").EntireColumn.AutoFit
  5380. xlApp.Columns("b:b").Select()
  5381. xlApp.Selection.HorizontalAlignment = Excel.Constants.xlCenter
  5382. xlApp.Selection.VerticalAlignment = Excel.Constants.xlCenter
  5383. xlApp.Columns("d:d").Select()
  5384. xlApp.Selection.HorizontalAlignment = Excel.Constants.xlCenter
  5385. xlApp.Selection.VerticalAlignment = Excel.Constants.xlCenter
  5386. xlApp.Columns("g:g").Select()
  5387. xlApp.Selection.HorizontalAlignment = Excel.Constants.xlCenter
  5388. xlApp.Selection.VerticalAlignment = Excel.Constants.xlCenter
  5389. PTCache = xlBook.PivotCaches.Add _
  5390. (SourceType:=Microsoft.Office.Interop.Excel.XlPivotTableSourceType.xlDatabase,
  5391. SourceData:=xlSheet.Range("b4:g123").CurrentRegion.Address)
  5392. PT = PTCache.CreatePivotTable _
  5393. (TableDestination:=xlSheet.Cells(4, 13),
  5394. TableName:="PivotTable1")
  5395. With PT
  5396. .PivotFields("日期").Orientation = Microsoft.Office.Interop.Excel.XlPivotFieldOrientation.xlColumnField
  5397. .PivotFields("客户").Orientation = Microsoft.Office.Interop.Excel.XlPivotFieldOrientation.xlRowField
  5398. .PivotFields("尺数").Orientation = Microsoft.Office.Interop.Excel.XlPivotFieldOrientation.xlDataField
  5399. End With
  5400. xlSheet.PivotTables("PivotTable1").TableStyle2 = "PivotStyleMedium9"
  5401. '----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  5402. xlSheet = xlBook.Worksheets.Add()
  5403. xlSheet.Name = "全部"
  5404. xlApp.DisplayAlerts = False
  5405. sql = "select date as 日期,custname as 客户, po_no as 订单号, order_item as 项次号, replace(name,char(10),'') as 品名,thick as 厚度, cast(sum(qty) as numeric(10,1)) as 尺数,deli as 发货人,deli_no as 发货单号,card as 卡号,source1 as 皮源 from rt_ship_temp_1
  5406. where DATE BETWEEN '" & String.Format("{0:d}", DateTimePicker1.Value) & "' AND '" & String.Format("{0:d}", DateTimePicker2.Value) & "' group by date,custname,po_no,order_item,thick,deli_no,name,deli,card,source1"
  5407. cmd.CommandText = sql
  5408. da.SelectCommand = cmd
  5409. Dim dt2 As New DataTable
  5410. da.Fill(dt2)
  5411. sql = "select date as 日期,cust as 客户,N'退货' as 订单号,color + ' [' + comment + ' ]' as 品名,cast(qty as numeric(10,1)) as 尺数 from rt_k3_sale_reject where date BETWEEN '" & String.Format("{0:d}", DateTimePicker1.Value) & "' AND '" & String.Format("{0:d}", DateTimePicker2.Value) & "'"
  5412. cmd.CommandText = sql
  5413. da.SelectCommand = cmd
  5414. da.Fill(dt2)
  5415. DataGridView2.DataSource = dt2
  5416. DataGridView2.SelectAll()
  5417. Me.DataGridView2.ClipboardCopyMode = DataGridViewClipboardCopyMode.EnableAlwaysIncludeHeaderText
  5418. Me.DataGridView2.RowHeadersVisible = False
  5419. Clipboard.SetDataObject(DataGridView2.GetClipboardContent())
  5420. xlSheet.Cells(4, 2).PasteSpecial()
  5421. Clipboard.SetDataObject(DBNull.Value)
  5422. xlApp.ActiveSheet.ListObjects.Add(Microsoft.Office.Interop.Excel.XlListObjectSourceType.xlSrcRange, xlApp.Range("B4:L" & dt2.Rows.Count + 5), , Microsoft.Office.Interop.Excel.XlYesNoGuess.xlYes).Name = "表1"
  5423. sql = "select deli as 发货人,cast(sum(qty) as numeric(10,1)) as 尺数 from rt_ship_temp_1 where DATE BETWEEN '" & String.Format("{0:d}", DateTimePicker1.Value) & "' AND '" & String.Format("{0:d}", DateTimePicker2.Value) & "' group by deli "
  5424. cmd.CommandText = sql
  5425. da.SelectCommand = cmd
  5426. dt1 = New DataTable
  5427. da.Fill(dt1)
  5428. dgv_2.DataSource = dt1
  5429. dgv_2.SelectAll()
  5430. Me.dgv_2.ClipboardCopyMode = DataGridViewClipboardCopyMode.EnableAlwaysIncludeHeaderText
  5431. Me.dgv_2.RowHeadersVisible = False
  5432. Clipboard.SetDataObject(dgv_2.GetClipboardContent())
  5433. xlApp.Cells(4, 14).Select()
  5434. xlSheet.PasteSpecial()
  5435. Clipboard.SetDataObject(DBNull.Value)
  5436. xlApp.ActiveSheet.ListObjects.Add(Microsoft.Office.Interop.Excel.XlListObjectSourceType.xlSrcRange, xlApp.Range("N4:o" & dt1.Rows.Count + 3 + 1), , Microsoft.Office.Interop.Excel.XlYesNoGuess.xlYes).Name = "表2"
  5437. xlSheet.Columns("b:b").ColumnWidth = 22
  5438. xlSheet.Columns("c:c").ColumnWidth = 25
  5439. xlSheet.Columns("d:d").ColumnWidth = 25
  5440. xlSheet.Columns("e:e").ColumnWidth = 40
  5441. xlApp.Columns("f:f").ColumnWidth = 100
  5442. 'xlApp.Columns("H").Select
  5443. 'With xlApp.Selection.Font
  5444. ' .Color = -16776961
  5445. ' .TintAndShade = 0
  5446. 'End With
  5447. xlSheet.Columns("H:H").NumberFormatLocal = "#,###.0_ ;[紅色]-0.0"
  5448. xlApp.Selection.NumberFormatLocal = "@"
  5449. ' xlApp.Selection.NumberFormatLocal = "#,###.0_ ;[红色]-0.0 "
  5450. xlApp.Columns("b:L").EntireColumn.AutoFit
  5451. xlApp.Columns("b:b").Select()
  5452. xlApp.Selection.HorizontalAlignment = Excel.Constants.xlCenter
  5453. xlApp.Selection.VerticalAlignment = Excel.Constants.xlCenter
  5454. xlApp.Columns("d:d").Select()
  5455. xlApp.Selection.HorizontalAlignment = Excel.Constants.xlCenter
  5456. xlApp.Selection.VerticalAlignment = Excel.Constants.xlCenter
  5457. xlApp.Columns("e:e").Select()
  5458. xlApp.Selection.HorizontalAlignment = Excel.Constants.xlCenter
  5459. xlApp.Selection.VerticalAlignment = Excel.Constants.xlCenter
  5460. xlApp.Columns("g:g").Select()
  5461. xlApp.Selection.HorizontalAlignment = Excel.Constants.xlCenter
  5462. xlApp.Selection.VerticalAlignment = Excel.Constants.xlCenter
  5463. xlApp.Columns("i:i").Select()
  5464. xlApp.Selection.HorizontalAlignment = Excel.Constants.xlCenter
  5465. xlApp.Selection.VerticalAlignment = Excel.Constants.xlCenter
  5466. xlApp.Columns("j:j").Select()
  5467. xlApp.Selection.HorizontalAlignment = Excel.Constants.xlRight
  5468. xlApp.Selection.VerticalAlignment = Excel.Constants.xlCenter
  5469. PTCache = xlBook.PivotCaches.Add _
  5470. (SourceType:=Microsoft.Office.Interop.Excel.XlPivotTableSourceType.xlDatabase,
  5471. SourceData:=xlSheet.Range("b4:L1000").CurrentRegion.Address)
  5472. PT = PTCache.CreatePivotTable _
  5473. (TableDestination:=xlSheet.Cells(4, 17),
  5474. TableName:="PivotTable1")
  5475. With PT
  5476. .PivotFields("日期").Orientation = Microsoft.Office.Interop.Excel.XlPivotFieldOrientation.xlColumnField
  5477. .PivotFields("客户").Orientation = Microsoft.Office.Interop.Excel.XlPivotFieldOrientation.xlRowField
  5478. .PivotFields("尺数").Orientation = Microsoft.Office.Interop.Excel.XlPivotFieldOrientation.xlDataField
  5479. End With
  5480. xlSheet.PivotTables("PivotTable1").TableStyle2 = "PivotStyleMedium9"
  5481. '-----------------------------------------------------------------------------贴膜
  5482. xlSheet = xlBook.Worksheets.Add()
  5483. xlSheet.Name = "贴膜"
  5484. sql = "select date as 日期,custname as 客户,deli_no as 发货单号,replace(color1,char(10),'') as 颜色,pattern as 纹路, size as 分类,cast(sum(qty) as numeric(10,1)) as 尺数,deli as 发货人 from rt_ship_temp_1 where DATE BETWEEN '" & String.Format("{0:d}", DateTimePicker1.Value) & "' AND '" & String.Format("{0:d}", DateTimePicker2.Value) & "' and pattern is not null
  5485. group by date,custname,deli_no,color1,pattern,size,deli order by date,custname,deli_no,color1,pattern,sum(sf),deli"
  5486. cmd.CommandText = sql
  5487. da.SelectCommand = cmd
  5488. dt1 = New DataTable
  5489. da.Fill(dt1)
  5490. DGV_3.DataSource = dt1
  5491. DGV_3.SelectAll()
  5492. Me.DGV_3.ClipboardCopyMode = DataGridViewClipboardCopyMode.EnableAlwaysIncludeHeaderText
  5493. Me.DGV_3.RowHeadersVisible = False
  5494. Clipboard.SetDataObject(DGV_3.GetClipboardContent())
  5495. xlSheet.Cells(4, 2).Select()
  5496. xlApp.Selection.PasteSpecial()
  5497. Clipboard.SetDataObject(DBNull.Value)
  5498. xlApp.ActiveSheet.ListObjects.Add(Microsoft.Office.Interop.Excel.XlListObjectSourceType.xlSrcRange, xlApp.Range("B4:i" & dt1.Rows.Count + 3 + 1), , Microsoft.Office.Interop.Excel.XlYesNoGuess.xlYes).Name = "表1"
  5499. sql = "select deli as 发货人,cast(sum(qty) as numeric(10,1)) as 尺数 from rt_ship_temp_1 where DATE BETWEEN '" & String.Format("{0:d}", DateTimePicker1.Value) & "' AND '" & String.Format("{0:d}", DateTimePicker2.Value) & "' and pattern is not null group by deli "
  5500. cmd.CommandText = sql
  5501. da.SelectCommand = cmd
  5502. dt1 = New DataTable
  5503. da.Fill(dt1)
  5504. dgv_4.DataSource = dt1
  5505. dgv_4.SelectAll()
  5506. Me.dgv_4.ClipboardCopyMode = DataGridViewClipboardCopyMode.EnableAlwaysIncludeHeaderText
  5507. Me.dgv_4.RowHeadersVisible = False
  5508. Clipboard.SetDataObject(dgv_4.GetClipboardContent())
  5509. xlSheet.Cells(4, 13).Select()
  5510. xlApp.Selection.PasteSpecial()
  5511. Clipboard.SetDataObject(DBNull.Value)
  5512. xlSheet.ListObjects.Add(Microsoft.Office.Interop.Excel.XlListObjectSourceType.xlSrcRange, xlApp.Range("m4:n" & dt1.Rows.Count + 3 + 1), , Microsoft.Office.Interop.Excel.XlYesNoGuess.xlYes).Name = "表2"
  5513. xlSheet.Columns("b:b").ColumnWidth = 22
  5514. xlSheet.Columns("c:c").ColumnWidth = 25
  5515. xlSheet.Columns("d:d").ColumnWidth = 25
  5516. xlSheet.Columns("e:e").ColumnWidth = 40
  5517. ' xlApp.Columns("f:k").NumberFormatLocal = "#,###.0_ ;[红色]-0.0 "
  5518. xlApp.Columns("b:k").EntireColumn.AutoFit
  5519. xlApp.Columns("b:b").Select()
  5520. xlApp.Selection.HorizontalAlignment = Excel.Constants.xlCenter
  5521. xlApp.Selection.VerticalAlignment = Excel.Constants.xlCenter
  5522. xlApp.Columns("d:d").Select()
  5523. xlApp.Selection.HorizontalAlignment = Excel.Constants.xlCenter
  5524. xlApp.Selection.VerticalAlignment = Excel.Constants.xlCenter
  5525. xlApp.Columns("g:g").Select()
  5526. xlApp.Selection.HorizontalAlignment = Excel.Constants.xlCenter
  5527. xlApp.Selection.VerticalAlignment = Excel.Constants.xlCenter
  5528. xlApp.Cells(1, 1).Select()
  5529. PTCache = xlBook.PivotCaches.Add _
  5530. (SourceType:=Microsoft.Office.Interop.Excel.XlPivotTableSourceType.xlDatabase,
  5531. SourceData:=xlSheet.Range("b4:i18").CurrentRegion.Address)
  5532. PT = PTCache.CreatePivotTable _
  5533. (TableDestination:=xlSheet.Cells(4, 16),
  5534. TableName:="PivotTable1")
  5535. With PT
  5536. .PivotFields("日期").Orientation = Microsoft.Office.Interop.Excel.XlPivotFieldOrientation.xlColumnField
  5537. .PivotFields("客户").Orientation = Microsoft.Office.Interop.Excel.XlPivotFieldOrientation.xlRowField
  5538. .PivotFields("尺数").Orientation = Microsoft.Office.Interop.Excel.XlPivotFieldOrientation.xlDataField
  5539. End With
  5540. xlSheet.PivotTables("PivotTable1").TableStyle2 = "PivotStyleMedium9"
  5541. xlBook.SaveAs("d:\销售汇总自" & String.Format("{0:MMdd}", DateTimePicker1.Value) & "至" & String.Format("{0:MMdd}", DateTimePicker2.Value) & "止" & String.Format("{0:HHss}", Now) & ".xls")
  5542. ' KillExcel(xlApp)
  5543. End Sub
  5544. Private Sub ListBox3_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ListBox3.SelectedIndexChanged
  5545. End Sub
  5546. Private Sub DataGridView2_CellContentClick(sender As Object, e As DataGridViewCellEventArgs) Handles DataGridView2.CellContentClick
  5547. End Sub
  5548. Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click '更新color order_no qty work_no order_item
  5549. Dim dt As DataTable
  5550. sql = "update rt_ship_temp_1 set po_no=order_no where order_no Is Not null And po_no Is null "
  5551. cmd.CommandText = sql
  5552. cmd.ExecuteScalar()
  5553. sql = "update rt_ship_temp_1 set qty=qty_sf1 where qty_sf1 Is Not null And qty Is null "
  5554. cmd.CommandText = sql
  5555. cmd.ExecuteScalar()
  5556. sql = "update rt_ship_temp_1 set work_no=i_no where i_no Is Not null And work_no Is null "
  5557. cmd.CommandText = sql
  5558. cmd.ExecuteScalar()
  5559. sql = "update rt_ship_temp_1 set qty=sf where qty Is null "
  5560. cmd.CommandText = sql
  5561. cmd.ExecuteScalar()
  5562. sql = "update rt_ship_temp_1 set order_item='' where order_item Is null "
  5563. cmd.CommandText = sql
  5564. cmd.ExecuteScalar()
  5565. sql = "SELECT * FROM rt_ship_temp_1 WHERE COLOR1 IS NULL" '--------------------------
  5566. cmd.CommandText = sql
  5567. dt = New DataTable
  5568. da.SelectCommand = cmd
  5569. da.Fill(dt)
  5570. For x As Integer = 0 To dt.Rows.Count - 1
  5571. If dt.Rows(x).Item("name").ToString = "" Then
  5572. sql = "update rt_ship_temp_1 set color1=N'" & dt.Rows(x).Item("color") & "' where filename=N'" & dt.Rows(x).Item("filename") & "' and po_no=N'" & dt.Rows(x).Item("po_no") & "' and thick='" & dt.Rows(x).Item("thick") & "' and serial=N'" & dt.Rows(x).Item("serial") & "'"
  5573. cmd.CommandText = sql
  5574. cmd.ExecuteScalar()
  5575. Else
  5576. mysplit = Split(dt.Rows(x).Item("name"), ",")
  5577. If UBound(mysplit) = 0 Then
  5578. mysplit = Split(dt.Rows(x).Item("name"), ",")
  5579. End If
  5580. If UBound(mysplit) = 0 Then
  5581. mysplit = Split(dt.Rows(x).Item("name"), "/")
  5582. End If
  5583. If UBound(mysplit) > 0 Then
  5584. sql = "update rt_ship_temp_1 set color1=N'" & mysplit(UBound(mysplit)).ToString.Replace("'", "") & "' where filename=N'" & dt.Rows(x).Item("filename") & "' and name=N'" & dt.Rows(x).Item("name").ToString.Replace("'", "''") & "' and qty='" & dt.Rows(x).Item("qty") & "'"
  5585. cmd.CommandText = sql
  5586. cmd.ExecuteScalar()
  5587. Else
  5588. sql = "update rt_ship_temp_1 set color1=N'" & dt.Rows(x).Item("NAME").ToString.Replace("'", "") & "' where filename=N'" & dt.Rows(x).Item("filename") & "' and name=N'" & dt.Rows(x).Item("name").ToString.Replace("'", "''") & "' and qty='" & dt.Rows(x).Item("qty") & "'"
  5589. cmd.CommandText = sql
  5590. cmd.ExecuteScalar()
  5591. End If
  5592. End If
  5593. Next
  5594. MsgBox("")
  5595. End Sub
  5596. Private Sub Button6_Click(sender As Object, e As EventArgs) Handles Button6.Click
  5597. update_custname()
  5598. sql = "UPDATE rt_ship_temp_1 SET THICK='1.24' WHERE NAME LIKE '%1.24%' "
  5599. cmd.CommandText = sql
  5600. cmd.ExecuteScalar()
  5601. sql = "UPDATE rt_ship_temp_1 SET THICK='1.24' WHERE NAME LIKE '%1.2mm-1.4%' "
  5602. cmd.CommandText = sql
  5603. cmd.ExecuteScalar()
  5604. sql = "UPDATE rt_ship_temp_1 SET THICK='1.24' WHERE NAME LIKE '%1.2M1.4MM%' "
  5605. cmd.CommandText = sql
  5606. cmd.ExecuteScalar()
  5607. sql = "UPDATE rt_ship_temp_1 SET THICK='1.24' WHERE NAME LIKE '%1.2-1.4%' "
  5608. cmd.CommandText = sql
  5609. cmd.ExecuteScalar()
  5610. sql = "UPDATE rt_ship_temp_1 SET THICK='1.46' WHERE NAME LIKE '%1.46%' "
  5611. cmd.CommandText = sql
  5612. cmd.ExecuteScalar()
  5613. sql = "UPDATE rt_ship_temp_1 SET THICK='1.46' WHERE NAME LIKE '%1.4-1.6%' "
  5614. cmd.CommandText = sql
  5615. cmd.ExecuteScalar()
  5616. sql = "UPDATE rt_ship_temp_1 SET THICK='1.68' WHERE NAME LIKE '%1.6-1.8%' "
  5617. cmd.CommandText = sql
  5618. cmd.ExecuteScalar()
  5619. '------------------纹路
  5620. sql = "UPDATE rt_ship_temp_1 SET rt_ship_temp_1.pattern = rt_pu_pattern1.pattern
  5621. FROM rt_ship_temp_1 left OUTER JOIN rt_pu_pattern1 ON rt_ship_temp_1.name LIKE '%' + rt_pu_pattern1.pattern + '%'"
  5622. cmd.CommandText = sql
  5623. cmd.ExecuteScalar()
  5624. '-----size
  5625. sql = "update rt_ship_temp_1 set order_no='' where order_no is null"
  5626. cmd.CommandText = sql
  5627. cmd.ExecuteScalar()
  5628. sql = "update rt_ship_temp_1 set work_no='' where work_no is null"
  5629. cmd.CommandText = sql
  5630. cmd.ExecuteScalar()
  5631. sql = "update rt_ship_temp_1 set card='' where card is null"
  5632. cmd.CommandText = sql
  5633. cmd.ExecuteScalar()
  5634. sql = "update rt_ship_temp_1 set po_no='' where po_no is null"
  5635. cmd.CommandText = sql
  5636. cmd.ExecuteScalar()
  5637. sql = "update rt_ship_temp_1 set size=N'8以上身' where name like N'榔皮%' "
  5638. cmd.CommandText = sql
  5639. cmd.ExecuteScalar()
  5640. sql = "update rt_ship_temp_1 set size=N'8以上软' where name like N'软榔%' "
  5641. cmd.CommandText = sql
  5642. cmd.ExecuteScalar()
  5643. sql = "update rt_ship_temp_1 set size=N'8尺以上' where pattern is not null and (custname like N'%松城%' or custname like N'%欣錩%' or custname like N'%金帝%' or custname like N'%澳孚%' or custname like N'%东家%' or custname like N'%颖亿%' or custname like N'%穎億%' or custname like N'%东治%' or custname like N'%华新%' or custname like N'%蜘蛛王%' or custname like N'%加和%') "
  5644. cmd.CommandText = sql
  5645. cmd.ExecuteScalar()
  5646. sql = "update rt_ship_temp_1 set size=N'8以上身' where pattern is not null and (custname like N'%志捷%' or custname like N'%金威利%' or custname like N'%威弘%' or custname like N'%极路客%' or custname like N'%永弘%' or custname like N'%上杰%') and color1 not like '%SM%' "
  5647. cmd.CommandText = sql
  5648. cmd.ExecuteScalar()
  5649. sql = "update rt_ship_temp_1 set size=N'4-8小皮' where pattern is not null and ( custname like N'%金威利%' or custname like N'%威弘%' ) and color1 like '%SM%' "
  5650. cmd.CommandText = sql
  5651. cmd.ExecuteScalar()
  5652. sql = "update rt_ship_temp_1 set size=N'4-8尺' where pattern is not null and (custname like N'%吉兴%' or custname like N'%百合%' or custname like N'%鑫龙%' or custname like N'%鑫茂%' ) "
  5653. cmd.CommandText = sql
  5654. cmd.ExecuteScalar()
  5655. sql = "update rt_ship_temp_1 set size=N'12以上' where pattern is not null and (custname like N'%好兄弟%' ) and name not like '%4-8%' "
  5656. cmd.CommandText = sql
  5657. cmd.ExecuteScalar()
  5658. sql = "update rt_ship_temp_1 set size=N'4-8尺' where pattern is not null and (custname like N'%好兄弟%' ) and name like '%4-8%' "
  5659. cmd.CommandText = sql
  5660. cmd.ExecuteScalar()
  5661. sql = "update rt_ship_temp_1 set size=N'4-8小皮' where pattern is not null and (custname like N'%铭鑫%') "
  5662. cmd.CommandText = sql
  5663. cmd.ExecuteScalar()
  5664. sql = "update rt_ship_temp_1 set size=N'8以上身' where pattern is not null and (custname like N'%永山%' or custname like N'%亿博%' or custname like N'%宏美%' or custname like N'%大田%' or custname like N'%宏福%' or custname like N'%THANG%' or custname like N'%HATAY%' or custname like N'%利亚%') "
  5665. cmd.CommandText = sql
  5666. cmd.ExecuteScalar()
  5667. sql = "update rt_ship_temp_1 set size=N'8-12尺' where pattern is not null and (custname like N'%锐奇%' or custname like N'%凯运%' or custname like N'%东霖%') "
  5668. cmd.CommandText = sql
  5669. cmd.ExecuteScalar()
  5670. 'sql = "update rt_ship_temp_1 set size=N'8-12尺' where pattern is not null and (custname like N'%好兄弟%') and po_no like N'%样品%' "
  5671. 'cmd.CommandText = sql
  5672. 'cmd.ExecuteScalar()
  5673. sql = "update rt_ship_temp_1 set size=N'8以上' where pattern is not null and (custname like N'%周连发%') "
  5674. cmd.CommandText = sql
  5675. cmd.ExecuteScalar()
  5676. 'sql = "update rt_ship_temp_1 set size=N'12以上' where pattern is not null and (custname like N'%好兄弟%') and po_no not like N'%样品%' "
  5677. 'cmd.CommandText = sql
  5678. 'cmd.ExecuteScalar()
  5679. sql = "update rt_ship_temp_1 set size=N'8-12尺和12以上' where pattern is not null and custname like N'%源泰%' "
  5680. cmd.CommandText = sql
  5681. cmd.ExecuteScalar()
  5682. sql = "update rt_ship_temp_1 set size=N'12以上' where pattern is not null and (custname like N'%名创鞋业%') "
  5683. cmd.CommandText = sql
  5684. cmd.ExecuteScalar()
  5685. sql = "update rt_ship_temp_1 set size=N'12以上' where pattern is not null and (name like N'%12以上%') "
  5686. cmd.CommandText = sql
  5687. cmd.ExecuteScalar()
  5688. MsgBox("更新完成")
  5689. End Sub
  5690. Private Sub update_date()
  5691. Dim dt As New DataTable
  5692. Dim mysplit() As String
  5693. Dim str() As String
  5694. sql = "select * from rt_ship_temp_1 where date is null"
  5695. cmd.CommandText = sql
  5696. dt = New DataTable
  5697. da.SelectCommand = cmd
  5698. da.Fill(dt)
  5699. Dim mymonth As Integer
  5700. Dim myday As Integer
  5701. Dim mydate As String
  5702. Dim d As Date
  5703. For x As Integer = 0 To dt.Rows.Count - 1
  5704. mysplit = Split(dt.Rows(x).Item("filename"), ".xls")
  5705. If UBound(mysplit) = 0 Then
  5706. mysplit = Split(dt.Rows(x).Item("filename"), ".xlsx")
  5707. End If
  5708. str = Split(mysplit(0), ".")
  5709. If IsNumeric(Mid(str(0), Len(str(0)) - 1, 2)) Then
  5710. mymonth = Mid(str(0), Len(str(0)) - 1, 2)
  5711. Else
  5712. mymonth = Mid(str(0), Len(str(0)) - 1, 1)
  5713. End If
  5714. If IsNumeric(Mid(str(1), 1, 2)) Then
  5715. If IsNumeric(Mid(str(1), 2, 1)) Then
  5716. myday = Mid(str(1), 1, 2)
  5717. Else
  5718. myday = Mid(str(1), 1, 1)
  5719. End If
  5720. Else
  5721. If IsNumeric(Mid(str(1), 2, 1)) Then
  5722. myday = Mid(str(1), 1, 2)
  5723. Else
  5724. myday = Mid(str(1), 1, 1)
  5725. End If
  5726. 'myday = Mid(str(1), 2, 1)
  5727. End If
  5728. mydate = "2022" & "/" & mymonth & "/" & myday
  5729. d = mydate
  5730. sql = "update rt_ship_temp_1 set date='" & d & "' where po_no=N'" & dt.Rows(x).Item("po_no") & "' and order_no=N'" & dt.Rows(x).Item("order_no") & "' and qty='" & dt.Rows(x).Item("qty") & "' and filename=N'" & dt.Rows(x).Item("filename") & "' and serial='" & dt.Rows(x).Item("serial") & "' and cust='" & dt.Rows(x).Item("cust") & "'"
  5731. cmd.CommandText = sql
  5732. cmd.ExecuteScalar()
  5733. Next
  5734. End Sub
  5735. Private Sub getdate() '----------------新增temp之后改日期
  5736. Dim dt As New DataTable
  5737. Dim mysplit() As String
  5738. Dim str() As String
  5739. sql = "update rt_ship_temp_1 set po_no ='' where po_no is null"
  5740. cmd.CommandText = sql
  5741. cmd.ExecuteScalar()
  5742. sql = "update rt_ship_temp_1 set serial ='' where serial is null"
  5743. cmd.CommandText = sql
  5744. cmd.ExecuteScalar()
  5745. sql = "select * from rt_ship_temp_1 where date is null"
  5746. cmd.CommandText = sql
  5747. dt = New DataTable
  5748. da.SelectCommand = cmd
  5749. da.Fill(dt)
  5750. Dim mymonth As Integer
  5751. Dim myday As Integer
  5752. Dim mydate As String
  5753. Dim d As Date
  5754. For x As Integer = 0 To dt.Rows.Count - 1
  5755. 'If dt.Rows(x).Item("custname") Like "*鑫*" Then
  5756. ' Dim aaaa As Integer
  5757. ' aaaa = 1
  5758. ' End If
  5759. mysplit = Split(dt.Rows(x).Item("filename"), ".xls")
  5760. If UBound(mysplit) = 0 Then
  5761. mysplit = Split(dt.Rows(x).Item("filename"), ".xlsx")
  5762. End If
  5763. str = Split(mysplit(0), ".")
  5764. If IsNumeric(Mid(str(0), Len(str(0)) - 1, 2)) Then
  5765. mymonth = Mid(str(0), Len(str(0)) - 1, 2)
  5766. Else
  5767. mymonth = Mid(str(0), Len(str(0)) , 1)
  5768. End If
  5769. If IsNumeric(Mid(str(1), 1, 2)) Then
  5770. If IsNumeric(Mid(str(1), 2, 1)) Then
  5771. myday = Mid(str(1), 1, 2)
  5772. Else
  5773. myday = Mid(str(1), 1, 1)
  5774. End If
  5775. Else
  5776. If IsNumeric(Mid(str(1), 2, 1)) Then
  5777. myday = Mid(str(1), 1, 2)
  5778. Else
  5779. myday = Mid(str(1), 1, 1)
  5780. End If
  5781. 'myday = Mid(str(1), 2, 1)
  5782. End If
  5783. mydate = "2024" & "/" & mymonth & "/" & myday
  5784. d = mydate
  5785. sql = "update rt_ship_temp_1 set date='" & d & "' where po_no=N'" & dt.Rows(x).Item("po_no").ToString.Replace("'", "''") & "' and qty='" & dt.Rows(x).Item("qty") & "' and filename=N'" &
  5786. dt.Rows(x).Item("filename") & "' and serial='" & dt.Rows(x).Item("serial") & "' and po_no=N'" & dt.Rows(x).Item("po_no").ToString.Replace("'", "''") & "'"
  5787. cmd.CommandText = sql
  5788. cmd.ExecuteScalar()
  5789. Next
  5790. sql = "update rt_ship_temp_1 set size=N'8以上身' where name like N'榔皮%' "
  5791. cmd.CommandText = sql
  5792. cmd.ExecuteScalar()
  5793. sql = "update rt_ship_temp_1 set size=N'8以上软' where name like N'软榔%' "
  5794. cmd.CommandText = sql
  5795. cmd.ExecuteScalar()
  5796. sql = "update rt_ship_temp_1 set size=N'8尺以上' where pattern is not null and (custname like N'%澳孚%' or custname like N'%东家%' or custname like N'%东治%' or custname like N'%华新%' or custname like N'%蜘蛛王%') "
  5797. cmd.CommandText = sql
  5798. cmd.ExecuteScalar()
  5799. sql = "update rt_ship_temp_1 set size=N'8以上身' where pattern is not null and (custname like N'%金威利%' or custname like N'%威弘%') and color not like '%SM%' "
  5800. cmd.CommandText = sql
  5801. cmd.ExecuteScalar()
  5802. sql = "update rt_ship_temp_1 set size=N'4-8小皮' where pattern is not null and (custname like N'%金威利%' or custname like N'%威弘%') and color like '%SM%' "
  5803. cmd.CommandText = sql
  5804. cmd.ExecuteScalar()
  5805. sql = "update rt_ship_temp_1 set size=N'8以上身' where pattern is not null and (custname like N'%永山%' or custname like N'%宏福%' or custname like N'%亿博%' or custname like N'%宏美%' or custname like N'%大田%') "
  5806. cmd.CommandText = sql
  5807. cmd.ExecuteScalar()
  5808. sql = "update rt_ship_temp_1 set size=N'8-12尺' where pattern is not null and (custname like N'%锐奇%' or custname like N'%凯运%' or custname like N'%东霖%') "
  5809. cmd.CommandText = sql
  5810. cmd.ExecuteScalar()
  5811. sql = "update rt_ship_temp_1 set size=N'8-12尺和12以上' where pattern is not null and custname like N'%源泰%' "
  5812. cmd.CommandText = sql
  5813. cmd.ExecuteScalar()
  5814. MsgBox("更新完成")
  5815. End Sub
  5816. Private Sub Button7_Click(sender As Object, e As EventArgs) Handles Button7.Click
  5817. End Sub
  5818. Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
  5819. Dim dt As New DataTable
  5820. If IsNumeric(TextBox4.Text) Then
  5821. Else
  5822. MsgBox("未输入单号/单号格式有误")
  5823. Exit Sub
  5824. End If
  5825. sql = "select count(*) from rt_ship_temp_1 where DATE
  5826. BETWEEN '" & String.Format("{0:d}", DateTimePicker1.Value) & "' AND '" & String.Format("{0:d}", DateTimePicker2.Value) & "' and cust is null or custname is null"
  5827. cmd.CommandText = sql
  5828. If cmd.ExecuteScalar > 0 Then
  5829. sql = "select filename 档案名,color1 as 颜色,qty as 尺数,no as 序号 from rt_ship_temp_1 where DATE
  5830. BETWEEN '" & String.Format("{0:d}", DateTimePicker1.Value) & "' AND '" & String.Format("{0:d}", DateTimePicker2.Value) & "' and cust is null or custname is null order by filename"
  5831. dt = New DataTable
  5832. cmd.CommandText = sql
  5833. da.SelectCommand = cmd
  5834. da.Fill(dt)
  5835. dgv1.DataSource = dt
  5836. MsgBox("请检查客户名/客户编号")
  5837. Exit Sub
  5838. End If
  5839. sql = "select count(*) from rt_ship_temp_1 where pattern is not null and size is null and DATE
  5840. BETWEEN '" & String.Format("{0:d}", DateTimePicker1.Value) & "' AND '" & String.Format("{0:d}", DateTimePicker2.Value) & "'"
  5841. cmd.CommandText = sql
  5842. If cmd.ExecuteScalar > 0 Then
  5843. MsgBox("请检查贴膜皮身")
  5844. Exit Sub
  5845. End If
  5846. sql = "select count(*) from rt_ship_temp_1 where size is not null and pattern is null and DATE
  5847. BETWEEN '" & String.Format("{0:d}", DateTimePicker1.Value) & "' AND '" & String.Format("{0:d}", DateTimePicker2.Value) & "'"
  5848. cmd.CommandText = sql
  5849. If cmd.ExecuteScalar > 0 Then
  5850. MsgBox("请检查纹路")
  5851. Exit Sub
  5852. End If
  5853. sql = "select count(*) from rt_ship_temp_1 where date is null"
  5854. cmd.CommandText = sql
  5855. If cmd.ExecuteScalar > 0 Then
  5856. sql = "select filename 档案名,color1 as 颜色,qty as 尺数,no as 序号 from rt_ship_temp_1 where date is null order by filename"
  5857. dt = New DataTable
  5858. cmd.CommandText = sql
  5859. da.SelectCommand = cmd
  5860. da.Fill(dt)
  5861. dgv1.DataSource = dt
  5862. MsgBox("请检查出货日期")
  5863. Exit Sub
  5864. End If
  5865. sql = "select count(*) from rt_ship_temp_1 where DATE
  5866. BETWEEN '" & String.Format("{0:d}", DateTimePicker1.Value) & "' AND '" & String.Format("{0:d}", DateTimePicker2.Value) & "' and color1 is null "
  5867. cmd.CommandText = sql
  5868. If cmd.ExecuteScalar > 0 Then
  5869. sql = "select filename 档案名,color1 as 颜色,qty as 尺数,no as 序号 from rt_ship_temp_1 where color1 is null order by filename"
  5870. dt = New DataTable
  5871. cmd.CommandText = sql
  5872. da.SelectCommand = cmd
  5873. da.Fill(dt)
  5874. dgv1.DataSource = dt
  5875. MsgBox("请检查颜色栏位")
  5876. Exit Sub
  5877. End If
  5878. sql = "select count(*) from rt_ship_temp_1 where DATE
  5879. BETWEEN '" & String.Format("{0:d}", DateTimePicker1.Value) & "' AND '" & String.Format("{0:d}", DateTimePicker2.Value) & "' and deli is null "
  5880. cmd.CommandText = sql
  5881. If cmd.ExecuteScalar > 0 Then
  5882. MsgBox("请检查送货人")
  5883. Exit Sub
  5884. End If
  5885. sql = "select count(*) from rt_ship_temp_1 where DATE
  5886. BETWEEN '" & String.Format("{0:d}", DateTimePicker1.Value) & "' AND '" & String.Format("{0:d}", DateTimePicker2.Value) & "' and thick is null "
  5887. cmd.CommandText = sql
  5888. If cmd.ExecuteScalar > 0 Then
  5889. MsgBox("请检查厚度")
  5890. Exit Sub
  5891. End If
  5892. Dim xlApp As Microsoft.Office.Interop.Excel.Application
  5893. Dim xlBook As Microsoft.Office.Interop.Excel.Workbook
  5894. Dim xlSheet As Microsoft.Office.Interop.Excel.Worksheet
  5895. Dim xlSheet2 As Microsoft.Office.Interop.Excel.Worksheet
  5896. Dim file_name As String = ""
  5897. Dim file_name1 As String = ""
  5898. Dim my_weight As Double = 0
  5899. Dim a As Integer = 0
  5900. Dim my_count As Integer = 0
  5901. 'OpenFileDialog1.Multiselect = True
  5902. 'If OpenFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
  5903. ' file_name = OpenFileDialog1.FileName
  5904. ' file_name1 = OpenFileDialog1.SafeFileName
  5905. 'Else
  5906. ' Exit Sub
  5907. 'End If
  5908. xlApp = CreateObject("Excel.Application")
  5909. xlApp.Visible = True
  5910. xlApp.DisplayAlerts = False
  5911. 'sql = "delete from rt_bg_io"
  5912. 'cmd.CommandText = sql
  5913. 'cmd.ExecuteNonQuery()
  5914. xlBook = xlApp.Workbooks.Open("D:\K3\k3表格模板\销售出库空白模版.xls",, True)
  5915. xlBook.Activate()
  5916. Dim dt2 As New DataTable
  5917. For i = 1 To xlApp.Worksheets.Count
  5918. If xlApp.Workbooks(1).Worksheets(i).name = "Page1" Then
  5919. xlSheet = xlApp.Workbooks(1).Worksheets(i)
  5920. xlSheet.Activate()
  5921. Exit For
  5922. End If
  5923. Next
  5924. dt = New DataTable
  5925. sql = "SELECT po_no,deli_no,work_no,thick, cust,custname,date,filename,deli,order_item,color1 FROM rt_ship_temp_1 where DATE
  5926. BETWEEN '" & String.Format("{0:d}", DateTimePicker1.Value) & "' AND '" & String.Format("{0:d}", DateTimePicker2.Value) & "'
  5927. group by deli_no,po_no,cust,date,filename,custname,work_no,thick,deli,order_item,color1,thick order by date,cust,deli_no "
  5928. cmd.CommandText = sql
  5929. da.SelectCommand = cmd
  5930. da.Fill(dt)
  5931. Dim aa As Integer
  5932. aa = TextBox4.Text
  5933. Dim my_no As String = "XSCK"
  5934. Dim yy As Integer = 1
  5935. Dim x As Integer = 0
  5936. For x = 0 To dt.Rows.Count - 1
  5937. xlSheet.Cells(x + 2, 1) = dt.Rows(x).Item("date")
  5938. xlSheet.Cells(x + 2, 2) = dt.Rows(x).Item("date")
  5939. xlSheet.Cells(x + 2, 3) = "'吴小男"
  5940. xlSheet.Cells(x + 2, 4) = "'" & my_no & aa
  5941. xlSheet.Cells(x + 2, 5) = "'zhang"
  5942. xlSheet.Cells(x + 2, 9) = "'" & dt.Rows(x).Item("cust")
  5943. xlSheet.Cells(x + 2, 10) = "'" & dt.Rows(x).Item("custname")
  5944. xlSheet.Cells(x + 2, 34) = dt.Rows(x).Item("date")
  5945. xlSheet.Cells(x + 2, 46) = "'" & dt.Rows(x).Item("po_no")
  5946. If dt.Rows(x).Item("custname") Like "*上杰*" Or dt.Rows(x).Item("custname") Like "*永正*" Or dt.Rows(x).Item("custname") Like "*宏福*" Then
  5947. xlSheet.Cells(x + 2, 47) = "'" & dt.Rows(x).Item("order_item")
  5948. Else
  5949. xlSheet.Cells(x + 2, 47) = dt.Rows(x).Item("work_no")
  5950. End If
  5951. 'If dt.Rows(x).Item("custname") Like "%样%" Then
  5952. ' xlSheet.Cells(x + 2, 47) = "'样品"
  5953. 'End If
  5954. ' xlSheet.Cells(x + 5, 48) = "型体号"
  5955. 'If dt.Rows(x).Item("custname") Like "*澳孚*" Or dt.Rows(x).Item("custname") Like "*贝孚第*" Or dt.Rows(x).Item("custname") Like "*大田*" Or dt.Rows(x).Item("custname") Like "*德艺科技*" Or dt.Rows(x).Item("custname") Like "*澳孚*" Or
  5956. ' dt.Rows(x).Item("custname") Like "*东家*" Or dt.Rows(x).Item("custname") Like "*东霖*" Or dt.Rows(x).Item("custname") Like "*东治*" Or dt.Rows(x).Item("custname") Like "*贵州唐先生*" Or dt.Rows(x).Item("custname") Like "*宏美二厂*" Or
  5957. ' dt.Rows(x).Item("custname") Like "*龙优*" Or dt.Rows(x).Item("custname") Like "*美迪洋*" Or dt.Rows(x).Item("custname") Like "*美浩实业*" Or dt.Rows(x).Item("custname") Like "*名志鞋业*" Or dt.Rows(x).Item("custname") Like "*秋夏皮业*" Or
  5958. ' dt.Rows(x).Item("custname") Like "*三益鞋厂*" Or dt.Rows(x).Item("custname") Like "*三元鞋厂*" Or dt.Rows(x).Item("custname") Like "*卫士*" Or dt.Rows(x).Item("custname") Like "*许宝贝*" Or dt.Rows(x).Item("custname") Like "*永盛*" Or
  5959. ' dt.Rows(x).Item("custname") Like "*振兴皮行*" Or dt.Rows(x).Item("custname") Like "*中山华新*" Or dt.Rows(x).Item("custname") Like "*汇力*" Or dt.Rows(x).Item("custname") Like "*惠雄*" Or dt.Rows(x).Item("custname") Like "*金帝*" Or dt.Rows(x).Item("custname") Like "*凯运皮革*" Or dt.Rows(x).Item("custname") Like "*励泰*" Or dt.Rows(x).Item("custname") Like "*锐奇*" Then
  5960. 'Else
  5961. 'End If
  5962. ' If dt.Rows(x).Item("custname") Like "*样*" Or dt.Rows(x).Item("custname") Like "*志捷*" Then
  5963. 'End If
  5964. If dt.Rows(x).Item("deli") = "陈立雄" Then
  5965. xlSheet.Cells(x + 2, 49) = "'021"
  5966. xlSheet.Cells(x + 2, 50) = "'陈立雄"
  5967. End If
  5968. If dt.Rows(x).Item("deli") = "尤珊荣" Then
  5969. xlSheet.Cells(x + 2, 49) = "'020"
  5970. xlSheet.Cells(x + 2, 50) = "'尤珊荣"
  5971. End If
  5972. If dt.Rows(x).Item("deli") = "许燕江" Then
  5973. xlSheet.Cells(x + 2, 49) = "'206"
  5974. xlSheet.Cells(x + 2, 50) = "'许燕江"
  5975. End If
  5976. If dt.Rows(x).Item("deli") = "蔡青山" Then
  5977. xlSheet.Cells(x + 2, 49) = "'016"
  5978. xlSheet.Cells(x + 2, 50) = "'蔡青山"
  5979. End If
  5980. If dt.Rows(x).Item("deli") = "陈建超" Then
  5981. xlSheet.Cells(x + 2, 49) = "'247"
  5982. xlSheet.Cells(x + 2, 50) = "'陈建超"
  5983. End If
  5984. If dt.Rows(x).Item("deli") = "蔡春燕" Then
  5985. xlSheet.Cells(x + 2, 49) = "'246"
  5986. xlSheet.Cells(x + 2, 50) = "'蔡春燕"
  5987. End If
  5988. If dt.Rows(x).Item("deli") = "叶以" Then
  5989. xlSheet.Cells(x + 2, 49) = "'248"
  5990. xlSheet.Cells(x + 2, 50) = "'叶以"
  5991. End If
  5992. For i = 1 To xlApp.Worksheets.Count
  5993. If xlApp.Workbooks(1).Worksheets(i).name = "Page2" Then
  5994. xlSheet2 = xlApp.Workbooks(1).Worksheets(i)
  5995. xlSheet2.Activate()
  5996. Exit For
  5997. End If
  5998. Next
  5999. dt2 = New DataTable
  6000. ' sql = "select date,cust,color1,deli_no,card,thick,sum(qty) as qty,pattern from rt_ship_temp_1 where DATE BETWEEN '" & String.Format("{0:d}", DateTimePicker1.Value) & "' AND '" & String.Format("{0:d}", DateTimePicker2.Value) & "' and deli_no='" & dt.Rows(x).Item("deli_no") & "' and filename=N'" & dt.Rows(x).Item("filename") & "' group by date,cust,color1,deli_no,card,thick,pattern"
  6001. ' sql = "SELECT FILENAME,COMMENT,sum( qty) as qty, work_no, color1, pattern, SIZE,name,
  6002. ' thick, deli_no, card,CASE
  6003. 'WHEN source1 LIKE N'%美国广东%' THEN N'516.F.A2'
  6004. 'WHEN source1 LIKE N'%APP%' THEN N'516.F.A3'
  6005. 'WHEN source1 LIKE N'%阿根廷%' THEN N'516.F.B1'
  6006. 'WHEN source1 LIKE N'%澳州%' THEN N'516.F.C1'
  6007. 'WHEN source1 LIKE N'%越南美国%' THEN N'516.F.A3'
  6008. 'WHEN source1 LIKE N'%澳洲%' THEN N'516.F.C1'
  6009. 'WHEN source1 LIKE N'%南非%' THEN N'516.F.E1'
  6010. 'WHEN source1 LIKE N'%乌拉圭%' THEN N'516.F.F1'
  6011. 'WHEN source1 LIKE N'%墨西哥%' THEN N'516.F.G1'
  6012. 'WHEN source1 LIKE N'%泰国日本%' THEN N'516.F.S1'
  6013. 'WHEN source1 LIKE N'%新西兰%' THEN N'516.F.I1'
  6014. 'WHEN source1 LIKE N'%欧州%' THEN N'516.F.J1'
  6015. 'WHEN source1 LIKE N'%孟加拉%' THEN N'516.F.K1'
  6016. 'WHEN source1 LIKE N'%西班牙%' THEN N'516.F.L1'
  6017. 'WHEN source1 LIKE N'%巴西%' THEN N'516.F.N1'
  6018. 'WHEN source1 LIKE N'%英国%' THEN N'516.F.O1'
  6019. 'WHEN source1 LIKE N'%牛种%' THEN N'516.F.P1'
  6020. 'WHEN source1 LIKE N'%智利%' THEN N'516.F.Q1'
  6021. 'WHEN source1 LIKE N'%德国%' THEN N'516.F.R1'
  6022. 'WHEN source1 LIKE N'%日本%' THEN N'516.F.S1'
  6023. 'WHEN source1 LIKE N'%俄罗斯%' THEN N'516.F.T1'
  6024. 'WHEN source1 LIKE N'%台湾泰庆%' THEN N'516.F.Z1'
  6025. 'WHEN source1 LIKE N'%杂皮%' THEN N'516.F.Z9'
  6026. 'WHEN source1 LIKE N'%二层%' THEN N'516.P.01' ELSE '516.F.Z9'
  6027. 'END AS source2,
  6028. ' CASE
  6029. 'WHEN source1 LIKE N'%美国广东%' THEN N'美国广东 二层'
  6030. 'WHEN source1 LIKE N'%APP%' THEN N'美国APP 二层'
  6031. 'WHEN source1 LIKE N'%越南美国%' THEN N'美国APP 二层'
  6032. 'WHEN source1 LIKE N'%阿根廷%' THEN N'阿根廷 二层'
  6033. 'WHEN source1 LIKE N'%澳州%' THEN N'澳洲 二层'
  6034. 'WHEN source1 LIKE N'%澳洲%' THEN N'澳洲 二层'
  6035. 'WHEN source1 LIKE N'%南非%' THEN N'南非 二层'
  6036. 'WHEN source1 LIKE N'%乌拉圭%' THEN N'乌拉圭 二层'
  6037. 'WHEN source1 LIKE N'%墨西哥%' THEN N'墨西哥 二层'
  6038. 'WHEN source1 LIKE N'%泰国日本%' THEN N'日本 二层'
  6039. 'WHEN source1 LIKE N'%新西兰%' THEN N'新西兰 二层'
  6040. 'WHEN source1 LIKE N'%欧州%' THEN N'欧洲 二层'
  6041. 'WHEN source1 LIKE N'%孟加拉%' THEN N'孟加拉 二层'
  6042. 'WHEN source1 LIKE N'%西班牙%' THEN N'西班牙 二层'
  6043. 'WHEN source1 LIKE N'%巴西%' THEN N'巴西 二层'
  6044. 'WHEN source1 LIKE N'%英国%' THEN N'英国 二层'
  6045. 'WHEN source1 LIKE N'%牛种%' THEN N'肯尼亚 二层'
  6046. 'WHEN source1 LIKE N'%智利%' THEN N'智利 二层'
  6047. 'WHEN source1 LIKE N'%德国%' THEN N'德国 二层'
  6048. 'WHEN source1 LIKE N'%日本%' THEN N'日本 二层'
  6049. 'WHEN source1 LIKE N'%俄罗斯%' THEN N'俄罗斯 二层'
  6050. 'WHEN source1 LIKE N'%台湾泰庆%' THEN N'台湾泰庆 二层'
  6051. 'WHEN source1 LIKE N'%杂皮%' THEN N'杂皮 二层'
  6052. 'WHEN source1 LIKE N'%二层%' THEN N'二层' ELSE N'杂皮 二层'
  6053. 'END AS source3
  6054. 'from rt_ship_temp_1 where po_no=N'" & dt.Rows(x).Item("po_no").ToString.Replace("'", "''") & "' and date='" & dt.Rows(x).Item("date") & "' and work_no=N'" & dt.Rows(x).Item("work_no").ToString.Replace("'", "''") & "' and deli_no='" & dt.Rows(x).Item("deli_no") & "' and filename=N'" & dt.Rows(x).Item("filename") & "' and color1=N'" & dt.Rows(x).Item("color1") & "' group by FILENAME,COMMENT,work_no,color1,source1,pattern,size,name,thick,deli_no,card ORDER BY QTY"
  6055. ' sql = "SELECT TOP (100) PERCENT rt_ship_temp_1.custname, rt_ship_temp_1.card AS 卡号, CAST(SUM(rt_ship_temp_1.qty)
  6056. ' AS numeric(10, 1)) AS 尺数, CASE WHEN RIGHT(rt_ship_temp_1.card, 1) = 'F' THEN 'BRF' + substring(rt_ship_temp_1.card,
  6057. ' 0, len(rt_ship_temp_1.card)) ELSE '' END AS 卡号1, CASE WHEN rt_finish_stock.name IS NULL
  6058. ' THEN N'杂皮 二层' ELSE rt_finish_stock.name END AS 品名, CASE WHEN rt_finish_stock.sf IS NULL
  6059. ' THEN '' ELSE rt_finish_stock.sf END AS 库存尺数, CASE WHEN rt_finish_stock.code IS NULL
  6060. ' THEN '516.F.XX' ELSE rt_finish_stock.code END AS 编码, rt_ship_temp_1.color1 AS 颜色,
  6061. ' rt_ship_temp_1.date AS 出货日期, rt_ship_temp_1.po_no, rt_ship_temp_1.work_no, rt_ship_temp_1.thick,
  6062. ' rt_ship_temp_1.deli_no, rt_ship_temp_1.cust, rt_finish_stock.lot
  6063. 'FROM rt_ship_temp_1 LEFT OUTER JOIN
  6064. ' rt_finish_stock ON rt_ship_temp_1.card = rt_finish_stock.lot
  6065. 'WHERE (rt_ship_temp_1.po_no=N'" & dt.Rows(x).Item("po_no").ToString.Replace("'", "''") & "' and rt_ship_temp_1.date='" & dt.Rows(x).Item("date") & "' and rt_ship_temp_1.work_no=N'" & dt.Rows(x).Item("work_no").ToString.Replace("'", "''") & "' and rt_ship_temp_1.deli_no='" & dt.Rows(x).Item("deli_no") & "' and rt_ship_temp_1.filename=N'" & dt.Rows(x).Item("filename") & "' and rt_ship_temp_1.color1=N'" & dt.Rows(x).Item("color1") & "')
  6066. 'GROUP BY rt_ship_temp_1.custname, rt_ship_temp_1.card, rt_finish_stock.name, rt_finish_stock.sf, rt_finish_stock.code,
  6067. ' rt_ship_temp_1.color1, rt_ship_temp_1.date, rt_ship_temp_1.po_no, rt_ship_temp_1.work_no, rt_ship_temp_1.thick,
  6068. ' rt_ship_temp_1.deli_no, rt_ship_temp_1.cust, rt_finish_stock.lot
  6069. 'ORDER BY 出货日期"
  6070. ' sql = "SELECT CASE WHEN 卡号 = '' and pattern is null THEN '2024999999F' when 卡号 = '' and pattern is not null THEN '2024999999P' else 卡号 END AS 卡号, SUM(尺数) AS 尺数, 品名, 编码, 颜色, thick, deli_no,
  6071. ' size, name, deli, filename, comment, pattern
  6072. 'FROM (SELECT TOP (100) PERCENT rt_ship_temp_1.card AS 卡号, CAST(SUM(rt_ship_temp_1.qty) AS numeric(10, 1)) AS 尺数,
  6073. ' CASE WHEN RIGHT(rt_ship_temp_1.card, 1) = 'F' THEN 'BRF' + substring(rt_ship_temp_1.card, 0,
  6074. ' len(rt_ship_temp_1.card)) ELSE '' END AS 卡号1, CASE WHEN rt_finish_stock.name IS NULL
  6075. ' THEN N'杂皮 二层' ELSE rt_finish_stock.name END AS 品名, CASE WHEN rt_finish_stock.code IS NULL
  6076. ' THEN '516.F.XX' ELSE rt_finish_stock.code END AS 编码, rt_ship_temp_1.color1 AS 颜色,
  6077. ' rt_ship_temp_1.date AS 出货日期, rt_ship_temp_1.po_no, rt_ship_temp_1.work_no, rt_ship_temp_1.thick,
  6078. ' rt_ship_temp_1.deli_no, rt_ship_temp_1.cust, rt_finish_stock.lot, rt_ship_temp_1.size, rt_ship_temp_1.order_item,
  6079. ' rt_ship_temp_1.name, rt_ship_temp_1.custname, rt_ship_temp_1.filename, rt_ship_temp_1.qty,
  6080. ' rt_ship_temp_1.comment, rt_ship_temp_1.pattern, rt_ship_temp_1.deli
  6081. ' FROM rt_ship_temp_1 LEFT OUTER JOIN
  6082. ' rt_finish_stock ON rt_ship_temp_1.card = rt_finish_stock.lot
  6083. ' WHERE (rt_ship_temp_1.po_no=N'" & dt.Rows(x).Item("po_no").ToString.Replace("'", "''") & "' and rt_ship_temp_1.date='" & dt.Rows(x).Item("date") & "' and rt_ship_temp_1.work_no=N'" & dt.Rows(x).Item("work_no").ToString.Replace("'", "''") & "' and rt_ship_temp_1.deli_no='" & dt.Rows(x).Item("deli_no") & "' and rt_ship_temp_1.filename=N'" & dt.Rows(x).Item("filename") & "' and rt_ship_temp_1.color1=N'" & dt.Rows(x).Item("color1") & "')
  6084. ' GROUP BY rt_ship_temp_1.card, rt_finish_stock.name, rt_finish_stock.code, rt_ship_temp_1.color1, rt_ship_temp_1.date,
  6085. ' rt_ship_temp_1.po_no, rt_ship_temp_1.work_no, rt_ship_temp_1.thick, rt_ship_temp_1.deli_no,
  6086. ' rt_ship_temp_1.cust, rt_finish_stock.lot, rt_ship_temp_1.size, rt_ship_temp_1.order_item, rt_ship_temp_1.name,
  6087. ' rt_ship_temp_1.custname, rt_ship_temp_1.filename, rt_ship_temp_1.qty, rt_ship_temp_1.comment,
  6088. ' rt_ship_temp_1.pattern, rt_ship_temp_1.deli) AS q
  6089. 'GROUP BY 卡号, 品名, 编码, 颜色, thick, deli_no, size, name, deli, filename, comment, pattern"
  6090. sql = "SELECT FILENAME,COMMENT,cast(sum(qty) as numeric(10,1)) as qty, work_no, color1, pattern, SIZE,name,
  6091. thick, deli_no,source1, card,CASE
  6092. WHEN source1 LIKE N'%美国广东%' THEN N'516.F.A2'
  6093. WHEN source1 LIKE N'%APP%' THEN N'516.F.A3'
  6094. WHEN source1 LIKE N'%阿根廷%' THEN N'516.F.B1'
  6095. WHEN source1 LIKE N'%澳州%' THEN N'516.F.C1'
  6096. WHEN source1 LIKE N'%越南美国%' THEN N'516.F.A3'
  6097. WHEN source1 LIKE N'%澳洲%' THEN N'516.F.C1'
  6098. WHEN source1 LIKE N'%南非%' THEN N'516.F.E1'
  6099. WHEN source1 LIKE N'%乌拉圭%' THEN N'516.F.F1'
  6100. WHEN source1 LIKE N'%墨西哥%' THEN N'516.F.G1'
  6101. WHEN source1 LIKE N'%泰国日本%' THEN N'516.F.S1'
  6102. WHEN source1 LIKE N'%新西兰%' THEN N'516.F.I1'
  6103. WHEN source1 LIKE N'%欧州%' THEN N'516.F.J1'
  6104. WHEN source1 LIKE N'%孟加拉%' THEN N'516.F.K1'
  6105. WHEN source1 LIKE N'%西班牙%' THEN N'516.F.L1'
  6106. WHEN source1 LIKE N'%巴西%' THEN N'516.F.N1'
  6107. WHEN source1 LIKE N'%英国%' THEN N'516.F.O1'
  6108. WHEN source1 LIKE N'%牛种%' THEN N'516.F.P1'
  6109. WHEN source1 LIKE N'%智利%' THEN N'516.F.Q1'
  6110. WHEN source1 LIKE N'%德国%' THEN N'516.F.R1'
  6111. WHEN source1 LIKE N'%日本%' THEN N'516.F.S1'
  6112. WHEN source1 LIKE N'%俄罗斯%' THEN N'516.F.T1'
  6113. WHEN source1 LIKE N'%台湾泰庆%' THEN N'516.F.Z1'
  6114. WHEN source1 LIKE N'%杂皮%' THEN N'516.F.Z9'
  6115. WHEN source1 LIKE N'%二层%' THEN N'516.P.01' ELSE '516.F.Z9'
  6116. END AS source2,
  6117. CASE
  6118. WHEN source1 LIKE N'%美国广东%' THEN N'516 美国 二层'
  6119. WHEN source1 LIKE N'%信德%' THEN N'516 信德 二层'
  6120. WHEN source1 LIKE N'%APP%' THEN N'516 美国 二层'
  6121. WHEN source1 LIKE N'%美国%' THEN N'516 美国 二层'
  6122. WHEN source1 LIKE N'%阿根廷%' THEN N'516 阿根廷 二层'
  6123. WHEN source1 LIKE N'%意大利%' THEN N'516 意大利 二层'
  6124. WHEN source1 LIKE N'%澳洲%' THEN N'516 澳大利亚 二层'
  6125. WHEN source1 LIKE N'%澳大利亚%' THEN N'516 澳大利亚 二层'
  6126. WHEN source1 LIKE N'%南非%' THEN N'516 南非 二层'
  6127. WHEN source1 LIKE N'%乌拉圭%' THEN N'516 乌拉圭 二层'
  6128. WHEN (source1 LIKE N'%墨西哥%' and not(source1 LIKE N'%美国%')) THEN N'516 墨西哥 二层'
  6129. WHEN source1 LIKE N'%泰国日本%' THEN N'516 日本 二层'
  6130. WHEN source1 LIKE N'%新西兰%' THEN N'516 新西兰 二层'
  6131. WHEN source1 LIKE N'%欧洲%' THEN N'516 欧洲 二层'
  6132. WHEN source1 LIKE N'%孟加拉%' THEN N'516 孟加拉 二层'
  6133. WHEN source1 LIKE N'%西班牙%' THEN N'516 西班牙 二层'
  6134. WHEN (source1 LIKE N'%巴西%') or (source1 LIKE N'%南美%') THEN N'516 巴西 二层'
  6135. WHEN source1 LIKE N'%英国%' THEN N'516 英国 二层'
  6136. WHEN source1 LIKE N'%牛种%' THEN N'516 肯尼亚 二层'
  6137. WHEN source1 LIKE N'%智利%' THEN N'516 智利 二层'
  6138. WHEN source1 LIKE N'%泰国美国%' THEN N'516 美国 二层'
  6139. WHEN source1 LIKE N'%德国%' THEN N'516 德国 二层'
  6140. WHEN source1 LIKE N'%肯尼亚%' THEN N'516 肯尼亚 二层'
  6141. WHEN source1 LIKE N'%日本%' THEN N'516 日本 二层'
  6142. WHEN source1 LIKE N'泰国' THEN N'516 泰国 二层'
  6143. WHEN source1 LIKE N'%无铬鞣%' THEN N'516 无铬鞣 二层'
  6144. WHEN source1 LIKE N'%俄罗斯%' THEN N'516 俄罗斯 二层'
  6145. WHEN source1 LIKE N'BX%' THEN N'516 巴西 二层'
  6146. WHEN source1 LIKE N'%台湾泰庆%' THEN N'516 美国 二层'
  6147. WHEN pattern is not null THEN N'516 贴膜皮'
  6148. WHEN (source1 like N'%外购%') THEN N'516 小皮 二层'
  6149. WHEN source1 LIKE N'%杂皮%' THEN N'516 杂皮 二层'
  6150. ELSE N'516 杂皮 二层'
  6151. END AS source3
  6152. from rt_ship_temp_1 where (rt_ship_temp_1.po_no=N'" & dt.Rows(x).Item("po_no").ToString.Replace("'", "''") & "' and rt_ship_temp_1.thick='" & dt.Rows(x).Item("thick") & "' and rt_ship_temp_1.date='" & dt.Rows(x).Item("date") & "' and rt_ship_temp_1.work_no=N'" & dt.Rows(x).Item("work_no").ToString.Replace("'", "''") & "' and rt_ship_temp_1.deli_no=N'" & dt.Rows(x).Item("deli_no") & "' and rt_ship_temp_1.filename=N'" & dt.Rows(x).Item("filename") & "' and rt_ship_temp_1.color1=N'" & dt.Rows(x).Item("color1") & "') group by FILENAME,COMMENT,work_no,color1,source1,pattern,size,name,thick,deli_no,card ORDER BY source3"
  6153. cmd.CommandText = sql
  6154. da.SelectCommand = cmd
  6155. da.Fill(dt2)
  6156. Dim serial As Integer = 1
  6157. For y = 0 To dt2.Rows.Count - 1
  6158. xlSheet2.Cells(yy + 1 + y, 5) = "'" & serial '行号
  6159. xlSheet2.Cells(yy + 1 + y, 6) = "'" & my_no & aa
  6160. ' xlSheet2.Cells(yy 1 5 + y, 7) = "'21"
  6161. If IsDBNull(dt2.Rows(y).Item("pattern")) Then
  6162. xlSheet2.Cells(yy + 1 + y, 9) = "516.F.FM"
  6163. xlSheet2.Cells(yy + 1 + y, 10) = "二层皮"
  6164. xlSheet2.Cells(yy + 1 + y, 17) = dt2.Rows(y).Item("source3")
  6165. Else
  6166. xlSheet2.Cells(yy + 1 + y, 9) = "516.P.PU"
  6167. xlSheet2.Cells(yy + 1 + y, 10) = "贴膜皮"
  6168. If dt2.Rows(y).Item("size") Like "12*" Then
  6169. xlSheet2.Cells(yy + 1 + y, 17) = "'516 贴膜 12+"
  6170. ElseIf dt2.Rows(y).Item("size") Like "8*" Then
  6171. xlSheet2.Cells(yy + 1 + y, 17) = "'516 贴膜 8-12"
  6172. ElseIf dt2.Rows(y).Item("size") Like "4*" Then
  6173. xlSheet2.Cells(yy + 1 + y, 17) = "'516 贴膜 4-8"
  6174. End If
  6175. End If
  6176. ' xlSheet2.Cells(yy + 5 + y, 15) = "'3 尺/kg"
  6177. ' xlSheet2.Cells(yy + 5 + y, 16) = "'平方英尺"
  6178. xlSheet2.Cells(yy + 1 + y, 18) = dt2.Rows(y).Item("qty")
  6179. xlSheet2.Cells(yy + 1 + y, 21) = "'" & dt2.Rows(y).Item("SIZE")
  6180. xlSheet2.Cells(yy + 1 + y, 22) = dt2.Rows(y).Item("qty")
  6181. If dt2.Rows(y).Item("FILENAME") Like "*顽刻*" Then
  6182. xlSheet2.Cells(yy + 1 + y, 54) = "顽刻"
  6183. ElseIf dt2.Rows(y).Item("FILENAME") Like "*顺泰盛*" Then
  6184. xlSheet2.Cells(yy + 1 + y, 54) = "顺泰盛"
  6185. ElseIf dt2.Rows(y).Item("FILENAME") Like "*红晟*" Then
  6186. xlSheet2.Cells(yy + 1 + y, 54) = "红晟"
  6187. ElseIf dt2.Rows(y).Item("FILENAME") Like "*富拓*" Then
  6188. xlSheet2.Cells(yy + 1 + y, 54) = "富拓"
  6189. ElseIf dt2.Rows(y).Item("FILENAME") Like "*浩博*" Then
  6190. xlSheet2.Cells(yy + 1 + y, 54) = "浩博"
  6191. End If
  6192. If dt2.Rows(y).Item("COMMENT") Like "*顽刻*" Then
  6193. xlSheet2.Cells(yy + 1 + y, 54) = "顽刻"
  6194. End If
  6195. ' xlSheet2.Cells(yy + 5 + y, 28) = "'516-R"
  6196. ' xlSheet2.Cells(yy + 5 + y, 29) = "'待售成品仓/赤湖"
  6197. xlSheet2.Cells(yy + 1 + y, 55) = "'" & dt2.Rows(y).Item("color1")
  6198. xlSheet2.Cells(yy + 1 + y, 56) = "'" & dt2.Rows(y).Item("name")
  6199. xlSheet2.Cells(yy + 1 + y, 57) = "'" & dt2.Rows(y).Item("thick")
  6200. xlSheet2.Cells(yy + 1 + y, 58) = "'" & dt2.Rows(y).Item("card") '流程卡号
  6201. ' xlSheet2.Cells(yy + 1 + y, 63) = "'" & dt2.Rows(y).Item("work_no") '工作指令号
  6202. xlSheet2.Cells(yy + 1 + y, 63) = dt2.Rows(y).Item("COMMENT")
  6203. If Len(dt2.Rows(y).Item("pattern").ToString) < 2 Then
  6204. xlSheet2.Cells(yy + 1 + y, 64) = "'反毛皮"
  6205. Else
  6206. xlSheet2.Cells(yy + 1 + y, 64) = "'贴膜"
  6207. End If
  6208. xlSheet2.Cells(yy + 1 + y, 65) = "'" & dt2.Rows(y).Item("pattern") '贴膜纹路
  6209. xlSheet2.Cells(yy + 1 + y, 66) = "'" & dt2.Rows(y).Item("deli_no") '送货单号
  6210. serial = serial + 1
  6211. Next
  6212. yy = yy + dt2.Rows.Count
  6213. aa = aa + 1
  6214. Next
  6215. '' xlSheet.Range("C2:C" & x + 1).FillDown()
  6216. ''xlSheet.Range("E2:E" & x + 1).FillDown()
  6217. xlSheet.Range("F2:F" & x + 1).FillDown()
  6218. xlSheet.Range("G2:G" & x + 1).FillDown()
  6219. xlSheet.Range("H2:H" & x + 1).FillDown()
  6220. xlSheet.Range("K2:K" & x + 1).FillDown()
  6221. xlSheet.Range("L2:L" & x + 1).FillDown()
  6222. xlSheet.Range("M2:M" & x + 1).FillDown()
  6223. xlSheet.Range("N2:N" & x + 1).FillDown()
  6224. xlSheet.Range("O2:O" & x + 1).FillDown()
  6225. xlSheet.Range("P2:P" & x + 1).FillDown()
  6226. xlSheet.Range("Q2:Q" & x + 1).FillDown()
  6227. xlSheet.Range("U2:U" & x + 1).FillDown()
  6228. xlSheet.Range("V2:V" & x + 1).FillDown()
  6229. xlSheet.Range("W2:W" & x + 1).FillDown()
  6230. xlSheet.Range("X2:X" & x + 1).FillDown()
  6231. xlSheet.Range("Y2:Y" & x + 1).FillDown()
  6232. xlSheet.Range("AD2:AD" & x + 1).FillDown()
  6233. xlSheet.Range("AE2:AE" & x + 1).FillDown()
  6234. xlSheet2.Range("C2:C" & yy).FillDown()
  6235. xlSheet2.Range("A2:A" & yy).FillDown()
  6236. xlSheet2.Range("G2:G" & yy).FillDown()
  6237. xlSheet2.Range("N2:N" & yy).FillDown()
  6238. xlSheet2.Range("O2:O" & yy).FillDown()
  6239. xlSheet2.Range("P2:P" & yy).FillDown()
  6240. xlSheet2.Range("S2:S" & yy).FillDown()
  6241. xlSheet2.Range("T2:T" & yy).FillDown()
  6242. xlSheet2.Range("W2:W" & yy).FillDown()
  6243. xlSheet2.Range("X2:X" & yy).FillDown()
  6244. xlSheet2.Range("Y2:Y" & yy).FillDown()
  6245. xlSheet2.Range("AB2:AB" & yy).FillDown()
  6246. xlSheet2.Range("AC2:AC" & yy).FillDown()
  6247. Dim PTCache As Microsoft.Office.Interop.Excel.PivotCache
  6248. Dim PT As Microsoft.Office.Interop.Excel.PivotTable
  6249. PTCache = xlBook.PivotCaches.Add _
  6250. (SourceType:=Microsoft.Office.Interop.Excel.XlPivotTableSourceType.xlDatabase,
  6251. SourceData:=xlSheet2.Range("a1:BN" & xlSheet2.UsedRange.Rows.Count).CurrentRegion.Address)
  6252. PT = PTCache.CreatePivotTable _
  6253. (TableDestination:=xlSheet2.Cells(2, 67),
  6254. TableName:="PivotTable1")
  6255. With PT
  6256. '.PivotFields("批号").Orientation = Microsoft.Office.Interop.Excel.XlPivotFieldOrientation.xlColumnField
  6257. .PivotFields("批号").Orientation = Microsoft.Office.Interop.Excel.XlPivotFieldOrientation.xlRowField
  6258. .PivotFields("实发数量").Orientation = Microsoft.Office.Interop.Excel.XlPivotFieldOrientation.xlDataField
  6259. End With
  6260. xlSheet2.PivotTables("PivotTable1").TableStyle2 = "PivotStyleMedium9"
  6261. 'dt = New DataTable
  6262. 'sql = "SELECT no, sf, order_no, i_no, color, thick, deli_no, serial, card, filename, work_no, orderitem, pattern, cust, date FROM rt_ship_temp"
  6263. 'cmd.CommandText = sql
  6264. 'da.SelectCommand = cmd
  6265. 'da.Fill(dt)
  6266. 'For x As Integer = 0 To dt.Rows.Count - 1
  6267. ' xlSheet2.Cells(x + 2, 2) = dt.Rows(x).Item("date")
  6268. ' xlSheet2.Cells(x + 2, 4) = My
  6269. ' xlSheet2.Cells(x + 2, 6) = "1"
  6270. ' xlSheet2.Cells(x + 2, 9) = dt.Rows(x).Item("cust")
  6271. ' xlSheet2.Cells(x + 2, 12) = "FXF02"
  6272. ' xlSheet2.Cells(x + 2, 14) = "233"
  6273. ' xlSheet2.Cells(x + 2, 16) = "112"
  6274. ' xlSheet2.Cells(x + 2, 17) = "成品仓阿娇"
  6275. ' xlSheet2.Cells(x + 2, 21) = "XSLX01"
  6276. ' xlSheet2.Cells(x + 2, 24) = "0"
  6277. ' xlSheet2.Cells(x + 2, 30) = "017"
  6278. ' xlSheet2.Cells(x + 2, 34) = "0"
  6279. ' xlSheet2.Cells(x + 2, 46) = dt.Rows(x).Item("order_no")
  6280. 'Next
  6281. MsgBox("")
  6282. End Sub
  6283. Private Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click
  6284. End Sub
  6285. Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click '更新发货单号
  6286. 'Dim p1, p2 As String
  6287. 'If chkZhiDan.SelectedIndices.Count = 0 Then
  6288. ' MsgBox("请先选择发货人")
  6289. ' Exit Sub
  6290. 'Else
  6291. ' p1 = chkZhiDan.SelectedItem
  6292. 'End If
  6293. If DataGridView2.Columns.Contains("项次号") Then
  6294. If DataGridView2.Columns.Contains("备注") Then
  6295. For x As Integer = 0 To DataGridView2.Rows.Count - 1
  6296. sql = "update rt_ship_temp_1 Set deli_no=N'" & DataGridView2.Rows(x).Cells("发货单号").Value & "',deli=N'" & DataGridView2.Rows(x).Cells("发货人").Value & "' where po_no =N'" & DataGridView2.Rows(x).Cells("订单号").Value & "' and work_no=N'" & DataGridView2.Rows(x).Cells("指令号").Value & "' and name=N'" & DataGridView2.Rows(x).Cells("品名").Value & "' and color1=N'" & DataGridView2.Rows(x).Cells("颜色").Value & "' and order_item='" & DataGridView2.Rows(x).Cells("项次号").Value & "' and filename=N'" & DataGridView1.Rows(DataGridView1.CurrentCell.RowIndex).Cells(0).Value & "' and comment=N'" & DataGridView2.Rows(x).Cells("备注").Value & "'"
  6297. cmd.CommandText = sql
  6298. cmd.ExecuteScalar()
  6299. Next
  6300. Else
  6301. For x As Integer = 0 To DataGridView2.Rows.Count - 1
  6302. sql = "update rt_ship_temp_1 Set deli_no=N'" & DataGridView2.Rows(x).Cells("发货单号").Value & "',deli=N'" & DataGridView2.Rows(x).Cells("发货人").Value & "' where po_no =N'" & DataGridView2.Rows(x).Cells("订单号").Value & "' and work_no=N'" & DataGridView2.Rows(x).Cells("指令号").Value.replace("'", "''") & "' and name=N'" & DataGridView2.Rows(x).Cells("品名").Value & "' and color1=N'" & DataGridView2.Rows(x).Cells("颜色").Value & "' and order_item='" & DataGridView2.Rows(x).Cells("项次号").Value & "' and filename=N'" & DataGridView1.Rows(DataGridView1.CurrentCell.RowIndex).Cells(0).Value & "'"
  6303. cmd.CommandText = sql
  6304. cmd.ExecuteScalar()
  6305. Next
  6306. End If
  6307. Else
  6308. For x As Integer = 0 To DataGridView2.Rows.Count - 1
  6309. If DataGridView2.Rows(x).Cells("发货单号").Value Is Nothing Then
  6310. Else
  6311. sql = "update rt_ship_temp_1 Set deli_no=N'" & DataGridView2.Rows(x).Cells("发货单号").Value & "',deli=N'" & DataGridView2.Rows(x).Cells("发货人").Value & "' where po_no =N'" & DataGridView2.Rows(x).Cells("订单号").Value.ToString.Replace("'", "''") & "' and work_no=N'" & DataGridView2.Rows(x).Cells("指令号").Value.ToString.Replace("'", "''") & "' and name=N'" & DataGridView2.Rows(x).Cells("品名").Value.ToString.Replace("'", "''") & "' and color1=N'" & DataGridView2.Rows(x).Cells("颜色").Value & "' and thick='" & DataGridView2.Rows(x).Cells("厚度").Value & "' and filename=N'" & DataGridView1.Rows(DataGridView1.CurrentCell.RowIndex).Cells(0).Value & "'"
  6312. cmd.CommandText = sql
  6313. cmd.ExecuteScalar()
  6314. End If
  6315. Next
  6316. End If
  6317. MsgBox("")
  6318. End Sub
  6319. Private Sub chkZhiDan_SelectedIndexChanged(sender As Object, e As EventArgs) Handles chkZhiDan.SelectedIndexChanged
  6320. Dim index1, index2 As Integer
  6321. index1 = chkZhiDan.SelectedIndex
  6322. For x As Integer = 0 To chkZhiDan.Items.Count - 1
  6323. If x <> index1 Then
  6324. chkZhiDan.SetItemChecked(x, False)
  6325. Else
  6326. chkZhiDan.SetItemChecked(index1, True)
  6327. For y As Integer = 0 To DataGridView2.Rows.Count - 1
  6328. DataGridView2.Rows(y).Cells("发货人").Value = chkZhiDan.SelectedItem
  6329. Next
  6330. End If
  6331. Next
  6332. End Sub
  6333. Private Sub chkZhiDan_MouseClick(sender As Object, e As MouseEventArgs) Handles chkZhiDan.MouseClick
  6334. 'Dim index1, index2 As Integer
  6335. 'index1 = chkZhiDan.SelectedIndex
  6336. 'For x As Integer = 0 To chkZhiDan.Items.Count - 1
  6337. ' If x <> index1 Then
  6338. ' chkZhiDan.SetItemChecked(x, False)
  6339. ' Else
  6340. ' chkZhiDan.SetItemChecked(index1, True)
  6341. ' End If
  6342. 'Next
  6343. End Sub
  6344. Private Sub chkSongHuo_SelectedIndexChanged(sender As Object, e As EventArgs) Handles chkSongHuo.SelectedIndexChanged
  6345. Dim index1, index2 As Integer
  6346. index1 = chkSongHuo.SelectedIndex
  6347. For x As Integer = 0 To chkSongHuo.Items.Count - 1
  6348. If x <> index1 Then
  6349. chkSongHuo.SetItemChecked(x, False)
  6350. Else
  6351. chkSongHuo.SetItemChecked(index1, True)
  6352. End If
  6353. Next
  6354. End Sub
  6355. Private Sub DataGridView2_MouseUp(sender As Object, e As MouseEventArgs) Handles DataGridView2.MouseUp
  6356. Dim x As Double = 0
  6357. Dim y As Double = 0
  6358. Dim z As Double = 0
  6359. Dim a As Int16 = 0
  6360. Dim b As Double = 0
  6361. For i As Integer = 0 To DataGridView2.SelectedRows.Count - 1
  6362. x = x + Math.Round(DataGridView2.Rows(DataGridView2.SelectedRows.Item(i).Index).Cells("尺数").Value, 2)
  6363. Next i
  6364. TextBox3.Text = DataGridView2.SelectedRows.Count
  6365. TextBox2.Text = x
  6366. End Sub
  6367. Private Sub Button12_Click(sender As Object, e As EventArgs) Handles Button12.Click
  6368. Dim cust As String
  6369. Dim name As String
  6370. Dim my_po As String
  6371. Dim work_no As String
  6372. Dim my_date As String
  6373. Dim my_color As String
  6374. Dim my_thick As String
  6375. Dim my_qty As Double
  6376. Dim deli_no As String
  6377. Dim deli As String
  6378. my_date = InputBox("请输入日期")
  6379. cust = InputBox("请输入客户")
  6380. name = InputBox("请输入品名")
  6381. my_po = InputBox("请输入订单号")
  6382. work_no = InputBox("请输入指令号")
  6383. my_color = InputBox("请输入颜色")
  6384. my_thick = InputBox("请输入厚度")
  6385. my_qty = InputBox("请输入数量")
  6386. deli = InputBox("请输入发货人")
  6387. deli_no = InputBox("请输入发货单号")
  6388. Dim s1 As Integer
  6389. sql = "select serial from rt_ship_temp_1 where filename=N'" & cust & my_date & "'"
  6390. cmd.CommandText = sql
  6391. If cmd.ExecuteScalar Is Nothing Then
  6392. s1 = 1
  6393. Else
  6394. s1 = cmd.ExecuteScalar + 1
  6395. End If
  6396. sql = "insert into rt_ship_temp_1 (color1,work_no,thick,po_no,filename,name,qty,deli,deli_no) values(N'" & my_color & "',N'" & work_no.ToString.Replace("'", "''") & "',N'" & my_thick & "',N'" & my_po & "',N'手动" & cust & my_date & ".xls',N'" & name & "','" & my_qty & "',N'" & deli & "','" & deli_no & "')"
  6397. cmd.CommandText = sql
  6398. cmd.ExecuteScalar()
  6399. getdate()
  6400. Button6.PerformClick()
  6401. MsgBox("")
  6402. End Sub
  6403. Private Sub Button13_Click(sender As Object, e As EventArgs) Handles Button13.Click
  6404. Dim dt As DataTable
  6405. sql = "select count(*) from rt_ship_temp_1 where cust is null or custname is null"
  6406. cmd.CommandText = sql
  6407. If cmd.ExecuteScalar > 0 Then
  6408. sql = "select filename 档案名,color1 as 颜色,qty as 尺数,no as 序号 from rt_ship_temp_1 where cust is null or custname is null order by filename"
  6409. dt = New DataTable
  6410. cmd.CommandText = sql
  6411. da.SelectCommand = cmd
  6412. da.Fill(dt)
  6413. dgv1.DataSource = dt
  6414. MsgBox("请检查客户名/客户编号")
  6415. Exit Sub
  6416. End If
  6417. sql = "select count(*) from rt_ship_temp_1 where date is null"
  6418. cmd.CommandText = sql
  6419. If cmd.ExecuteScalar > 0 Then
  6420. sql = "select filename 档案名,color1 as 颜色,qty as 尺数,no as 序号 from rt_ship_temp_1 where date is null order by filename"
  6421. dt = New DataTable
  6422. cmd.CommandText = sql
  6423. da.SelectCommand = cmd
  6424. da.Fill(dt)
  6425. dgv1.DataSource = dt
  6426. MsgBox("请检查出货日期")
  6427. Exit Sub
  6428. End If
  6429. sql = "select count(*) from rt_ship_temp_1 where color1 is null "
  6430. cmd.CommandText = sql
  6431. If cmd.ExecuteScalar > 0 Then
  6432. sql = "select filename 档案名,color1 as 颜色,qty as 尺数,no as 序号 from rt_ship_temp_1 where color1 is null order by filename"
  6433. dt = New DataTable
  6434. cmd.CommandText = sql
  6435. da.SelectCommand = cmd
  6436. da.Fill(dt)
  6437. dgv1.DataSource = dt
  6438. MsgBox("请检查颜色栏位")
  6439. Exit Sub
  6440. End If
  6441. sql = "select count(*) from rt_ship_temp_1 where deli is null "
  6442. cmd.CommandText = sql
  6443. If cmd.ExecuteScalar > 0 Then
  6444. MsgBox("请检查送货人")
  6445. Exit Sub
  6446. End If
  6447. End Sub
  6448. Private Sub Button14_Click(sender As Object, e As EventArgs) Handles Button14.Click
  6449. getdate()
  6450. MsgBox("")
  6451. End Sub
  6452. Private Sub update_custname()
  6453. sql = "update rt_ship_temp_1 set cust=N'A01.050' ,custname=N'金威利' where filename like N'%076%' and filename not like N'%076样%' "
  6454. cmd.CommandText = sql
  6455. cmd.ExecuteScalar()
  6456. sql = "update rt_ship_temp_1 set cust=N'A01.109' ,custname=N'正纬(人民币)' where filename like N'%正纬%' "
  6457. cmd.CommandText = sql
  6458. cmd.ExecuteScalar()
  6459. sql = "update rt_ship_temp_1 set cust=N'A01.98' ,custname=N'金帝' where filename like N'%温州%' or filename like N'%金帝%' or filename like N'%湖北%' or filename like N'%泉州%' "
  6460. cmd.CommandText = sql
  6461. cmd.ExecuteScalar()
  6462. 'sql = "update rt_ship_temp_1 set cust=N'A01.98' ,custname=N'金帝' where filename like N'%金帝%' "
  6463. 'cmd.CommandText = sql
  6464. 'cmd.ExecuteScalar()
  6465. sql = "update rt_ship_temp_1 set cust=N'A01.006-1' ,custname=N'吉兴(美元)' where filename like N'%吉兴%' "
  6466. cmd.CommandText = sql
  6467. cmd.ExecuteScalar()
  6468. sql = "update rt_ship_temp_1 set cust=N'A01.061-1' ,custname=N'松城(美元)' where filename like N'%松城%' "
  6469. cmd.CommandText = sql
  6470. cmd.ExecuteScalar()
  6471. sql = "update rt_ship_temp_1 set cust=N'A01.006-1' ,custname=N'吉兴(美元)' where filename like N'%吉兴%' "
  6472. cmd.CommandText = sql
  6473. cmd.ExecuteScalar()
  6474. sql = "update rt_ship_temp_1 set cust=N'A01.107' ,custname=N'赛特' where filename like N'%赛特%' "
  6475. cmd.CommandText = sql
  6476. cmd.ExecuteScalar()
  6477. sql = "update rt_ship_temp_1 set cust=N'A01.092' ,custname=N'合成行东莞有限公司' where filename like N'%合成行%' "
  6478. cmd.CommandText = sql
  6479. cmd.ExecuteScalar()
  6480. sql = "update rt_ship_temp_1 set cust=N'A01.056-1' ,custname=N'永弘(美元)' where filename like N'%永弘%' "
  6481. cmd.CommandText = sql
  6482. cmd.ExecuteScalar()
  6483. sql = "update rt_ship_temp_1 set cust=N'A00.048' ,custname=N'珍琦' where filename like N'%珍琦%' "
  6484. cmd.CommandText = sql
  6485. cmd.ExecuteScalar()
  6486. sql = "update rt_ship_temp_1 set cust=N'A01.104' ,custname=N'咏升' where filename like N'%咏升%' "
  6487. cmd.CommandText = sql
  6488. cmd.ExecuteScalar()
  6489. sql = "update rt_ship_temp_1 set cust=N'A01.003' ,custname=N'美迪洋' where filename like N'%美迪洋%' "
  6490. cmd.CommandText = sql
  6491. cmd.ExecuteScalar()
  6492. sql = "update rt_ship_temp_1 set cust=N'A01.028-1' ,custname=N'中山华新(美元)' where filename like N'%华新%' "
  6493. cmd.CommandText = sql
  6494. cmd.ExecuteScalar()
  6495. sql = "update rt_ship_temp_1 set cust=N'A01.043' ,custname=N'惠雄' where filename like N'%惠雄%' "
  6496. cmd.CommandText = sql
  6497. cmd.ExecuteScalar()
  6498. sql = "update rt_ship_temp_1 set cust=N'A01.015-1' ,custname=N'欣錩(美元)' where filename like N'%欣昌%' "
  6499. cmd.CommandText = sql
  6500. cmd.ExecuteScalar()
  6501. sql = "update rt_ship_temp_1 set cust=N'C.09.003' ,custname=N'鑫龙' where filename like N'%鑫龙%' "
  6502. cmd.CommandText = sql
  6503. cmd.ExecuteScalar()
  6504. sql = "update rt_ship_temp_1 set cust=N'A00.001' ,custname=N'现金' where filename like N'%有人鞋业%' "
  6505. cmd.CommandText = sql
  6506. cmd.ExecuteScalar()
  6507. sql = "update rt_ship_temp_1 set cust=N'A00.001' ,custname=N'现金' where filename like N'%富拓%' "
  6508. cmd.CommandText = sql
  6509. cmd.ExecuteScalar()
  6510. sql = "update rt_ship_temp_1 set cust=N'A01.090' ,custname=N'鑫茂' where filename like N'%鑫茂%' "
  6511. cmd.CommandText = sql
  6512. cmd.ExecuteScalar()
  6513. sql = "update rt_ship_temp_1 set cust=N'A01.068-1' ,custname=N'东治(美元)' where filename like N'%东治%' "
  6514. cmd.CommandText = sql
  6515. cmd.ExecuteScalar()
  6516. sql = "update rt_ship_temp_1 set cust=N'A01.084' ,custname=N'鑫越' where filename like N'%商汤%' "
  6517. cmd.CommandText = sql
  6518. cmd.ExecuteScalar()
  6519. sql = "update rt_ship_temp_1 set cust=N'A00.049' ,custname=N'利亚' where filename like N'%利亚%' "
  6520. cmd.CommandText = sql
  6521. cmd.ExecuteScalar()
  6522. sql = "update rt_ship_temp_1 set cust=N'A00.049' ,custname=N'利亚' where filename like N'%浩博%' "
  6523. cmd.CommandText = sql
  6524. cmd.ExecuteScalar()
  6525. sql = "update rt_ship_temp_1 set cust=N'A01.080' ,custname=N'百合' where filename like N'%百合%' "
  6526. cmd.CommandText = sql
  6527. cmd.ExecuteScalar()
  6528. sql = "update rt_ship_temp_1 set cust=N'A01.022-1' ,custname=N'三元鞋厂(美元)' where filename like N'%三元%' "
  6529. cmd.CommandText = sql
  6530. cmd.ExecuteScalar()
  6531. sql = "update rt_ship_temp_1 set cust=N'A01.004-1' ,custname=N'大田(美元)' where filename like N'%大田%' "
  6532. cmd.CommandText = sql
  6533. cmd.ExecuteScalar()
  6534. sql = "update rt_ship_temp_1 set cust=N'A01.082-1' ,custname=N'THANG LONG美元' where filename like N'%THANG%' "
  6535. cmd.CommandText = sql
  6536. cmd.ExecuteScalar()
  6537. sql = "update rt_ship_temp_1 set cust=N'A02.11' ,custname=N'源泰' where filename like N'%聚兴%' "
  6538. cmd.CommandText = sql
  6539. cmd.ExecuteScalar()
  6540. sql = "update rt_ship_temp_1 set cust=N'A01.105' ,custname=N'好兄弟鞋业' where (filename like N'%好兄弟%' OR FILENAME LIKE N'%名扬%' OR FILENAME LIKE N'%名创%' OR FILENAME LIKE N'%名晋%' OR FILENAME LIKE N'%名志%' OR FILENAME LIKE N'%名越%') "
  6541. cmd.CommandText = sql
  6542. cmd.ExecuteScalar()
  6543. sql = "update rt_ship_temp_1 set cust=N'A02.004' ,custname=N'华昌皮业' where (filename like N'%华世%') "
  6544. cmd.CommandText = sql
  6545. cmd.ExecuteScalar()
  6546. sql = "update rt_ship_temp_1 set cust=N'A01.110' ,custname=N'华鑫(美元)' where (filename like N'%华鑫%') "
  6547. cmd.CommandText = sql
  6548. cmd.ExecuteScalar()
  6549. sql = "update rt_ship_temp_1 set cust=N'A00.049' ,custname=N'利亚' where (filename like N'%顺泰盛%' OR FILENAME LIKE N'%红晟%' OR FILENAME LIKE N'%lpcc%' OR FILENAME LIKE N'%荣创%' ) "
  6550. cmd.CommandText = sql
  6551. cmd.ExecuteScalar()
  6552. sql = "update rt_ship_temp_1 set cust=N'A01.071' ,custname=N'旭晨' where filename like N'%旭晨%' "
  6553. cmd.CommandText = sql
  6554. cmd.ExecuteScalar()
  6555. sql = "update rt_ship_temp_1 set cust=N'A06.001' ,custname=N'许宝贝' where filename like N'%宝贝%' "
  6556. cmd.CommandText = sql
  6557. cmd.ExecuteScalar()
  6558. sql = "update rt_ship_temp_1 set cust=N'A01.058-1' ,custname=N'HATAY(美元)' where filename like N'%HATAY%' "
  6559. cmd.CommandText = sql
  6560. cmd.ExecuteScalar()
  6561. sql = "update rt_ship_temp_1 set cust=N'A01.050-2' ,custname=N'金威利样品' where filename like N'%076样%' "
  6562. cmd.CommandText = sql
  6563. cmd.ExecuteScalar()
  6564. sql = "update rt_ship_temp_1 set cust=N'A01.054-1' ,custname=N'中山志捷(美元)' where filename like N'%志捷%' "
  6565. cmd.CommandText = sql
  6566. cmd.ExecuteScalar()
  6567. sql = "update rt_ship_temp_1 set cust=N'A01.054-1' ,custname=N'中山志捷(美元)' where filename like N'%正永%' "
  6568. cmd.CommandText = sql
  6569. cmd.ExecuteScalar()
  6570. sql = "update rt_ship_temp_1 set cust=N'A02.10' ,custname=N'锐奇鞋业' where filename like N'%锐奇%' "
  6571. cmd.CommandText = sql
  6572. cmd.ExecuteScalar()
  6573. sql = "update rt_ship_temp_1 set cust=N'A01.016-1' ,custname=N'何先生/SAMIL(美元)' where filename like N'%SAMIL%' "
  6574. cmd.CommandText = sql
  6575. cmd.ExecuteScalar()
  6576. sql = "update rt_ship_temp_1 set cust=N'A01.002-1' ,custname=N'上杰(越南)(美元)' where filename like N'%上杰%'"
  6577. cmd.CommandText = sql
  6578. cmd.ExecuteScalar()
  6579. sql = "update rt_ship_temp_1 set cust=N'A01.040-1' ,custname=N'东家(美元)' where filename like N'%东家%' "
  6580. cmd.CommandText = sql
  6581. cmd.ExecuteScalar()
  6582. sql = "update rt_ship_temp_1 set cust=N'A01.100' ,custname=N'永驰' where filename like N'%永驰%'"
  6583. cmd.CommandText = sql
  6584. cmd.ExecuteScalar()
  6585. sql = "update rt_ship_temp_1 set cust=N'A01.052-1' ,custname=N'永正(美元)' where filename like N'%永正%' "
  6586. cmd.CommandText = sql
  6587. cmd.ExecuteScalar()
  6588. sql = "update rt_ship_temp_1 set cust=N'A01.000' ,custname=N'威弘' where filename like N'%威弘%' "
  6589. cmd.CommandText = sql
  6590. cmd.ExecuteScalar()
  6591. sql = "update rt_ship_temp_1 set cust=N'A01.019-1' ,custname=N'亿博(美元)' where filename like N'%亿博%' "
  6592. cmd.CommandText = sql
  6593. cmd.ExecuteScalar()
  6594. sql = "update rt_ship_temp_1 set cust=N'A01.033-1' ,custname=N'颖亿(美元)' where filename like N'%穎億%' "
  6595. cmd.CommandText = sql
  6596. cmd.ExecuteScalar()
  6597. sql = "update rt_ship_temp_1 set cust=N'A01.005-1' ,custname=N'宏美二厂(美元)' where filename like N'%宏美%' or filename like N'%reebok%' " '----待改
  6598. cmd.CommandText = sql
  6599. cmd.ExecuteScalar()
  6600. sql = "update rt_ship_temp_1 set cust=N'A01.048' ,custname=N'极路客' where filename like N'%极路客%' "
  6601. cmd.CommandText = sql
  6602. cmd.ExecuteScalar()
  6603. sql = "update rt_ship_temp_1 set cust=N'A01.008-1' ,custname=N'加和(美元)' where filename like N'%加和%' "
  6604. cmd.CommandText = sql
  6605. cmd.ExecuteScalar()
  6606. sql = "update rt_ship_temp_1 set cust=N'A01.067-1' ,custname=N'创德(美元)' where filename like N'%evergree%' "
  6607. cmd.CommandText = sql
  6608. cmd.ExecuteScalar()
  6609. sql = "update rt_ship_temp_1 set cust=N'A01.062-1' ,custname=N'PROPERWELL(美元)' where filename like N'%properwell%' "
  6610. cmd.CommandText = sql
  6611. cmd.ExecuteScalar()
  6612. sql = "update rt_ship_temp_1 set cust=N'A01.063-1' ,custname=N'coach(美元)' where filename like N'%thanh%' "
  6613. cmd.CommandText = sql
  6614. cmd.ExecuteScalar()
  6615. sql = "update rt_ship_temp_1 set cust=N'A01.063-1' ,custname=N'coach(美元)' where filename like N'%STELLA%' "
  6616. cmd.CommandText = sql
  6617. cmd.ExecuteScalar()
  6618. sql = "update rt_ship_temp_1 set cust=N'A01.063-1' ,custname=N'coach(美元)' where filename like N'%coach%' or filename like '%INDIA%' or filename like '%PONTUS%' or filename like '%RAMA%' or filename like '%INDIA%' or filename like '%KHE%' or filename like '%BRANCH%'"
  6619. cmd.CommandText = sql
  6620. cmd.ExecuteScalar() 'sql = "update rt_ship_temp_1 set cust=N'' ,custname=N'coach(美元)' where filename like N'%076样%' "
  6621. 'cmd.CommandText = sql
  6622. 'cmd.ExecuteScalar()
  6623. sql = "update rt_ship_temp_1 set cust=N'A01.024-1' ,custname=N'PEI HAI-BRM(美元)' where filename like N'%pei hai%' "
  6624. cmd.CommandText = sql
  6625. cmd.ExecuteScalar()
  6626. sql = "update rt_ship_temp_1 set cust=N'A01.073-1' ,custname=N'澳孚(美元)' where filename like N'%澳孚%' "
  6627. cmd.CommandText = sql
  6628. cmd.ExecuteScalar()
  6629. sql = "update rt_ship_temp_1 set cust=N'A01.001-1' ,custname=N'宏福(美元)' where filename like N'%宏福%' "
  6630. cmd.CommandText = sql
  6631. cmd.ExecuteScalar()
  6632. sql = "update rt_ship_temp_1 set cust=N'A01.102' ,custname=N'永丰' where filename like N'%永丰%' "
  6633. cmd.CommandText = sql
  6634. cmd.ExecuteScalar()
  6635. sql = "update rt_ship_temp_1 set cust=N'A01.087' ,custname=N'乐迪' where filename like N'%乐迪%' "
  6636. cmd.CommandText = sql
  6637. cmd.ExecuteScalar()
  6638. sql = "update rt_ship_temp_1 set cust=N'A01.088' ,custname=N'铭鑫' where filename like N'%铭鑫%' "
  6639. cmd.CommandText = sql
  6640. cmd.ExecuteScalar()
  6641. sql = "update rt_ship_temp_1 set cust=N'A01.060' ,custname=N'励泰' where filename like N'%励泰%' "
  6642. cmd.CommandText = sql
  6643. cmd.ExecuteScalar()
  6644. sql = "update rt_ship_temp_1 set cust=N'A06.008' ,custname=N'周连发' where filename like N'%周连发%' "
  6645. cmd.CommandText = sql
  6646. cmd.ExecuteScalar()
  6647. sql = "update rt_ship_temp_1 set cust=N'A01.022-1' ,custname=N'三元鞋厂(美元)' where filename like N'%三元%' "
  6648. cmd.CommandText = sql
  6649. cmd.ExecuteScalar()
  6650. MsgBox("")
  6651. End Sub
  6652. Private Sub Button15_Click(sender As Object, e As EventArgs) Handles Button15.Click
  6653. update_custname()
  6654. End Sub
  6655. Private Sub Button16_Click(sender As Object, e As EventArgs) Handles Button16.Click
  6656. Dim new_card As String
  6657. new_card = InputBox("请输入新卡号")
  6658. Dim msg As MsgBoxResult = MsgBox("确认要将卡号" & DataGridView2.Rows(DataGridView2.CurrentCell.RowIndex).Cells("卡号").Value & "替换为" & new_card & " ?", MsgBoxStyle.YesNo, "警告")
  6659. If msg = vbYes Then
  6660. If DataGridView2.Columns.Contains("项次号") Then
  6661. If DataGridView2.Columns.Contains("备注") Then
  6662. sql = "update rt_ship_temp_1 Set card='" & new_card & "' where po_no =N'" & DataGridView2.Rows(DataGridView2.CurrentCell.RowIndex).Cells("订单号").Value & "' and work_no=N'" & DataGridView2.Rows(DataGridView2.CurrentCell.RowIndex).Cells("指令号").Value & "' and name=N'" & DataGridView2.Rows(DataGridView2.CurrentCell.RowIndex).Cells("品名").Value & "' and card='" & DataGridView2.Rows(DataGridView2.CurrentCell.RowIndex).Cells("卡号").Value & "' and order_item='" & DataGridView2.Rows(DataGridView2.CurrentCell.RowIndex).Cells("项次号").Value & "' and filename=N'" & DataGridView1.Rows(DataGridView1.CurrentCell.RowIndex).Cells(0).Value & "' and comment=N'" & DataGridView2.Rows(DataGridView2.CurrentCell.RowIndex).Cells("备注").Value & "'"
  6663. cmd.CommandText = sql
  6664. cmd.ExecuteScalar()
  6665. Else
  6666. sql = "update rt_ship_temp_1 Set card='" & new_card & "' where po_no =N'" & DataGridView2.Rows(DataGridView2.CurrentCell.RowIndex).Cells("订单号").Value & "' and work_no=N'" & DataGridView2.Rows(DataGridView2.CurrentCell.RowIndex).Cells("指令号").Value & "' and name=N'" & DataGridView2.Rows(DataGridView2.CurrentCell.RowIndex).Cells("品名").Value & "' and card='" & DataGridView2.Rows(DataGridView2.CurrentCell.RowIndex).Cells("卡号").Value & "' and order_item='" & DataGridView2.Rows(DataGridView2.CurrentCell.RowIndex).Cells("项次号").Value & "' and filename=N'" & DataGridView1.Rows(DataGridView1.CurrentCell.RowIndex).Cells(0).Value & "'"
  6667. cmd.CommandText = sql
  6668. cmd.ExecuteScalar()
  6669. End If
  6670. Else
  6671. sql = "update rt_ship_temp_1 Set card='" & new_card & "' where po_no =N'" & DataGridView2.Rows(DataGridView2.CurrentCell.RowIndex).Cells("订单号").Value.ToString.Replace("'", "''") & "' and work_no=N'" & DataGridView2.Rows(DataGridView2.CurrentCell.RowIndex).Cells("指令号").Value.ToString.Replace("'", "''") & "' and name=N'" & DataGridView2.Rows(DataGridView2.CurrentCell.RowIndex).Cells("品名").Value.ToString.Replace("'", "''") & "' and thick='" & DataGridView2.Rows(DataGridView2.CurrentCell.RowIndex).Cells("厚度").Value & "' and card='" & DataGridView2.Rows(DataGridView2.CurrentCell.RowIndex).Cells("卡号").Value & "' and filename=N'" & DataGridView1.Rows(DataGridView1.CurrentCell.RowIndex).Cells(0).Value & "'"
  6672. cmd.CommandText = sql
  6673. cmd.ExecuteScalar()
  6674. End If
  6675. Else
  6676. End If
  6677. MsgBox("")
  6678. End Sub
  6679. Private Sub DataGridView1_CellEnter(sender As Object, e As DataGridViewCellEventArgs) Handles DataGridView1.CellEnter
  6680. ' If DataGridView1.Rows(DataGridView1.CurrentCell.RowIndex).Cells("filename").Value Like "*上杰*" Or DataGridView1.Rows(DataGridView1.CurrentCell.RowIndex).Cells("filename").Value Like "*宏美发*" Or DataGridView1.Rows(DataGridView1.CurrentCell.RowIndex).Cells("filename").Value Like "*永正*" Or DataGridView1.Rows(DataGridView1.CurrentCell.RowIndex).Cells("filename").Value Like "*宏福*" Then '---加order_item
  6681. ' sql = "select name as 品名,color1 as 颜色,thick as 厚度,card as 卡号,po_no as 订单号,work_no as 指令号,order_item as 项次号, cast(sum(qty) as numeric(10,1)) as 尺数,deli as 发货人,deli_no as 发货单号 from rt_ship_temp_1 where filename=N'" & DataGridView1.Rows(DataGridView1.CurrentCell.RowIndex).Cells("filename").Value & "' group by name,color1,thick,card,po_no,work_no,order_item,deli,deli_no"
  6682. ' sql = "SELECT rt_ship_temp_1.name AS 品名, rt_ship_temp_1.color1 AS 颜色, rt_ship_temp_1.thick AS 厚度,
  6683. ' rt_ship_temp_1.card AS 卡号, RT_RETAN_RECORD.source AS 皮源, rt_ship_temp_1.po_no AS 订单号,
  6684. ' rt_ship_temp_1.work_no AS 指令号,order_item as 项次号,CAST(SUM(rt_ship_temp_1.qty) AS numeric(10, 1)) AS 尺数,
  6685. ' rt_ship_temp_1.deli AS 发货人, rt_ship_temp_1.deli_no AS 发货单号
  6686. 'FROM rt_ship_temp_1 LEFT OUTER JOIN
  6687. ' RT_RETAN_RECORD ON rt_ship_temp_1.card = RT_RETAN_RECORD.card
  6688. 'WHERE (rt_ship_temp_1.filename=N'" & DataGridView1.Rows(DataGridView1.CurrentCell.RowIndex).Cells("filename").Value & "')
  6689. 'GROUP BY rt_ship_temp_1.name, rt_ship_temp_1.color1, rt_ship_temp_1.thick, rt_ship_temp_1.card, rt_ship_temp_1.po_no,
  6690. ' rt_ship_temp_1.work_no, rt_ship_temp_1.deli_no,rt_ship_temp_1.order_item, rt_ship_temp_1.deli, RT_RETAN_RECORD.source"
  6691. ' sql = "SELECT rt_ship_temp_1.name AS 品名, rt_ship_temp_1.color1 AS 颜色, rt_ship_temp_1.thick AS 厚度,
  6692. ' rt_ship_temp_1.card AS 卡号, rt_finish_stock.name, rt_ship_temp_1.po_no AS 订单号, rt_ship_temp_1.work_no AS 指令号,
  6693. ' rt_ship_temp_1.order_item AS 项次号, CAST(SUM(rt_ship_temp_1.qty) AS numeric(10, 1)) AS 尺数,
  6694. ' rt_ship_temp_1.deli AS 发货人, rt_ship_temp_1.deli_no AS 发货单号
  6695. 'FROM rt_ship_temp_1 LEFT OUTER JOIN
  6696. ' rt_finish_stock ON rt_ship_temp_1.card = rt_finish_stock.lot
  6697. 'WHERE (rt_ship_temp_1.filename = N'" & DataGridView1.Rows(DataGridView1.CurrentCell.RowIndex).Cells("filename").Value & "')
  6698. 'GROUP BY rt_ship_temp_1.name, rt_ship_temp_1.color1, rt_ship_temp_1.thick, rt_ship_temp_1.card, rt_ship_temp_1.po_no,
  6699. ' rt_ship_temp_1.work_no, rt_ship_temp_1.deli_no, rt_ship_temp_1.order_item, rt_ship_temp_1.deli, rt_finish_stock.name"
  6700. ' If DataGridView1.Rows(DataGridView1.CurrentCell.RowIndex).Cells("filename").Value Like "*上杰*" Then
  6701. ' sql = "select name as 品名,color1 as 颜色,thick as 厚度,card as 卡号,po_no as 订单号,work_no as 指令号,order_item as 项次号, cast(sum(qty) as numeric(10,1)) as 尺数,comment as 备注,deli as 发货人,deli_no as 发货单号 from rt_ship_temp_1 where filename=N'" & DataGridView1.Rows(DataGridView1.CurrentCell.RowIndex).Cells("filename").Value & "' group by name,color1,thick,card,po_no,work_no,order_item,comment,deli,deli_no"
  6702. ' sql = "SELECT rt_ship_temp_1.name AS 品名, rt_ship_temp_1.color1 AS 颜色, rt_ship_temp_1.thick AS 厚度,
  6703. ' rt_ship_temp_1.card AS 卡号, RT_RETAN_RECORD.source AS 皮源, rt_ship_temp_1.po_no AS 订单号,
  6704. ' rt_ship_temp_1.work_no AS 指令号,order_item as 项次号,CAST(SUM(rt_ship_temp_1.qty) AS numeric(10, 1)) AS 尺数, rt_ship_temp_1.comment as 备注,
  6705. ' rt_ship_temp_1.deli AS 发货人, rt_ship_temp_1.deli_no AS 发货单号
  6706. 'FROM rt_ship_temp_1 LEFT OUTER JOIN
  6707. ' RT_RETAN_RECORD ON rt_ship_temp_1.card = RT_RETAN_RECORD.card
  6708. 'WHERE (rt_ship_temp_1.filename=N'" & DataGridView1.Rows(DataGridView1.CurrentCell.RowIndex).Cells("filename").Value & "')
  6709. 'GROUP BY rt_ship_temp_1.name, rt_ship_temp_1.color1, rt_ship_temp_1.thick, rt_ship_temp_1.card, rt_ship_temp_1.po_no,
  6710. ' rt_ship_temp_1.work_no, rt_ship_temp_1.deli_no,rt_ship_temp_1.comment,rt_ship_temp_1.order_item, rt_ship_temp_1.deli, RT_RETAN_RECORD.source"
  6711. ' sql = "SELECT rt_ship_temp_1.name AS 品名, rt_ship_temp_1.color1 AS 颜色, rt_ship_temp_1.thick AS 厚度,
  6712. ' rt_ship_temp_1.card AS 卡号, rt_finish_stock.name, rt_ship_temp_1.po_no AS 订单号, rt_ship_temp_1.work_no AS 指令号,
  6713. ' rt_ship_temp_1.order_item AS 项次号, CAST(SUM(rt_ship_temp_1.qty) AS numeric(10, 1)) AS 尺数,
  6714. ' rt_ship_temp_1.deli AS 发货人, rt_ship_temp_1.deli_no AS 发货单号
  6715. 'FROM rt_ship_temp_1 LEFT OUTER JOIN
  6716. ' rt_finish_stock ON rt_ship_temp_1.card = rt_finish_stock.lot
  6717. 'WHERE (rt_ship_temp_1.filename = N'" & DataGridView1.Rows(DataGridView1.CurrentCell.RowIndex).Cells("filename").Value & "')
  6718. 'GROUP BY rt_ship_temp_1.name, rt_ship_temp_1.color1, rt_ship_temp_1.thick, rt_ship_temp_1.card, rt_ship_temp_1.po_no,
  6719. ' rt_ship_temp_1.work_no, rt_ship_temp_1.deli_no, rt_ship_temp_1.order_item, rt_ship_temp_1.deli, rt_finish_stock.name"
  6720. ' End If
  6721. ' ElseIf DataGridView1.Rows(DataGridView1.CurrentCell.RowIndex).Cells("filename").Value Like "*076样*" Or DataGridView1.Rows(DataGridView1.CurrentCell.RowIndex).Cells("filename").Value Like "*好兄弟*" Then '-----加comment
  6722. ' sql = "select name as 品名,color1 as 颜色,thick as 厚度,card as 卡号,po_no as 订单号,work_no as 指令号,comment as 备注, cast(sum(qty) as numeric(10,1)) as 尺数,deli as 发货人,deli_no as 发货单号 from rt_ship_temp_1 where filename=N'" & DataGridView1.Rows(DataGridView1.CurrentCell.RowIndex).Cells("filename").Value & "' group by name,color1,thick,card,po_no,work_no,comment,deli_no,deli"
  6723. ' sql = "SELECT rt_ship_temp_1.name AS 品名, rt_ship_temp_1.color1 AS 颜色, rt_ship_temp_1.thick AS 厚度,
  6724. ' rt_ship_temp_1.card AS 卡号, RT_RETAN_RECORD.source AS 皮源, rt_ship_temp_1.po_no AS 订单号,
  6725. ' rt_ship_temp_1.work_no AS 指令号,comment as 备注, CAST(SUM(rt_ship_temp_1.qty) AS numeric(10, 1)) AS 尺数,
  6726. ' rt_ship_temp_1.deli AS 发货人, rt_ship_temp_1.deli_no AS 发货单号
  6727. 'FROM rt_ship_temp_1 LEFT OUTER JOIN
  6728. ' RT_RETAN_RECORD ON rt_ship_temp_1.card = RT_RETAN_RECORD.card
  6729. 'WHERE (rt_ship_temp_1.filename=N'" & DataGridView1.Rows(DataGridView1.CurrentCell.RowIndex).Cells("filename").Value & "')
  6730. 'GROUP BY rt_ship_temp_1.name, rt_ship_temp_1.color1, rt_ship_temp_1.thick, rt_ship_temp_1.card, rt_ship_temp_1.po_no,
  6731. ' rt_ship_temp_1.work_no, rt_ship_temp_1.deli_no,rt_ship_temp_1.comment, rt_ship_temp_1.deli, RT_RETAN_RECORD.source"
  6732. ' sql = "SELECT rt_ship_temp_1.name AS 品名, rt_ship_temp_1.color1 AS 颜色, rt_ship_temp_1.thick AS 厚度,
  6733. ' rt_ship_temp_1.card AS 卡号, rt_finish_stock.name, rt_ship_temp_1.po_no AS 订单号, rt_ship_temp_1.work_no AS 指令号,comment as 备注,
  6734. ' CAST(SUM(rt_ship_temp_1.qty) AS numeric(10, 1)) AS 尺数,
  6735. ' rt_ship_temp_1.deli AS 发货人, rt_ship_temp_1.deli_no AS 发货单号
  6736. 'FROM rt_ship_temp_1 LEFT OUTER JOIN
  6737. ' rt_finish_stock ON rt_ship_temp_1.card = rt_finish_stock.lot
  6738. 'WHERE (rt_ship_temp_1.filename = N'" & DataGridView1.Rows(DataGridView1.CurrentCell.RowIndex).Cells("filename").Value & "')
  6739. 'GROUP BY rt_ship_temp_1.name, rt_ship_temp_1.color1, rt_ship_temp_1.thick, rt_ship_temp_1.card, rt_ship_temp_1.po_no,
  6740. ' rt_ship_temp_1.work_no, rt_ship_temp_1.deli_no, rt_ship_temp_1.comment, rt_ship_temp_1.deli, rt_finish_stock.name"
  6741. ' Else '---其他
  6742. ' sql = "select name as 品名,color1 as 颜色,thick as 厚度,card as 卡号,po_no as 订单号,work_no as 指令号, cast(sum(qty) as numeric(10,1)) as 尺数,deli as 发货人,deli_no as 发货单号 from rt_ship_temp_1 where filename=N'" & DataGridView1.Rows(DataGridView1.CurrentCell.RowIndex).Cells("filename").Value & "' group by name,color1,thick,card,po_no,work_no,deli_no,deli"
  6743. ' sql = "SELECT rt_ship_temp_1.name AS 品名, rt_ship_temp_1.color1 AS 颜色, rt_ship_temp_1.thick AS 厚度,
  6744. ' rt_ship_temp_1.card AS 卡号, RT_RETAN_RECORD.source AS 皮源, rt_ship_temp_1.po_no AS 订单号,
  6745. ' rt_ship_temp_1.work_no AS 指令号, CAST(SUM(rt_ship_temp_1.qty) AS numeric(10, 1)) AS 尺数,
  6746. ' rt_ship_temp_1.deli AS 发货人, rt_ship_temp_1.deli_no AS 发货单号
  6747. 'FROM rt_ship_temp_1 LEFT OUTER JOIN
  6748. ' RT_RETAN_RECORD ON rt_ship_temp_1.card = RT_RETAN_RECORD.card
  6749. 'WHERE (rt_ship_temp_1.filename=N'" & DataGridView1.Rows(DataGridView1.CurrentCell.RowIndex).Cells("filename").Value & "')
  6750. 'GROUP BY rt_ship_temp_1.name, rt_ship_temp_1.color1, rt_ship_temp_1.thick, rt_ship_temp_1.card, rt_ship_temp_1.po_no,
  6751. ' rt_ship_temp_1.work_no, rt_ship_temp_1.deli_no, rt_ship_temp_1.deli, RT_RETAN_RECORD.source"
  6752. ' sql = "SELECT rt_ship_temp_1.name AS 品名, rt_ship_temp_1.color1 AS 颜色, rt_ship_temp_1.thick AS 厚度,
  6753. ' rt_ship_temp_1.card AS 卡号, rt_finish_stock.name, rt_ship_temp_1.po_no AS 订单号, rt_ship_temp_1.work_no AS 指令号,
  6754. ' CAST(SUM(rt_ship_temp_1.qty) AS numeric(10, 1)) AS 尺数,
  6755. ' rt_ship_temp_1.deli AS 发货人, rt_ship_temp_1.deli_no AS 发货单号
  6756. 'FROM rt_ship_temp_1 LEFT OUTER JOIN
  6757. ' rt_finish_stock ON rt_ship_temp_1.card = rt_finish_stock.lot
  6758. 'WHERE (rt_ship_temp_1.filename = N'" & DataGridView1.Rows(DataGridView1.CurrentCell.RowIndex).Cells("filename").Value & "')
  6759. 'GROUP BY rt_ship_temp_1.name, rt_ship_temp_1.color1, rt_ship_temp_1.thick, rt_ship_temp_1.card, rt_ship_temp_1.po_no,
  6760. ' rt_ship_temp_1.work_no, rt_ship_temp_1.deli_no, rt_ship_temp_1.deli, rt_finish_stock.name"
  6761. ' End If
  6762. ' cmd.CommandText = sql
  6763. ' da.SelectCommand = cmd
  6764. ' dt1 = New DataTable
  6765. ' da.Fill(dt1)
  6766. ' DataGridView2.DataSource = Nothing
  6767. ' DataGridView2.DataSource = dt1
  6768. ' DataGridView2.Columns(0).Width = 400
  6769. ' DataGridView2.Columns(1).Width = 200
  6770. ' DataGridView2.Columns(3).Width = 200
  6771. End Sub
  6772. Private Sub Button17_Click(sender As Object, e As EventArgs) Handles Button17.Click
  6773. If dgv_edit.Visible = False Then
  6774. dgv_edit.Visible = True
  6775. Button11.Enabled = True
  6776. Else
  6777. dgv_edit.Visible = False
  6778. Button11.Enabled = False
  6779. Exit Sub
  6780. End If
  6781. sql = "select date,name,po_no,work_no,qty as 尺数,card,order_no,deli,deli_no,id from rt_ship_temp_1 where filename=N'" & DataGridView1.Rows(DataGridView1.CurrentCell.RowIndex).Cells("filename").Value & "' and name=N'" & DataGridView2.Rows(DataGridView2.CurrentCell.RowIndex).Cells("品名").Value & "' and card=N'" & DataGridView2.Rows(DataGridView2.CurrentCell.RowIndex).Cells("卡号").Value & "' and po_no=N'" & DataGridView2.Rows(DataGridView2.CurrentCell.RowIndex).Cells("订单号").Value & "' and thick=N'" & DataGridView2.Rows(DataGridView2.CurrentCell.RowIndex).Cells("厚度").Value & "'" & " order by id "
  6782. cmd.CommandText = sql
  6783. dgv_edit.Visible = True
  6784. da.SelectCommand = cmd
  6785. dt1 = New DataTable
  6786. da.Fill(dt1)
  6787. Dim myRow As DataRow
  6788. myRow = dt1.NewRow
  6789. If IsDBNull(dt1.Compute("sum(尺数)", "")) Then
  6790. myRow(4) = 0
  6791. Else
  6792. myRow(4) = Math.Round(dt1.Compute("sum(尺数)", ""), 1)
  6793. End If
  6794. myRow(3) = "合计"
  6795. dt1.Rows.InsertAt(myRow, 0)
  6796. dgv_edit.DataSource = dt1
  6797. dgv_edit.Columns(0).Width = 150
  6798. dgv_edit.Columns(1).Width = 150
  6799. dgv_edit.Columns(3).Width = 150
  6800. End Sub
  6801. Private Sub dgv_edit_CellContentClick(sender As Object, e As DataGridViewCellEventArgs) Handles dgv_edit.CellContentClick
  6802. End Sub
  6803. Private Sub dgv_edit_CellMouseUp(sender As Object, e As DataGridViewCellMouseEventArgs) Handles dgv_edit.CellMouseUp
  6804. Dim x As Double = 0
  6805. Dim y As Double = 0
  6806. Dim z As Double = 0
  6807. Dim a As Int16 = 0
  6808. Dim b As Double = 0
  6809. For i As Integer = 0 To dgv_edit.SelectedRows.Count - 1
  6810. x = x + Math.Round(dgv_edit.Rows(dgv_edit.SelectedRows.Item(i).Index).Cells("尺数").Value, 1)
  6811. Next i
  6812. ' TextBox3.Text = dgv2.SelectedRows.Count
  6813. TextBox5.Text = x
  6814. End Sub
  6815. Private Sub Button18_Click(sender As Object, e As EventArgs) Handles Button18.Click
  6816. Dim my_card As String = ""
  6817. my_card = InputBox("请输入新卡号")
  6818. Dim msg As MsgBoxResult
  6819. msg = MsgBox("确定将卡号更改为 : " & my_card & "?", vbYesNo)
  6820. If msg = vbNo Then Exit Sub
  6821. For i As Integer = 0 To dgv_edit.SelectedRows.Count - 1
  6822. sql = "update rt_ship_temp_1 set card=N'" & my_card & "' where id='" & dgv_edit.Rows(dgv_edit.SelectedRows.Item(i).Index).Cells("id").Value & "'"
  6823. cmd.CommandText = sql
  6824. cmd.ExecuteNonQuery()
  6825. Next i
  6826. MsgBox("修改完成")
  6827. update() '更新资料
  6828. End Sub
  6829. Private Sub Button19_Click(sender As Object, e As EventArgs) Handles Button19.Click
  6830. Dim dt As New DataTable
  6831. Dim file_name As String = ""
  6832. Dim a As Integer = 0
  6833. Dim my_count As Integer = 0
  6834. If OpenFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
  6835. file_name = OpenFileDialog1.FileName
  6836. End If
  6837. Dim filepath As String = "k3/在制品"
  6838. Dim sourceFileName As String = file_name
  6839. Dim address2 As String = "ftp://" & my_ip & ":7788/" & filepath & "/" & OpenFileDialog1.SafeFileName
  6840. Dim address3() As String
  6841. address3 = Split(address2, "ftp://" & my_ip & ":7788/")
  6842. Dim add4 As String
  6843. add4 = "d:\k3\在制品\" & OpenFileDialog1.SafeFileName
  6844. Dim userName As String = "matchy3c"
  6845. Dim password As String = "Lafayette11"
  6846. Dim showUI As Boolean = True
  6847. Dim connectionTimeout As Integer = 500
  6848. Dim client As WebClient = New WebClient
  6849. client.Credentials = New NetworkCredential(userName, password)
  6850. client.Proxy = GlobalProxySelection.GetEmptyWebProxy()
  6851. client.UploadFile(address2, sourceFileName)
  6852. sql = "delete from rt_finish_stock" '-------
  6853. cmd.CommandText = sql
  6854. cmd.ExecuteNonQuery()
  6855. sql = "Select * FROM OPENDATASOURCE ('Microsoft.ACE.OLEDB.12.0','Excel 12.0;HDR=Yes;IMEX=1;Database=" & add4 & "')...[即时库存$]"
  6856. cmd.CommandText = sql
  6857. da.SelectCommand = cmd
  6858. da.Fill(dt)
  6859. dgv1.DataSource = dt
  6860. dt.Columns.Add("filename")
  6861. For x As Integer = 0 To dt.Rows.Count - 1
  6862. dt.Rows(x).Item("filename") = file_name
  6863. Next
  6864. Dim my_sqlbulk As New SqlBulkCopy(conn)
  6865. my_sqlbulk.DestinationTableName = "dbo.rt_finish_stock"
  6866. my_sqlbulk.WriteToServer(dt)
  6867. MsgBox("导入完成!")
  6868. End Sub
  6869. Private Sub Button11_Click(sender As Object, e As EventArgs) Handles Button11.Click
  6870. sql = "delete from rt_ship_temp_1 where filename=N'" & DataGridView1.Rows(DataGridView1.CurrentCell.RowIndex).Cells("filename").Value & "'"
  6871. Dim msg As String
  6872. msg = MsgBox("确定要删除 " & DataGridView1.Rows(DataGridView1.CurrentCell.RowIndex).Cells("filename").Value & " ?", vbYesNo)
  6873. If msg = vbNo Then
  6874. Exit Sub
  6875. Else
  6876. cmd.CommandText = sql
  6877. cmd.ExecuteScalar()
  6878. MsgBox("已删除")
  6879. update()
  6880. End If
  6881. End Sub
  6882. Private Sub Button20_Click(sender As Object, e As EventArgs) Handles Button20.Click
  6883. Dim dt As New DataTable
  6884. sql = "select date as 日期,cust as 客户,card as 卡号,color as 颜色,source as 皮源, cast(SUM(sf) as numeric(10,1)) AS 尺数 from rt_measure_daily where color like N'%" & TextBox6.Text & "%' group by date,cust,card,color,source order by Date desc"
  6885. cmd.CommandText = sql
  6886. da.SelectCommand = cmd
  6887. da.Fill(dt)
  6888. dgv_color.DataSource = dt
  6889. dgv_color.Columns(2).Width = 150
  6890. dgv_color.Columns(3).Width = 200
  6891. dgv_color.Columns(4).Width = 200
  6892. sql = "SELECT top(30) date as 日期, custname as 客户, name as 品名, cast(SUM(qty) as numeric(10,1)) AS 尺数 FROM rt_ship_temp_1 WHERE name like N'%" & TextBox6.Text & "%' GROUP BY date, cust, color1, name, custname
  6893. ORDER BY date DESC"
  6894. cmd.CommandText = sql
  6895. da.SelectCommand = cmd
  6896. dt = New DataTable
  6897. da.Fill(dt)
  6898. dgv_out.DataSource = dt
  6899. dgv_out.Columns(1).Width = 120
  6900. dgv_out.Columns(2).Width = 220
  6901. End Sub
  6902. Private Sub TextBox7_TextChanged(sender As Object, e As EventArgs) Handles TextBox7.TextChanged
  6903. End Sub
  6904. Private Sub Button21_Click(sender As Object, e As EventArgs) Handles Button21.Click ' 汇出(毛)
  6905. ' Dim xlApp As Microsoft.Office.Interop.Excel.Application
  6906. ' Dim xlBook As Microsoft.Office.Interop.Excel.Workbook
  6907. ' Dim xlSheet As Microsoft.Office.Interop.Excel.Worksheet
  6908. ' xlApp = CreateObject("Excel.Application")
  6909. ' xlBook = xlApp.Workbooks.Add
  6910. ' xlApp.DisplayAlerts = False
  6911. ' xlBook.Activate()
  6912. ' xlBook.Parent.Windows(1).Visible = True
  6913. ' xlSheet = xlBook.Worksheets.Add
  6914. ' xlSheet.Activate()
  6915. ' xlApp.Visible = True
  6916. ' Dim xx As Integer = 0
  6917. ' Dim y As Integer = 0
  6918. ' Dim P1 As Image
  6919. ' Dim P2 As Image
  6920. ' Dim P3 As Image
  6921. ' Dim P4 As Image
  6922. ' Dim P5 As Image
  6923. ' Dim P6 As Image
  6924. ' Dim P7 As Image
  6925. ' Dim P8 As Image
  6926. ' Dim P9 As Image
  6927. ' Dim FILE_NAME As String
  6928. ' Dim FILE_NAME1 As String
  6929. ' sql = "SELECT RT_SYS_CHEM_MAIN.name AS 化料名称, RT_SYS_CHEM_MAIN.DEP AS 使用部门,
  6930. ' RT_SYS_CHEM_MAIN.CLASS1 AS 化工分类, RT_SYS_CHEM_MAIN.CLASS2 AS 海关分类,
  6931. ' RT_CHEM_MSDS.SUPPLIER AS 供应商, RT_CHEM_MSDS.D1, RT_CHEM_MSDS.D2, RT_CHEM_MSDS.D3,
  6932. ' RT_CHEM_MSDS.D4, RT_CHEM_MSDS.D5, RT_CHEM_MSDS.D6, RT_CHEM_MSDS.D7, RT_CHEM_MSDS.D8,
  6933. ' RT_CHEM_MSDS.D9, RT_SYS_CHEM_MAIN.stock1, RT_SYS_CHEM_MAIN.stock2, RT_SYS_CHEM_MAIN.stock3,
  6934. ' RT_CHEM_MSDS.SUPPLIER
  6935. 'FROM RT_SYS_CHEM_MAIN LEFT OUTER JOIN
  6936. ' RT_CHEM_MSDS ON RT_SYS_CHEM_MAIN.name = RT_CHEM_MSDS.SYS_NAME
  6937. 'WHERE (RT_SYS_CHEM_MAIN.stock1 + RT_SYS_CHEM_MAIN.stock2 + RT_SYS_CHEM_MAIN.stock3 <> 0)"
  6938. ' Dim DT As New DataTable
  6939. ' cmd.CommandText = sql
  6940. ' da.SelectCommand = cmd
  6941. ' da.Fill(DT)
  6942. ' Dim z1 As Integer = 0
  6943. ' For x As Integer = 0 To DT.Rows.Count - 1
  6944. ' Dim MY_CHEM As String
  6945. ' MY_CHEM = DT.Rows(x).Item("化料名称").ToString
  6946. ' MY_CHEM = MY_CHEM.Replace(" ", "_")
  6947. ' ' MY_CHEM = MY_CHEM.Replace("-", "_")
  6948. ' MY_CHEM = MY_CHEM.Replace("/", "-")
  6949. ' ' xlSheet = xlBook.Worksheets.Add
  6950. ' 'xlSheet.Name = MY_CHEM
  6951. ' 'xlSheet.Activate()
  6952. ' ' xlSheet.Hyperlinks.Add(Anchor:=xlSheet.Cells(1, 1), Address:="", SubAddress:="总表!A1", TextToDisplay:="总表")
  6953. ' xlSheet.Cells(x * 16 + 1, 1) = DT.Rows(x).Item("化料名称")
  6954. ' xlSheet.Cells(x * 16 + 1, 1).font.bold = True
  6955. ' xlSheet.Cells(x * 16 + 1, 1).font.size = 24
  6956. ' xlApp.Range(xlSheet.Cells(x * 16 + 1, 1), xlSheet.Cells(x * 16 + 1, 8)).Select()
  6957. ' ' xlApp.Range("E2").Activate()
  6958. ' xlApp.Selection.Merge
  6959. ' xlApp.Selection.HorizontalAlignment = xlCenter
  6960. ' With xlApp.Selection.Borders(xlEdgeLeft)
  6961. ' .LineStyle = xlContinuous
  6962. ' .ColorIndex = 0
  6963. ' .TintAndShade = 0
  6964. ' .Weight = xlMedium
  6965. ' End With
  6966. ' With xlApp.Selection.Borders(xlEdgeTop)
  6967. ' .LineStyle = xlContinuous
  6968. ' .ColorIndex = 0
  6969. ' .TintAndShade = 0
  6970. ' .Weight = xlMedium
  6971. ' End With
  6972. ' With xlApp.Selection.Borders(xlEdgeBottom)
  6973. ' .LineStyle = xlContinuous
  6974. ' .ColorIndex = 0
  6975. ' .TintAndShade = 0
  6976. ' .Weight = xlMedium
  6977. ' End With
  6978. ' With xlApp.Selection.Borders(xlEdgeRight)
  6979. ' .LineStyle = xlContinuous
  6980. ' .ColorIndex = 0
  6981. ' .TintAndShade = 0
  6982. ' .Weight = xlMedium
  6983. ' End With
  6984. ' xlSheet.Cells(x * 16 + 7, 1) = "化 工 分 类 :"
  6985. ' xlSheet.Cells(x * 16 + 7, 1).font.bold = True
  6986. ' xlSheet.Cells(x * 16 + 7, 1).font.size = 12
  6987. ' xlSheet.Cells(x * 16 + 7, 3) = DT.Rows(x).Item("化工分类")
  6988. ' xlSheet.Cells(x * 16 + 7, 3).font.bold = True
  6989. ' xlSheet.Cells(x * 16 + 7, 3).font.size = 12
  6990. ' xlSheet.Cells(x * 16 + 4, 1) = "供 应 商 :"
  6991. ' xlSheet.Cells(x * 16 + 4, 1).font.bold = True
  6992. ' xlSheet.Cells(x * 16 + 4, 1).font.size = 12
  6993. ' xlSheet.Cells(x * 16 + 4, 3) = DT.Rows(x).Item("供应商")
  6994. ' xlSheet.Cells(x * 16 + 4, 3).font.bold = True
  6995. ' xlSheet.Cells(x * 16 + 4, 3).font.size = 12
  6996. ' xlSheet.Cells(x * 16 + 12, 1) = "验收日期/批号 :"
  6997. ' xlSheet.Cells(x * 16 + 12, 1).font.bold = True
  6998. ' xlSheet.Cells(x * 16 + 12, 1).font.size = 12
  6999. ' xlSheet.Cells(x * 16 + 15, 1) = "有 效 期 限 : 二 年"
  7000. ' xlSheet.Cells(x * 16 + 15, 1).font.bold = True
  7001. ' xlSheet.Cells(x * 16 + 15, 1).font.size = 12
  7002. ' xlApp.Range(xlSheet.Cells(x * 16 + 6, 5), xlSheet.Cells(x * 16 + 15, 8)).Select()
  7003. ' ' xlApp.Range("E2").Activate()
  7004. ' '
  7005. ' ' xlApp.Selection.Merge
  7006. ' ' xlApp.Selection.HorizontalAlignment = xlCenter
  7007. ' With xlApp.Selection.Borders(xlEdgeLeft)
  7008. ' .LineStyle = xlContinuous
  7009. ' .ColorIndex = 0
  7010. ' .TintAndShade = 0
  7011. ' .Weight = xlMedium
  7012. ' End With
  7013. ' With xlApp.Selection.Borders(xlEdgeTop)
  7014. ' .LineStyle = xlContinuous
  7015. ' .ColorIndex = 0
  7016. ' .TintAndShade = 0
  7017. ' .Weight = xlMedium
  7018. ' End With
  7019. ' With xlApp.Selection.Borders(xlEdgeBottom)
  7020. ' .LineStyle = xlContinuous
  7021. ' .ColorIndex = 0
  7022. ' .TintAndShade = 0
  7023. ' .Weight = xlMedium
  7024. ' End With
  7025. ' With xlApp.Selection.Borders(xlEdgeRight)
  7026. ' .LineStyle = xlContinuous
  7027. ' .ColorIndex = 0
  7028. ' .TintAndShade = 0
  7029. ' .Weight = xlMedium
  7030. ' End With
  7031. ' xlApp.Range(xlSheet.Cells(x * 16 + 4, 8), xlSheet.Cells(x * 16 + 5, 8)).Select()
  7032. ' ' xlApp.Range("E2").Activate()
  7033. ' '
  7034. ' xlApp.Selection.Merge
  7035. ' xlApp.Selection.FormulaR1C1 = "危险"
  7036. ' xlApp.Selection.HorizontalAlignment = xlCenter
  7037. ' '-----边框
  7038. ' With xlApp.Selection.Borders(xlEdgeLeft)
  7039. ' .LineStyle = xlContinuous
  7040. ' .ColorIndex = 0
  7041. ' .TintAndShade = 0
  7042. ' .Weight = xlMedium
  7043. ' End With
  7044. ' With xlApp.Selection.Borders(xlEdgeTop)
  7045. ' .LineStyle = xlContinuous
  7046. ' .ColorIndex = 0
  7047. ' .TintAndShade = 0
  7048. ' .Weight = xlMedium
  7049. ' End With
  7050. ' With xlApp.Selection.Borders(xlEdgeBottom)
  7051. ' .LineStyle = xlContinuous
  7052. ' .ColorIndex = 0
  7053. ' .TintAndShade = 0
  7054. ' .Weight = xlMedium
  7055. ' End With
  7056. ' With xlApp.Selection.Borders(xlEdgeRight)
  7057. ' .LineStyle = xlContinuous
  7058. ' .ColorIndex = 0
  7059. ' .TintAndShade = 0
  7060. ' .Weight = xlMedium
  7061. ' End With
  7062. ' '------字体
  7063. ' With xlApp.Selection.Interior
  7064. ' .Pattern = xlSolid
  7065. ' .PatternColorIndex = xlAutomatic
  7066. ' .ThemeColor = xlThemeColorLight1
  7067. ' .TintAndShade = 0
  7068. ' .PatternTintAndShade = 0
  7069. ' End With
  7070. ' With xlApp.Selection.Font
  7071. ' .ThemeColor = xlThemeColorDark1
  7072. ' .TintAndShade = 0
  7073. ' End With
  7074. ' With xlApp.Selection.Font
  7075. ' .Size = 18
  7076. ' .ThemeColor = xlThemeColorDark1
  7077. ' .ThemeFont = xlThemeFontMinor
  7078. ' End With
  7079. ' Dim zzz As Integer = 0
  7080. ' For z As Integer = 1 To 9
  7081. ' If Not (IsDBNull(DT.Rows(x).Item("d" & z))) Then
  7082. ' System.Windows.Forms.Clipboard.SetDataObject(p(z), True) '复制到剪贴板
  7083. ' If zzz < 4 Then
  7084. ' Dim range1 As Excel.Range = xlSheet.Range(xlApp.Cells(x * 16 + 6, zzz Mod 4 + 5), xlApp.Cells(x * 16 + 6, zzz Mod 4 + 5)) '粘贴图片的位置
  7085. ' xlSheet.Paste(range1, p(z))
  7086. ' Else
  7087. ' Dim range1 As Excel.Range = xlSheet.Range(xlApp.Cells(x * 16 + 11, zzz Mod 4 + 5), xlApp.Cells(x * 16 + 11, zzz Mod 4 + 5)) '粘贴图片的位置
  7088. ' xlSheet.Paste(range1, p(z))
  7089. ' End If
  7090. ' Dim pic1 As String
  7091. ' pic1 = "picture " & z1 + 1
  7092. ' xlApp.ActiveSheet.Shapes.Range(pic1).Select
  7093. ' xlApp.Selection.ShapeRange.ScaleWidth(0.025, Microsoft.Office.Core.MsoTriState.msoFalse, Microsoft.Office.Core.MsoScaleFrom.msoScaleFromTopLeft)
  7094. ' xlApp.Selection.ShapeRange.Incrementtop(5)
  7095. ' xlApp.Selection.ShapeRange.Incrementleft(5)
  7096. ' zzz = zzz + 1
  7097. ' z1 = z1 + 1
  7098. ' End If
  7099. ' Next
  7100. ' Dim r As String
  7101. ' r = "A" & (x + 1) * 16 + 1
  7102. ' xlApp.ActiveSheet.HPageBreaks.Add(xlApp.Range(r))
  7103. ' Next
  7104. ' ''xlApp.ActiveSheet.PageSetup.PrintArea = "$A$1:$E$660"
  7105. ' 'xlApp.ActiveSheet.PageSetup.PrintArea = "$a$1:$E$" & y * 13
  7106. ' '' xlSheet.Columns("C:C").ColumnWidth = 10.75
  7107. ' xlApp.ActiveWindow.View = Microsoft.Office.Interop.Excel.XlWindowView.xlPageBreakPreview
  7108. ' 'DT2.DefaultView.Sort = "项次 "
  7109. ' MsgBox("输出完成")
  7110. End Sub
  7111. Private Sub Button23_Click(sender As Object, e As EventArgs) Handles Button23.Click
  7112. sql = "SELECT filename, CAST(SUM(qty) AS numeric(10, 1)) AS 尺数
  7113. FROM rt_ship_temp_1
  7114. WHERE (filename LIKE 'C:\a\11%')
  7115. GROUP BY filename ORDER BY filename desc"
  7116. cmd.CommandText = sql
  7117. da.SelectCommand = cmd
  7118. Dim dt As New DataTable
  7119. da.Fill(dt)
  7120. DataGridView1.DataSource = dt
  7121. DataGridView1.Columns(0).Width = 300
  7122. End Sub
  7123. End Class