12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923 |
- Imports System.Data.SqlClient
- Imports OfficeOpenXml
- Imports System.Net
- Imports Microsoft.Office.Interop
- 'Imports Microsoft.Office.Interop.Excel
- 'Imports Microsoft.Office.Core.XlPivotFieldOrientation
- Public Class Frm_BG_main
- Dim cmd As New SqlCommand
- Dim da As New SqlDataAdapter
- Dim my_year111 As Integer
- Dim my_month111 As Integer
- 'Dim my_year As Integer
- Dim dt1 As New DataTable
- Dim sql As String
- Dim conn As New SqlConnection
- Dim xlApp As Microsoft.Office.Interop.Excel.Application
- Dim xlBook As Microsoft.Office.Interop.Excel.Workbook
- Dim xlSheet As Microsoft.Office.Interop.Excel.Worksheet
- Dim xlRange As Microsoft.Office.Interop.Excel.Range
- Dim PTCache As Microsoft.Office.Interop.Excel.PivotCache
- Dim PT As Microsoft.Office.Interop.Excel.PivotTable
- Private Sub Button7_Click(sender As Object, e As EventArgs) Handles Button7.Click
- Frm_wb_out.Show()
- End Sub
-
- Private Sub Button13_Click(sender As Object, e As EventArgs) Handles Button13.Click
- Frm_Stock_Month.Show()
-
- End Sub
-
- Private Sub Button6_Click(sender As Object, e As EventArgs) Handles Button6.Click
- Frm_BG_PROCESS.Show()
-
- End Sub
-
- Private Sub Button9_Click(sender As Object, e As EventArgs) Handles Button9.Click
- Frm_BG_Record.Show()
- End Sub
-
- Private Sub Button19_Click(sender As Object, e As EventArgs) Handles Button19.Click
- Frm_Ship_detail.Show()
-
- End Sub
-
- Private Sub Button20_Click(sender As Object, e As EventArgs) Handles Button20.Click
- Frm_BG_IN_SUM.Show()
-
- End Sub
-
- Private Sub Button21_Click(sender As Object, e As EventArgs) Handles Button21.Click
- Frm_BG_OUT_SUM.Show()
- End Sub
-
- Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
- Frm_BG_Chem_Out_Daily.Show()
-
- End Sub
-
- Private Sub Button22_Click(sender As Object, e As EventArgs) Handles Button22.Click '---每日发货
-
- Dim xlApp As Microsoft.Office.Interop.Excel.Application
- Dim xlBook As Microsoft.Office.Interop.Excel.Workbook
- Dim xlSheet As Microsoft.Office.Interop.Excel.Worksheet
-
- Dim name(1000) As String
- Dim no(1000) As String
- Dim SERIAL(1000) As String
- Dim YEAR1(1000) As String
- Dim MONTH1(1000) As String
- Dim DATE1(1000) As String
- Dim COMMENT(1000) As String
- Dim qty(1000) As Double
- Dim QTY1(1000) As Double
- Dim po_no(1000) As String
- Dim sku_no(1000) As String
- Dim nw(1000) As Double
- Dim gw(1000) As Double
- Dim price(1000) As Double
-
-
- Dim dt As New DataTable
- Dim file_name As String = ""
- Dim file_name1 As String = ""
-
-
- ListBox1.Items.Clear()
-
- Dim my_weight As Double = 0
-
-
-
-
-
-
- Dim a As Integer = 0
- Dim my_count As Integer = 0
- 'OpenFileDialog1.Multiselect = True
- If OpenFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
-
- file_name = OpenFileDialog1.FileName
- file_name1 = OpenFileDialog1.SafeFileName
- Else
- Exit Sub
-
- End If
-
-
-
- xlApp = CreateObject("Excel.Application")
- xlApp.Visible = True
- xlApp.DisplayAlerts = False
-
-
-
- 'sql = "delete from rt_bg_io"
- 'cmd.CommandText = sql
- 'cmd.ExecuteNonQuery()
-
-
-
- xlBook = xlApp.Workbooks.Open(file_name,, True)
- xlBook.Activate()
-
-
-
-
-
- Dim yy As Integer = 0
-
-
-
-
-
-
-
-
- ListBox1.Items.Add(file_name)
-
-
- Dim my_customer As String = ""
-
- If OpenFileDialog1.SafeFileName Like "*上杰*" And OpenFileDialog1.SafeFileName Like "*越南*" Then '---------------------------------------上杰越南
-
-
- my_weight = InputBox("请输入货柜重量",, 0)
-
-
- sql = "delete from rt_ship_daily_sj_vn"
- cmd.CommandText = sql
- cmd.ExecuteNonQuery()
-
-
-
-
-
-
- xlSheet = xlApp.Workbooks(1).Worksheets(1)
- xlSheet.Activate()
-
-
-
-
-
-
- Dim y As Integer = 0
- For y = 14 To xlApp.ActiveSheet.UsedRange.Rows.Count
-
- If Len(xlSheet.Cells(y, 2).value) < 1 Then
- Exit For
- End If
-
- Next y
-
-
- xlApp.Range("A14:N" & y - 1).Select()
-
-
- xlApp.Selection.UnMerge
- 'xlApp.Selection.SpecialCells(Microsoft.Office.Interop.Excel.XlCellType.xlCellTypeBlanks).Select
- 'xlApp.CutCopyMode = False
- 'xlApp.Selection.FormulaR1C1 = "=R[-1]C"
-
-
- For y = 14 To y - 1
-
- sql = "insert into rt_ship_daily_sj_vn (my_weight,no,name,qty,weight,po_no,unit_price,sku_no,order_month) values(" & my_weight & ",'" & xlSheet.Cells(y, 1).value & "',N'" & xlSheet.Cells(y, 2).value & "'," & xlSheet.Cells(y, 3).value & "," & Math.Round(xlSheet.Cells(y, 5).value, 3) & ",N'" & Math.Round(xlSheet.Cells(y, 6).value, 3) & "'," & xlSheet.Cells(y, 9).value & ",N'" & xlSheet.Cells(y, 10).value & "','" & xlSheet.Cells(y, 11).value & "')"
- cmd.CommandText = sql
- cmd.ExecuteScalar()
-
-
-
- Next
-
-
- sql = "select po_no as 订单号,name as 品名, thick as 厚度, cast(sum(qty) as numeric(10,1)) as 尺数,cast(sum(weight) as numeric(10,1)) as 重量 from (SELECT my_weight,no, po_no, name,qty,weight, case when left(name,3)='1.2' then '1.24' when left(name,3)='1.4' then '1.46' end as thick FROM RT_SHIP_DAILY_sj_vn) as p group by po_no,name,thick"
-
- cmd.CommandText = sql
- dt = New DataTable
- da.SelectCommand = cmd
- da.Fill(dt)
-
- dgv1.DataSource = dt
-
-
-
-
- sql = "select 品名,厚度,尺数,cast(尺数/SUM(尺数) OVER () *货柜重 as numeric(10,4)) as 重量 from
- (SELECT 品名, thick AS 厚度, CAST(SUM(qty) AS numeric(10, 1)) AS 尺数, CAST(SUM(weight) AS numeric(10, 1)) AS 重量 ,
- AVG(my_weight) AS 货柜重
- FROM (SELECT my_weight, no, po_no, name, qty, weight, CASE WHEN LEFT(name, 3) = '1.2' THEN '1.24' WHEN LEFT(name,
- 3) = '1.4' THEN '1.46' END AS thick, CASE WHEN name LIKE '%PU%' OR
- name LIKE '%action%' OR
- name LIKE N'%榔%' THEN 'PU' ELSE '反毛' END AS 品名
- FROM RT_SHIP_DAILY_SJ_VN) AS p
- GROUP BY 品名, thick) as q"
-
- cmd.CommandText = sql
- dt = New DataTable
- da.SelectCommand = cmd
- da.Fill(dt)
-
- dgv2.DataSource = dt
-
-
-
-
- ' sql = "select 品名,thick as 厚度, cast(sum(qty_sf) as numeric(10,1)) as 尺数,sum(weight) as 净重 from (SELECT no, po_no, no1, m_no, name, ltrim(thick) as thick, color, qty_sf, no2, p, nw, gw,cast(qty_sf/SUM(qty_sf) OVER (PARTITION BY no) *nw as numeric(10,1)) as weight,case when name like '%PU%' or name like N'%纹%' or name like '%action%' or name like N'%榔%' then 'pu' else '反毛' end as 品名
- 'FROM RT_SHIP_DAILY_JH) as p group by 品名,thick"
-
- ' cmd.CommandText = sql
- ' dt = New DataTable
- ' da.SelectCommand = cmd
- ' da.Fill(dt)
-
-
- 'dgv3.DataSource = dt
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- ElseIf OpenFileDialog1.SafeFileName Like "*上杰*" Then '----------------------------------------------------------------------------------上杰
-
-
- sql = "delete from rt_ship_daily_sj"
- cmd.CommandText = sql
- cmd.ExecuteNonQuery()
-
-
- xlSheet = xlApp.Workbooks(1).Worksheets(1)
-
- Dim y As Integer = 0
- For y = 14 To xlApp.Workbooks(1).Worksheets(1).UsedRange.Rows.Count
-
- If Len(xlSheet.Cells(y, 2).value) < 1 Then
- Exit For
- End If
-
- Next y
-
-
- xlApp.Range("A14:N" & y - 1).Select()
- ' If xlApp.Selection.mergecells = True Then
- xlApp.Selection.UnMerge
- 'xlApp.Selection.SpecialCells(Microsoft.Office.Interop.Excel.XlCellType.xlCellTypeBlanks).Select
- 'xlApp.CutCopyMode = False
- 'xlApp.Selection.FormulaR1C1 = "=R[-1]C"
-
- ' End If
-
- Dim my_no As String
- Dim my_nw As Double
- Dim my_gw As Double
- Dim my_sf As Double
- Dim my_price As Double
- Dim s1 As Integer = 1
- For y = 14 To y - 1
-
- If Not (xlSheet.Cells(y, 10).value Is Nothing) Then
-
- If (xlSheet.Cells(y, 6).value Is Nothing) And (xlSheet.Cells(y, 7).value Is Nothing) Then
- my_nw = xlSheet.Cells(y - 1, 6).value
- my_gw = xlSheet.Cells(y - 1, 7).value
- my_no = xlSheet.Cells(y - 1, 1).value
-
-
- Else
- my_nw = xlSheet.Cells(y, 6).value
- my_gw = xlSheet.Cells(y, 7).value
- my_no = xlSheet.Cells(y, 1).value
-
-
- End If
- my_sf = xlSheet.Cells(y, 3).value
- my_price = xlSheet.Cells(y, 12).value
- sql = "insert into rt_ship_daily_sj (filename,serial,order_item,no,name,qty_sf,nw,gw,po_no,qty_sf1,unit_price) values
- (N'" & file_name & "','" & s1 & "','" & xlSheet.Cells(y, 9).value & "','" & my_no & "',N'" & xlSheet.Cells(y, 2).value & "'," & my_sf & "," & my_nw & "," & my_gw & ",N'" & xlSheet.Cells(y, 8).value & "'," & xlSheet.Cells(y, 10).value & "," & my_price & ")"
- cmd.CommandText = sql
- cmd.ExecuteScalar()
-
- End If
-
- Next
-
-
- ' 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 品名"
-
- ' cmd.CommandText = sql
- ' dt = New DataTable
- ' da.SelectCommand = cmd
- ' da.Fill(dt)
-
-
- ' dt.Columns.Add("尺数")
- ' dt.Columns.Add("货值")
-
-
-
- ' For rr As Integer = 0 To dt.Rows.Count - 1
-
- ' 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
- 'GROUP BY 品名 having 品名=N'" & dt.Rows(rr).Item("品名") & "'"
- ' cmd.CommandText = sql
-
- ' dt.Rows(rr).Item("尺数") = cmd.ExecuteScalar
-
-
- ' Next
-
-
-
- ' For rr As Integer = 0 To dt.Rows.Count - 1
-
- ' 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
- 'GROUP BY 品名 having 品名=N'" & dt.Rows(rr).Item("品名") & "'"
- ' cmd.CommandText = sql
-
- ' dt.Rows(rr).Item("货值") = cmd.ExecuteScalar
-
-
- ' Next
- ' dgv1.DataSource = dt
-
-
-
- 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
- (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 净重
- FROM rt_ship_daily_sj) as p group by 品名,po_no,厚度" '----旧
-
- 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 "
-
-
- cmd.CommandText = sql
- dt = New DataTable
- da.SelectCommand = cmd
-
-
- da.Fill(dt)
-
-
- dgv1.DataSource = dt
-
-
- dgv1.Columns("品名").Width = 300
-
- dgv1.Columns("订单号").Width = 180
-
- dgv1.Columns("项次号").Width = 80
-
- dgv1.Columns("尺数").Width = 120
-
-
-
- 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
- (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 净重
- FROM rt_ship_daily_sj) as p group by 品名,po_no,厚度,颜色) as q group by 品名,颜色,厚度 order by 品名"
-
- cmd.CommandText = sql
- dt = New DataTable
- da.SelectCommand = cmd
- da.Fill(dt)
-
-
- dgv2.DataSource = dt
-
-
-
-
-
- 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
- (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 净重
- FROM rt_ship_daily_sj) as p group by 品名,po_no,厚度,颜色) as q group by 品名,颜色 order by 品名"
-
- cmd.CommandText = sql
- dt = New DataTable
- da.SelectCommand = cmd
- da.Fill(dt)
-
-
- dgv3.DataSource = dt
-
-
-
-
-
-
-
- ElseIf OpenFileDialog1.SafeFileName Like "*永正货柜*" Then '--------------------------------------------------------------------------永正货柜
-
-
- sql = "delete from rt_ship_uz_HG"
- cmd.CommandText = sql
- cmd.ExecuteNonQuery()
-
-
- xlSheet = xlApp.Workbooks(1).Worksheets(1)
-
- Dim y As Integer = 0
- For y = 14 To xlApp.Workbooks(1).Worksheets(1).UsedRange.Rows.Count
-
- If Len(xlSheet.Cells(y, 2).value) < 1 Then
- Exit For
- End If
-
- Next y
-
-
- xlApp.Range("A14:N" & y - 1).Select()
- ' If xlApp.Selection.mergecells = True Then
-
-
- xlApp.Selection.UnMerge
- 'xlApp.Selection.SpecialCells(Microsoft.Office.Interop.Excel.XlCellType.xlCellTypeBlanks).Select
- 'xlApp.CutCopyMode = False
- 'xlApp.Selection.FormulaR1C1 = "=R[-1]C"
- ' End If
-
-
- Dim mc As Integer = 1
- For y = 14 To y - 1
-
- sql = "insert into rt_ship_uz_HG (no,name,qty_sf,nw,gw,po_no,qty_sf1,unit_price,serial) 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, 9).value & "," & xlSheet.Cells(y, 14).value & "," & mc & ")"
- cmd.CommandText = sql
- cmd.ExecuteScalar()
-
- mc = mc + 1
-
- Next
-
-
- ' 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 品名,厚度"
-
- ' cmd.CommandText = sql
- ' dt = New DataTable
- ' da.SelectCommand = cmd
- ' da.Fill(dt)
-
-
- ' dt.Columns.Add("尺数")
- ' dt.Columns.Add("货值")
-
-
-
- ' For rr As Integer = 0 To dt.Rows.Count - 1
-
- ' 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
- 'GROUP BY 品名 having 品名=N'" & dt.Rows(rr).Item("品名") & "'"
- ' cmd.CommandText = sql
-
- ' dt.Rows(rr).Item("尺数") = cmd.ExecuteScalar
-
-
- ' Next
-
-
-
- ' For rr As Integer = 0 To dt.Rows.Count - 1
-
- ' 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
- 'GROUP BY 品名 having 品名=N'" & dt.Rows(rr).Item("品名") & "'"
- ' cmd.CommandText = sql
-
- ' dt.Rows(rr).Item("货值") = cmd.ExecuteScalar
-
-
- ' Next
- ' dgv1.DataSource = dt
-
-
-
- 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,
- 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,品名,颜色"
- cmd.CommandText = sql
- dt = New DataTable
- da.SelectCommand = cmd
- da.Fill(dt)
-
-
- dgv1.DataSource = dt
-
-
- dgv1.Columns(0).Width = 200
- dgv1.Columns(1).Width = 80
- dgv1.Columns(2).Width = 80
-
-
-
-
-
-
-
-
-
-
-
-
-
- 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
- ( select po_no as 订单号,类别,sum(nw) as 净重,sum(gw) as 毛重, 颜色,sum(qty_sf1) as 尺数,sum(qty_sf1*单价)as 货值,count(*) 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,
- 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 类别"
- cmd.CommandText = sql
- dt = New DataTable
- da.SelectCommand = cmd
- da.Fill(dt)
-
-
- dgv2.DataSource = dt
-
-
-
- dgv2.Columns(0).Width = 70
- dgv2.Columns(1).Width = 70
- dgv2.Columns(2).Width = 120
- dgv2.Columns(3).Width = 70
- dgv2.Columns(4).Width = 120
- dgv2.Columns(5).Width = 120
-
-
-
-
- With dgv2.Columns("尺数").DefaultCellStyle
- .Format = "n2"
- .Alignment = DataGridViewContentAlignment.MiddleRight
-
- End With
-
- With dgv2.Columns("货值").DefaultCellStyle
- .Format = "n2"
- .Alignment = DataGridViewContentAlignment.MiddleRight
-
- End With
-
- With dgv2.Columns("净重").DefaultCellStyle
- .Format = "n2"
- .Alignment = DataGridViewContentAlignment.MiddleRight
-
- End With
-
- With dgv2.Columns("毛重").DefaultCellStyle
- .Format = "n2"
- .Alignment = DataGridViewContentAlignment.MiddleRight
-
- End With
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- ElseIf OpenFileDialog1.SafeFileName Like "永正发货*" Then '-----------永正发货
-
- sql = "delete from rt_ship_daily_uz_1"
- cmd.CommandText = sql
- cmd.ExecuteNonQuery()
-
- xlSheet = xlApp.Workbooks(1).Worksheets(1)
-
- Dim y As Integer = 0
- For y = 14 To xlApp.Workbooks(1).Worksheets(1).UsedRange.Rows.Count
-
- If Len(xlSheet.Cells(y, 2).value) < 1 Then
- Exit For
- End If
-
- Next y
-
- yy = y - 1
- xlApp.Range("A14:q" & yy).Select()
-
- 'If xlApp.Selection.mergecells = True Then
-
- xlApp.Selection.UnMerge
- 'xlApp.Selection.SpecialCells(Microsoft.Office.Interop.Excel.XlCellType.xlCellTypeBlanks).Select
- 'xlApp.CutCopyMode = False
- 'xlApp.Selection.FormulaR1C1 = "=R[-1]C"
- 'End If
-
- Dim my_card As String
- Dim my_no As String
- Dim my_nw As String
- Dim my_gw As String
- Dim my_name As String
- Dim my_po As String
- Dim my_price As String
- Dim s1 As String = 1
- Dim my_skuno As String
- Dim my_order_item As String
-
-
-
- For y = 14 To y - 1
-
-
- If y = 14 Then
-
- my_no = xlSheet.Cells(y, 1).value
- my_order_item = xlSheet.Cells(y, 1).value
- my_name = xlSheet.Cells(y, 2).value
- my_card = xlSheet.Cells(y, 5).value
- my_nw = xlSheet.Cells(y, 6).value
- my_gw = xlSheet.Cells(y, 7).value
- my_po = xlSheet.Cells(y, 8).value
- my_skuno = xlSheet.Cells(y, 12).value
-
-
- End If
-
-
- If xlSheet.Cells(y, 1).value Is Nothing And xlSheet.Cells(y, 3).value Is Nothing And xlSheet.Cells(y, 8).value Is Nothing And xlSheet.Cells(y, 10).value Is Nothing Then
-
- Else
-
- If xlSheet.Cells(y, 10).value Is Nothing Then
-
- Else
-
-
-
- If xlSheet.Cells(y, 3).value Is Nothing And xlSheet.Cells(y, 6).value Is Nothing And xlSheet.Cells(y, 7).value Is Nothing Then
-
-
-
-
- my_name = xlSheet.Cells(y, 2).value
- my_po = xlSheet.Cells(y, 8).value
-
-
-
-
-
-
- Else
- my_no = xlSheet.Cells(y, 1).value
- my_name = xlSheet.Cells(y, 2).value
- my_po = xlSheet.Cells(y, 8).value
- my_nw = xlSheet.Cells(y, 6).value
- my_gw = xlSheet.Cells(y, 7).value
-
-
-
-
- End If
-
- If xlSheet.Cells(y, 16).value Is Nothing Then
- my_price = 0
- ListBox2.Items.Add(my_no & "_" & my_name & "_" & xlSheet.Cells(y, 10).value & " 无单价")
- Else
- my_price = xlSheet.Cells(y, 16).value
- End If
-
-
- If my_nw Is Nothing Then my_nw = 0
- If my_gw Is Nothing Then my_gw = 0
-
- sql = "insert into rt_ship_daily_uz_1 (order_item,filename,sku_no,serial,card,no,name,nw,gw,po_no,qty_sf1,unit_price) values('" & xlSheet.Cells(y, 9).value & "',N'" & file_name & "','" & my_skuno & "','" & s1 & "','" & xlSheet.Cells(y, 5).value & "','" & my_no & "',N'" & my_name & "'," & my_nw & "," & my_gw & ",'" & my_po & "'," & xlSheet.Cells(y, 10).value & "," & my_price & ")"
-
-
- cmd.CommandText = sql
- cmd.ExecuteScalar()
- s1 = s1 + 1
-
-
-
-
- End If
- End If
-
-
- Next
-
-
- 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
- (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 净重
- FROM RT_SHIP_DAILY_UZ_1) as p group by 品名,po_no,厚度" '----旧
-
-
-
- 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"
-
-
-
- cmd.CommandText = sql
- dt = New DataTable
- da.SelectCommand = cmd
- da.Fill(dt)
-
- dt.Columns.Add("发货单号")
-
-
- dgv1.DataSource = dt
-
-
- dgv1.Columns("品名").Width = 300
- dgv1.Columns("订单号").Width = 120
- dgv1.Columns("项次号").Width = 80
- dgv1.Columns("尺数").Width = 120
-
-
-
-
-
-
- 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
- (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 净重
- FROM RT_SHIP_DAILY_UZ_1) as p group by 品名,po_no,厚度) as q group by 品名,厚度 order by 品名"
-
- cmd.CommandText = sql
- dt = New DataTable
- da.SelectCommand = cmd
- da.Fill(dt)
-
-
- dgv2.DataSource = dt
-
-
-
-
-
- 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
- (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 净重
- FROM RT_SHIP_DAILY_UZ_1) as p group by 品名,po_no,厚度) as q group by 品名 order by 品名"
-
- cmd.CommandText = sql
- dt = New DataTable
- da.SelectCommand = cmd
- da.Fill(dt)
-
-
- dgv3.DataSource = dt
-
-
-
-
-
- ElseIf OpenFileDialog1.SafeFileName Like "*亿博样*" And Not (OpenFileDialog1.SafeFileName Like "*华盛*") Then
-
- sql = "delete from rt_ship_daily_yby"
- cmd.CommandText = sql
- cmd.ExecuteNonQuery()
-
-
- Dim s1 As Integer = 0
- Dim my_no As Integer
-
-
- For i = 1 To xlApp.Worksheets.Count
-
-
- If xlApp.Workbooks(1).Worksheets(i).name = "1" Then
- xlSheet = xlApp.Workbooks(1).Worksheets(i)
- xlSheet.Activate()
- Exit For
- End If
-
-
-
- Next
-
-
-
-
-
-
- Dim y As Integer = 0
- For y = 2 To xlApp.ActiveSheet.UsedRange.Rows.Count
-
- If xlSheet.Cells(y, 2).value = "合计:" Then
- Exit For
- End If
-
- Next y
-
-
- xlApp.Range("A2:i" & y - 1).Select()
- ' If xlApp.Selection.mergecells = True Then
-
- xlApp.Selection.UnMerge
-
-
- 'xlApp.Selection.SpecialCells(Microsoft.Office.Interop.Excel.XlCellType.xlCellTypeBlanks).Select
- 'xlApp.CutCopyMode = False
- 'xlApp.Selection.FormulaR1C1 = "=R[-1]C"
-
- 'End If
-
-
- s1 = 1
- For y = 2 To y - 1
-
-
-
-
- If xlSheet.Cells(y, 1).value Is Nothing Then
-
- Else
- my_no = xlSheet.Cells(y, 1).value
- End If
-
-
-
- sql = "insert into rt_ship_daily_yby (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 & "')"
- cmd.CommandText = sql
- cmd.ExecuteScalar()
- s1 = s1 + 1
-
-
- Next
-
-
- 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 厚度
- FROM RT_SHIP_DAILY_YB ) as p group by 订单号,厚度" '旧
-
- 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"
-
- cmd.CommandText = sql
- dt = New DataTable
- da.SelectCommand = cmd
- da.Fill(dt)
-
- dgv1.DataSource = dt
-
- dgv1.Columns("品名").Width = 350
- dgv1.Columns("订单号").Width = 150
-
-
-
-
-
- ElseIf OpenFileDialog1.SafeFileName Like "亿博*" And Not (OpenFileDialog1.SafeFileName Like "*亿博样*") Then
-
-
- sql = "delete from rt_ship_daily_yb"
- cmd.CommandText = sql
- cmd.ExecuteNonQuery()
-
-
- Dim s1 As Integer = 0
- Dim my_no As Integer
-
-
- For i = 1 To xlApp.Worksheets.Count
-
-
- If xlApp.Workbooks(1).Worksheets(i).name = "1" Then
- xlSheet = xlApp.Workbooks(1).Worksheets(i)
- xlSheet.Activate()
- Exit For
- End If
-
-
-
- Next
-
-
-
-
-
-
- Dim y As Integer = 0
- For y = 2 To xlApp.ActiveSheet.UsedRange.Rows.Count
-
- If xlSheet.Cells(y, 2).value = "合计:" Then
- Exit For
- End If
-
- Next y
-
-
- xlApp.Range("A2:i" & y - 1).Select()
- ' If xlApp.Selection.mergecells = True Then
-
- xlApp.Selection.UnMerge
-
-
- xlApp.Selection.SpecialCells(Microsoft.Office.Interop.Excel.XlCellType.xlCellTypeBlanks).Select
- xlApp.CutCopyMode = False
- xlApp.Selection.FormulaR1C1 = "=R[-1]C"
-
- 'End If
-
-
- s1 = 1
- For y = 2 To y - 1
-
-
-
-
- If xlSheet.Cells(y, 1).value Is Nothing Then
-
- Else
- my_no = xlSheet.Cells(y, 1).value
- End If
-
-
-
- sql = "insert into rt_ship_daily_yb (serial,filename,no,name,qty,nw,gw,po_no,unit_price) 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 & "',0)"
- cmd.CommandText = sql
- cmd.ExecuteScalar()
- s1 = s1 + 1
-
-
- Next
-
-
- 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 厚度
- FROM RT_SHIP_DAILY_YB ) as p group by 订单号,厚度" '旧
-
- sql = "SELECT name as 品名,po_no as 订单号, cast(sum(qty) as numeric(10,1)) as 尺数,deli_no as 发货单号 from RT_SHIP_DAILY_YB group by po_no,name,deli_no"
-
- cmd.CommandText = sql
- dt = New DataTable
- da.SelectCommand = cmd
- da.Fill(dt)
-
- dgv1.DataSource = dt
-
- dgv1.Columns("品名").Width = 350
- dgv1.Columns("订单号").Width = 150
-
-
-
-
-
- ' 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 厚度
- 'FROM RT_SHIP_DAILY_YB) as p group by 订单号,类别,厚度"
-
- ' cmd.CommandText = sql
- ' dt = New DataTable
- ' da.SelectCommand = cmd
- ' da.Fill(dt)
-
-
- ' dgv2.DataSource = dt
-
-
- ' 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 厚度
- 'FROM RT_SHIP_DAILY_YB) as p group by 订单号,类别,厚度) as q group by 类别"
-
- ' cmd.CommandText = sql
- ' dt = New DataTable
- ' da.SelectCommand = cmd
- ' da.Fill(dt)
-
-
- ' dgv3.DataSource = dt
-
-
-
-
- ' 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
- 'FROM RT_SHIP_DAILY_PUMA) as p group by name"
-
- ' cmd.CommandText = sql
- ' dt = New DataTable
- ' da.SelectCommand = cmd
- ' da.Fill(dt)
-
-
-
-
-
-
-
-
-
-
- 'sql = ""
-
-
- 'cmd.CommandText = sql
- 'dt = New DataTable
- 'da.SelectCommand = cmd
- 'da.Fill(dt)
-
-
- 'dgv2.DataSource = dt
-
-
-
-
-
-
-
-
-
- ElseIf OpenFileDialog1.SafeFileName Like "加和*" Then
-
-
-
- sql = "delete from rt_ship_daily_jh"
- cmd.CommandText = sql
- cmd.ExecuteNonQuery()
-
-
- For i = 1 To xlApp.Worksheets.Count
-
-
- If xlApp.Workbooks(1).Worksheets(i).name = "加和" Then
- xlSheet = xlApp.Workbooks(1).Worksheets(i)
- xlSheet.Activate()
- Exit For
- End If
-
-
-
- Next
-
-
-
-
- Dim y As Integer = 0
- For y = 4 To xlApp.ActiveSheet.UsedRange.Rows.Count
-
- If Len(xlSheet.Cells(y, 5).value) < 1 Then
- Exit For
- End If
-
- Next y
-
-
- xlApp.Range("A4:m" & y - 1).Select()
-
- ' If xlApp.Selection.mergecells = True Then
- xlApp.Selection.UnMerge
- 'xlApp.Selection.SpecialCells(Microsoft.Office.Interop.Excel.XlCellType.xlCellTypeBlanks).Select
- 'xlApp.CutCopyMode = False
- 'xlApp.Selection.FormulaR1C1 = "=R[-1]C"
- ' End If
-
-
- For y = 4 To y - 1
-
- sql = "insert into rt_ship_daily_jh (no1,po_no,m_no,name,thick,
- color,qty_sf,nw,gw,no2) values('" &
- xlSheet.Cells(y, 1).value & "',N'" & xlSheet.Cells(y, 2).value & "','" & xlSheet.Cells(y, 4).value & "',N'" & xlSheet.Cells(y, 5).value & "','" & xlSheet.Cells(y, 6).value &
- "',N'" & xlSheet.Cells(y, 7).value & "'," & xlSheet.Cells(y, 8).value & "," & xlSheet.Cells(y, 11).value & "," & xlSheet.Cells(y, 12).value & "," & xlSheet.Cells(y, 10).value & ")"
- cmd.CommandText = sql
- cmd.ExecuteScalar()
-
-
-
- Next
-
-
- ' sql = "select po_no as 订单号,m_no as 料号,name as 品名, color as 颜色,thick as 厚度,cast(sum(qty_sf) as numeric(10,1)) as 尺数,cast(sum(weight) as numeric(10,1)) as 净重 from (SELECT no1, po_no, no2, m_no, name, ltrim(thick) as thick, color, qty_sf, nw, gw,cast(qty_sf/SUM(qty_sf) OVER (PARTITION BY no1) *nw as numeric(10,1)) as weight
- ' FROM RT_SHIP_DAILY_JH) as p group by po_no,m_no,name,color,thick"
-
- ' cmd.CommandText = sql
- ' dt = New DataTable
- ' da.SelectCommand = cmd
- ' da.Fill(dt)
-
- ' dgv1.DataSource = dt
-
-
-
-
- ' sql = "select po_no as 订单号,thick as 厚度,cast(sum(qty_sf) as numeric(10,1)) as 尺数,cast(sum(weight) as numeric(10,1)) as 净重 from (SELECT no1, po_no, no2, m_no, name, ltrim(thick) as thick, color, qty_sf, nw, gw,cast(qty_sf/SUM(qty_sf) OVER (PARTITION BY no1) *nw as numeric(10,1)) as weight FROM RT_SHIP_DAILY_JH) as p group by po_no,thick"
-
- ' cmd.CommandText = sql
- ' dt = New DataTable
- ' da.SelectCommand = cmd
- ' da.Fill(dt)
-
- ' dgv2.DataSource = dt
-
-
-
-
- ' sql = "select 品名,thick as 厚度, cast(sum(qty_sf) as numeric(10,1)) as 尺数,sum(weight) as 净重 from (SELECT no1, po_no, no2, m_no, name, ltrim(thick) as thick, color, qty_sf, nw, gw,cast(qty_sf/SUM(qty_sf) OVER (PARTITION BY no1) *nw as numeric(10,1)) as weight,case when name like '%PU%' or name like N'%纹%' or name like '%action%' or name like N'%榔%' then 'pu' else '反毛' end as 品名
- 'FROM RT_SHIP_DAILY_JH) as p group by 品名,thick"
-
- ' cmd.CommandText = sql
- ' dt = New DataTable
- ' da.SelectCommand = cmd
- ' da.Fill(dt)
-
-
- ' dgv3.DataSource = dt
-
-
-
- sql = "SELECT no1, po_no, no2, m_no, name, ltrim(thick) as thick, color, qty_sf, nw, gw,cast(qty_sf/SUM(qty_sf) OVER (PARTITION BY no1) *nw as numeric(10,1)) as weight,
- case when name like '%PU%' or name like N'%纹%' or name like '%action%' or name like N'%榔%' then 'pu' else '反毛' end as 品名
- FROM RT_SHIP_DAILY_JH"
-
- cmd.CommandText = sql
- dt = New DataTable
- da.SelectCommand = cmd
- da.Fill(dt)
-
-
- dgv1.DataSource = dt
-
-
-
-
-
-
- ElseIf OpenFileDialog1.SafeFileName Like "吉兴*" Then
-
-
-
- sql = "delete from rt_ship_daily_JX"
- cmd.CommandText = sql
- cmd.ExecuteNonQuery()
-
-
- 'For i = 1 To xlApp.Worksheets.Count
-
-
- ' If xlApp.Workbooks(1).Worksheets(i).name = "0" Then
- ' Exit For
- ' End If
-
-
-
- 'Next
-
-
- xlSheet = xlApp.Workbooks(1).Worksheets(1)
- xlSheet.Activate()
-
-
-
- Dim y As Integer = 0
- For y = 8 To xlApp.ActiveSheet.UsedRange.Rows.Count
-
- If Len(xlSheet.Cells(y, 2).value) < 1 Then
- Exit For
- End If
-
- Next y
-
-
- xlApp.Range("A2:u" & y - 1).Select()
-
-
- xlApp.Selection.UnMerge
-
-
- xlApp.Selection.SpecialCells(Microsoft.Office.Interop.Excel.XlCellType.xlCellTypeBlanks).Select
- xlApp.CutCopyMode = False
- xlApp.Selection.FormulaR1C1 = "=R[-1]C"
-
-
-
- For y = 8 To y - 1
-
- 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 & "')"
- cmd.CommandText = sql
- cmd.ExecuteScalar()
-
-
-
- Next
-
-
- sql = "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 订单号,类别,厚度"
-
- cmd.CommandText = sql
- dt = New DataTable
- da.SelectCommand = cmd
- da.Fill(dt)
-
- dgv1.DataSource = dt
-
-
-
-
- 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 类别"
-
- cmd.CommandText = sql
- dt = New DataTable
- da.SelectCommand = cmd
- da.Fill(dt)
-
-
- dgv2.DataSource = dt
-
-
- ElseIf OpenFileDialog1.SafeFileName Like "*PEI HAI*" Then
-
-
- sql = "delete from rt_ship_daily_xbh"
- cmd.CommandText = sql
- cmd.ExecuteNonQuery()
-
-
- Dim s1 As Integer = 0
- Dim my_no As Integer
-
-
- For i = 1 To xlApp.Worksheets.Count
-
-
- If xlApp.Workbooks(1).Worksheets(i).name = "1" Then
- xlSheet = xlApp.Workbooks(1).Worksheets(i)
- xlSheet.Activate()
- Exit For
- End If
-
-
-
- Next
-
-
-
-
-
-
- Dim y As Integer = 0
- For y = 2 To xlApp.ActiveSheet.UsedRange.Rows.Count
-
- If xlSheet.Cells(y, 2).value Is Nothing Then
- Exit For
- End If
-
- Next y
-
-
- xlApp.Range("A2:J" & y - 1).Select()
- ' If xlApp.Selection.mergecells = True Then
-
- xlApp.Selection.UnMerge
-
-
- xlApp.Selection.SpecialCells(Microsoft.Office.Interop.Excel.XlCellType.xlCellTypeBlanks).Select
- xlApp.CutCopyMode = False
- xlApp.Selection.FormulaR1C1 = "=R[-1]C"
-
- 'End If
-
-
- s1 = 1
- For y = 2 To y - 1
-
-
-
-
- If xlSheet.Cells(y, 1).value Is Nothing Then
-
- Else
- my_no = xlSheet.Cells(y, 1).value
- End If
-
-
-
- sql = "insert into rt_ship_daily_xbh (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 & "')"
- cmd.CommandText = sql
- cmd.ExecuteScalar()
- s1 = s1 + 1
-
-
- Next
-
-
- 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 厚度
- FROM RT_SHIP_DAILY_YB ) as p group by 订单号,厚度" '旧
-
- sql = "SELECT name as 品名,po_no as 订单号, cast(sum(qty) as numeric(10,1)) as 尺数,deli_no as 发货单号 from RT_SHIP_DAILY_xbh group by po_no,name,deli_no"
-
- cmd.CommandText = sql
- dt = New DataTable
- da.SelectCommand = cmd
- da.Fill(dt)
-
- dgv1.DataSource = dt
-
- dgv1.Columns("品名").Width = 400
- dgv1.Columns("订单号").Width = 150
-
-
-
- ElseIf OpenFileDialog1.SafeFileName Like "*锐奇*" Then
-
-
- sql = "delete from rt_ship_daily_ruiqi"
- cmd.CommandText = sql
- cmd.ExecuteNonQuery()
-
-
- Dim s1 As Integer = 0
- Dim my_no As Integer
-
-
- For i = 1 To xlApp.Worksheets.Count
-
-
- If xlApp.Workbooks(1).Worksheets(i).name = "1" Then
- xlSheet = xlApp.Workbooks(1).Worksheets(i)
- xlSheet.Activate()
- Exit For
- End If
-
-
-
- Next
-
-
-
-
-
-
- Dim y As Integer = 0
- For y = 2 To xlApp.ActiveSheet.UsedRange.Rows.Count
-
- If xlSheet.Cells(y, 2).value Is Nothing Then
- Exit For
- End If
-
- Next y
-
-
- xlApp.Range("A2:h" & y - 1).Select()
- ' If xlApp.Selection.mergecells = True Then
-
- xlApp.Selection.UnMerge
-
-
-
-
- 'End If
-
-
- s1 = 1
- For y = 2 To y - 1
-
-
-
-
- If xlSheet.Cells(y, 1).value Is Nothing Then
-
- Else
- my_no = xlSheet.Cells(y, 1).value
- End If
-
-
-
- sql = "insert into rt_ship_daily_ruiqi (serial,filename,no,name,qty,po_no,work_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 & "')"
- cmd.CommandText = sql
- cmd.ExecuteScalar()
- s1 = s1 + 1
-
-
- Next
-
-
- 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 厚度
- FROM RT_SHIP_DAILY_YB ) as p group by 订单号,厚度" '旧
-
- 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"
-
- cmd.CommandText = sql
- dt = New DataTable
- da.SelectCommand = cmd
- da.Fill(dt)
-
- dgv1.DataSource = dt
-
- dgv1.Columns("品名").Width = 300
- dgv1.Columns("采购号").Width = 150
- dgv1.Columns("订单号").Width = 200
-
- ElseIf OpenFileDialog1.SafeFileName Like "宏美*" Then
- ElseIf OpenFileDialog1.SafeFileName Like "*HATAY*" Then
- ElseIf OpenFileDialog1.SafeFileName Like "宏美*" Then
- ElseIf OpenFileDialog1.SafeFileName Like "*亿博*" And OpenFileDialog1.SafeFileName Like "*华盛*" Then
-
- sql = "delete from rt_ship_daily_yby_huasheng"
- cmd.CommandText = sql
- cmd.ExecuteNonQuery()
-
-
- Dim s1 As Integer = 0
- Dim my_no As Integer
-
-
- For i = 1 To xlApp.Worksheets.Count
-
-
- If xlApp.Workbooks(1).Worksheets(i).name = "明细" Then
- xlSheet = xlApp.Workbooks(1).Worksheets(i)
- xlSheet.Activate()
- Exit For
- End If
-
-
-
- Next
-
-
-
-
-
-
- Dim y As Integer = 0
- For y = 2 To xlApp.ActiveSheet.UsedRange.Rows.Count
-
- If xlSheet.Cells(y, 2).value = "合计:" Then
- Exit For
- End If
-
- Next y
-
-
- xlApp.Range("A2:i" & y - 1).Select()
- ' If xlApp.Selection.mergecells = True Then
-
- xlApp.Selection.UnMerge
-
-
- xlApp.Selection.SpecialCells(Microsoft.Office.Interop.Excel.XlCellType.xlCellTypeBlanks).Select
- xlApp.CutCopyMode = False
- xlApp.Selection.FormulaR1C1 = "=R[-1]C"
-
- 'End If
-
-
- s1 = 1
- For y = 2 To y - 1
-
-
-
-
- If xlSheet.Cells(y, 1).value Is Nothing Then
-
- Else
- my_no = xlSheet.Cells(y, 1).value
- End If
-
-
-
- sql = "insert into rt_ship_daily_yby_huasheng (serial,filename,no,name,qty,nw,gw,po_no,thick) values('" & s1 & "',N'" & file_name & "','" & my_no & "',N'" & xlSheet.Cells(y, 2).value & "'," & xlSheet.Cells(y, 4).value & "," & xlSheet.Cells(y, 7).value & "," & xlSheet.Cells(y, 8).value & ",N'" & xlSheet.Cells(y, 9).value & "','" & xlSheet.Cells(y, 3).value & "')"
- cmd.CommandText = sql
- cmd.ExecuteScalar()
- s1 = s1 + 1
-
-
- Next
-
-
- 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 厚度
- FROM RT_SHIP_DAILY_YB ) as p group by 订单号,厚度" '旧
-
- 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"
-
- cmd.CommandText = sql
- dt = New DataTable
- da.SelectCommand = cmd
- da.Fill(dt)
-
- dgv1.DataSource = dt
-
- dgv1.Columns("品名").Width = 350
- dgv1.Columns("订单号").Width = 150
-
- ElseIf OpenFileDialog1.SafeFileName Like "EVERGREE*" Then
-
- sql = "delete from rt_ship_daily_evergree"
- cmd.CommandText = sql
- cmd.ExecuteNonQuery()
-
-
- Dim s1 As Integer = 0
- Dim my_no As Integer
-
-
- For i = 1 To xlApp.Worksheets.Count
-
-
- If xlApp.Workbooks(1).Worksheets(i).name = "1" Then
- xlSheet = xlApp.Workbooks(1).Worksheets(i)
- xlSheet.Activate()
- Exit For
- End If
-
-
-
- Next
-
-
-
-
-
-
- Dim y As Integer = 0
- For y = 2 To xlApp.ActiveSheet.UsedRange.Rows.Count
-
- If xlSheet.Cells(y, 2).value Is Nothing Then
- Exit For
- End If
-
- Next y
-
-
- xlApp.Range("A2:J" & y - 1).Select()
- ' If xlApp.Selection.mergecells = True Then
-
- xlApp.Selection.UnMerge
-
-
- xlApp.Selection.SpecialCells(Microsoft.Office.Interop.Excel.XlCellType.xlCellTypeBlanks).Select
- xlApp.CutCopyMode = False
- xlApp.Selection.FormulaR1C1 = "=R[-1]C"
-
- 'End If
-
-
- s1 = 1
- For y = 2 To y - 1
-
-
-
-
- If xlSheet.Cells(y, 1).value Is Nothing Then
-
- Else
- my_no = xlSheet.Cells(y, 1).value
- End If
-
-
-
- sql = "insert into rt_ship_daily_evergree (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 & "')"
- cmd.CommandText = sql
- cmd.ExecuteScalar()
- s1 = s1 + 1
-
-
- Next
-
-
- 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 厚度
- FROM RT_SHIP_DAILY_YB ) as p group by 订单号,厚度" '旧
-
- sql = "SELECT name as 品名,po_no as 订单号, cast(sum(qty) as numeric(10,1)) as 尺数,deli_no as 发货单号 from RT_SHIP_DAILY_evergree group by po_no,name,deli_no"
-
- cmd.CommandText = sql
- dt = New DataTable
- da.SelectCommand = cmd
- da.Fill(dt)
-
- dgv1.DataSource = dt
-
- dgv1.Columns("品名").Width = 400
- dgv1.Columns("订单号").Width = 150
- ElseIf OpenFileDialog1.SafeFileName Like "*THANH*" Then
-
- sql = "delete from rt_ship_daily_thanhhu"
- cmd.CommandText = sql
- cmd.ExecuteNonQuery()
-
-
- Dim s1 As Integer = 0
- Dim my_no As Integer
-
-
- For i = 1 To xlApp.Worksheets.Count
-
-
- If xlApp.Workbooks(1).Worksheets(i).name = "1" Then
- xlSheet = xlApp.Workbooks(1).Worksheets(i)
- xlSheet.Activate()
- Exit For
- End If
-
-
-
- Next
-
-
-
-
-
-
- Dim y As Integer = 0
- For y = 2 To xlApp.ActiveSheet.UsedRange.Rows.Count
-
- If xlSheet.Cells(y, 2).value Is Nothing Then
- Exit For
- End If
-
- Next y
-
-
- xlApp.Range("A2:J" & y - 1).Select()
- ' If xlApp.Selection.mergecells = True Then
-
- xlApp.Selection.UnMerge
-
-
- xlApp.Selection.SpecialCells(Microsoft.Office.Interop.Excel.XlCellType.xlCellTypeBlanks).Select
- xlApp.CutCopyMode = False
- xlApp.Selection.FormulaR1C1 = "=R[-1]C"
-
- 'End If
-
-
- s1 = 1
- For y = 2 To y - 1
-
-
-
-
- If xlSheet.Cells(y, 1).value Is Nothing Then
-
- Else
- my_no = xlSheet.Cells(y, 1).value
- End If
-
-
-
- sql = "insert into rt_ship_daily_thanhhu (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 & "')"
- cmd.CommandText = sql
- cmd.ExecuteScalar()
- s1 = s1 + 1
-
-
- Next
-
-
- 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 厚度
- FROM RT_SHIP_DAILY_YB ) as p group by 订单号,厚度" '旧
-
- 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"
-
- cmd.CommandText = sql
- dt = New DataTable
- da.SelectCommand = cmd
- da.Fill(dt)
-
- dgv1.DataSource = dt
-
- dgv1.Columns("品名").Width = 400
- dgv1.Columns("订单号").Width = 150
-
-
-
-
-
- ElseIf OpenFileDialog1.SafeFileName Like "PROPER*" Then
-
- sql = "delete from rt_ship_daily_PROPERWELL"
- cmd.CommandText = sql
- cmd.ExecuteNonQuery()
-
-
- Dim s1 As Integer = 0
- Dim my_no As Integer
-
-
- For i = 1 To xlApp.Worksheets.Count
-
-
- If xlApp.Workbooks(1).Worksheets(i).name = "1" Then
- xlSheet = xlApp.Workbooks(1).Worksheets(i)
- xlSheet.Activate()
- Exit For
- End If
-
-
-
- Next
-
-
-
-
-
-
- Dim y As Integer = 0
- For y = 2 To xlApp.ActiveSheet.UsedRange.Rows.Count
-
- If xlSheet.Cells(y, 2).value Is Nothing Then
- Exit For
- End If
-
- Next y
-
-
- xlApp.Range("A2:J" & y - 1).Select()
- ' If xlApp.Selection.mergecells = True Then
-
- xlApp.Selection.UnMerge
-
-
- xlApp.Selection.SpecialCells(Microsoft.Office.Interop.Excel.XlCellType.xlCellTypeBlanks).Select
- xlApp.CutCopyMode = False
- xlApp.Selection.FormulaR1C1 = "=R[-1]C"
-
- 'End If
-
-
- s1 = 1
- For y = 2 To y - 1
-
-
-
-
- If xlSheet.Cells(y, 1).value Is Nothing Then
-
- Else
- my_no = xlSheet.Cells(y, 1).value
- End If
-
-
-
- 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 & "')"
- cmd.CommandText = sql
- cmd.ExecuteScalar()
- s1 = s1 + 1
-
-
- Next
-
-
- 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 厚度
- FROM RT_SHIP_DAILY_YB ) as p group by 订单号,厚度" '旧
-
- 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"
-
- cmd.CommandText = sql
- dt = New DataTable
- da.SelectCommand = cmd
- da.Fill(dt)
-
- dgv1.DataSource = dt
-
- dgv1.Columns("品名").Width = 400
- dgv1.Columns("订单号").Width = 150
-
- ElseIf OpenFileDialog1.SafeFileName Like "*STELLA*" Then
- sql = "delete from rt_ship_daily_STELLA"
- cmd.CommandText = sql
- cmd.ExecuteNonQuery()
-
-
- Dim s1 As Integer = 0
- Dim my_no As Integer
-
-
- For i = 1 To xlApp.Worksheets.Count
-
-
- If xlApp.Workbooks(1).Worksheets(i).name = "1" Then
- xlSheet = xlApp.Workbooks(1).Worksheets(i)
- xlSheet.Activate()
- Exit For
- End If
-
-
-
- Next
-
-
-
-
-
-
- Dim y As Integer = 0
- For y = 2 To xlApp.ActiveSheet.UsedRange.Rows.Count
-
- If xlSheet.Cells(y, 2).value Is Nothing Then
- Exit For
- End If
-
- Next y
-
-
- xlApp.Range("A2:J" & y - 1).Select()
- ' If xlApp.Selection.mergecells = True Then
-
- xlApp.Selection.UnMerge
-
-
- xlApp.Selection.SpecialCells(Microsoft.Office.Interop.Excel.XlCellType.xlCellTypeBlanks).Select
- xlApp.CutCopyMode = False
- xlApp.Selection.FormulaR1C1 = "=R[-1]C"
-
- 'End If
-
-
- s1 = 1
- For y = 2 To y - 1
-
-
-
-
- If xlSheet.Cells(y, 1).value Is Nothing Then
-
- Else
- my_no = xlSheet.Cells(y, 1).value
- End If
-
-
-
- sql = "insert into rt_ship_daily_stella (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 & "')"
- cmd.CommandText = sql
- cmd.ExecuteScalar()
- s1 = s1 + 1
-
-
- Next
-
-
- 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 厚度
- FROM RT_SHIP_DAILY_YB ) as p group by 订单号,厚度" '旧
-
- sql = "SELECT name as 品名,po_no as 订单号, cast(sum(qty) as numeric(10,1)) as 尺数,deli_no as 发货单号 from RT_SHIP_DAILY_stella group by po_no,name,deli_no"
-
- cmd.CommandText = sql
- dt = New DataTable
- da.SelectCommand = cmd
- da.Fill(dt)
-
- dgv1.DataSource = dt
-
- dgv1.Columns("品名").Width = 400
- dgv1.Columns("订单号").Width = 150
-
- ElseIf OpenFileDialog1.SafeFileName Like "*HATAY*" Then
-
-
-
- sql = "delete from rt_ship_daily_HATAY"
- cmd.CommandText = sql
- cmd.ExecuteNonQuery()
-
-
- 'For i = 1 To xlApp.Worksheets.Count
-
-
- ' If xlApp.Workbooks(1).Worksheets(i).name = "0" Then
- ' Exit For
- ' End If
-
-
-
- 'Next
-
-
- xlSheet = xlApp.Workbooks(1).Worksheets(1)
- xlSheet.Activate()
-
-
-
- Dim y As Integer = 0
- For y = 2 To xlApp.ActiveSheet.UsedRange.Rows.Count
-
- If Len(xlSheet.Cells(y, 2).value) < 1 Then
- Exit For
- End If
-
- Next y
-
-
- xlApp.Range("A2:j" & y - 1).Select()
-
-
- xlApp.Selection.UnMerge
-
-
- xlApp.Selection.SpecialCells(Microsoft.Office.Interop.Excel.XlCellType.xlCellTypeBlanks).Select
- xlApp.CutCopyMode = False
- xlApp.Selection.FormulaR1C1 = "=R[-1]C"
-
-
-
- For y = 2 To y - 1
-
- sql = "insert into rt_ship_daily_HATAY (no,name,qty,nw,gw,po_no) 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 & "')"
- cmd.CommandText = sql
- cmd.ExecuteScalar()
-
-
-
- Next
-
-
- sql = "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_HATAY) as p group by 订单号,类别,厚度"
-
- cmd.CommandText = sql
- dt = New DataTable
- da.SelectCommand = cmd
- da.Fill(dt)
-
- dgv1.DataSource = dt
-
-
-
-
- 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_HATAY) as p group by 订单号,类别,厚度) as q group by 类别"
-
- cmd.CommandText = sql
- dt = New DataTable
- da.SelectCommand = cmd
- da.Fill(dt)
-
-
- dgv2.DataSource = dt
-
-
-
-
- ElseIf OpenFileDialog1.SafeFileName Like "东治*" Then
- ElseIf OpenFileDialog1.SafeFileName Like "东家*" Then
-
-
- sql = "delete from rt_ship_daily_dj"
- cmd.CommandText = sql
- cmd.ExecuteNonQuery()
-
-
- For i = 1 To xlApp.Worksheets.Count
-
-
- If xlApp.Workbooks(1).Worksheets(i).name = "0" Then
- xlSheet = xlApp.Workbooks(1).Worksheets(i)
- xlSheet.Activate()
- Exit For
- End If
-
-
-
- Next
-
-
-
-
-
-
- Dim y As Integer = 0
- For y = 2 To xlApp.ActiveSheet.UsedRange.Rows.Count
-
- If Len(xlSheet.Cells(y, 7).value) < 1 Then
- Exit For
- End If
-
- Next y
-
-
- xlApp.Range("A2:K" & y - 1).Select()
-
-
- xlApp.Selection.UnMerge
-
-
- xlApp.Selection.SpecialCells(Microsoft.Office.Interop.Excel.XlCellType.xlCellTypeBlanks).Select
- xlApp.CutCopyMode = False
- xlApp.Selection.FormulaR1C1 = "=R[-1]C"
-
-
-
- For y = 2 To y - 1
-
- 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 & ")"
- cmd.CommandText = sql
- cmd.ExecuteScalar()
-
-
-
- Next
-
-
- sql = "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 订单号,类别,厚度"
-
- cmd.CommandText = sql
- dt = New DataTable
- da.SelectCommand = cmd
- da.Fill(dt)
-
- dgv1.DataSource = dt
-
-
-
-
- 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 类别"
-
- cmd.CommandText = sql
- dt = New DataTable
- da.SelectCommand = cmd
- da.Fill(dt)
-
-
- dgv2.DataSource = dt
-
-
-
-
-
-
-
- ' 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
- 'FROM RT_SHIP_DAILY_PUMA) as p group by name"
-
- ' cmd.CommandText = sql
- ' dt = New DataTable
- ' da.SelectCommand = cmd
- ' da.Fill(dt)
-
-
-
-
-
-
-
-
-
-
- 'sql = ""
-
-
- 'cmd.CommandText = sql
- 'dt = New DataTable
- 'da.SelectCommand = cmd
- 'da.Fill(dt)
-
-
- 'dgv2.DataSource = dt
-
-
-
-
-
-
-
- ElseIf OpenFileDialog1.SafeFileName Like "*威弘*" Then
-
-
-
-
- sql = "delete from rt_ship_daily_wh"
- cmd.CommandText = sql
- cmd.ExecuteNonQuery()
-
- Dim s1 As Integer = 1
- Dim s11 As Integer = 1001
-
-
-
- For i = 1 To xlApp.Worksheets.Count
-
-
- xlSheet = xlApp.Worksheets(i)
- xlSheet.Activate()
-
-
-
- Dim y As Integer
- For y = xlApp.Workbooks(1).Worksheets(i).UsedRange.Rows.Count To 3 Step -1
-
- If xlSheet.Cells(y, 1).value = Nothing Then
- GoTo OK2
- End If
-
- If xlSheet.Cells(y, 1).value.ToString = "数量合计" Then
- Exit For
- End If
- OK2:
-
- Next y
-
- Dim yyy As Integer
-
- For yyy = 3 To xlApp.Workbooks(1).Worksheets(i).UsedRange.Rows.Count
-
- If xlSheet.Cells(yyy, 14).value = "制 表" Then
- Exit For
- End If
-
-
- Next yyy
-
-
-
-
-
-
-
- xlSheet.Range("A3:A" & y - 1).Select()
-
- xlApp.Selection.UnMerge
- 'xlApp.Selection.SpecialCells(Microsoft.Office.Interop.Excel.XlCellType.xlCellTypeBlanks).Select
- 'xlApp.CutCopyMode = False
- 'xlApp.Selection.FormulaR1C1 = "=R[-1]C"
-
- xlSheet.Range("c4:g" & y - 1).Select()
-
- xlApp.Selection.UnMerge
- 'xlApp.Selection.SpecialCells(Microsoft.Office.Interop.Excel.XlCellType.xlCellTypeBlanks).Select
- 'xlApp.CutCopyMode = False
- 'xlApp.Selection.FormulaR1C1 = "=R[-1]C"
-
-
- xlSheet.Range("k3:k" & yyy - 1).Select()
-
- xlApp.Selection.UnMerge
- 'xlApp.Selection.SpecialCells(Microsoft.Office.Interop.Excel.XlCellType.xlCellTypeBlanks).Select
- 'xlApp.CutCopyMode = False
- 'xlApp.Selection.FormulaR1C1 = "=R[-1]C"
-
-
- If xlSheet.Range("N3:Q" & yyy - 1).MergeCells.ToString <> "False" Then
-
- xlSheet.Range("N3:Q" & yyy - 1).Select()
-
- xlApp.Selection.UnMerge
- 'xlApp.Selection.SpecialCells(Microsoft.Office.Interop.Excel.XlCellType.xlCellTypeBlanks).Select
- 'xlApp.CutCopyMode = False
- 'xlApp.Selection.FormulaR1C1 = "=R[-1]C"
-
-
-
- End If
-
-
- Dim my_no As String
- Dim my_po As String
- Dim my_work As String
- Dim my_color As String
- Dim my_thick As String
- Dim my_no1 As String
- Dim my_po1 As String
- Dim my_work1 As String
- Dim my_color1 As String
- Dim my_thick1 As String
- Dim my_card As String
-
-
- For y = 3 To y - 1
-
-
-
-
- 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
- ' Exit For
- Else
- If xlSheet.Cells(y, 2).value Is Nothing Then
- Else
- If xlSheet.Cells(y, 4).VALUE Is Nothing Then
-
- If xlSheet.Cells(y, 1).value Is Nothing Then
-
- Else
- my_no = xlSheet.Cells(y, 1).value
- End If
-
-
-
- sql = "insert into rt_ship_daily_wh (filename,card,serial,no,sf,order_no,i_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 & "')"
- cmd.CommandText = sql
- cmd.ExecuteScalar()
- s1 = s1 + 1
-
- Else
-
- If xlSheet.Cells(y, 1).value Is Nothing Then
-
- Else
- my_no = xlSheet.Cells(y, 1).value
- End If
-
-
- my_po = xlSheet.Cells(y, 4).value
- my_work = xlSheet.Cells(y, 5).value
- my_color = xlSheet.Cells(y, 6).value
- my_thick = xlSheet.Cells(y, 7).value
-
- sql = "insert into rt_ship_daily_wh (filename,card,serial,no,sf,order_no,i_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 & "')"
- cmd.CommandText = sql
- cmd.ExecuteScalar()
- s1 = s1 + 1
-
- End If
- End If
- End If
-
-
-
- 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
-
- ' Exit For
- Else
-
- If xlSheet.Cells(y, 12).value Is Nothing Then
- Else
-
- If xlSheet.Cells(y, 14).VALUE Is Nothing Then
- If xlSheet.Cells(y, 11).value Is Nothing Then
- Else
- my_no1 = xlSheet.Cells(y, 11).value
- End If
- sql = "insert into rt_ship_daily_wh (filename,card,serial,no,sf,order_no,i_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 & "')"
- cmd.CommandText = sql
- cmd.ExecuteScalar()
- s11 = s11 + 1
-
- Else
- If xlSheet.Cells(y, 11).value Is Nothing Then
- Else
- my_no1 = xlSheet.Cells(y, 11).value
- End If
-
- my_po1 = xlSheet.Cells(y, 14).value
- my_work1 = xlSheet.Cells(y, 15).value
- my_color1 = xlSheet.Cells(y, 16).value
- my_thick1 = xlSheet.Cells(y, 17).value
-
- sql = "insert into rt_ship_daily_wh (filename,card,serial,no,sf,order_no,i_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 & "')"
- cmd.CommandText = sql
- cmd.ExecuteScalar()
- s11 = s11 + 1
-
- End If
-
-
-
- End If
-
-
- '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 & "')"
- 'cmd.CommandText = sql
- 'cmd.ExecuteScalar()
-
-
- End If
-
-
-
- Next
-
-
-
- Next
-
-
-
-
- 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 订单号, 指令号, 颜色"
- cmd.CommandText = sql
- dt = New DataTable
- da.SelectCommand = cmd
- da.Fill(dt)
- dgv1.DataSource = dt
-
- 'dt.Columns.Add("尺数")
- 'dt.Columns.Add("货值")
-
- sql = "SELECT 订单类别, 厚度, SUM(尺数) AS 尺数, 类别
- FROM (SELECT CASE WHEN LEFT(order_no, 2)
- = 'RT' THEN N'人民币' WHEN order_no LIKE 'SX%' THEN '美元' ELSE order_no END AS 订单类别,
- i_no AS 指令号, color AS 颜色, thick AS 厚度, CAST(SUM(sf) AS numeric(10, 1)) AS 尺数,
- CASE WHEN color LIKE '%pu%' OR
- color LIKE '%action%' OR
- color LIKE N'%纹%' THEN 'PU' ELSE '反毛' END AS 类别
- FROM RT_ship_daily_wh
- GROUP BY order_no, i_no, color, thick) AS p
- GROUP BY 订单类别, 厚度, 类别
- ORDER BY 订单类别"
- cmd.CommandText = sql
- dt = New DataTable
- da.SelectCommand = cmd
- da.Fill(dt)
- dgv2.DataSource = dt
-
-
- sql = "SELECT 订单类别, SUM(尺数) AS 尺数, 类别
- FROM (SELECT CASE WHEN LEFT(order_no, 2)
- = 'RT' THEN N'人民币' WHEN order_no LIKE 'SX%' THEN '美元' ELSE order_no END AS 订单类别,
- i_no AS 指令号, color AS 颜色, thick AS 厚度, CAST(SUM(sf) AS numeric(10, 1)) AS 尺数,
- CASE WHEN color LIKE '%pu%' OR
- color LIKE '%action%' OR
- color LIKE N'%纹%' THEN 'PU' ELSE '反毛' END AS 类别
- FROM RT_ship_daily_wh
- GROUP BY order_no, i_no, color, thick) AS p
- GROUP BY 订单类别, 类别 ORDER BY 订单类别"
- cmd.CommandText = sql
- dt = New DataTable
- da.SelectCommand = cmd
- da.Fill(dt)
- dgv3.DataSource = dt
-
-
-
-
-
- ElseIf OpenFileDialog1.SafeFileName Like "SAMIL*" Then
-
-
-
-
- sql = "delete from rt_ship_daily_samil"
- cmd.CommandText = sql
- cmd.ExecuteNonQuery()
-
-
- Dim s1 As Integer = 1
-
-
- 'For i = 1 To xlApp.Worksheets.Count
-
-
- ' If xlApp.Workbooks(1).Worksheets(i).name = "0" Then
- ' Exit For
- ' End If
-
-
-
- 'Next
-
-
- xlSheet = xlApp.Workbooks(1).Worksheets(1)
- xlSheet.Activate()
-
-
- Dim y As Integer = 0
- For y = 2 To xlApp.ActiveSheet.UsedRange.Rows.Count
-
- If Len(xlSheet.Cells(y, 2).value) < 1 Then
- Exit For
- End If
-
- Next y
-
- xlApp.Range("A2:j" & y - 1).Select()
-
- xlApp.Selection.UnMerge
-
- xlApp.Selection.SpecialCells(Microsoft.Office.Interop.Excel.XlCellType.xlCellTypeBlanks).Select
- xlApp.CutCopyMode = False
- xlApp.Selection.FormulaR1C1 = "=R[-1]C"
-
-
- For y = 2 To y - 1
-
- sql = "insert into rt_ship_daily_samil (serial,filename,card,no,name,qty,nw,gw,po_no) values('" & s1 & "',N'" & file_name & "','" & xlSheet.Cells(y, 6).value & "','" & xlSheet.Cells(y, 1).value & "',N'" & xlSheet.Cells(y, 2).value & "'," & xlSheet.Cells(y, 3).value & "," & xlSheet.Cells(y, 7).value & "," & xlSheet.Cells(y, 8).value & ",N'" & xlSheet.Cells(y, 9).value.ToString.Replace("'", "''") & "')"
- cmd.CommandText = sql
- cmd.ExecuteScalar()
-
-
-
- Next
-
-
- sql = "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 订单号,类别,厚度" '旧
-
-
- 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"
-
- cmd.CommandText = sql
- dt = New DataTable
- da.SelectCommand = cmd
- da.Fill(dt)
-
- dgv1.DataSource = dt
-
- dgv1.Columns("品名").Width = 350
- dgv1.Columns("订单号").Width = 180
-
-
-
-
-
- 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 类别"
-
- cmd.CommandText = sql
- dt = New DataTable
- da.SelectCommand = cmd
- da.Fill(dt)
-
-
- dgv2.DataSource = dt
-
-
-
-
-
-
- ElseIf OpenFileDialog1.SafeFileName Like "宏福*" Then '-----------------PUMA
-
-
-
- Dim conn1 As New SqlConnection
- conn1.ConnectionString = connstring
- conn1.Open()
- Dim cmd1 As New SqlCommand
- cmd1.Connection = conn1
- Dim dr As SqlDataReader
-
-
-
- sql = "delete from rt_ship_daily_puma"
- cmd.CommandText = sql
- cmd.ExecuteNonQuery()
-
-
- For i = 1 To xlApp.Worksheets.Count
-
-
- If xlApp.Workbooks(1).Worksheets(i).name = "1" Then
- xlSheet = xlApp.Workbooks(1).Worksheets(i)
- xlSheet.Activate()
- Exit For
- End If
-
-
-
- Next
-
-
-
-
-
-
- Dim y As Integer = 0
- For y = 4 To xlApp.ActiveSheet.UsedRange.Rows.Count
-
- If Len(xlSheet.Cells(y, 2).value) < 1 Then
- Exit For
- End If
-
- Next y
-
-
- xlApp.Range("A4:v" & y - 1).Select()
- 'If xlApp.Selection.mergecells = True Then
-
- xlApp.Selection.UnMerge
- xlApp.Selection.SpecialCells(Microsoft.Office.Interop.Excel.XlCellType.xlCellTypeBlanks).Select
- xlApp.CutCopyMode = False
- xlApp.Selection.FormulaR1C1 = "=R[-1]C"
-
- ' End If
-
- For y = 4 To y - 1
-
- 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 & "')"
- cmd.CommandText = sql
- cmd.ExecuteScalar()
-
-
-
- Next
-
-
- 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
- (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
- (select no,name,color,qty_sf,unit_price,po_no,gw1,cast(count as numeric(10,1)) as pa from
- (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
- FROM RT_SHIP_DAILY_PUMA) as r) as s) as t group by name,po_no order by 品名,po_no"
-
- cmd.CommandText = sql
- dt = New DataTable
- da.SelectCommand = cmd
- da.Fill(dt)
-
- dgv1.DataSource = dt
-
-
-
-
- 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
- (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
- (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
- (select no,name,color,qty_sf,unit_price,po_no,gw1,cast(count as numeric(10,2)) as pa from
- (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
- FROM RT_SHIP_DAILY_PUMA) as r) as s) as t group by name,po_no) as u) as v group by 品名"
-
- cmd.CommandText = sql
- dt = New DataTable
- da.SelectCommand = cmd
- da.Fill(dt)
-
-
- dgv2.DataSource = dt
-
-
-
-
-
-
- ' 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
- 'FROM RT_SHIP_DAILY_PUMA) as p group by name"
-
- ' cmd.CommandText = sql
- ' dt = New DataTable
- ' da.SelectCommand = cmd
- ' da.Fill(dt)
-
-
-
-
-
-
-
-
-
-
- 'sql = ""
-
-
- 'cmd.CommandText = sql
- 'dt = New DataTable
- 'da.SelectCommand = cmd
- 'da.Fill(dt)
-
-
- 'dgv2.DataSource = dt
-
-
-
- ElseIf OpenFileDialog1.SafeFileName Like "HATAY*" Then
- ElseIf OpenFileDialog1.SafeFileName Like "穎億*" Then
-
-
-
- sql = "delete from rt_ship_daily_yy"
- cmd.CommandText = sql
- cmd.ExecuteNonQuery()
-
-
- For i = 1 To xlApp.Worksheets.Count
-
-
- If xlApp.Workbooks(1).Worksheets(i).name = "0" Then
- xlSheet = xlApp.Workbooks(1).Worksheets(i)
- xlSheet.Activate()
- Exit For
- End If
- Next
-
- Dim y As Integer = 0
- For y = 2 To xlApp.ActiveSheet.UsedRange.Rows.Count
-
- If Len(xlSheet.Cells(y, 2).value) < 1 Then
- Exit For
- End If
-
- Next y
-
-
- 'xlApp.Range("A2:k" & y - 1).Select()
- ''If xlApp.Selection.mergecells = True Then
-
- 'xlApp.Selection.UnMerge
- 'xlApp.Selection.SpecialCells(Microsoft.Office.Interop.Excel.XlCellType.xlCellTypeBlanks).Select
- 'xlApp.CutCopyMode = False
- 'xlApp.Selection.FormulaR1C1 = "=R[-1]C"
-
- For y = 2 To y - 1
-
- sql = "insert into rt_ship_daily_yy (filename,no,name,pcs,qty,unit,
- nw,gw,po_no,work_no,supplier,coin) values(N'" & file_name & "','" &
- xlSheet.Cells(y, 1).value & "',N'" & xlSheet.Cells(y, 2).value & "','" & xlSheet.Cells(y, 3).value & "','" & xlSheet.Cells(y, 4).value & "','" &
- xlSheet.Cells(y, 5).value & "','" & xlSheet.Cells(y, 6).value & "','" & xlSheet.Cells(y, 7).value & "','" &
- xlSheet.Cells(y, 8).value & "','" & xlSheet.Cells(y, 9).value & "',N'" & xlSheet.Cells(y, 10).value & "','" &
- xlSheet.Cells(y, 11).value & "')"
- cmd.CommandText = sql
- cmd.ExecuteScalar()
-
-
-
- Next
-
- sql = "select name as 品名,cast(sum(qty) as numeric(10,1)) as 尺数,po_no as 订单号,work_no as 指令号,deli_no as 发货单号 from rt_ship_daily_yy group by name,po_no,work_no,deli_no"
-
- cmd.CommandText = sql
- dt = New DataTable
- da.SelectCommand = cmd
- da.Fill(dt)
-
- dgv1.DataSource = dt
-
- dgv1.Columns("品名").Width = 350
- dgv1.Columns("指令号").Width = 250
-
-
-
-
-
-
-
-
-
- ElseIf OpenFileDialog1.SafeFileName Like "澳孚*" Then
-
- sql = "delete from rt_ship_daily_af"
- cmd.CommandText = sql
- cmd.ExecuteNonQuery()
-
-
- xlSheet = xlApp.Workbooks(1).Worksheets(1)
-
- Dim y As Integer = 0
- For y = 2 To xlApp.Workbooks(1).Worksheets(1).UsedRange.Rows.Count
-
- If Len(xlSheet.Cells(y, 2).value) < 1 Then
- Exit For
- End If
-
- Next y
-
-
- xlApp.Range("A2:l" & y - 1).Select()
- ' If xlApp.Selection.mergecells = True Then
- xlApp.Selection.UnMerge
- 'xlApp.Selection.SpecialCells(Microsoft.Office.Interop.Excel.XlCellType.xlCellTypeBlanks).Select
- 'xlApp.CutCopyMode = False
- 'xlApp.Selection.FormulaR1C1 = "=R[-1]C"
-
- ' End If
-
- Dim my_no As String
- Dim my_nw As Double
- Dim my_gw As Double
- Dim my_sf As Double
- Dim my_price As Double
-
- Dim s1 As Integer = 0
-
- For y = 2 To y - 1
-
- If Not (xlSheet.Cells(y, 9).value Is Nothing) Then
-
- If (xlSheet.Cells(y, 5).value Is Nothing) And (xlSheet.Cells(y, 6).value Is Nothing) Then
- my_nw = xlSheet.Cells(y - 1, 5).value
- my_gw = xlSheet.Cells(y - 1, 6).value
- my_no = xlSheet.Cells(y - 1, 1).value
-
-
- Else
- my_nw = xlSheet.Cells(y, 5).value
- my_gw = xlSheet.Cells(y, 6).value
- my_no = xlSheet.Cells(y, 1).value
-
-
- End If
- my_sf = xlSheet.Cells(y, 3).value
- my_price = xlSheet.Cells(y, 11).value
- sql = "insert into rt_ship_daily_af (filename,serial,no,name,qty_sf,nw,gw,
- po_no,work_no,unit_price) values(N'" & file_name & "','" & s1 & "','" &
- my_no & "',N'" & xlSheet.Cells(y, 2).value & "'," & my_sf & "," & my_nw & "," & my_gw & ",N'" &
- xlSheet.Cells(y, 8).value & "','" & xlSheet.Cells(y, 9).value & "','" & my_price & "')"
- cmd.CommandText = sql
- cmd.ExecuteScalar()
-
- End If
-
- Next
-
-
- sql = "select 品名,po_no as 订购单号,厚度,cast(sum(qty_sf) as numeric(10,1)) as 尺数,cast(sum(unit_price*qty_sf)/sum(qty_sf) as numeric(10,2)) as 单价,cast(sum(unit_price*qty_sf) as numeric(10,2)) as 货值,sum(净重) as 净重 from
- (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_sf, 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_sf/sum(qty_sf) over (partition by no) *nw as numeric(10,1)) as 净重 FROM rt_ship_daily_af) as p group by 品名,po_no,厚度" '旧
-
-
- sql = "select name as 品名,po_no as 订单号,work_no as 指令号,sum(qty_sf) as 尺数,deli_no as 发货单号 from rt_ship_daily_af group by name,po_no,work_no,deli_no"
-
-
- cmd.CommandText = sql
- dt = New DataTable
- da.SelectCommand = cmd
- da.Fill(dt)
-
-
- dgv1.DataSource = dt
-
- dgv1.Columns("品名").Width = 250
- dgv1.Columns("指令号").Width = 150
-
-
-
- ' 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
- '(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_sf, 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 净重
- 'FROM rt_ship_daily_sj) as p group by 品名,po_no,厚度,颜色) as q group by 品名,颜色,厚度 order by 品名"
-
- ' cmd.CommandText = sql
- ' dt = New DataTable
- ' da.SelectCommand = cmd
- ' da.Fill(dt)
-
-
- ' dgv2.DataSource = dt
-
-
-
-
-
- ' 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
- '(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 净重
- 'FROM rt_ship_daily_sj) as p group by 品名,po_no,厚度,颜色) as q group by 品名,颜色 order by 品名"
-
- ' cmd.CommandText = sql
- ' dt = New DataTable
- ' da.SelectCommand = cmd
- ' da.Fill(dt)
-
-
- ' dgv3.DataSource = dt
-
-
-
-
-
-
-
-
-
-
-
- ElseIf OpenFileDialog1.SafeFileName Like "极路客*" Then '--------------------------------------------极路客
-
-
-
- sql = "delete from rt_ship_daily_jlk"
- cmd.CommandText = sql
- cmd.ExecuteNonQuery()
-
- Dim s1 As Integer = 1
- Dim s11 As Integer = 1001
-
-
-
- For i = 1 To xlApp.Worksheets.Count
-
-
- xlSheet = xlApp.Worksheets(i)
- xlSheet.Activate()
-
-
-
- Dim y As Integer
- For y = xlApp.Workbooks(1).Worksheets(i).UsedRange.Rows.Count To 3 Step -1
-
- If xlSheet.Cells(y, 1).value = Nothing Then
- GoTo OK3
- End If
-
- If xlSheet.Cells(y, 1).value.ToString = "重量总计:" Then
- Exit For
- End If
-
-
- Next y
-
- OK3:
-
- Dim yyy As Integer
-
- For yyy = 3 To xlApp.Workbooks(1).Worksheets(i).UsedRange.Rows.Count
-
- If xlSheet.Cells(yyy, 10).value = "数量总计:" Then
- Exit For
- End If
-
-
- Next yyy
-
-
- xlSheet.Range("A4:A" & y - 1).Select()
-
- xlApp.Selection.UnMerge
- 'xlApp.Selection.SpecialCells(Microsoft.Office.Interop.Excel.XlCellType.xlCellTypeBlanks).Select
- 'xlApp.CutCopyMode = False
- 'xlApp.Selection.FormulaR1C1 = "=R[-1]C"
-
- xlSheet.Range("d4:e" & y - 1).Select()
-
- xlApp.Selection.UnMerge
- 'xlApp.Selection.SpecialCells(Microsoft.Office.Interop.Excel.XlCellType.xlCellTypeBlanks).Select
- 'xlApp.CutCopyMode = False
- 'xlApp.Selection.FormulaR1C1 = "=R[-1]C"
-
-
- xlSheet.Range("j3:k" & yyy - 1).Select()
-
- xlApp.Selection.UnMerge
- 'xlApp.Selection.SpecialCells(Microsoft.Office.Interop.Excel.XlCellType.xlCellTypeBlanks).Select
- 'xlApp.CutCopyMode = False
- 'xlApp.Selection.FormulaR1C1 = "=R[-1]C"
-
-
- 'If xlSheet.Range("N3:Q" & yyy - 1).MergeCells.ToString <> "False" Then
-
- ' xlSheet.Range("N3:Q" & yyy - 1).Select()
-
- ' xlApp.Selection.UnMerge
- ' 'xlApp.Selection.SpecialCells(Microsoft.Office.Interop.Excel.XlCellType.xlCellTypeBlanks).Select
- ' 'xlApp.CutCopyMode = False
- ' 'xlApp.Selection.FormulaR1C1 = "=R[-1]C"
-
-
-
- 'End If
-
-
- Dim my_no As String
- Dim my_po As String
- Dim my_work As String
- Dim my_color As String
- Dim my_thick As String
- Dim my_no1 As String
- Dim my_po1 As String
- Dim my_work1 As String
- Dim my_color1 As String
- Dim my_thick1 As String
- Dim my_card As String
-
-
- For y = 4 To y - 1
-
-
- If y = 4 Then
-
-
- my_no = xlSheet.Cells(y, 1).value
- my_color = xlSheet.Cells(y, 4).value
- my_thick = xlSheet.Cells(y, 5).value
-
- my_no1 = xlSheet.Cells(y, 7).value
- my_color1 = xlSheet.Cells(y, 10).value
- my_thick1 = xlSheet.Cells(y, 11).value
-
-
-
-
- End If
-
-
-
-
-
- If xlSheet.Cells(y, 2).value = Nothing And xlSheet.Cells(y, 4).value = Nothing And xlSheet.Cells(y, 5).value = Nothing Then
- ' Exit For
- Else
- If xlSheet.Cells(y, 2).value Is Nothing Then
- Else
-
- If xlSheet.Cells(y, 1).value Is Nothing Then
-
- Else
- my_no = xlSheet.Cells(y, 1).value
- End If
-
-
-
-
- If xlSheet.Cells(y, 4).value Is Nothing And xlSheet.Cells(y, 5).value Is Nothing Then
- Else
-
-
- my_color = xlSheet.Cells(y, 4).value
- my_thick = xlSheet.Cells(y, 5).value
-
-
- End If
-
-
-
-
- sql = "insert into rt_ship_daily_jlk (filename,card,serial,no,qty,color,thick) values(N'" &
- file_name & "','" & xlSheet.Cells(y, 3).value & "','" & s1 & "','" & my_no & "','" & xlSheet.Cells(y, 2).value & "',N'" & my_color & "','" & my_thick & "')"
- cmd.CommandText = sql
- cmd.ExecuteScalar()
- s1 = s1 + 1
-
-
- End If
- End If
-
-
-
-
-
-
-
- If xlSheet.Cells(y, 8).value = Nothing And xlSheet.Cells(y, 10).value = Nothing And xlSheet.Cells(y, 11).value = Nothing Then
- ' Exit For
- Else
- If xlSheet.Cells(y, 8).value Is Nothing Then
- Else
-
- If xlSheet.Cells(y, 7).value Is Nothing Then
-
- Else
- my_no1 = xlSheet.Cells(y, 7).value
- End If
-
-
-
-
- If xlSheet.Cells(y, 10).value Is Nothing And xlSheet.Cells(y, 11).value Is Nothing Then
- Else
-
-
- my_color1 = xlSheet.Cells(y, 10).value
- my_thick1 = xlSheet.Cells(y, 11).value
-
-
-
-
- End If
-
-
-
-
- sql = "insert into rt_ship_daily_jlk (filename,card,serial,no,qty,color,thick) values(N'" &
- file_name & "','" & xlSheet.Cells(y, 9).value & "','" & s11 & "','" & my_no1 & "','" & xlSheet.Cells(y, 8).value & "',N'" & my_color1 & "','" & my_thick1 & "')"
- cmd.CommandText = sql
- cmd.ExecuteScalar()
- s11 = s11 + 1
-
-
-
- End If
- End If
-
-
-
-
-
-
-
- Next
-
-
-
- Next
-
-
-
-
- sql = "SELECT color as 颜色,thick as 厚度,sum(qty) as 尺数,DELE_NO AS 发货单号 from rt_ship_daily_jlk group by color,thick,DELI_NO "
- cmd.CommandText = sql
- dt = New DataTable
- da.SelectCommand = cmd
- da.Fill(dt)
-
-
-
- dgv1.DataSource = dt
-
- 'dt.Columns.Add("尺数")
- 'dt.Columns.Add("货值")
-
- ' sql = "SELECT 订单类别, 厚度, SUM(尺数) AS 尺数, 类别
- 'FROM (SELECT CASE WHEN LEFT(order_no, 2)
- ' = 'RT' THEN N'人民币' WHEN order_no LIKE 'SX%' THEN '美元' ELSE order_no END AS 订单类别,
- ' i_no AS 指令号, color AS 颜色, thick AS 厚度, CAST(SUM(sf) AS numeric(10, 1)) AS 尺数,
- ' CASE WHEN color LIKE '%pu%' OR
- ' color LIKE '%action%' OR
- ' color LIKE N'%纹%' THEN 'PU' ELSE '反毛' END AS 类别
- ' FROM RT_ship_daily_wh
- ' GROUP BY order_no, i_no, color, thick) AS p
- 'GROUP BY 订单类别, 厚度, 类别
- 'ORDER BY 订单类别"
- ' cmd.CommandText = sql
- ' dt = New DataTable
- ' da.SelectCommand = cmd
- ' da.Fill(dt)
- ' dgv2.DataSource = dt
-
-
- ' sql = "SELECT 订单类别, SUM(尺数) AS 尺数, 类别
- 'FROM (SELECT CASE WHEN LEFT(order_no, 2)
- ' = 'RT' THEN N'人民币' WHEN order_no LIKE 'SX%' THEN '美元' ELSE order_no END AS 订单类别,
- ' i_no AS 指令号, color AS 颜色, thick AS 厚度, CAST(SUM(sf) AS numeric(10, 1)) AS 尺数,
- ' CASE WHEN color LIKE '%pu%' OR
- ' color LIKE '%action%' OR
- ' color LIKE N'%纹%' THEN 'PU' ELSE '反毛' END AS 类别
- ' FROM RT_ship_daily_wh
- ' GROUP BY order_no, i_no, color, thick) AS p
- 'GROUP BY 订单类别, 类别 ORDER BY 订单类别"
- ' cmd.CommandText = sql
- ' dt = New DataTable
- ' da.SelectCommand = cmd
- ' da.Fill(dt)
- ' dgv3.DataSource = dt
-
-
-
-
- ElseIf OpenFileDialog1.SafeFileName Like "HATAY*" Then
- ElseIf OpenFileDialog1.SafeFileName Like "DCLASE*" Then
- ElseIf OpenFileDialog1.SafeFileName Like "078*" Then
- ElseIf OpenFileDialog1.SafeFileName Like "076发货*" Then '------------------------金威利
-
- sql = "delete from rt_ship_076_1"
- cmd.CommandText = sql
-
- cmd.ExecuteNonQuery()
-
- Dim my_total_weight As Double = 0
-
- Dim s1 As Integer = 1
- Dim s11 As Integer = 1001
-
- For i = 1 To xlApp.Worksheets.Count
-
- xlSheet = xlApp.Worksheets(i)
- xlSheet.Activate()
-
- Dim y As Integer
- For y = xlApp.Workbooks(1).Worksheets(i).UsedRange.Rows.Count To 3 Step -1
-
- If xlSheet.Cells(y, 1).value = Nothing Then
-
- If xlSheet.Cells(y, 2).value = "重量" Then
-
-
-
- End If
-
-
- GoTo OK
- End If
-
- If xlSheet.Cells(y, 1).value.ToString = "数量合计" Then
- Exit For
- End If
- OK:
-
- Next y
-
- Dim yyy As Integer
-
- For yyy = 3 To xlApp.Workbooks(1).Worksheets(i).UsedRange.Rows.Count
-
- If xlSheet.Cells(yyy, 14).value = "制 表" Then
- Exit For
- End If
-
-
- Next yyy
-
-
-
- If xlSheet.Cells(y + 2, 2).value Like "重量*" Then
-
- Dim q() As String
- Dim r() As String
-
- q = Split(xlSheet.Cells(y + 2, 2).value, "重量")
- r = Split(q(1), "KG")
-
- If IsNumeric(r(0)) Then
- Else
-
- r = Split(q(1), "kg")
-
- If IsNumeric(r(0)) Then
- Else
-
- r = Split(q(1), "Kg")
- End If
-
-
-
- End If
-
-
-
-
- 'my_total_weight = r(0)
-
-
-
-
- End If
-
-
-
- xlSheet.Range("A3:A" & y - 1).Select()
-
- xlApp.Selection.UnMerge
- 'xlApp.Selection.SpecialCells(Microsoft.Office.Interop.Excel.XlCellType.xlCellTypeBlanks).Select
- 'xlApp.CutCopyMode = False
- 'xlApp.Selection.FormulaR1C1 = "=R[-1]C"
-
- xlSheet.Range("c3:g" & y - 1).Select()
-
- xlApp.Selection.UnMerge
- 'xlApp.Selection.SpecialCells(Microsoft.Office.Interop.Excel.XlCellType.xlCellTypeBlanks).Select
- 'xlApp.CutCopyMode = False
- 'xlApp.Selection.FormulaR1C1 = "=R[-1]C"
-
-
- xlSheet.Range("N3:Q" & yyy - 1).Select()
-
- xlApp.Selection.UnMerge
- 'xlApp.Selection.SpecialCells(Microsoft.Office.Interop.Excel.XlCellType.xlCellTypeBlanks).Select
- 'xlApp.CutCopyMode = False
- 'xlApp.Selection.FormulaR1C1 = "=R[-1]C"
-
-
- If xlSheet.Range("K3:L" & yyy - 1).MergeCells.ToString <> "False" Then
-
- xlSheet.Range("K3:L" & yyy - 1).Select()
-
- xlApp.Selection.UnMerge
- 'xlApp.Selection.SpecialCells(Microsoft.Office.Interop.Excel.XlCellType.xlCellTypeBlanks).Select
- 'xlApp.CutCopyMode = False
- 'xlApp.Selection.FormulaR1C1 = "=R[-1]C"
-
-
-
- End If
-
-
- Dim my_card As String
- Dim my_no As String
- Dim my_po As String
- Dim my_work As String
- Dim my_color As String
- Dim my_thick As String
- Dim my_no1 As String
- Dim my_po1 As String
- Dim my_work1 As String
- Dim my_color1 As String
- Dim my_thick1 As String
-
-
-
-
- For y = 3 To y - 1
-
-
-
-
- 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
- ' Exit For
- Else
- If xlSheet.Cells(y, 2).value Is Nothing Then
- Else
- If xlSheet.Cells(y, 4).VALUE Is Nothing Then
-
- If xlSheet.Cells(y, 1).value Is Nothing Then
-
- Else
- my_no = xlSheet.Cells(y, 1).value
- End If
-
-
-
- sql = "insert into rt_ship_076_1 (filename,card,serial,no,sf,order_no,i_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 & "')"
- cmd.CommandText = sql
- cmd.ExecuteScalar()
- s1 = s1 + 1
-
- Else
-
- If xlSheet.Cells(y, 1).value Is Nothing Then
-
- Else
- my_no = xlSheet.Cells(y, 1).value
- End If
-
-
- my_po = xlSheet.Cells(y, 4).value
- my_work = xlSheet.Cells(y, 5).value
- my_color = xlSheet.Cells(y, 6).value
- my_thick = xlSheet.Cells(y, 7).value
-
- sql = "insert into rt_ship_076_1 (filename,card,serial,no,sf,order_no,i_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 & "')"
- cmd.CommandText = sql
- cmd.ExecuteScalar()
- s1 = s1 + 1
-
- End If
- End If
- End If
-
-
-
- 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
-
- ' Exit For
- Else
-
- If xlSheet.Cells(y, 12).value Is Nothing Then
- Else
-
- If xlSheet.Cells(y, 14).VALUE Is Nothing Then
- If xlSheet.Cells(y, 11).value Is Nothing Then
- Else
- my_no1 = xlSheet.Cells(y, 11).value
- End If
- sql = "insert into rt_ship_076_1 (filename,card,serial,no,sf,order_no,i_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 & "')"
- cmd.CommandText = sql
- cmd.ExecuteScalar()
- s11 = s11 + 1
-
- Else
- If xlSheet.Cells(y, 11).value Is Nothing Then
- Else
- my_no1 = xlSheet.Cells(y, 11).value
- End If
-
- my_po1 = xlSheet.Cells(y, 14).value
- my_work1 = xlSheet.Cells(y, 15).value
- my_color1 = xlSheet.Cells(y, 16).value
- my_thick1 = xlSheet.Cells(y, 17).value
-
- sql = "insert into rt_ship_076_1 (filename,card,serial,no,sf,order_no,i_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 & "')"
- cmd.CommandText = sql
- cmd.ExecuteScalar()
- s11 = s11 + 1
-
- End If
-
-
-
- End If
-
-
- '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 & "')"
- 'cmd.CommandText = sql
- 'cmd.ExecuteScalar()
-
-
- End If
-
-
-
- Next
-
-
-
- Next
-
- sql = "insert into rt_ship_temp select * from rt_ship_076_1"
- cmd.CommandText = sql
- cmd.ExecuteNonQuery()
-
-
-
-
-
-
- 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_076_1 GROUP BY order_no, i_no, color, thick,DELI_NO "
- cmd.CommandText = sql
- dt = New DataTable
- da.SelectCommand = cmd
- da.Fill(dt)
-
- dt.Columns.Add("发货单号")
-
- dgv1.DataSource = dt
-
-
- 'dt.Columns.Add("货值")
-
- sql = "SELECT 订单类别, 厚度, SUM(尺数) AS 尺数, 类别
- FROM (SELECT CASE WHEN LEFT(order_no, 2)
- = 'RT' THEN N'人民币' WHEN order_no LIKE 'SX%' THEN '美元' ELSE order_no END AS 订单类别,
- i_no AS 指令号, color AS 颜色, thick AS 厚度, CAST(SUM(sf) AS numeric(10, 1)) AS 尺数,
- CASE WHEN color LIKE '%pu%' OR
- color LIKE '%action%' OR
- color LIKE N'%纹%' THEN 'PU' ELSE '反毛' END AS 类别
- FROM RT_ship_076_1
- GROUP BY order_no, i_no, color, thick) AS p
- GROUP BY 订单类别, 厚度, 类别
- ORDER BY 订单类别"
- cmd.CommandText = sql
- dt = New DataTable
- da.SelectCommand = cmd
- da.Fill(dt)
- dgv2.DataSource = dt
-
-
- sql = "SELECT 订单类别, SUM(尺数) AS 尺数, 类别
- FROM (SELECT CASE WHEN LEFT(order_no, 2)
- = 'RT' THEN N'人民币' WHEN order_no LIKE 'SX%' THEN '美元' ELSE order_no END AS 订单类别,
- i_no AS 指令号, color AS 颜色, thick AS 厚度, CAST(SUM(sf) AS numeric(10, 1)) AS 尺数,
- CASE WHEN color LIKE '%pu%' OR
- color LIKE '%action%' OR
- color LIKE N'%纹%' THEN 'PU' ELSE '反毛' END AS 类别
- FROM RT_ship_076_1
- GROUP BY order_no, i_no, color, thick) AS p
- GROUP BY 订单类别, 类别 ORDER BY 订单类别"
- cmd.CommandText = sql
- dt = New DataTable
- da.SelectCommand = cmd
- da.Fill(dt)
- dgv3.DataSource = dt
-
-
-
-
-
- For rr As Integer = 0 To dt.Rows.Count - 1
- 'sql = ""
- 'cmd.CommandText = sql
- 'dt.Rows(rr).Item("尺数") = cmd.ExecuteScalar
- Next
-
-
-
- For rr As Integer = 0 To dt.Rows.Count - 1
- 'sql = ""
- 'cmd.CommandText = sql
- 'dt.Rows(rr).Item("货值") = cmd.ExecuteScalar
- Next
- 'DataGridView1.DataSource = dt
-
-
- Else
-
- MsgBox("找不到相对应的模组")
- End If
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- xlApp.Visible = True
-
-
-
-
- xlSheet = Nothing '釋放sheet物件
-
-
- ' xlApp.Quit() '關閉Excel
-
- xlApp = Nothing
-
- MsgBox("作业完成")
-
-
- End Sub
-
- Private Sub Frm_BG_main_Load(sender As Object, e As EventArgs) Handles MyBase.Load
-
- conn.ConnectionString = connstring
- conn.Open()
- cmd.Connection = conn
-
-
- sql = "select filename from rt_ship_076_1 group by filename"
- cmd.CommandText = sql
-
- If Not (cmd.ExecuteScalar Is Nothing) Then
- ListBox3.Items.Add(cmd.ExecuteScalar)
- End If
-
- sql = "select filename from rt_ship_daily_af group by filename"
- cmd.CommandText = sql
-
- If Not (cmd.ExecuteScalar Is Nothing) Then
- ListBox3.Items.Add(cmd.ExecuteScalar)
- End If
-
- sql = "select filename from rt_ship_daily_evergree group by filename"
- cmd.CommandText = sql
-
- If Not (cmd.ExecuteScalar Is Nothing) Then
- ListBox3.Items.Add(cmd.ExecuteScalar)
- End If
-
-
- 'sql = "select filename from rt_ship_daily_jh group by filename"
- 'cmd.CommandText = sql
-
- 'If Not (cmd.ExecuteScalar Is Nothing) Then
- ' ListBox3.Items.Add(cmd.ExecuteScalar)
- 'End If
-
- sql = "select filename from rt_ship_daily_jlk group by filename"
- cmd.CommandText = sql
-
- If Not (cmd.ExecuteScalar Is Nothing) Then
- ListBox3.Items.Add(cmd.ExecuteScalar)
- End If
-
- sql = "select filename from rt_ship_daily_properwell group by filename"
- cmd.CommandText = sql
-
- If Not (cmd.ExecuteScalar Is Nothing) Then
- ListBox3.Items.Add(cmd.ExecuteScalar)
- End If
-
- 'sql = "select filename from rt_ship_daily_puma group by filename"
- 'cmd.CommandText = sql
-
- 'If Not (cmd.ExecuteScalar Is Nothing) Then
- ' ListBox3.Items.Add(cmd.ExecuteScalar)
- 'End If
-
-
- sql = "select filename from rt_ship_daily_ruiqi group by filename"
- cmd.CommandText = sql
-
- If Not (cmd.ExecuteScalar Is Nothing) Then
- ListBox3.Items.Add(cmd.ExecuteScalar)
- End If
-
- sql = "select filename from rt_ship_daily_samil group by filename"
- cmd.CommandText = sql
-
- If Not (cmd.ExecuteScalar Is Nothing) Then
- ListBox3.Items.Add(cmd.ExecuteScalar)
- End If
-
-
- sql = "select filename from rt_ship_daily_sj group by filename"
- cmd.CommandText = sql
-
- If Not (cmd.ExecuteScalar Is Nothing) Then
- ListBox3.Items.Add(cmd.ExecuteScalar)
- End If
-
- sql = "select filename from rt_ship_daily_stella group by filename"
- cmd.CommandText = sql
-
- If Not (cmd.ExecuteScalar Is Nothing) Then
- ListBox3.Items.Add(cmd.ExecuteScalar)
- End If
-
-
- sql = "select filename from rt_ship_daily_thanhhu group by filename"
- cmd.CommandText = sql
-
- If Not (cmd.ExecuteScalar Is Nothing) Then
- ListBox3.Items.Add(cmd.ExecuteScalar)
- End If
-
- sql = "select filename from rt_ship_daily_uz_1 group by filename"
- cmd.CommandText = sql
-
- If Not (cmd.ExecuteScalar Is Nothing) Then
- ListBox3.Items.Add(cmd.ExecuteScalar)
- End If
-
-
- sql = "select filename from rt_ship_daily_wh group by filename"
- cmd.CommandText = sql
-
- If Not (cmd.ExecuteScalar Is Nothing) Then
- ListBox3.Items.Add(cmd.ExecuteScalar)
- End If
-
- sql = "select filename from rt_ship_daily_xbh group by filename"
- cmd.CommandText = sql
-
- If Not (cmd.ExecuteScalar Is Nothing) Then
- ListBox3.Items.Add(cmd.ExecuteScalar)
- End If
-
-
- sql = "select filename from rt_ship_daily_yb group by filename"
- cmd.CommandText = sql
-
- If Not (cmd.ExecuteScalar Is Nothing) Then
- ListBox3.Items.Add(cmd.ExecuteScalar)
- End If
-
- sql = "select filename from rt_ship_daily_yby group by filename"
- cmd.CommandText = sql
-
- If Not (cmd.ExecuteScalar Is Nothing) Then
- ListBox3.Items.Add(cmd.ExecuteScalar)
- End If
-
-
- sql = "select filename from rt_ship_daily_yby_huasheng group by filename"
- cmd.CommandText = sql
-
- If Not (cmd.ExecuteScalar Is Nothing) Then
- ListBox3.Items.Add(cmd.ExecuteScalar)
- End If
-
-
- sql = "select filename from rt_ship_daily_yy group by filename"
- cmd.CommandText = sql
-
- If Not (cmd.ExecuteScalar Is Nothing) Then
- ListBox3.Items.Add(cmd.ExecuteScalar)
- End If
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- End Sub
-
- Private Sub DataGridView2_MouseUp(sender As Object, e As MouseEventArgs) Handles dgv2.MouseUp
-
- Dim x As Double = 0
- Dim y As Double = 0
- Dim z As Double = 0
- Dim a As Int16 = 0
- Dim b As Double = 0
-
- For i As Integer = 0 To dgv2.SelectedRows.Count - 1
-
- x = x + Math.Round(dgv2.Rows(dgv2.SelectedRows.Item(i).Index).Cells("尺数").Value, 2)
-
- y = y + Math.Round(dgv2.Rows(dgv2.SelectedRows.Item(i).Index).Cells("货值").Value, 2)
-
- z = z + Math.Round(dgv2.Rows(dgv2.SelectedRows.Item(i).Index).Cells("净重").Value, 2)
-
- a = a + dgv2.Rows(dgv2.SelectedRows.Item(i).Index).Cells("件数").Value
-
- b = b + Math.Round(dgv2.Rows(dgv2.SelectedRows.Item(i).Index).Cells("毛重").Value, 2)
-
- Next i
-
- TextBox3.Text = dgv2.SelectedRows.Count
-
- TextBox2.Text = x
- TextBox1.Text = y
- TextBox4.Text = z
- TextBox5.Text = a
- TextBox6.Text = b
-
-
-
-
- End Sub
-
- Private Sub Button23_Click(sender As Object, e As EventArgs) Handles Button23.Click '---报关进口汇总
-
-
- sql = "SELECT DATE1 AS 报关日期, Date2 AS 进厂日期, MONTH(Date2) AS 进厂月份, XNO AS 手册号, NAME AS 海关分类,type as 进口类型,matl_name AS 品名, QTY AS 数量, PRICE AS 单价, price*qty as 货值, ORIGIN AS 产地 FROM RT_BG_IN_DETAIL WHERE date2 between '" & dtp1.Value & "' and '" & dtp2.Value & "'"
- cmd.CommandText = sql
- da.SelectCommand = cmd
- Dim dt1 As New DataTable
- da.Fill(dt1)
-
-
- If dt1.Rows.Count = 0 Then
- MsgBox("查无记录")
- Exit Sub
- End If
-
- dgv1.DataSource = dt1
-
-
-
- Dim xlApp As Microsoft.Office.Interop.Excel.Application
- Dim xlBook As Microsoft.Office.Interop.Excel.Workbook
- Dim xlSheet As Microsoft.Office.Interop.Excel.Worksheet
- Dim xlRange As Microsoft.Office.Interop.Excel.Range
-
- xlApp = CreateObject("Excel.Application")
- xlApp.Visible = False
- xlApp.DisplayAlerts = False
-
- xlBook = xlApp.Workbooks.Add
- xlSheet = xlBook.Worksheets(1)
- xlSheet.Name = "报关进口汇总"
- xlSheet.Activate()
-
- xlSheet.Cells(5, 5).select
-
-
-
-
-
-
- dgv1.SelectAll()
-
-
- Me.dgv1.ClipboardCopyMode = DataGridViewClipboardCopyMode.EnableAlwaysIncludeHeaderText
- Me.dgv1.RowHeadersVisible = False
-
- Clipboard.SetDataObject(dgv1.GetClipboardContent())
-
-
-
- xlApp.Range("B30").Select()
-
- xlSheet.Paste()
-
- xlApp.Visible = True
-
-
- '''' xlApp.ActiveSheet.Paste
- ''''xlApp.CutCopyMode = False
- xlApp.ActiveSheet.ListObjects.Add(Microsoft.Office.Interop.Excel.XlListObjectSourceType.xlSrcRange, xlApp.Range("$B$30:$L$" & dt1.Rows.Count + 25), , Microsoft.Office.Interop.Excel.XlYesNoGuess.xlYes).Name = "表1"
-
-
-
-
- Dim PTCache As Microsoft.Office.Interop.Excel.PivotCache
- Dim PT As Microsoft.Office.Interop.Excel.PivotTable
-
- 'Create the Cache
- PTCache = xlApp.ActiveWorkbook.PivotCaches.Create(SourceType:=Microsoft.Office.Interop.Excel.XlPivotTableSourceType.xlDatabase, SourceData:=xlApp.Range("$B$30:$L$" & dt1.Rows.Count + 25))
-
- 'Select the destination sheet
- xlSheet.Range("b2").Select()
-
- 'Create the Pivot table
- PT = xlSheet.PivotTables.Add(PivotCache:=PTCache, TableDestination:=xlSheet.Range("B2"), TableName:="Pivot1")
-
- xlApp.ActiveWorkbook.ShowPivotTableFieldList = True
-
- 'Adding fields
-
-
-
-
- With xlApp.ActiveSheet.PivotTables("Pivot1").PivotFields("海关分类")
- .Orientation = Microsoft.Office.Core.XlPivotFieldOrientation.xlRowField
- .Position = 1
- End With
-
- With xlApp.ActiveSheet.PivotTables("Pivot1").PivotFields("进厂月份")
- .Orientation = Microsoft.Office.Core.XlPivotFieldOrientation.xlColumnField
- .Position = 1
- End With
-
- With xlApp.ActiveSheet.PivotTables("Pivot1").PivotFields("手册号")
- .Orientation = Microsoft.Office.Core.XlPivotFieldOrientation.xlColumnField
- .Position = 1
- End With
-
-
-
-
-
- With xlApp.ActiveSheet.PivotTables("pivot1")
- .AddDataField(xlApp.ActiveSheet.PivotTables("Pivot1").PivotFields("数量"), "数量合计", Microsoft.Office.Interop.Excel.XlConsolidationFunction.xlSum)
- End With
-
-
- With xlApp.ActiveSheet.PivotTables("pivot1")
- .AddDataField(xlApp.ActiveSheet.PivotTables("Pivot1").PivotFields("货值"), "货值合计", Microsoft.Office.Interop.Excel.XlConsolidationFunction.xlSum)
- End With
-
-
-
- xlApp.Visible = True
- xlApp = Nothing
- xlBook = Nothing
- xlSheet = Nothing
-
-
-
- End Sub
-
- Private Sub Button24_Click(sender As Object, e As EventArgs) Handles Button24.Click
-
- Frm_BG_FM_MEASURE.Show()
-
- End Sub
-
- Private Sub Button25_Click(sender As Object, e As EventArgs) Handles Button25.Click '----报关出口汇总
-
-
-
- sql = "SELECT RT_BG_OUT.XNO AS 手册号, RT_BG_OUT.date1 AS 报关日期, RT_BG_OUT.NO AS 报关单号,
- MONTH(RT_BG_OUT.date1) AS 报关月份,
- CASE WHEN RT_BG_OUT.name LIKE '%pu%' THEN N'PU皮二层皮' ELSE N'牛二层皮' END AS 品名,
- RT_BG_OUT.NAME AS 品名1, RT_BG_OUT.QTY AS 重量, CAST(RT_BG_OUT.TOTAL AS numeric(10, 1)) AS 货值, CAST(RT_BG_OUT.TOTAL/rt_bg_out.qty AS numeric(10, 3)) AS 单价,
- CAST(RT_BG_OUT.FEE AS numeric(10, 1)) AS 工缴费, RT_BG_MTL_NAME.L_no AS 料号,
- CAST(RT_BG_OUT.FEE / RT_BG_OUT.QTY AS NUMERIC(10, 1)) AS 工缴费单价, RT_BG_OUT.COMMENT AS 客户,
- RT_BG_OUT.DES AS 目的地
- FROM RT_BG_OUT LEFT OUTER JOIN
- RT_BG_MTL_NAME ON RT_BG_OUT.NAME = RT_BG_MTL_NAME.NAME where date1 between '" & dtp1.Value & "' and '" & dtp2.Value & "'"
- cmd.CommandText = sql
- da.SelectCommand = cmd
- Dim dt1 As New DataTable
- da.Fill(dt1)
-
-
- If dt1.Rows.Count = 0 Then
- MsgBox("查无记录")
- Exit Sub
- End If
-
- dgv1.DataSource = dt1
-
-
- Dim xlApp As Microsoft.Office.Interop.Excel.Application
- Dim xlBook As Microsoft.Office.Interop.Excel.Workbook
- Dim xlSheet As Microsoft.Office.Interop.Excel.Worksheet
- Dim xlRange As Microsoft.Office.Interop.Excel.Range
-
- xlApp = CreateObject("Excel.Application")
- xlApp.Visible = True
- xlApp.DisplayAlerts = False
-
- xlBook = xlApp.Workbooks.Add
- xlSheet = xlBook.Worksheets(1)
- xlSheet.Name = "报关出口汇总"
- xlSheet.Activate()
-
- xlApp.Range("d25:d2000").Select()
- xlApp.Selection.NumberFormatLocal = "@"
-
-
- xlSheet.Cells(5, 5).select
-
-
-
-
- dgv1.SelectAll()
-
-
- Me.dgv1.ClipboardCopyMode = DataGridViewClipboardCopyMode.EnableAlwaysIncludeHeaderText
- Me.dgv1.RowHeadersVisible = False
-
- Dim DT_OBJECT As DataObject =DGV1.GetClipboardContent()
- Clipboard.SetDataObject(DT_OBJECT)
-
- 'Dim t As New System.Windows.Forms.DataObject
- 't = dgv1.GetClipboardContent
- 'System.Windows.Forms.Clipboard.SetDataObject(t, False, 2, 2)
-
-
-
-
- xlApp.Range("B25").Select()
-
- xlSheet.PasteSpecial("Unicode 文本", False, False)
- 'xlSheet.Paste()
-
- xlApp.Visible = True
-
-
- '''' xlApp.ActiveSheet.Paste
- ''''xlApp.CutCopyMode = False
- xlApp.ActiveSheet.ListObjects.Add(Microsoft.Office.Interop.Excel.XlListObjectSourceType.xlSrcRange, xlApp.Range("$B$25:$o$" & dt1.Rows.Count + 25), , Microsoft.Office.Interop.Excel.XlYesNoGuess.xlYes).Name = "表1"
-
-
-
-
- Dim PTCache As Microsoft.Office.Interop.Excel.PivotCache
- Dim PT As Microsoft.Office.Interop.Excel.PivotTable
-
- 'Create the Cache
- PTCache = xlApp.ActiveWorkbook.PivotCaches.Create(SourceType:=Microsoft.Office.Interop.Excel.XlPivotTableSourceType.xlDatabase, SourceData:=xlApp.Range("$B$25:$o$" & dt1.Rows.Count + 25))
-
- 'Select the destination sheet
- xlSheet.Range("b2").Select()
-
- 'Create the Pivot table
- PT = xlSheet.PivotTables.Add(PivotCache:=PTCache, TableDestination:=xlSheet.Range("B2"), TableName:="Pivot1")
-
- xlApp.ActiveWorkbook.ShowPivotTableFieldList = True
-
- 'Adding fields
-
-
- With xlApp.ActiveSheet.PivotTables("Pivot1").PivotFields("手册号")
- .Orientation = Microsoft.Office.Core.XlPivotFieldOrientation.xlRowField
- .Position = 1
- End With
-
- With xlApp.ActiveSheet.PivotTables("Pivot1").PivotFields("报关月份")
- .Orientation = Microsoft.Office.Core.XlPivotFieldOrientation.xlColumnField
- .Position = 1
- End With
-
-
- With xlApp.ActiveSheet.PivotTables("pivot1")
- .AddDataField(xlApp.ActiveSheet.PivotTables("Pivot1").PivotFields("重量"), "重量合计", Microsoft.Office.Interop.Excel.XlConsolidationFunction.xlSum)
- End With
-
-
- With xlApp.ActiveSheet.PivotTables("pivot1")
- .AddDataField(xlApp.ActiveSheet.PivotTables("Pivot1").PivotFields("货值"), "货值合计", Microsoft.Office.Interop.Excel.XlConsolidationFunction.xlSum)
- End With
-
-
-
- xlApp.Visible = True
- xlApp = Nothing
- xlBook = Nothing
- xlSheet = Nothing
-
-
-
- End Sub
-
- Private Sub Button27_Click(sender As Object, e As EventArgs) Handles Button27.Click '----保税入库
-
-
-
- sql = "SELECT m_in AS 入库数量, LEFT(xno, 12) AS 手册号, date AS 日期, MONTH(date) AS 月份, item_new AS 品名, name AS 明细 FROM RT_BG_IO WHERE (m_in <> 0) AND (date between '" & dtp1.Value & "' and '" & dtp2.Value & "') AND (item_new NOT LIKE N'%牛二层皮%')"
- cmd.CommandText = sql
- da.SelectCommand = cmd
- Dim dt1 As New DataTable
- da.Fill(dt1)
-
- If dt1.Rows.Count = 0 Then
- MsgBox("查无记录")
- Exit Sub
- End If
- dgv1.DataSource = dt1
-
-
- Dim xlApp As Microsoft.Office.Interop.Excel.Application
- Dim xlBook As Microsoft.Office.Interop.Excel.Workbook
- Dim xlSheet As Microsoft.Office.Interop.Excel.Worksheet
- Dim xlRange As Microsoft.Office.Interop.Excel.Range
-
- xlApp = CreateObject("Excel.Application")
- xlApp.Visible = False
- xlApp.DisplayAlerts = False
-
- xlBook = xlApp.Workbooks.Add
- xlSheet = xlBook.Worksheets(1)
- xlSheet.Name = "保税入库汇总"
- xlSheet.Activate()
-
- xlSheet.Cells(5, 5).select
-
-
-
-
-
-
-
- dgv1.SelectAll()
-
-
- Me.dgv1.ClipboardCopyMode = DataGridViewClipboardCopyMode.EnableAlwaysIncludeHeaderText
- Me.dgv1.RowHeadersVisible = False
-
- Clipboard.SetDataObject(dgv1.GetClipboardContent())
-
-
-
- xlApp.Range("B30").Select()
-
- xlSheet.Paste()
-
- xlApp.Visible = True
-
-
- '''' xlApp.ActiveSheet.Paste
- ''''xlApp.CutCopyMode = False
- xlApp.ActiveSheet.ListObjects.Add(Microsoft.Office.Interop.Excel.XlListObjectSourceType.xlSrcRange, xlApp.Range("$B$30:$g$" & dt1.Rows.Count + 30), , Microsoft.Office.Interop.Excel.XlYesNoGuess.xlYes).Name = "表1"
-
-
-
-
- Dim PTCache As Microsoft.Office.Interop.Excel.PivotCache
- Dim PT As Microsoft.Office.Interop.Excel.PivotTable
-
- 'Create the Cache
- PTCache = xlApp.ActiveWorkbook.PivotCaches.Create(SourceType:=Microsoft.Office.Interop.Excel.XlPivotTableSourceType.xlDatabase, SourceData:=xlApp.Range("$B$30:$g$" & dt1.Rows.Count + 30))
-
- 'Select the destination sheet
- xlSheet.Range("b2").Select()
-
- 'Create the Pivot table
- PT = xlSheet.PivotTables.Add(PivotCache:=PTCache, TableDestination:=xlSheet.Range("B2"), TableName:="Pivot1")
-
- xlApp.ActiveWorkbook.ShowPivotTableFieldList = True
-
- 'Adding fields
-
-
- With xlApp.ActiveSheet.PivotTables("Pivot1").PivotFields("品名")
- .Orientation = Microsoft.Office.Core.XlPivotFieldOrientation.xlRowField
- .Position = 1
- End With
-
-
- With xlApp.ActiveSheet.PivotTables("Pivot1").PivotFields("手册号")
- .Orientation = Microsoft.Office.Core.XlPivotFieldOrientation.xlColumnField
- .Position = 1
- End With
-
-
- With xlApp.ActiveSheet.PivotTables("Pivot1").PivotFields("月份")
- .Orientation = Microsoft.Office.Core.XlPivotFieldOrientation.xlColumnField
- .Position = 1
- End With
-
-
- With xlApp.ActiveSheet.PivotTables("pivot1")
- .AddDataField(xlApp.ActiveSheet.PivotTables("Pivot1").PivotFields("入库数量"), "重量合计", Microsoft.Office.Interop.Excel.XlConsolidationFunction.xlSum)
- End With
-
-
- 'With xlApp.ActiveSheet.PivotTables("pivot1")
- ' .AddDataField(xlApp.ActiveSheet.PivotTables("Pivot1").PivotFields("货值"), "货值合计", Microsoft.Office.Interop.Excel.XlConsolidationFunction.xlSum)
- 'End With
-
-
-
- xlApp.Visible = True
- xlApp = Nothing
- xlBook = Nothing
- xlSheet = Nothing
-
-
-
-
-
-
-
-
- End Sub
-
- Private Sub Button26_Click(sender As Object, e As EventArgs) Handles Button26.Click '----保税出库汇总
-
-
- sql = "SELECT m_out AS 出库数量, LEFT(xno, 12) AS 手册号, date AS 日期, MONTH(date) AS 月份, item_new AS 品名, name AS 明细 FROM RT_BG_IO WHERE (m_out <> 0) AND (date between '" & dtp1.Value & "' and '" & dtp2.Value & "') And (item_new Not LIKE N'%牛二层皮%')"
- cmd.CommandText = sql
- da.SelectCommand = cmd
- Dim dt1 As New DataTable
- da.Fill(dt1)
- If dt1.Rows.Count = 0 Then
- MsgBox("查无记录")
- Exit Sub
- End If
- dgv1.DataSource = dt1
-
-
- Dim xlApp As Microsoft.Office.Interop.Excel.Application
- Dim xlBook As Microsoft.Office.Interop.Excel.Workbook
- Dim xlSheet As Microsoft.Office.Interop.Excel.Worksheet
- Dim xlRange As Microsoft.Office.Interop.Excel.Range
-
- xlApp = CreateObject("Excel.Application")
- xlApp.Visible = False
- xlApp.DisplayAlerts = False
-
- xlBook = xlApp.Workbooks.Add
- xlSheet = xlBook.Worksheets(1)
- xlSheet.Name = "保税出库汇总"
- xlSheet.Activate()
-
- xlSheet.Cells(5, 5).select
-
-
-
-
-
-
- dgv1.SelectAll()
-
-
- Me.dgv1.ClipboardCopyMode = DataGridViewClipboardCopyMode.EnableAlwaysIncludeHeaderText
- Me.dgv1.RowHeadersVisible = False
-
- Clipboard.SetDataObject(dgv1.GetClipboardContent())
-
-
-
- xlApp.Range("B25").Select()
-
- xlSheet.Paste()
-
- xlApp.Visible = True
-
-
- '''' xlApp.ActiveSheet.Paste
- ''''xlApp.CutCopyMode = False
- xlApp.ActiveSheet.ListObjects.Add(Microsoft.Office.Interop.Excel.XlListObjectSourceType.xlSrcRange, xlApp.Range("$B$25:$g$" & dt1.Rows.Count + 25), , Microsoft.Office.Interop.Excel.XlYesNoGuess.xlYes).Name = "表1"
-
-
-
-
- Dim PTCache As Microsoft.Office.Interop.Excel.PivotCache
- Dim PT As Microsoft.Office.Interop.Excel.PivotTable
-
- 'Create the Cache
- PTCache = xlApp.ActiveWorkbook.PivotCaches.Create(SourceType:=Microsoft.Office.Interop.Excel.XlPivotTableSourceType.xlDatabase, SourceData:=xlApp.Range("$B$25:$g$" & dt1.Rows.Count + 25))
-
- 'Select the destination sheet
- xlSheet.Range("b2").Select()
-
- 'Create the Pivot table
- PT = xlSheet.PivotTables.Add(PivotCache:=PTCache, TableDestination:=xlSheet.Range("B2"), TableName:="Pivot1")
-
- xlApp.ActiveWorkbook.ShowPivotTableFieldList = True
-
- 'Adding fields
-
-
- With xlApp.ActiveSheet.PivotTables("Pivot1").PivotFields("品名")
- .Orientation = Microsoft.Office.Core.XlPivotFieldOrientation.xlRowField
- .Position = 1
- End With
-
-
- With xlApp.ActiveSheet.PivotTables("Pivot1").PivotFields("手册号")
- .Orientation = Microsoft.Office.Core.XlPivotFieldOrientation.xlColumnField
- .Position = 1
- End With
-
-
- With xlApp.ActiveSheet.PivotTables("Pivot1").PivotFields("月份")
- .Orientation = Microsoft.Office.Core.XlPivotFieldOrientation.xlColumnField
- .Position = 1
- End With
-
-
- With xlApp.ActiveSheet.PivotTables("pivot1")
- .AddDataField(xlApp.ActiveSheet.PivotTables("Pivot1").PivotFields("出库数量"), "重量合计", Microsoft.Office.Interop.Excel.XlConsolidationFunction.xlSum)
- End With
-
-
- 'With xlApp.ActiveSheet.PivotTables("pivot1")
- ' .AddDataField(xlApp.ActiveSheet.PivotTables("Pivot1").PivotFields("货值"), "货值合计", Microsoft.Office.Interop.Excel.XlConsolidationFunction.xlSum)
- 'End With
-
-
-
- xlApp.Visible = True
- xlApp = Nothing
- xlBook = Nothing
- xlSheet = Nothing
-
-
-
-
- End Sub
-
- Private Sub Button28_Click(sender As Object, e As EventArgs) Handles Button28.Click '---成品入库
-
-
-
- sql = "SELECT left(xno,12) AS 手册号, item_new AS 品名, name AS 明细, date AS 入库日期,month(date) as 入库月份, CAST(m_in AS numeric(10, 1)) AS 入库数量 FROM RT_BG_IO WHERE (item_new LIKE N'%牛二层皮%') AND (date between '" & dtp1.Value & "' and '" & dtp2.Value & "') AND (m_in <> 0)"
- cmd.CommandText = sql
- da.SelectCommand = cmd
- Dim dt1 As New DataTable
- da.Fill(dt1)
- If dt1.Rows.Count = 0 Then
- MsgBox("查无记录")
- Exit Sub
- End If
- dgv1.DataSource = dt1
-
- Dim xlApp As Microsoft.Office.Interop.Excel.Application
- Dim xlBook As Microsoft.Office.Interop.Excel.Workbook
- Dim xlSheet As Microsoft.Office.Interop.Excel.Worksheet
- Dim xlRange As Microsoft.Office.Interop.Excel.Range
-
- xlApp = CreateObject("Excel.Application")
- xlApp.Visible = False
- xlApp.DisplayAlerts = False
-
- xlBook = xlApp.Workbooks.Add
- xlSheet = xlBook.Worksheets(1)
- xlSheet.Name = "保税入库汇总"
- xlSheet.Activate()
-
- xlSheet.Cells(5, 5).select
-
-
-
-
-
-
- dgv1.SelectAll()
-
-
- Me.dgv1.ClipboardCopyMode = DataGridViewClipboardCopyMode.EnableAlwaysIncludeHeaderText
- Me.dgv1.RowHeadersVisible = False
-
- Clipboard.SetDataObject(dgv1.GetClipboardContent())
-
-
-
- xlApp.Range("B25").Select()
-
- xlSheet.Paste()
-
- xlApp.Visible = True
-
-
- '''' xlApp.ActiveSheet.Paste
- ''''xlApp.CutCopyMode = False
- xlApp.ActiveSheet.ListObjects.Add(Microsoft.Office.Interop.Excel.XlListObjectSourceType.xlSrcRange, xlApp.Range("$B$25:$g$" & dt1.Rows.Count + 25), , Microsoft.Office.Interop.Excel.XlYesNoGuess.xlYes).Name = "表1"
-
-
-
-
- Dim PTCache As Microsoft.Office.Interop.Excel.PivotCache
- Dim PT As Microsoft.Office.Interop.Excel.PivotTable
-
- 'Create the Cache
- PTCache = xlApp.ActiveWorkbook.PivotCaches.Create(SourceType:=Microsoft.Office.Interop.Excel.XlPivotTableSourceType.xlDatabase, SourceData:=xlApp.Range("$B$25:$g$" & dt1.Rows.Count + 25))
-
- 'Select the destination sheet
- xlSheet.Range("b2").Select()
-
- 'Create the Pivot table
- PT = xlSheet.PivotTables.Add(PivotCache:=PTCache, TableDestination:=xlSheet.Range("B2"), TableName:="Pivot1")
-
- xlApp.ActiveWorkbook.ShowPivotTableFieldList = True
-
- 'Adding fields
-
-
- With xlApp.ActiveSheet.PivotTables("Pivot1").PivotFields("品名")
- .Orientation = Microsoft.Office.Core.XlPivotFieldOrientation.xlRowField
- .Position = 1
- End With
-
-
- With xlApp.ActiveSheet.PivotTables("Pivot1").PivotFields("手册号")
- .Orientation = Microsoft.Office.Core.XlPivotFieldOrientation.xlColumnField
- .Position = 1
- End With
-
-
- With xlApp.ActiveSheet.PivotTables("Pivot1").PivotFields("入库月份")
- .Orientation = Microsoft.Office.Core.XlPivotFieldOrientation.xlColumnField
- .Position = 1
- End With
-
-
- With xlApp.ActiveSheet.PivotTables("pivot1")
- .AddDataField(xlApp.ActiveSheet.PivotTables("Pivot1").PivotFields("入库数量"), "重量合计", Microsoft.Office.Interop.Excel.XlConsolidationFunction.xlSum)
- End With
-
-
- 'With xlApp.ActiveSheet.PivotTables("pivot1")
- ' .AddDataField(xlApp.ActiveSheet.PivotTables("Pivot1").PivotFields("货值"), "货值合计", Microsoft.Office.Interop.Excel.XlConsolidationFunction.xlSum)
- 'End With
-
-
-
- xlApp.Visible = True
- xlApp = Nothing
- xlBook = Nothing
- xlSheet = Nothing
-
-
-
-
-
-
- End Sub
-
- Private Sub Button29_Click(sender As Object, e As EventArgs) Handles Button29.Click '----保税成品出库
-
- sql = "SELECT left(xno,12) AS 手册号, item_new AS 品名, name AS 明细, date AS 出库日期,month(date) as 出库月份, CAST(m_out AS numeric(10, 1)) AS 出库数量 FROM RT_BG_IO WHERE (item_new LIKE N'%牛二层皮%') AND (date between '" & dtp1.Value & "' and '" & dtp2.Value & "') AND (m_out <> 0)"
- cmd.CommandText = sql
- da.SelectCommand = cmd
- Dim dt1 As New DataTable
- da.Fill(dt1)
- If dt1.Rows.Count = 0 Then
- MsgBox("查无记录")
- Exit Sub
- End If
- dgv1.DataSource = dt1
-
-
-
- Dim xlApp As Microsoft.Office.Interop.Excel.Application
- Dim xlBook As Microsoft.Office.Interop.Excel.Workbook
- Dim xlSheet As Microsoft.Office.Interop.Excel.Worksheet
- Dim xlRange As Microsoft.Office.Interop.Excel.Range
-
- xlApp = CreateObject("Excel.Application")
- xlApp.Visible = False
- xlApp.DisplayAlerts = False
-
- xlBook = xlApp.Workbooks.Add
- xlSheet = xlBook.Worksheets(1)
- xlSheet.Name = "保税出库汇总"
- xlSheet.Activate()
-
- xlSheet.Cells(5, 5).select
-
-
-
-
-
-
- dgv1.SelectAll()
-
-
- Me.dgv1.ClipboardCopyMode = DataGridViewClipboardCopyMode.EnableAlwaysIncludeHeaderText
- Me.dgv1.RowHeadersVisible = False
-
- Clipboard.SetDataObject(dgv1.GetClipboardContent())
-
-
-
- xlApp.Range("B25").Select()
-
- xlSheet.Paste()
-
- xlApp.Visible = True
-
-
- '''' xlApp.ActiveSheet.Paste
- ''''xlApp.CutCopyMode = False
- xlApp.ActiveSheet.ListObjects.Add(Microsoft.Office.Interop.Excel.XlListObjectSourceType.xlSrcRange, xlApp.Range("$B$25:$g$" & dt1.Rows.Count + 25), , Microsoft.Office.Interop.Excel.XlYesNoGuess.xlYes).Name = "表1"
-
-
-
-
- Dim PTCache As Microsoft.Office.Interop.Excel.PivotCache
- Dim PT As Microsoft.Office.Interop.Excel.PivotTable
-
- 'Create the Cache
- PTCache = xlApp.ActiveWorkbook.PivotCaches.Create(SourceType:=Microsoft.Office.Interop.Excel.XlPivotTableSourceType.xlDatabase, SourceData:=xlApp.Range("$B$25:$g$" & dt1.Rows.Count + 25))
-
- 'Select the destination sheet
- xlSheet.Range("b2").Select()
-
- 'Create the Pivot table
- PT = xlSheet.PivotTables.Add(PivotCache:=PTCache, TableDestination:=xlSheet.Range("B2"), TableName:="Pivot1")
-
- xlApp.ActiveWorkbook.ShowPivotTableFieldList = True
-
- 'Adding fields
-
-
- With xlApp.ActiveSheet.PivotTables("Pivot1").PivotFields("品名")
- .Orientation = Microsoft.Office.Core.XlPivotFieldOrientation.xlRowField
- .Position = 1
- End With
-
-
- With xlApp.ActiveSheet.PivotTables("Pivot1").PivotFields("手册号")
- .Orientation = Microsoft.Office.Core.XlPivotFieldOrientation.xlColumnField
- .Position = 1
- End With
-
-
- With xlApp.ActiveSheet.PivotTables("Pivot1").PivotFields("出库月份")
- .Orientation = Microsoft.Office.Core.XlPivotFieldOrientation.xlColumnField
- .Position = 1
- End With
-
-
- With xlApp.ActiveSheet.PivotTables("pivot1")
- .AddDataField(xlApp.ActiveSheet.PivotTables("Pivot1").PivotFields("出库数量"), "重量合计", Microsoft.Office.Interop.Excel.XlConsolidationFunction.xlSum)
- End With
-
-
- 'With xlApp.ActiveSheet.PivotTables("pivot1")
- ' .AddDataField(xlApp.ActiveSheet.PivotTables("Pivot1").PivotFields("货值"), "货值合计", Microsoft.Office.Interop.Excel.XlConsolidationFunction.xlSum)
- 'End With
-
-
-
- xlApp.Visible = True
- xlApp = Nothing
- xlBook = Nothing
- xlSheet = Nothing
-
-
-
-
-
-
-
-
- End Sub
-
- Private Sub Button30_Click(sender As Object, e As EventArgs) Handles Button30.Click '--生产耗料
-
- sql = "SELECT distinct 手册号, 成品, 明细, 入库数量, 入库日期, 料件, 单耗, 料件耗用, 领料日期, MONTH(领料日期) AS 领料月份 FROM (SELECT TOP (100) PERCENT right(RT_BG_IO.xno, 5) AS 手册号, RT_BG_IO.item AS 成品, RT_BG_IO.name AS 明细, RT_BG_IO.m_in AS 入库数量, RT_BG_IO.date AS 入库日期, RT_BG_COM.NAME AS 料件, RT_BG_COM.PERCENTS AS 单耗, RT_BG_COM.PERCENTS * RT_BG_IO.m_in AS 料件耗用, CASE WHEN rt_bg_com.name LIKE N'%聚%' THEN DATEADD(day, - 2, RT_BG_IO.date) WHEN rt_bg_com.name LIKE N'%pu%' OR rt_bg_com.name LIKE N'%促%' THEN DATEADD(day, - 3, RT_BG_IO.date) WHEN rt_bg_com.name LIKE N'%蓝%' THEN DATEADD(day, - 14, RT_BG_IO.date) ELSE DATEADD(day, - 7, RT_BG_IO.date) END AS 领料日期 FROM RT_BG_IO INNER JOIN RT_BG_COM ON LEFT(RT_BG_IO.xno, 12) = RT_BG_COM.XNO AND RT_BG_IO.item = RT_BG_COM.product1 WHERE (RT_BG_IO.item LIKE N'%牛二层皮%') AND (RT_BG_IO.name LIKE '%入%') AND (RT_BG_IO.m_in <> 0) AND (date between '" & dtp1.Value & "' and '" & dtp2.Value & "') ORDER BY 入库数量) AS p"
-
- cmd.CommandText = sql
- da.SelectCommand = cmd
- Dim dt1 As New DataTable
- da.Fill(dt1)
- If dt1.Rows.Count = 0 Then
- MsgBox("查无记录")
- Exit Sub
- End If
- dgv1.DataSource = dt1
-
- Dim xlApp As Microsoft.Office.Interop.Excel.Application
- Dim xlBook As Microsoft.Office.Interop.Excel.Workbook
- Dim xlSheet As Microsoft.Office.Interop.Excel.Worksheet
- Dim xlRange As Microsoft.Office.Interop.Excel.Range
-
- xlApp = CreateObject("Excel.Application")
- xlApp.Visible = False
- xlApp.DisplayAlerts = False
-
- xlBook = xlApp.Workbooks.Add
- xlSheet = xlBook.Worksheets(1)
- xlSheet.Name = "料件领料汇总"
- xlSheet.Activate()
-
- xlSheet.Cells(5, 5).select
-
- dgv1.SelectAll()
-
- Me.dgv1.ClipboardCopyMode = DataGridViewClipboardCopyMode.EnableAlwaysIncludeHeaderText
- Me.dgv1.RowHeadersVisible = False
-
- Clipboard.SetDataObject(dgv1.GetClipboardContent())
-
- xlApp.Range("B30").Select()
-
- xlSheet.Paste()
-
- xlApp.Visible = True
-
- '''' xlApp.ActiveSheet.Paste
- ''''xlApp.CutCopyMode = False
- xlApp.ActiveSheet.ListObjects.Add(Microsoft.Office.Interop.Excel.XlListObjectSourceType.xlSrcRange, xlApp.Range("$B$30:$k$" & dt1.Rows.Count + 30), , Microsoft.Office.Interop.Excel.XlYesNoGuess.xlYes).Name = "表1"
-
- Dim PTCache As Microsoft.Office.Interop.Excel.PivotCache
- Dim PT As Microsoft.Office.Interop.Excel.PivotTable
-
- 'Create the Cache
- PTCache = xlApp.ActiveWorkbook.PivotCaches.Create(SourceType:=Microsoft.Office.Interop.Excel.XlPivotTableSourceType.xlDatabase, SourceData:=xlApp.Range("$B$30:$k$" & dt1.Rows.Count + 30))
-
- 'Select the destination sheet
- xlSheet.Range("b2").Select()
-
- 'Create the Pivot table
- PT = xlSheet.PivotTables.Add(PivotCache:=PTCache, TableDestination:=xlSheet.Range("B2"), TableName:="Pivot1")
-
- xlApp.ActiveWorkbook.ShowPivotTableFieldList = True
-
- 'Adding fields
-
- With xlApp.ActiveSheet.PivotTables("Pivot1").PivotFields("料件")
- .Orientation = Microsoft.Office.Core.XlPivotFieldOrientation.xlRowField
- .Position = 1
- End With
-
- With xlApp.ActiveSheet.PivotTables("Pivot1").PivotFields("成品")
- .Orientation = Microsoft.Office.Core.XlPivotFieldOrientation.xlColumnField
- .Position = 1
- End With
- With xlApp.ActiveSheet.PivotTables("Pivot1").PivotFields("手册号")
- .Orientation = Microsoft.Office.Core.XlPivotFieldOrientation.xlColumnField
- .Position = 1
- End With
- With xlApp.ActiveSheet.PivotTables("Pivot1").PivotFields("领料月份")
- .Orientation = Microsoft.Office.Core.XlPivotFieldOrientation.xlColumnField
- .Position = 1
- End With
-
- With xlApp.ActiveSheet.PivotTables("pivot1")
- .AddDataField(xlApp.ActiveSheet.PivotTables("Pivot1").PivotFields("料件耗用"), "耗用合计", Microsoft.Office.Interop.Excel.XlConsolidationFunction.xlSum)
- End With
-
-
- 'With xlApp.ActiveSheet.PivotTables("pivot1")
- ' .AddDataField(xlApp.ActiveSheet.PivotTables("Pivot1").PivotFields("货值"), "货值合计", Microsoft.Office.Interop.Excel.XlConsolidationFunction.xlSum)
- 'End With
-
- xlApp.Visible = True
- xlApp = Nothing
- xlBook = Nothing
- xlSheet = Nothing
-
-
- End Sub
-
- Private Sub Button17_Click(sender As Object, e As EventArgs)
-
- End Sub
-
- Private Sub Button14_Click(sender As Object, e As EventArgs) Handles Button14.Click
-
- End Sub
-
- Private Sub Button8_Click(sender As Object, e As EventArgs)
-
- End Sub
-
- Private Sub Button16_Click(sender As Object, e As EventArgs)
-
- End Sub
-
- Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
-
- End Sub
-
- Private Sub Button10_Click(sender As Object, e As EventArgs) Handles Button10.Click
-
- End Sub
-
- Private Sub Button3_Click(sender As Object, e As EventArgs)
-
- End Sub
-
- Private Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click
-
- End Sub
-
- Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
-
- End Sub
-
- Private Sub GroupBox1_Enter(sender As Object, e As EventArgs) Handles GroupBox1.Enter
-
- End Sub
-
- Private Sub Button3_Click_1(sender As Object, e As EventArgs) Handles Button3.Click '-----------------------------汇总
-
-
- Dim a As Integer = 0
-
-
- sql = "SELECT DATE1 AS 报关日期, Date2 AS 进厂日期, MONTH(Date2) AS 进厂月份, XNO AS 手册号, NAME AS 海关分类,type as 进口类型,matl_name AS 品名, QTY AS 数量, PRICE AS 单价, price*qty as 货值, ORIGIN AS 产地 FROM RT_BG_IN_DETAIL WHERE date2 between '" & String.Format("{0:d}", dtp1.Value) & "' and '" & String.Format("{0:d}", dtp2.Value) & "'"
- cmd.CommandText = sql
- da.SelectCommand = cmd
-
- da.Fill(dt1)
-
-
- If dt1.Rows.Count = 0 Then
- MsgBox("查无记录")
- Exit Sub
- End If
-
- dgv1.DataSource = dt1
-
-
-
-
-
- xlApp = CreateObject("Excel.Application")
- xlApp.Visible = False
- 'xlApp.DisplayAlerts = False
-
-
- xlBook = xlApp.Workbooks.Add
-
- xlSheet = xlBook.Worksheets.Add
- xlSheet.Name = "报关进口"
- xlSheet.Activate()
- xlSheet.Hyperlinks.Add(Anchor:=xlSheet.Cells(1, 1), Address:="", SubAddress:="总表!A1", TextToDisplay:="总表")
-
-
-
-
- xlSheet.Cells(5, 5).select
-
-
-
-
-
-
- dgv1.SelectAll()
-
-
- Me.dgv1.ClipboardCopyMode = DataGridViewClipboardCopyMode.EnableAlwaysIncludeHeaderText
- Me.dgv1.RowHeadersVisible = False
-
- Clipboard.SetDataObject(dgv1.GetClipboardContent())
- System.Threading.Thread.Sleep(1000)
- xlApp.Range("B30").Select()
-
- 'xlSheet.PasteSpecial("Unicode 文本", False, False)
- xlSheet.PasteSpecial()
- Clipboard.SetDataObject(DBNull.Value)
- ' xlApp.Visible = True
-
- xlApp.ActiveSheet.ListObjects.Add(Microsoft.Office.Interop.Excel.XlListObjectSourceType.xlSrcRange, xlApp.Range("$B$30:$L$" & dt1.Rows.Count + 30), , Microsoft.Office.Interop.Excel.XlYesNoGuess.xlYes).Name = "表1"
-
-
- 'Create the Cache
- PTCache = xlApp.ActiveWorkbook.PivotCaches.Create(SourceType:=Microsoft.Office.Interop.Excel.XlPivotTableSourceType.xlDatabase, SourceData:=xlApp.Range("$B$30:$L$" & dt1.Rows.Count + 30))
-
- 'Select the destination sheet
- xlSheet.Range("b2").Select()
-
- 'Create the Pivot table
- PT = xlSheet.PivotTables.Add(PivotCache:=PTCache, TableDestination:=xlSheet.Range("B2"), TableName:="Pivot1")
-
- xlApp.ActiveWorkbook.ShowPivotTableFieldList = True
-
- 'Adding fields
-
-
- With xlApp.ActiveSheet.PivotTables("Pivot1").PivotFields("海关分类")
- .Orientation = Microsoft.Office.Core.XlPivotFieldOrientation.xlRowField
- .Position = 1
- End With
-
- With xlApp.ActiveSheet.PivotTables("Pivot1").PivotFields("进厂月份")
- .Orientation = Microsoft.Office.Core.XlPivotFieldOrientation.xlColumnField
- .Position = 1
- End With
-
- With xlApp.ActiveSheet.PivotTables("Pivot1").PivotFields("手册号")
- .Orientation = Microsoft.Office.Core.XlPivotFieldOrientation.xlColumnField
- .Position = 1
- End With
-
-
-
- With xlApp.ActiveSheet.PivotTables("pivot1")
- .AddDataField(xlApp.ActiveSheet.PivotTables("Pivot1").PivotFields("数量"), "数量合计", Microsoft.Office.Interop.Excel.XlConsolidationFunction.xlSum)
- End With
-
-
- With xlApp.ActiveSheet.PivotTables("pivot1")
- .AddDataField(xlApp.ActiveSheet.PivotTables("Pivot1").PivotFields("货值"), "货值合计", Microsoft.Office.Interop.Excel.XlConsolidationFunction.xlSum)
- End With
-
-
-
- sql = "SELECT distinct XNO as 手册号, date1 as 报关日期, no as 报关单号,comment as 客户,month(date1) as 报关月份,name AS 品名, QTY AS 重量, cast(TOTAL as numeric(10,2)) AS 货值, cast(FEE as numeric(10,2)) AS 工缴费 FROM RT_BG_OUT where date1 between '" & String.Format("{0:d}", dtp1.Value) & "' and '" & String.Format("{0:d}", dtp2.Value) & "'"
- cmd.CommandText = sql
- da.SelectCommand = cmd
- dt1 = New DataTable
- da.Fill(dt1) '------------------------------报关出口汇总
-
- dgv1.DataSource = dt1
- xlSheet = xlBook.Worksheets.Add
- xlSheet.Name = "报关出口"
- xlSheet.Activate()
-
- xlSheet.Cells(5, 5).select
-
- xlSheet.Hyperlinks.Add(Anchor:=xlSheet.Cells(1, 1), Address:="", SubAddress:="总表!A1", TextToDisplay:="总表")
-
- dgv1.SelectAll()
-
-
- Me.dgv1.ClipboardCopyMode = DataGridViewClipboardCopyMode.EnableAlwaysIncludeHeaderText
- Me.dgv1.RowHeadersVisible = False
-
- Clipboard.SetDataObject(dgv1.GetClipboardContent())
-
- System.Threading.Thread.Sleep(1000)
-
-
- xlApp.Columns("d:d").Select
- xlApp.Selection.NumberFormatLocal = "@"
-
-
- xlApp.Range("B25").Select()
-
-
- 'xlSheet.PasteSpecial("Unicode 文本", False, False)
-
- xlSheet.PasteSpecial()
- Clipboard.SetDataObject(DBNull.Value)
- ' xlApp.Visible = True
-
-
- '''' xlApp.ActiveSheet.Paste
- ''''xlApp.CutCopyMode = False
- xlApp.ActiveSheet.ListObjects.Add(Microsoft.Office.Interop.Excel.XlListObjectSourceType.xlSrcRange, xlApp.Range("$B$25:$j$" & dt1.Rows.Count + 25), , Microsoft.Office.Interop.Excel.XlYesNoGuess.xlYes).Name = "表1"
-
-
-
-
- 'Dim PTCache As Microsoft.Office.Interop.Excel.PivotCache
- 'Dim PT As Microsoft.Office.Interop.Excel.PivotTable
-
- 'Create the Cache
- PTCache = xlApp.ActiveWorkbook.PivotCaches.Create(SourceType:=Microsoft.Office.Interop.Excel.XlPivotTableSourceType.xlDatabase, SourceData:=xlApp.Range("$B$25:$j$" & dt1.Rows.Count + 25))
-
- 'Select the destination sheet
- xlSheet.Range("b2").Select()
-
- 'Create the Pivot table
- PT = xlSheet.PivotTables.Add(PivotCache:=PTCache, TableDestination:=xlSheet.Range("B2"), TableName:="Pivot1")
-
- xlApp.ActiveWorkbook.ShowPivotTableFieldList = True
-
- 'Adding fields
-
-
- With xlApp.ActiveSheet.PivotTables("Pivot1").PivotFields("手册号")
- .Orientation = Microsoft.Office.Core.XlPivotFieldOrientation.xlRowField
- .Position = 1
- End With
-
- With xlApp.ActiveSheet.PivotTables("Pivot1").PivotFields("报关月份")
- .Orientation = Microsoft.Office.Core.XlPivotFieldOrientation.xlColumnField
- .Position = 1
- End With
-
-
- With xlApp.ActiveSheet.PivotTables("pivot1")
- .AddDataField(xlApp.ActiveSheet.PivotTables("Pivot1").PivotFields("重量"), "重量合计", Microsoft.Office.Interop.Excel.XlConsolidationFunction.xlSum)
- End With
-
-
- With xlApp.ActiveSheet.PivotTables("pivot1")
- .AddDataField(xlApp.ActiveSheet.PivotTables("Pivot1").PivotFields("货值"), "货值合计", Microsoft.Office.Interop.Excel.XlConsolidationFunction.xlSum)
- End With
-
-
-
-
- '----------------------------------------------------------------------保税入库
-
-
- sql = "SELECT m_in AS 入库数量, LEFT(xno, 12) AS 手册号, date2 AS 进厂日期, MONTH(date2) AS 进厂月份, item_new AS 品名, name AS 明细 FROM RT_BG_IO WHERE (m_in <> 0) AND (date between '" & String.Format("{0:d}", dtp1.Value) & "' and '" & String.Format("{0:d}", dtp2.Value) & "') AND (item_new NOT LIKE N'%牛二层皮%')"
- cmd.CommandText = sql
- da.SelectCommand = cmd
- dt1 = New DataTable
- da.Fill(dt1)
-
-
- dgv1.DataSource = dt1
- xlSheet = xlBook.Worksheets.Add
- xlSheet.Name = "保税入库"
- xlSheet.Activate()
- xlSheet.Hyperlinks.Add(Anchor:=xlSheet.Cells(1, 1), Address:="", SubAddress:="总表!A1", TextToDisplay:="总表")
-
- xlSheet.Cells(5, 5).select
- dgv1.SelectAll()
-
-
- Me.dgv1.ClipboardCopyMode = DataGridViewClipboardCopyMode.EnableAlwaysIncludeHeaderText
- Me.dgv1.RowHeadersVisible = False
-
- Clipboard.SetDataObject(dgv1.GetClipboardContent())
-
- System.Threading.Thread.Sleep(1000)
-
- xlApp.Range("B30").Select()
-
- ' xlSheet.PasteSpecial("Unicode 文本", False, False)
- 'xlSheet.PasteSpecial()
-
- xlSheet.Paste()
-
- Clipboard.SetDataObject(DBNull.Value)
- ' xlApp.Visible = True
-
-
- '''' xlApp.ActiveSheet.Paste
- ''''xlApp.CutCopyMode = False
- xlApp.ActiveSheet.ListObjects.Add(Microsoft.Office.Interop.Excel.XlListObjectSourceType.xlSrcRange, xlApp.Range("$B$30:$g$" & dt1.Rows.Count + 31), , Microsoft.Office.Interop.Excel.XlYesNoGuess.xlYes).Name = "表1"
-
-
-
-
-
-
- 'Create the Cache
- PTCache = xlApp.ActiveWorkbook.PivotCaches.Create(SourceType:=Microsoft.Office.Interop.Excel.XlPivotTableSourceType.xlDatabase, SourceData:=xlApp.Range("$B$30:$g$" & dt1.Rows.Count + 31))
-
- 'Select the destination sheet
- xlSheet.Range("b2").Select()
-
- 'Create the Pivot table
- PT = xlSheet.PivotTables.Add(PivotCache:=PTCache, TableDestination:=xlSheet.Range("B2"), TableName:="Pivot1")
-
- xlApp.ActiveWorkbook.ShowPivotTableFieldList = True
-
- 'Adding fields
-
-
- With xlApp.ActiveSheet.PivotTables("Pivot1").PivotFields("品名")
- .Orientation = Microsoft.Office.Core.XlPivotFieldOrientation.xlRowField
- .Position = 1
- End With
-
-
- With xlApp.ActiveSheet.PivotTables("Pivot1").PivotFields("手册号")
- .Orientation = Microsoft.Office.Core.XlPivotFieldOrientation.xlColumnField
- .Position = 1
- End With
-
-
- With xlApp.ActiveSheet.PivotTables("Pivot1").PivotFields("进厂月份")
- .Orientation = Microsoft.Office.Core.XlPivotFieldOrientation.xlColumnField
- .Position = 1
- End With
-
-
- With xlApp.ActiveSheet.PivotTables("pivot1")
- .AddDataField(xlApp.ActiveSheet.PivotTables("Pivot1").PivotFields("入库数量"), "重量合计", Microsoft.Office.Interop.Excel.XlConsolidationFunction.xlSum)
- End With
-
-
- 'With xlApp.ActiveSheet.PivotTables("pivot1")
- ' .AddDataField(xlApp.ActiveSheet.PivotTables("Pivot1").PivotFields("货值"), "货值合计", Microsoft.Office.Interop.Excel.XlConsolidationFunction.xlSum)
- 'End With
-
-
-
-
- '--------------------------------------------------------------------------------------------------------------------------------保税出库汇总
- sql = "SELECT m_out AS 出库数量, LEFT(xno, 12) AS 手册号, date AS 日期, MONTH(date) AS 月份, item_new AS 品名, name AS 明细 FROM RT_BG_IO WHERE (m_out <> 0) AND (date between '" & String.Format("{0:d}", dtp1.Value) & "' and '" & String.Format("{0:d}", dtp2.Value) & "') And (item_new Not LIKE N'%牛二层皮%')"
- cmd.CommandText = sql
- da.SelectCommand = cmd
- dt1 = New DataTable
- da.Fill(dt1)
-
- dgv1.DataSource = dt1
-
-
-
-
- xlSheet = xlBook.Worksheets.Add
- xlSheet.Name = "保税出库"
- xlSheet.Activate()
-
- xlSheet.Cells(5, 5).select
-
- xlSheet.Hyperlinks.Add(Anchor:=xlSheet.Cells(1, 1), Address:="", SubAddress:="总表!A1", TextToDisplay:="总表")
-
- dgv1.SelectAll()
-
-
- Me.dgv1.ClipboardCopyMode = DataGridViewClipboardCopyMode.EnableAlwaysIncludeHeaderText
- Me.dgv1.RowHeadersVisible = False
-
- Clipboard.SetDataObject(dgv1.GetClipboardContent())
-
- System.Threading.Thread.Sleep(1000)
-
- xlApp.Range("B30").Select()
-
- ' xlSheet.PasteSpecial("Unicode 文本", False, False)
- xlSheet.PasteSpecial()
- Clipboard.SetDataObject(DBNull.Value)
- ' xlApp.Visible = True
-
-
- '''' xlApp.ActiveSheet.Paste
- ''''xlApp.CutCopyMode = False
- xlApp.ActiveSheet.ListObjects.Add(Microsoft.Office.Interop.Excel.XlListObjectSourceType.xlSrcRange, xlApp.Range("$B$30:$g$" & dt1.Rows.Count + 30), , Microsoft.Office.Interop.Excel.XlYesNoGuess.xlYes).Name = "表1"
-
-
-
-
-
- 'Create the Cache
- PTCache = xlApp.ActiveWorkbook.PivotCaches.Create(SourceType:=Microsoft.Office.Interop.Excel.XlPivotTableSourceType.xlDatabase, SourceData:=xlApp.Range("$B$30:$g$" & dt1.Rows.Count + 30))
-
- 'Select the destination sheet
- xlSheet.Range("b2").Select()
-
- 'Create the Pivot table
- PT = xlSheet.PivotTables.Add(PivotCache:=PTCache, TableDestination:=xlSheet.Range("B2"), TableName:="Pivot1")
-
- xlApp.ActiveWorkbook.ShowPivotTableFieldList = True
-
- 'Adding fields
-
-
- With xlApp.ActiveSheet.PivotTables("Pivot1").PivotFields("品名")
- .Orientation = Microsoft.Office.Core.XlPivotFieldOrientation.xlRowField
- .Position = 1
- End With
-
-
- With xlApp.ActiveSheet.PivotTables("Pivot1").PivotFields("手册号")
- .Orientation = Microsoft.Office.Core.XlPivotFieldOrientation.xlColumnField
- .Position = 1
- End With
-
-
- With xlApp.ActiveSheet.PivotTables("Pivot1").PivotFields("月份")
- .Orientation = Microsoft.Office.Core.XlPivotFieldOrientation.xlColumnField
- .Position = 1
- End With
-
-
- With xlApp.ActiveSheet.PivotTables("pivot1")
- .AddDataField(xlApp.ActiveSheet.PivotTables("Pivot1").PivotFields("出库数量"), "重量合计", Microsoft.Office.Interop.Excel.XlConsolidationFunction.xlSum)
- End With
-
-
-
- '---------------------------------------------------------------------------------------------------成品入库
-
-
- sql = "SELECT distinct left(xno,12) AS 手册号, item AS 品名, name AS 明细, date AS 入库日期,month(date) as 入库月份, CAST(m_in AS numeric(10, 1)) AS 入库数量 FROM RT_BG_IO WHERE (item_new LIKE N'%牛二层皮%') AND (date between '" & String.Format("{0:d}", dtp1.Value) & "' and '" & String.Format("{0:d}", dtp2.Value) & "') AND (m_in <> 0)"
- cmd.CommandText = sql
- da.SelectCommand = cmd
- dt1 = New DataTable
- da.Fill(dt1)
-
- dgv1.DataSource = dt1
-
-
- xlSheet = xlBook.Worksheets.Add
- xlSheet.Name = "成品入库"
- xlSheet.Activate()
-
- xlSheet.Cells(5, 5).select
- xlSheet.Hyperlinks.Add(Anchor:=xlSheet.Cells(1, 1), Address:="", SubAddress:="总表!A1", TextToDisplay:="总表")
-
-
- dgv1.SelectAll()
-
-
- Me.dgv1.ClipboardCopyMode = DataGridViewClipboardCopyMode.EnableAlwaysIncludeHeaderText
- Me.dgv1.RowHeadersVisible = False
-
- Clipboard.SetDataObject(dgv1.GetClipboardContent())
- System.Threading.Thread.Sleep(1000)
-
-
- xlApp.Range("B30").Select()
-
- 'xlSheet.PasteSpecial("Unicode 文本", False, False)
- xlSheet.PasteSpecial()
- Clipboard.SetDataObject(DBNull.Value)
- ' xlApp.Visible = True
-
-
- '''' xlApp.ActiveSheet.Paste
- ''''xlApp.CutCopyMode = False
- xlApp.ActiveSheet.ListObjects.Add(Microsoft.Office.Interop.Excel.XlListObjectSourceType.xlSrcRange, xlApp.Range("$B$30:$g$" & dt1.Rows.Count + 30), , Microsoft.Office.Interop.Excel.XlYesNoGuess.xlYes).Name = "表1"
-
-
-
-
-
-
- 'Create the Cache
- PTCache = xlApp.ActiveWorkbook.PivotCaches.Create(SourceType:=Microsoft.Office.Interop.Excel.XlPivotTableSourceType.xlDatabase, SourceData:=xlApp.Range("$B$30:$g$" & dt1.Rows.Count + 30))
-
- 'Select the destination sheet
- xlSheet.Range("b2").Select()
-
- 'Create the Pivot table
- PT = xlSheet.PivotTables.Add(PivotCache:=PTCache, TableDestination:=xlSheet.Range("B2"), TableName:="Pivot1")
-
- xlApp.ActiveWorkbook.ShowPivotTableFieldList = True
-
- 'Adding fields
-
-
- With xlApp.ActiveSheet.PivotTables("Pivot1").PivotFields("品名")
- .Orientation = Microsoft.Office.Core.XlPivotFieldOrientation.xlRowField
- .Position = 1
- End With
-
-
- With xlApp.ActiveSheet.PivotTables("Pivot1").PivotFields("手册号")
- .Orientation = Microsoft.Office.Core.XlPivotFieldOrientation.xlColumnField
- .Position = 1
- End With
-
-
- With xlApp.ActiveSheet.PivotTables("Pivot1").PivotFields("入库月份")
- .Orientation = Microsoft.Office.Core.XlPivotFieldOrientation.xlColumnField
- .Position = 1
- End With
-
-
- With xlApp.ActiveSheet.PivotTables("pivot1")
- .AddDataField(xlApp.ActiveSheet.PivotTables("Pivot1").PivotFields("入库数量"), "重量合计", Microsoft.Office.Interop.Excel.XlConsolidationFunction.xlSum)
- End With
-
-
-
- '--------------------------------------------------------------------------保税成品出库
-
-
- sql = "SELECT distinct left(xno,12) AS 手册号, item AS 品名, name AS 明细, date AS 出厂日期,month(date) as 出厂月份, CAST(m_out AS numeric(10, 2)) AS 出库数量 FROM RT_BG_IO WHERE (item_new LIKE N'%牛二层皮%') AND (date between '" & String.Format("{0:d}", dtp1.Value) & "' and '" & String.Format("{0:d}", dtp2.Value) & "') AND (m_out <> 0)"
- cmd.CommandText = sql
- da.SelectCommand = cmd
- dt1 = New DataTable
- da.Fill(dt1)
-
- dgv1.DataSource = dt1
-
-
-
-
- xlSheet = xlBook.Worksheets.Add
- xlSheet.Name = "成品出库"
- xlSheet.Activate()
-
- xlSheet.Cells(5, 5).select
- xlSheet.Hyperlinks.Add(Anchor:=xlSheet.Cells(1, 1), Address:="", SubAddress:="总表!A1", TextToDisplay:="总表")
-
-
- dgv1.SelectAll()
-
-
- Me.dgv1.ClipboardCopyMode = DataGridViewClipboardCopyMode.EnableAlwaysIncludeHeaderText
- Me.dgv1.RowHeadersVisible = False
-
- Clipboard.SetDataObject(dgv1.GetClipboardContent())
-
- System.Threading.Thread.Sleep(1000)
-
- xlApp.Range("B30").Select()
-
- 'xlSheet.PasteSpecial("Unicode 文本", False, False)
- xlSheet.PasteSpecial()
- Clipboard.SetDataObject(DBNull.Value)
- ' xlApp.Visible = True
-
-
- '''' xlApp.ActiveSheet.Paste
- ''''xlApp.CutCopyMode = False
- xlApp.ActiveSheet.ListObjects.Add(Microsoft.Office.Interop.Excel.XlListObjectSourceType.xlSrcRange, xlApp.Range("$B$30:$g$" & dt1.Rows.Count + 30), , Microsoft.Office.Interop.Excel.XlYesNoGuess.xlYes).Name = "表1"
-
-
- 'Create the Cache
- PTCache = xlApp.ActiveWorkbook.PivotCaches.Create(SourceType:=Microsoft.Office.Interop.Excel.XlPivotTableSourceType.xlDatabase, SourceData:=xlApp.Range("$B$30:$g$" & dt1.Rows.Count + 30))
-
- 'Select the destination sheet
- xlSheet.Range("b2").Select()
-
- 'Create the Pivot table
- PT = xlSheet.PivotTables.Add(PivotCache:=PTCache, TableDestination:=xlSheet.Range("B2"), TableName:="Pivot1")
-
- xlApp.ActiveWorkbook.ShowPivotTableFieldList = True
-
- 'Adding fields
-
-
- With xlApp.ActiveSheet.PivotTables("Pivot1").PivotFields("品名")
- .Orientation = Microsoft.Office.Core.XlPivotFieldOrientation.xlRowField
- .Position = 1
- End With
-
-
- With xlApp.ActiveSheet.PivotTables("Pivot1").PivotFields("手册号")
- .Orientation = Microsoft.Office.Core.XlPivotFieldOrientation.xlColumnField
- .Position = 1
- End With
-
-
- With xlApp.ActiveSheet.PivotTables("Pivot1").PivotFields("出厂月份")
- .Orientation = Microsoft.Office.Core.XlPivotFieldOrientation.xlColumnField
- .Position = 1
- End With
-
-
- With xlApp.ActiveSheet.PivotTables("pivot1")
- .AddDataField(xlApp.ActiveSheet.PivotTables("Pivot1").PivotFields("出库数量"), "重量合计", Microsoft.Office.Interop.Excel.XlConsolidationFunction.xlSum)
- End With
-
-
- '------------------------------------------------------------------------------成品入库耗料
-
- sql = "SELECT distinct 手册号, 成品, 明细, 入库数量, 入库日期, 料件, 单耗, 料件耗用, 领料日期, MONTH(领料日期) AS 领料月份 FROM (SELECT TOP (100) PERCENT LEFT(RT_BG_IO.xno, 12) AS 手册号, RT_BG_IO.item AS 成品, RT_BG_IO.name AS 明细,RT_BG_IO.m_in AS 入库数量, RT_BG_IO.date AS 入库日期, RT_BG_COM.NAME AS 料件, RT_BG_COM.PERCENTS AS 单耗, RT_BG_COM.PERCENTS * RT_BG_IO.m_in AS 料件耗用, CASE WHEN rt_bg_com.name LIKE N'%聚%' THEN DATEADD(day, - 2, RT_BG_IO.date) WHEN rt_bg_com.name LIKE N'%pu%' OR rt_bg_com.name LIKE N'%促%' THEN DATEADD(day, - 3, RT_BG_IO.date) WHEN rt_bg_com.name LIKE N'%蓝%' THEN DATEADD(day, - 14, RT_BG_IO.date) ELSE DATEADD(day, - 7, RT_BG_IO.date) END AS 领料日期 FROM RT_BG_IO INNER JOIN RT_BG_COM ON LEFT(RT_BG_IO.xno, 12) = RT_BG_COM.XNO AND RT_BG_IO.item = RT_BG_COM.product1 WHERE (RT_BG_IO.item LIKE N'%牛二层皮%') AND (RT_BG_IO.name LIKE '%入%') AND (RT_BG_IO.m_in <> 0) AND (date between '" & String.Format("{0:d}", dtp1.Value) & "' and '" & String.Format("{0:d}", dtp2.Value) & "') ORDER BY 入库数量) AS p"
-
- cmd.CommandText = sql
- da.SelectCommand = cmd
- dt1 = New DataTable
- da.Fill(dt1)
-
- dgv1.DataSource = dt1
-
- xlSheet = xlBook.Worksheets.Add
- xlSheet.Name = "生产领料"
- xlSheet.Activate()
-
- xlSheet.Cells(5, 5).select
-
- xlSheet.Hyperlinks.Add(Anchor:=xlSheet.Cells(1, 1), Address:="", SubAddress:="总表!A1", TextToDisplay:="总表")
-
-
- dgv1.SelectAll()
-
-
- Me.dgv1.ClipboardCopyMode = DataGridViewClipboardCopyMode.EnableAlwaysIncludeHeaderText
- Me.dgv1.RowHeadersVisible = False
-
- Clipboard.SetDataObject(dgv1.GetClipboardContent())
-
- System.Threading.Thread.Sleep(1000)
-
- xlApp.Range("B30").Select()
-
- 'xlSheet.PasteSpecial("Unicode 文本", False, False)
- ' xlSheet.PasteSpecial()
- xlSheet.Paste()
-
- Clipboard.SetDataObject(DBNull.Value)
- ' xlApp.Visible = True
-
-
- 'xlApp.ActiveSheet.Paste
- ''''xlApp.CutCopyMode = False
- xlApp.ActiveSheet.ListObjects.Add(Microsoft.Office.Interop.Excel.XlListObjectSourceType.xlSrcRange, xlApp.Range("$B$30:$k$" & dt1.Rows.Count + 30), , Microsoft.Office.Interop.Excel.XlYesNoGuess.xlYes).Name = "表1"
-
- 'Create the Cache
- PTCache = xlApp.ActiveWorkbook.PivotCaches.Create(SourceType:=Microsoft.Office.Interop.Excel.XlPivotTableSourceType.xlDatabase, SourceData:=xlApp.Range("$B$30:$k$" & dt1.Rows.Count + 30))
-
- 'Select the destination sheet
- xlSheet.Range("b2").Select()
-
- 'Create the Pivot table
- PT = xlSheet.PivotTables.Add(PivotCache:=PTCache, TableDestination:=xlSheet.Range("B2"), TableName:="Pivot1")
-
- xlApp.ActiveWorkbook.ShowPivotTableFieldList = True
-
-
- With xlApp.ActiveSheet.PivotTables("Pivot1").PivotFields("料件")
- .Orientation = Microsoft.Office.Core.XlPivotFieldOrientation.xlRowField
- .Position = 1
- End With
-
- With xlApp.ActiveSheet.PivotTables("Pivot1").PivotFields("领料月份")
- .Orientation = Microsoft.Office.Core.XlPivotFieldOrientation.xlColumnField
- .Position = 1
- End With
-
- With xlApp.ActiveSheet.PivotTables("Pivot1").PivotFields("手册号")
- .Orientation = Microsoft.Office.Core.XlPivotFieldOrientation.xlColumnField
- .Position = 1
- End With
-
- With xlApp.ActiveSheet.PivotTables("Pivot1").PivotFields("成品")
- .Orientation = Microsoft.Office.Core.XlPivotFieldOrientation.xlColumnField
- .Position = 1
- End With
-
-
-
-
- With xlApp.ActiveSheet.PivotTables("pivot1")
- .AddDataField(xlApp.ActiveSheet.PivotTables("Pivot1").PivotFields("料件耗用"), "耗用合计", Microsoft.Office.Interop.Excel.XlConsolidationFunction.xlSum)
- End With
-
-
-
-
- '------------------------------------------------------------------------------成品出库耗料
-
- sql = "SELECT distinct 手册号, 成品, 明细, 出库数量, 出库日期, 料件, 单耗, 料件耗用, 领料日期, MONTH(领料日期) AS 领料月份 FROM (SELECT TOP (100) PERCENT LEFT(RT_BG_IO.xno, 12) AS 手册号, RT_BG_IO.item AS 成品, RT_BG_IO.name AS 明细, RT_BG_IO.m_out AS 出库数量, RT_BG_IO.date AS 出库日期, RT_BG_COM.NAME AS 料件, RT_BG_COM.PERCENTS AS 单耗, RT_BG_COM.PERCENTS * RT_BG_IO.m_out AS 料件耗用, CASE WHEN rt_bg_com.name LIKE N'%聚%' THEN DATEADD(day, - 2, RT_BG_IO.date) WHEN rt_bg_com.name LIKE N'%pu%' OR rt_bg_com.name LIKE N'%促%' THEN DATEADD(day, - 3, RT_BG_IO.date) WHEN rt_bg_com.name LIKE N'%蓝%' THEN DATEADD(day, - 14, RT_BG_IO.date) ELSE DATEADD(day, - 7, RT_BG_IO.date) END AS 领料日期 FROM RT_BG_IO INNER JOIN RT_BG_COM ON LEFT(RT_BG_IO.xno, 12) = RT_BG_COM.XNO AND RT_BG_IO.item = RT_BG_COM.product1 WHERE (RT_BG_IO.item LIKE N'%牛二层皮%') AND (RT_BG_IO.name LIKE '%出%') AND (RT_BG_IO.m_out <> 0) AND (date between '" & String.Format("{0:d}", dtp1.Value) & "' and '" & String.Format("{0:d}", dtp2.Value) & "') ORDER BY 出库数量) AS p"
-
- cmd.CommandText = sql
- da.SelectCommand = cmd
- dt1 = New DataTable
- da.Fill(dt1)
-
- dgv1.DataSource = dt1
-
- xlSheet = xlBook.Worksheets.Add
- xlSheet.Name = "出口耗料"
- xlSheet.Activate()
-
- xlSheet.Cells(5, 5).select
-
- xlSheet.Hyperlinks.Add(Anchor:=xlSheet.Cells(1, 1), Address:="", SubAddress:="总表!A1", TextToDisplay:="总表")
-
-
- dgv1.SelectAll()
-
-
- Me.dgv1.ClipboardCopyMode = DataGridViewClipboardCopyMode.EnableAlwaysIncludeHeaderText
- Me.dgv1.RowHeadersVisible = False
-
- Clipboard.SetDataObject(dgv1.GetClipboardContent())
-
- System.Threading.Thread.Sleep(1000)
-
- xlApp.Range("B30").Select()
-
- 'xlSheet.PasteSpecial("Unicode 文本", False, False)
- xlSheet.PasteSpecial()
- Clipboard.SetDataObject(DBNull.Value)
- ' xlApp.Visible = True
-
-
- '''' xlApp.ActiveSheet.Paste
- ''''xlApp.CutCopyMode = False
- xlApp.ActiveSheet.ListObjects.Add(Microsoft.Office.Interop.Excel.XlListObjectSourceType.xlSrcRange, xlApp.Range("$B$30:$k$" & dt1.Rows.Count + 30), , Microsoft.Office.Interop.Excel.XlYesNoGuess.xlYes).Name = "表1"
-
- 'Create the Cache
- PTCache = xlApp.ActiveWorkbook.PivotCaches.Create(SourceType:=Microsoft.Office.Interop.Excel.XlPivotTableSourceType.xlDatabase, SourceData:=xlApp.Range("$B$30:$k$" & dt1.Rows.Count + 30))
-
- 'Select the destination sheet
- xlSheet.Range("b2").Select()
-
- 'Create the Pivot table
- PT = xlSheet.PivotTables.Add(PivotCache:=PTCache, TableDestination:=xlSheet.Range("B2"), TableName:="Pivot1")
-
- xlApp.ActiveWorkbook.ShowPivotTableFieldList = True
-
-
- With xlApp.ActiveSheet.PivotTables("Pivot1").PivotFields("料件")
- .Orientation = Microsoft.Office.Core.XlPivotFieldOrientation.xlRowField
- .Position = 1
- End With
-
- With xlApp.ActiveSheet.PivotTables("Pivot1").PivotFields("领料月份")
- .Orientation = Microsoft.Office.Core.XlPivotFieldOrientation.xlColumnField
- .Position = 1
- End With
-
- With xlApp.ActiveSheet.PivotTables("Pivot1").PivotFields("手册号")
- .Orientation = Microsoft.Office.Core.XlPivotFieldOrientation.xlColumnField
- .Position = 1
- End With
-
- With xlApp.ActiveSheet.PivotTables("Pivot1").PivotFields("成品")
- .Orientation = Microsoft.Office.Core.XlPivotFieldOrientation.xlColumnField
- .Position = 1
- End With
-
-
-
-
- With xlApp.ActiveSheet.PivotTables("pivot1")
- .AddDataField(xlApp.ActiveSheet.PivotTables("Pivot1").PivotFields("料件耗用"), "耗用合计", Microsoft.Office.Interop.Excel.XlConsolidationFunction.xlSum)
- End With
-
-
-
-
-
- '-----------------------------------------------------------------------------------analysis_data
-
-
- analysis_data("A0006", "蓝湿牛皮")
- analysis_data("A0006", "有机鞣料")
- analysis_data("A0006", "无机鞣料")
- ' analysis_data("A0006", "合成油脂(矿)")
- analysis_data("A0006", "合成油脂")
- analysis_data("A0006", "皮革整理剂")
- analysis_data("A0006", "表面活性剂")
- analysis_data("A0006", "聚氨酯混合液")
- analysis_data("A0006", "复鞣助剂")
- analysis_data("A0006", "制革染料")
- analysis_data("A0006", "PU树脂")
- analysis_data("A0006", "皮革促进剂")
-
- analysis_data("A0008", "蓝湿牛皮")
- analysis_data("A0008", "有机鞣料")
- analysis_data("A0008", "无机鞣料")
- analysis_data("A0008", "合成油脂(矿)")
- analysis_data("A0008", "合成油脂")
- analysis_data("A0008", "皮革整理剂")
- analysis_data("A0008", "表面活性剂")
- analysis_data("A0008", "聚氨酯混合液")
- analysis_data("A0008", "复鞣助剂")
- analysis_data("A0008", "制革染料")
- analysis_data("A0008", "PU树脂")
- analysis_data("A0008", "皮革促进剂")
-
-
-
- '------------------------------------------------车间
-
- analysis_data_1("A0008", "蓝湿牛皮")
- analysis_data_1("A0008", "有机鞣料")
- analysis_data_1("A0008", "无机鞣料")
- analysis_data_1("A0008", "合成油脂(矿)")
- analysis_data_1("A0008", "合成油脂")
- analysis_data_1("A0008", "皮革整理剂")
- analysis_data_1("A0008", "表面活性剂")
- analysis_data_1("A0008", "聚氨酯混合液")
- analysis_data_1("A0008", "复鞣助剂")
- analysis_data_1("A0008", "制革染料")
- analysis_data_1("A0008", "PU树脂")
- analysis_data_1("A0008", "皮革促进剂")
-
-
- analysis_data_1("A0006", "蓝湿牛皮")
- analysis_data_1("A0006", "有机鞣料")
- analysis_data_1("A0006", "无机鞣料")
- 'analysis_data_1("A0006", "合成油脂(矿)")
- analysis_data_1("A0006", "合成油脂")
- analysis_data_1("A0006", "皮革整理剂")
- analysis_data_1("A0006", "表面活性剂")
- analysis_data_1("A0006", "聚氨酯混合液")
- analysis_data_1("A0006", "复鞣助剂")
- analysis_data_1("A0006", "制革染料")
- analysis_data_1("A0006", "PU树脂")
- analysis_data_1("A0006", "皮革促进剂")
-
-
-
-
- '--------------------------------------------------成品
- analysis_finish("A0008", "PU牛二层皮")
- analysis_finish("A0008", "牛二层皮1")
- analysis_finish("A0008", "牛二层皮2")
- analysis_finish("A0008", "牛二层皮3")
- analysis_finish("A0008", "牛二层皮4")
-
-
-
- analysis_finish("A0006", "PU牛二层皮")
- analysis_finish("A0006", "牛二层皮5")
- analysis_finish("A0006", "牛二层皮6")
-
-
-
-
-
-
-
- sheet_sum()
-
-
-
-
-
-
- 'With xlApp.ActiveSheet.PivotTables("pivot1").PivotFields("出库累计")
- ' .Calculation = Microsoft.Office.Interop.Excel.XlPivotFieldCalculation.xlRunningTotal
- ' .BaseField = "日期"
- ' .NumberFormat = "#,##0.000;[红色](0.00)"
- 'End With
-
-
-
- 'With xlApp.ActiveSheet.PivotTables("pivot1").PivotFields("入库累计")
- ' .Calculation = Microsoft.Office.Interop.Excel.XlPivotFieldCalculation.xlRunningTotal
- ' .BaseField = "日期"
- ' .NumberFormat = "#,##0.000;[红色](0.00)"
- 'End With
-
-
-
- xlApp.Visible = True
-
-
- MsgBox("完成")
- xlApp.Visible = True
- xlApp.Visible = True
- xlApp = Nothing
- xlBook = Nothing
- xlSheet = Nothing
-
-
-
- End Sub
-
- Private Sub sheet_sum()
-
-
- xlSheet = xlBook.Worksheets.Add
- xlSheet.Name = "总表"
- xlSheet.Activate()
-
-
- xlSheet.Hyperlinks.Add(Anchor:=xlSheet.Cells(3, 3), Address:="", SubAddress:="报关进口!A1", TextToDisplay:="报关进口")
- xlSheet.Hyperlinks.Add(Anchor:=xlSheet.Cells(3, 4), Address:="", SubAddress:="报关出口!A1", TextToDisplay:="报关出口")
- xlSheet.Hyperlinks.Add(Anchor:=xlSheet.Cells(4, 3), Address:="", SubAddress:="保税入库!A1", TextToDisplay:="保税入库")
- xlSheet.Hyperlinks.Add(Anchor:=xlSheet.Cells(4, 4), Address:="", SubAddress:="保税出库!A1", TextToDisplay:="保税出库")
- xlSheet.Hyperlinks.Add(Anchor:=xlSheet.Cells(5, 3), Address:="", SubAddress:="成品入库!A1", TextToDisplay:="成品入库")
- xlSheet.Hyperlinks.Add(Anchor:=xlSheet.Cells(5, 4), Address:="", SubAddress:="成品出库!A1", TextToDisplay:="成品出库")
- xlSheet.Hyperlinks.Add(Anchor:=xlSheet.Cells(6, 3), Address:="", SubAddress:="生产领料!A1", TextToDisplay:="生产领料")
- xlSheet.Hyperlinks.Add(Anchor:=xlSheet.Cells(6, 4), Address:="", SubAddress:="出口耗料!A1", TextToDisplay:="出口耗料")
-
-
- xlSheet.Hyperlinks.Add(Anchor:=xlSheet.Cells(8, 3), Address:="", SubAddress:="A0008蓝湿牛皮!A1", TextToDisplay:="A0008蓝湿牛皮")
- xlSheet.Hyperlinks.Add(Anchor:=xlSheet.Cells(9, 3), Address:="", SubAddress:="A0008有机鞣料!A1", TextToDisplay:="A0008有机鞣料")
- xlSheet.Hyperlinks.Add(Anchor:=xlSheet.Cells(10, 3), Address:="", SubAddress:="A0008无机鞣料!A1", TextToDisplay:="A0008无机鞣料")
- xlSheet.Hyperlinks.Add(Anchor:=xlSheet.Cells(11, 3), Address:="", SubAddress:="'A0008合成油脂(矿)'!A1", TextToDisplay:="A0008合成油脂(矿)")
- xlSheet.Hyperlinks.Add(Anchor:=xlSheet.Cells(12, 3), Address:="", SubAddress:="A0008合成油脂!A1", TextToDisplay:="A0008合成油脂")
- xlSheet.Hyperlinks.Add(Anchor:=xlSheet.Cells(13, 3), Address:="", SubAddress:="A0008皮革整理剂!A1", TextToDisplay:="A0008皮革整理剂")
- xlSheet.Hyperlinks.Add(Anchor:=xlSheet.Cells(14, 3), Address:="", SubAddress:="A0008表面活性剂!A1", TextToDisplay:="A0008表面活性剂")
- xlSheet.Hyperlinks.Add(Anchor:=xlSheet.Cells(15, 3), Address:="", SubAddress:="A0008复鞣助剂!A1", TextToDisplay:="A0008复鞣助剂")
- xlSheet.Hyperlinks.Add(Anchor:=xlSheet.Cells(16, 3), Address:="", SubAddress:="A0008制革染料!A1", TextToDisplay:="A0008制革染料")
- xlSheet.Hyperlinks.Add(Anchor:=xlSheet.Cells(17, 3), Address:="", SubAddress:="A0008聚氨酯混合液!A1", TextToDisplay:="A0008聚氨酯混合液")
- xlSheet.Hyperlinks.Add(Anchor:=xlSheet.Cells(18, 3), Address:="", SubAddress:="A0008PU树脂!A1", TextToDisplay:="A0008PU树脂")
- xlSheet.Hyperlinks.Add(Anchor:=xlSheet.Cells(19, 3), Address:="", SubAddress:="A0008皮革促进剂!A1", TextToDisplay:="A0008皮革促进剂")
-
-
-
- xlSheet.Hyperlinks.Add(Anchor:=xlSheet.Cells(8, 4), Address:="", SubAddress:="A0006蓝湿牛皮!A1", TextToDisplay:="A0006蓝湿牛皮")
- xlSheet.Hyperlinks.Add(Anchor:=xlSheet.Cells(9, 4), Address:="", SubAddress:="A0006有机鞣料!A1", TextToDisplay:="A0006有机鞣料")
- xlSheet.Hyperlinks.Add(Anchor:=xlSheet.Cells(10, 4), Address:="", SubAddress:="A0006无机鞣料!A1", TextToDisplay:="A0006无机鞣料")
- ' xlSheet.Hyperlinks.Add(Anchor:=xlSheet.Cells(11, 3), Address:="", SubAddress:="A0006'合成油脂(矿)'!A1", TextToDisplay:="合成油脂(矿)")
- xlSheet.Hyperlinks.Add(Anchor:=xlSheet.Cells(12, 4), Address:="", SubAddress:="A0006合成油脂!A1", TextToDisplay:="A0006合成油脂")
- xlSheet.Hyperlinks.Add(Anchor:=xlSheet.Cells(13, 4), Address:="", SubAddress:="A0006皮革整理剂!A1", TextToDisplay:="A0006皮革整理剂")
- xlSheet.Hyperlinks.Add(Anchor:=xlSheet.Cells(14, 4), Address:="", SubAddress:="A0006表面活性剂!A1", TextToDisplay:="A0006表面活性剂")
- xlSheet.Hyperlinks.Add(Anchor:=xlSheet.Cells(15, 4), Address:="", SubAddress:="A0006复鞣助剂!A1", TextToDisplay:="A0006复鞣助剂")
- xlSheet.Hyperlinks.Add(Anchor:=xlSheet.Cells(16, 4), Address:="", SubAddress:="A0006制革染料!A1", TextToDisplay:="A0006制革染料")
- xlSheet.Hyperlinks.Add(Anchor:=xlSheet.Cells(17, 4), Address:="", SubAddress:="A0006聚氨酯混合液!A1", TextToDisplay:="A0006聚氨酯混合液")
- xlSheet.Hyperlinks.Add(Anchor:=xlSheet.Cells(18, 4), Address:="", SubAddress:="A0006PU树脂!A1", TextToDisplay:="A0006PU树脂")
- xlSheet.Hyperlinks.Add(Anchor:=xlSheet.Cells(19, 4), Address:="", SubAddress:="A0006皮革促进剂!A1", TextToDisplay:="A0006皮革促进剂")
-
-
-
- xlSheet.Hyperlinks.Add(Anchor:=xlSheet.Cells(9, 6), Address:="", SubAddress:="'A0008有机鞣料--车间'!A1", TextToDisplay:="A0008有机鞣料--车间")
- xlSheet.Hyperlinks.Add(Anchor:=xlSheet.Cells(10, 6), Address:="", SubAddress:="'A0008无机鞣料--车间'!A1", TextToDisplay:="A0008无机鞣料--车间")
- xlSheet.Hyperlinks.Add(Anchor:=xlSheet.Cells(11, 6), Address:="", SubAddress:="'A0008合成油脂(矿)--车间'!A1", TextToDisplay:="A0008合成油脂(矿)--车间")
- xlSheet.Hyperlinks.Add(Anchor:=xlSheet.Cells(12, 6), Address:="", SubAddress:="'A0008合成油脂--车间'!A1", TextToDisplay:="A0008合成油脂--车间")
- xlSheet.Hyperlinks.Add(Anchor:=xlSheet.Cells(13, 6), Address:="", SubAddress:="'A0008皮革整理剂--车间'!A1", TextToDisplay:="A0008皮革整理剂--车间")
- xlSheet.Hyperlinks.Add(Anchor:=xlSheet.Cells(14, 6), Address:="", SubAddress:="'A0008表面活性剂--车间'!A1", TextToDisplay:="A0008表面活性剂--车间")
- xlSheet.Hyperlinks.Add(Anchor:=xlSheet.Cells(15, 6), Address:="", SubAddress:="'A0008复鞣助剂--车间'!A1", TextToDisplay:="A0008复鞣助剂--车间")
- xlSheet.Hyperlinks.Add(Anchor:=xlSheet.Cells(16, 6), Address:="", SubAddress:="'A0008制革染料--车间'!A1", TextToDisplay:="A0008制革染料--车间")
- xlSheet.Hyperlinks.Add(Anchor:=xlSheet.Cells(17, 6), Address:="", SubAddress:="'A0008聚氨酯混合液--车间'!A1", TextToDisplay:="聚氨酯混合液--车间")
- xlSheet.Hyperlinks.Add(Anchor:=xlSheet.Cells(18, 6), Address:="", SubAddress:="'A0008PU树脂--车间'!A1", TextToDisplay:="A0008PU树脂--车间")
- xlSheet.Hyperlinks.Add(Anchor:=xlSheet.Cells(19, 6), Address:="", SubAddress:="'A0008皮革促进剂--车间'!A1", TextToDisplay:="A0008皮革促进剂-车间")
-
-
-
- xlSheet.Hyperlinks.Add(Anchor:=xlSheet.Cells(9, 7), Address:="", SubAddress:="'A0006有机鞣料--车间'!A1", TextToDisplay:="A0006有机鞣料--车间")
- xlSheet.Hyperlinks.Add(Anchor:=xlSheet.Cells(10, 7), Address:="", SubAddress:="'A0006无机鞣料--车间'!A1", TextToDisplay:="A0006无机鞣料--车间")
- xlSheet.Hyperlinks.Add(Anchor:=xlSheet.Cells(11, 7), Address:="", SubAddress:="'A0006合成油脂(矿)--车间'!A1", TextToDisplay:="A0006合成油脂(矿)--车间")
- xlSheet.Hyperlinks.Add(Anchor:=xlSheet.Cells(12, 7), Address:="", SubAddress:="'A0006合成油脂--车间'!A1", TextToDisplay:="A0006合成油脂--车间")
- xlSheet.Hyperlinks.Add(Anchor:=xlSheet.Cells(13, 7), Address:="", SubAddress:="'A0006皮革整理剂--车间'!A1", TextToDisplay:="A0006皮革整理剂--车间")
- xlSheet.Hyperlinks.Add(Anchor:=xlSheet.Cells(14, 7), Address:="", SubAddress:="'A0006表面活性剂--车间'!A1", TextToDisplay:="A0006表面活性剂--车间")
- xlSheet.Hyperlinks.Add(Anchor:=xlSheet.Cells(15, 7), Address:="", SubAddress:="'A0006复鞣助剂--车间'!A1", TextToDisplay:="A0006复鞣助剂--车间")
- xlSheet.Hyperlinks.Add(Anchor:=xlSheet.Cells(16, 7), Address:="", SubAddress:="'A0006制革染料--车间'!A1", TextToDisplay:="A0006制革染料--车间")
- xlSheet.Hyperlinks.Add(Anchor:=xlSheet.Cells(17, 7), Address:="", SubAddress:="'A0006聚氨酯混合液--车间'!A1", TextToDisplay:="A0006聚氨酯混合液--车间")
- xlSheet.Hyperlinks.Add(Anchor:=xlSheet.Cells(18, 7), Address:="", SubAddress:="'A0006PU树脂--车间'!A1", TextToDisplay:="A0006PU树脂--车间")
- xlSheet.Hyperlinks.Add(Anchor:=xlSheet.Cells(19, 7), Address:="", SubAddress:="'A0006皮革促进剂--车间'!A1", TextToDisplay:="A0006皮革促进剂-车间")
-
-
-
-
-
- xlSheet.Hyperlinks.Add(Anchor:=xlSheet.Cells(9, 9), Address:="", SubAddress:="'A0008牛二层皮1--成品'!A1", TextToDisplay:="A0008牛二层皮1--成品")
- xlSheet.Hyperlinks.Add(Anchor:=xlSheet.Cells(10, 9), Address:="", SubAddress:="'A0008牛二层皮2--成品'!A1", TextToDisplay:="A0008牛二层皮2--成品")
- xlSheet.Hyperlinks.Add(Anchor:=xlSheet.Cells(11, 9), Address:="", SubAddress:="'A0008牛二层皮3--成品'!A1", TextToDisplay:="A0008牛二层皮3--成品")
- xlSheet.Hyperlinks.Add(Anchor:=xlSheet.Cells(12, 9), Address:="", SubAddress:="'A0008牛二层皮4--成品'!A1", TextToDisplay:="A0008牛二层皮4--成品")
- xlSheet.Hyperlinks.Add(Anchor:=xlSheet.Cells(13, 9), Address:="", SubAddress:="'A0008PU牛二层皮--成品'!A1", TextToDisplay:="A0008PU牛二层皮--成品")
-
-
- xlSheet.Hyperlinks.Add(Anchor:=xlSheet.Cells(9, 10), Address:="", SubAddress:="'A0006牛二层皮5--成品'!A1", TextToDisplay:="A0006牛二层皮5--成品")
- xlSheet.Hyperlinks.Add(Anchor:=xlSheet.Cells(10, 10), Address:="", SubAddress:="'A0006牛二层皮6--成品'!A1", TextToDisplay:="A0006牛二层皮6--成品")
- xlSheet.Hyperlinks.Add(Anchor:=xlSheet.Cells(13, 10), Address:="", SubAddress:="'A0006PU牛二层皮--成品'!A1", TextToDisplay:="A0006PU牛二层皮--成品")
-
-
- xlSheet.Columns("A:K").EntireColumn.AutoFit
- xlSheet.Rows("1:60").Entirerow.AutoFit
- End Sub
- Private Sub analysis_data(xno As String, m_name As String) '------ 保税仓进销存
-
-
-
- sql = "SELECT date AS 日期, item_new AS 品名,m_in AS 入库数量, m_out as 出库数量, LEFT(xno, 12) AS 手册号, MONTH(date) AS 月份, name AS 明细 FROM RT_BG_IO WHERE item_new=N'" & m_name & "' and xno like '%0008%' and (date between '" & dtp1.Value & "' and '" & dtp2.Value & "')"
-
- sql = "SELECT case when name like N'%入%' then date2 else date end AS 日期, item_new AS 品名,m_in AS 入库数量, m_out as 出库数量, LEFT(xno, 12) AS 手册号, case when name like N'%入%' then MONTH(date2) else month(date) end AS 月份, name AS 明细 FROM RT_BG_IO WHERE item_new=N'" & m_name & "' and xno like '%" & xno & "%'"
- cmd.CommandText = sql
- da.SelectCommand = cmd
- dt1 = New DataTable
- da.Fill(dt1)
-
-
-
-
- dgv1.DataSource = dt1
- xlSheet = xlBook.Worksheets.Add
- xlSheet.Activate()
-
- xlSheet.Hyperlinks.Add(Anchor:=xlSheet.Cells(1, 1), Address:="", SubAddress:="总表!A1", TextToDisplay:="总表")
-
-
- If dt1.Rows.Count = 0 Then
-
- Exit Sub
-
- End If
-
-
- xlSheet.Cells(5, 5).select
- dgv1.SelectAll()
-
-
- Me.dgv1.ClipboardCopyMode = DataGridViewClipboardCopyMode.EnableAlwaysIncludeHeaderText
- Me.dgv1.RowHeadersVisible = False
-
- Clipboard.SetDataObject(dgv1.GetClipboardContent())
- System.Threading.Thread.Sleep(1000)
-
- xlApp.Rows("3:3").Select
- xlApp.Range("a3").Activate()
- ' xlApp.ActiveWindow.FreezePanes = True
-
-
- xlApp.Range("B2").Select()
-
-
-
- ' xlSheet.PasteSpecial("Unicode 文本", False, False)
- xlSheet.PasteSpecial()
-
- Clipboard.SetDataObject(DBNull.Value)
-
- ' xlApp.Visible = True
-
-
- xlSheet.Columns("B:B").ColumnWidth = 15
- xlSheet.Columns("c:c").ColumnWidth = 12
- xlSheet.Columns("D:D").ColumnWidth = 22
- xlSheet.Columns("e:e").ColumnWidth = 14
-
- ' xlSheet.Columns("A:L").EntireColumn.AutoFit
- xlSheet.Rows("1:500").Entirerow.AutoFit
-
-
-
- xlApp.ActiveSheet.ListObjects.Add(Microsoft.Office.Interop.Excel.XlListObjectSourceType.xlSrcRange, xlApp.Range("$B$2:$H$" & dt1.Rows.Count + 2), , Microsoft.Office.Interop.Excel.XlYesNoGuess.xlYes).Name = "表1"
-
- 'Create the Cache
- PTCache = xlApp.ActiveWorkbook.PivotCaches.Create(SourceType:=Microsoft.Office.Interop.Excel.XlPivotTableSourceType.xlDatabase, SourceData:=xlApp.Range("$B$2:$H$" & dt1.Rows.Count + 2))
-
- 'Select the destination sheet
- xlSheet.Range("J2").Select()
-
- 'Create the Pivot table
- PT = xlSheet.PivotTables.Add(PivotCache:=PTCache, TableDestination:=xlSheet.Range("J2"), TableName:="Pivot1")
-
- xlApp.ActiveWorkbook.ShowPivotTableFieldList = True
-
-
- With xlApp.ActiveSheet.PivotTables("Pivot1").PivotFields("日期")
- .Orientation = Microsoft.Office.Core.XlPivotFieldOrientation.xlRowField
-
- .Position = 1
- End With
-
- With xlApp.ActiveSheet.PivotTables("pivot1")
- .AddDataField(xlApp.ActiveSheet.PivotTables("pivot1").PivotFields("入库数量"), "加总-入库数量", Microsoft.Office.Interop.Excel.XlConsolidationFunction.xlSum)
- .AddDataField(xlApp.ActiveSheet.PivotTables("pivot1").PivotFields("出库数量"), "加总-出库数量", Microsoft.Office.Interop.Excel.XlConsolidationFunction.xlSum)
- ' .AddDataField(xlApp.ActiveSheet.PivotTables("pivot1").PivotFields("入库数量"), "入库累计", Microsoft.Office.Interop.Excel.XlConsolidationFunction.xlSum)
- '.AddDataField(xlApp.ActiveSheet.PivotTables("pivot1").PivotFields("出库数量"), "出库累计", Microsoft.Office.Interop.Excel.XlConsolidationFunction.xlSum)
- End With
-
-
-
-
- xlApp.ActiveSheet.PivotTables("pivot1").CalculatedFields.Add("入库", "=入库数量", True)
- xlApp.ActiveSheet.PivotTables("pivot1").PivotFields("入库").Orientation = Microsoft.Office.Core.XlPivotFieldOrientation.xlDataField
-
-
- xlApp.ActiveSheet.PivotTables("pivot1").CalculatedFields.Add("入库累计", "=入库数量", True)
- xlApp.ActiveSheet.PivotTables("pivot1").PivotFields("入库累计").Orientation = Microsoft.Office.Core.XlPivotFieldOrientation.xlDataField
-
-
- xlApp.ActiveSheet.PivotTables("pivot1").CalculatedFields.Add("出库累计", "=出库数量", True)
- xlApp.ActiveSheet.PivotTables("pivot1").PivotFields("出库累计").Orientation = Microsoft.Office.Core.XlPivotFieldOrientation.xlDataField
-
- 'With xlApp.ActiveSheet.PivotTables("pivot1").PivotFields("求和项:入库")
- ' .Calculation = Microsoft.Office.Interop.Excel.XlPivotFieldCalculation.xlRunningTotal
- ' .BaseField = "日期"
- ' .NumberFormat = "#,##0.000"
- 'End With
-
- With xlApp.ActiveSheet.PivotTables("pivot1").PivotFields("求和项:入库")
- .Calculation = Microsoft.Office.Interop.Excel.XlPivotFieldCalculation.xlRunningTotal
- .BaseField = "日期"
- .NumberFormat = "#,##0.000"
- End With
-
- With xlApp.ActiveSheet.PivotTables("pivot1").PivotFields("求和项:入库累计")
- .Calculation = Microsoft.Office.Interop.Excel.XlPivotFieldCalculation.xlRunningTotal
- .BaseField = "日期"
- .NumberFormat = "#,##0.000"
- End With
-
- 'With xlApp.ActiveSheet.PivotTables("pivot1").PivotFields("加總:入库累计")
- ' .Calculation = Microsoft.Office.Interop.Excel.XlPivotFieldCalculation.xlRunningTotal
- ' .BaseField = "日期"
- ' .NumberFormat = "#,##0.000"
- 'End With
- With xlApp.ActiveSheet.PivotTables("pivot1").PivotFields("求和项:出库累计")
- .Calculation = Microsoft.Office.Interop.Excel.XlPivotFieldCalculation.xlRunningTotal
- .BaseField = "日期"
- .NumberFormat = "#,##0.000"
- End With
-
- 'With xlApp.ActiveSheet.PivotTables("pivot1").PivotFields("加總:出库累计")
- ' .Calculation = Microsoft.Office.Interop.Excel.XlPivotFieldCalculation.xlRunningTotal
- ' .BaseField = "日期"
- ' .NumberFormat = "#,##0.000"
- 'End With
-
- Dim x As Integer = 0
- For x = 3 To 50000
-
- If xlSheet.Cells(x, 10).value.ToString = "总计" Then
- Exit For
- End If
-
-
- Next
-
-
- xlApp.Columns("M:M").Select
- xlApp.Selection.EntireColumn.Hidden = True
-
-
-
- 'xlApp.ActiveSheet.PivotTables("pivot1").PivotFields("求和项:入库").Orientation = Microsoft.Office.Core.XlPivotFieldOrientation.xlHidden
- 'xlApp.ActiveSheet.PivotTables("pivot1").PivotFields("加總:入库").Orientation = Microsoft.Office.Core.XlPivotFieldOrientation.xlHidden
- xlSheet.Range("p4").FormulaR1C1 = "=RC[-2]-RC[-1]"
- xlSheet.Range("p4").Select()
- xlApp.Selection.AutoFill(Destination:=xlApp.Range("p4:p" & x - 1))
-
-
- xlSheet.Cells(2, 16).value = "结存"
- ' xlSheet.Range("P:P").NumberFormat = "#,##0.000;[红色](0.00)"
-
- ' xlSheet.Range("K:L").NumberFormat = "#,##0.000;[红色](0.00)"
-
- xlSheet.Columns("P:P").ColumnWidth = 14.11
- ' xlSheet.Columns("P:P").NumberFormat = "#,##0.000;[红色](0.00)"
-
- End Sub
- Private Sub analysis_finish(xno As String, m_name As String) '-------成品进销存
-
- sql = "SELECT LEFT(xno, 12) AS 手册号, item AS 品名, name AS 明细, date AS 入库日期, MONTH(date) AS 入库月份, CAST(m_in AS numeric(10, 1)) AS 入库数量, CAST(m_out AS numeric(10, 1)) AS 出库数量, CASE WHEN m_in <> 0 THEN m_in WHEN m_out <> 0 THEN - m_out END AS io FROM RT_BG_IO WHERE (item =N'" & m_name & "') AND (xno LIKE '%" & xno & "%') ORDER BY 入库日期"
-
- dt1 = New DataTable
-
- cmd.CommandText = sql
- da.SelectCommand = cmd
- da.Fill(dt1)
- dt1.Columns.Add("结存")
-
- Dim my_qty As Decimal = 0
-
- For x As Integer = 0 To dt1.Rows.Count - 1
- If x = 0 Then
- dt1.Rows(x).Item("结存") = dt1.Rows(x).Item("io")
- my_qty = dt1.Rows(x).Item("结存")
- Else
-
- dt1.Rows(x).Item("结存") = my_qty + dt1.Rows(x).Item("io")
- my_qty = dt1.Rows(x).Item("结存")
-
-
-
- End If
-
- Next
-
-
- dgv1.DataSource = dt1
-
- xlSheet = xlBook.Worksheets.Add
- xlSheet.Name = xno & m_name & "--成品"
- xlSheet.Activate()
-
- xlSheet.Hyperlinks.Add(Anchor:=xlSheet.Cells(1, 1), Address:="", SubAddress:="总表!A1", TextToDisplay:="总表")
-
- xlSheet.Cells(5, 5).select
- dgv1.SelectAll()
-
-
- Me.dgv1.ClipboardCopyMode = DataGridViewClipboardCopyMode.EnableAlwaysIncludeHeaderText
- Me.dgv1.RowHeadersVisible = False
-
- Clipboard.SetDataObject(dgv1.GetClipboardContent())
-
-
- xlApp.Rows("3:3").Select
- xlApp.Range("a3").Activate()
- ' xlApp.ActiveWindow.FreezePanes = True
-
-
- xlApp.Range("B2").Select()
- System.Threading.Thread.Sleep(1000)
-
-
- xlSheet.PasteSpecial("Unicode 文本", False, False)
-
-
- Clipboard.SetDataObject(DBNull.Value)
-
- ' xlApp.Visible = True
-
-
- xlSheet.Columns("B:B").ColumnWidth = 15
- xlSheet.Columns("c:c").ColumnWidth = 12
- xlSheet.Columns("D:D").ColumnWidth = 22
- xlSheet.Columns("e:e").ColumnWidth = 14
-
- xlSheet.Columns("A:L").EntireColumn.AutoFit
- xlSheet.Rows("1:500").Entirerow.AutoFit
-
- 'xlSheet.Cells("O2").value = "结存"
-
- xlApp.ActiveSheet.ListObjects.Add(Microsoft.Office.Interop.Excel.XlListObjectSourceType.xlSrcRange, xlApp.Range("$B$2:$J$" & dt1.Rows.Count + 2), , Microsoft.Office.Interop.Excel.XlYesNoGuess.xlYes).Name = "表1"
-
-
- xlSheet.Columns("j:j").Select
- xlApp.Selection.Style = "Comma"
- xlApp.Selection.NumberFormatLocal = "#,###.00_ ;[红色]-#,###.00 "
-
-
-
-
-
- End Sub
-
- Private Sub analysis_data_1(xno As String, m_name As String) '------核算料件领料是否倒挂
-
-
-
- sql = "SELECT DISTINCT 领料日期, MONTH(领料日期) AS 领料月份 FROM (SELECT TOP (100) PERCENT RIGHT(RT_BG_IO.xno, 5) AS 手册号, RT_BG_IO.item AS 成品, RT_BG_IO.name AS 明细, RT_BG_IO.m_in AS 入库数量, RT_BG_IO.date AS 入库日期, RT_BG_COM.NAME AS 料件, RT_BG_COM.PERCENTS AS 单耗, RT_BG_COM.PERCENTS * RT_BG_IO.m_in AS 料件耗用, CASE WHEN rt_bg_com.name LIKE N'%聚%' THEN DATEADD(day, - 2, RT_BG_IO.date) WHEN rt_bg_com.name LIKE N'%pu%' OR rt_bg_com.name LIKE N'%促%' THEN DATEADD(day, - 3, RT_BG_IO.date) WHEN rt_bg_com.name LIKE N'%蓝%' THEN DATEADD(day, - 14, RT_BG_IO.date) ELSE DATEADD(day, - 7, RT_BG_IO.date) END AS 领料日期 FROM RT_BG_IO INNER JOIN RT_BG_COM ON LEFT(RT_BG_IO.xno, 12) = RT_BG_COM.XNO AND RT_BG_IO.item = RT_BG_COM.product1 WHERE (RT_BG_IO.name LIKE '%入%') AND (RT_BG_IO.m_in <> 0) ORDER BY 入库数量) AS p WHERE (手册号 = '" & xno & "') AND (料件 = N'" & m_name & "') AND (料件耗用 <> 0) ORDER BY 领料日期"
-
- cmd.CommandText = sql
-
- Dim my_date As Date
-
- my_date = cmd.ExecuteScalar
-
-
-
-
-
- sql = "SELECT SUM(m_out) AS 保税出库数量 FROM RT_BG_IO WHERE (xno like '%" & xno & "' and item_new = N'" & m_name & "' and date<='" & String.Format("{0:d}", my_date) & "') GROUP BY xno"
- cmd.CommandText = sql
- da.SelectCommand = cmd
- Dim q_begin As Decimal = 0
- q_begin = cmd.ExecuteScalar
-
- '------------------------0------1-----2-----3---------4------5-----6-----7---------8-----------9
- sql = "SELECT DISTINCT 手册号, 成品, 明细, 入库数量, 入库日期, 料件, 单耗, 料件耗用, 领料日期, MONTH(领料日期) AS 领料月份 FROM (SELECT TOP (100) PERCENT RIGHT(RT_BG_IO.xno, 5) AS 手册号, RT_BG_IO.item AS 成品, RT_BG_IO.name AS 明细, RT_BG_IO.m_in AS 入库数量, RT_BG_IO.date AS 入库日期, RT_BG_COM.NAME AS 料件, RT_BG_COM.PERCENTS AS 单耗, RT_BG_COM.PERCENTS * RT_BG_IO.m_in AS 料件耗用, CASE WHEN rt_bg_com.name LIKE N'%聚%' THEN DATEADD(day, - 2, RT_BG_IO.date) WHEN rt_bg_com.name LIKE N'%pu%' OR rt_bg_com.name LIKE N'%促%' THEN DATEADD(day, - 3, RT_BG_IO.date) WHEN rt_bg_com.name LIKE N'%蓝%' THEN DATEADD(day, - 14, RT_BG_IO.date) ELSE DATEADD(day, - 7, RT_BG_IO.date) END AS 领料日期 FROM RT_BG_IO INNER JOIN RT_BG_COM ON LEFT(RT_BG_IO.xno, 12) = RT_BG_COM.XNO AND RT_BG_IO.item = RT_BG_COM.product1 WHERE (RT_BG_IO.name LIKE '%入%') AND (RT_BG_IO.m_in <> 0) ORDER BY 入库数量) AS p WHERE (手册号 ='" & xno & "') AND (料件 = N'" & m_name & "') AND (料件耗用 <> 0) ORDER BY 领料日期"
-
-
-
-
-
- dt1 = New DataTable
-
- cmd.CommandText = sql
- da.SelectCommand = cmd
- da.Fill(dt1)
-
-
-
- dt1.Columns.Add("结存")
-
- Dim myRow As DataRow
- myRow = dt1.NewRow
- ' myRow(0) = xno
- 'myRow(5) =
- myRow(10) = q_begin
-
- dt1.Rows.InsertAt(myRow, 0)
-
-
-
- sql = "SELECT item, name, year, month, date1,m_out, bal, xno, date, id, item_new FROM RT_BG_IO WHERE (xno like '%" & xno & "') AND (item_new = N'" & m_name & "') AND (m_out <> 0) and date >'" & String.Format("{0:d}", my_date) & "'"
- cmd.CommandText = sql
- da.SelectCommand = cmd
- Dim dt2 As New DataTable
- da.Fill(dt2)
-
- For z As Integer = 0 To dt2.Rows.Count - 1
-
- myRow = dt1.NewRow
-
- myRow(7) = dt2.Rows(z).Item("m_out")
- myRow(8) = dt2.Rows(z).Item("date")
- myRow(9) = Month(dt2.Rows(z).Item("date"))
- dt1.Rows.InsertAt(myRow, dt1.Rows.Count)
-
- Next
-
- dt1.DefaultView.Sort = "领料日期,手册号"
-
- Dim dt11 As New DataTable
-
- dt11 = dt1.DefaultView.ToTable()
-
-
-
-
- Dim my_begin As Decimal = 0
- For z As Integer = 0 To dt11.Rows.Count - 1
-
- If z = 0 Then
- my_begin = dt11.Rows(z).Item("结存")
- Else
- If IsDBNull(dt11.Rows(z).Item("手册号")) Then
-
- my_begin = my_begin + dt11.Rows(z).Item("料件耗用")
- Else
- my_begin = my_begin - dt11.Rows(z).Item("料件耗用")
- End If
- dt11.Rows(z).Item("结存") = my_begin
- End If
-
- Next
-
- dgv1.DataSource = dt11
-
-
-
-
-
-
- 'sql = "SELECT date AS 日期, item_new AS 品名,m_in AS 入库数量, m_out as 出库数量, LEFT(xno, 12) AS 手册号, MONTH(date) AS 月份, name AS 明细 FROM RT_BG_IO WHERE item_new=N'" & m_name & "' and xno like '%0008%'"
- 'cmd.CommandText = sql
- 'da.SelectCommand = cmd
- 'dt1 = New DataTable
- 'da.Fill(dt1)
-
-
- 'dgv1.DataSource = dt1
- xlSheet = xlBook.Worksheets.Add
- xlSheet.Name = xno & m_name & "--车间"
- xlSheet.Activate()
-
- xlSheet.Hyperlinks.Add(Anchor:=xlSheet.Cells(1, 1), Address:="", SubAddress:="总表!A1", TextToDisplay:="总表")
-
- xlSheet.Cells(5, 5).select
- dgv1.SelectAll()
-
-
- Me.dgv1.ClipboardCopyMode = DataGridViewClipboardCopyMode.EnableAlwaysIncludeHeaderText
- Me.dgv1.RowHeadersVisible = False
-
- Clipboard.SetDataObject(dgv1.GetClipboardContent())
- System.Threading.Thread.Sleep(1000)
-
- 'xlApp.Rows("3:3").Select
- 'xlApp.Range("a3").Activate()
- ' xlApp.ActiveWindow.FreezePanes = True
-
-
- xlApp.Range("B2").Select()
-
- ' ExcelPackage.LicenseContext = LicenseContext.NonCommercial
-
- ' Dim filepath As New System.IO.FileInfo("d:\123.xlsx")
- 'Dim Package As New ExcelPackage(filepath)
- 'Dim wks As ExcelWorksheet = Package.Workbook.Worksheets.Add(xlSheet.Name)
-
-
-
-
- 'wks.Cells("A1").LoadFromDataTable(dt11, True)
-
-
- 'Package.Save()
-
-
-
-
- ' xlApp.Cells("B2").LoadFromDataTable(dt11, True)
-
-
- ' xlSheet.PasteSpecial("Unicode 文本", False, False)
- xlSheet.Paste()
-
- Clipboard.SetDataObject(DBNull.Value)
-
-
- ' xlApp.Visible = True
-
-
- xlSheet.Columns("B:B").ColumnWidth = 15
- xlSheet.Columns("c:c").ColumnWidth = 12
- xlSheet.Columns("D:D").ColumnWidth = 22
- xlSheet.Columns("e:e").ColumnWidth = 14
-
- xlSheet.Columns("A:L").EntireColumn.AutoFit
- xlSheet.Rows("1:500").Entirerow.AutoFit
-
- 'xlSheet.Cells("O2").value = "结存"
-
- xlApp.ActiveSheet.ListObjects.Add(Microsoft.Office.Interop.Excel.XlListObjectSourceType.xlSrcRange, xlApp.Range("$B$2:$L$" & dt11.Rows.Count + 2), , Microsoft.Office.Interop.Excel.XlYesNoGuess.xlYes).Name = "表1"
-
-
- xlSheet.Columns("L:L").Select
- xlApp.Selection.NumberFormatLocal = "0.00_ ;[红色]-0.00 "
-
-
-
-
-
-
-
-
-
-
- 'Create the Cache
- 'PTCache = xlApp.ActiveWorkbook.PivotCaches.Create(SourceType:=Microsoft.Office.Interop.Excel.XlPivotTableSourceType.xlDatabase, SourceData:=xlApp.Range("$B$2:$H$" & dt1.Rows.Count + 2))
-
- ''Select the destination sheet
- 'xlSheet.Range("J2").Select()
-
- ''Create the Pivot table
- 'PT = xlSheet.PivotTables.Add(PivotCache:=PTCache, TableDestination:=xlSheet.Range("J2"), TableName:="Pivot1")
-
- 'xlApp.ActiveWorkbook.ShowPivotTableFieldList = True
-
-
- 'With xlApp.ActiveSheet.PivotTables("Pivot1").PivotFields("日期")
- ' .Orientation = Microsoft.Office.Core.XlPivotFieldOrientation.xlRowField
-
- ' .Position = 1
- 'End With
-
- 'With xlApp.ActiveSheet.PivotTables("pivot1")
- ' .AddDataField(xlApp.ActiveSheet.PivotTables("pivot1").PivotFields("入库数量"), "入库数量", Microsoft.Office.Interop.Excel.XlConsolidationFunction.xlSum)
- ' .AddDataField(xlApp.ActiveSheet.PivotTables("pivot1").PivotFields("出库数量"), "出库数量", Microsoft.Office.Interop.Excel.XlConsolidationFunction.xlSum)
- ' ' .AddDataField(xlApp.ActiveSheet.PivotTables("pivot1").PivotFields("入库数量"), "入库累计", Microsoft.Office.Interop.Excel.XlConsolidationFunction.xlSum)
- ' '.AddDataField(xlApp.ActiveSheet.PivotTables("pivot1").PivotFields("出库数量"), "出库累计", Microsoft.Office.Interop.Excel.XlConsolidationFunction.xlSum)
- 'End With
-
-
-
-
- 'xlApp.ActiveSheet.PivotTables("pivot1").CalculatedFields.Add("入库", "=入库数量", True)
- 'xlApp.ActiveSheet.PivotTables("pivot1").PivotFields("入库").Orientation = Microsoft.Office.Core.XlPivotFieldOrientation.xlDataField
-
-
- 'xlApp.ActiveSheet.PivotTables("pivot1").CalculatedFields.Add("入库累计", "=入库数量", True)
- 'xlApp.ActiveSheet.PivotTables("pivot1").PivotFields("入库累计").Orientation = Microsoft.Office.Core.XlPivotFieldOrientation.xlDataField
-
-
- 'xlApp.ActiveSheet.PivotTables("pivot1").CalculatedFields.Add("出库累计", "=出库数量", True)
- 'xlApp.ActiveSheet.PivotTables("pivot1").PivotFields("出库累计").Orientation = Microsoft.Office.Core.XlPivotFieldOrientation.xlDataField
-
- 'With xlApp.ActiveSheet.PivotTables("pivot1").PivotFields("求和项:入库")
- ' .Calculation = Microsoft.Office.Interop.Excel.XlPivotFieldCalculation.xlRunningTotal
- ' .BaseField = "日期"
- ' .NumberFormat = "#,##0.000"
- 'End With
- 'With xlApp.ActiveSheet.PivotTables("pivot1").PivotFields("求和项:入库累计")
- ' .Calculation = Microsoft.Office.Interop.Excel.XlPivotFieldCalculation.xlRunningTotal
- ' .BaseField = "日期"
- ' .NumberFormat = "#,##0.000"
- 'End With
- 'With xlApp.ActiveSheet.PivotTables("pivot1").PivotFields("求和项:出库累计")
- ' .Calculation = Microsoft.Office.Interop.Excel.XlPivotFieldCalculation.xlRunningTotal
- ' .BaseField = "日期"
- ' .NumberFormat = "#,##0.000"
- 'End With
-
- 'Dim x As Integer = 0
- 'For x = 3 To 50000
-
- ' If xlSheet.Cells(x, 10).value.ToString = "总计" Then
- ' Exit For
- ' End If
-
-
- 'Next
-
-
- 'xlApp.ActiveSheet.PivotTables("pivot1").PivotFields("求和项:入库").Orientation = Microsoft.Office.Core.XlPivotFieldOrientation.xlHidden
- 'xlSheet.Range("o3").FormulaR1C1 = "=RC[-2]-RC[-1]"
- 'xlSheet.Range("o3").Select()
- 'xlApp.Selection.AutoFill(Destination:=xlApp.Range("o3:o" & x))
-
-
-
-
-
-
-
- End Sub
-
- Private Sub Button8_Click_1(sender As Object, e As EventArgs) Handles Button8.Click
-
- sql = "SELECT distinct 手册号, 成品, 明细, 出库数量, 出库日期, 料件, 单耗, 料件耗用, 领料日期, MONTH(领料日期) AS 领料月份 FROM (SELECT TOP (100) PERCENT LEFT(RT_BG_IO.xno, 12) AS 手册号, RT_BG_IO.item AS 成品, RT_BG_IO.name AS 明细, RT_BG_IO.m_out AS 出库数量, RT_BG_IO.date AS 出库日期, RT_BG_COM.NAME AS 料件, RT_BG_COM.PERCENTS AS 单耗, RT_BG_COM.PERCENTS * RT_BG_IO.m_out AS 料件耗用, CASE WHEN rt_bg_com.name LIKE N'%聚%' THEN DATEADD(day, - 2, RT_BG_IO.date) WHEN rt_bg_com.name LIKE N'%pu%' OR rt_bg_com.name LIKE N'%促%' THEN DATEADD(day, - 3, RT_BG_IO.date) WHEN rt_bg_com.name LIKE N'%蓝%' THEN DATEADD(day, - 14, RT_BG_IO.date) ELSE DATEADD(day, - 7, RT_BG_IO.date) END AS 领料日期 FROM RT_BG_IO INNER JOIN RT_BG_COM ON LEFT(RT_BG_IO.xno, 12) = RT_BG_COM.XNO AND RT_BG_IO.item = RT_BG_COM.product1 WHERE (RT_BG_IO.item LIKE N'%牛二层皮%') AND (RT_BG_IO.name LIKE '%出%') AND (RT_BG_IO.m_out <> 0) AND (date between '" & dtp1.Value & "' and '" & dtp2.Value & "') ORDER BY 出库数量) AS p"
-
- cmd.CommandText = sql
- da.SelectCommand = cmd
- Dim dt1 As New DataTable
- da.Fill(dt1)
- If dt1.Rows.Count = 0 Then
- MsgBox("查无记录")
- Exit Sub
- End If
- dgv1.DataSource = dt1
-
-
-
- Dim xlApp As Microsoft.Office.Interop.Excel.Application
- Dim xlBook As Microsoft.Office.Interop.Excel.Workbook
- Dim xlSheet As Microsoft.Office.Interop.Excel.Worksheet
- Dim xlRange As Microsoft.Office.Interop.Excel.Range
-
- xlApp = CreateObject("Excel.Application")
- xlApp.Visible = False
- xlApp.DisplayAlerts = False
-
- xlBook = xlApp.Workbooks.Add
- xlSheet = xlBook.Worksheets(1)
- xlSheet.Name = "料件领料汇总"
- xlSheet.Activate()
-
- xlSheet.Cells(5, 5).select
-
-
-
-
-
-
- dgv1.SelectAll()
-
-
- Me.dgv1.ClipboardCopyMode = DataGridViewClipboardCopyMode.EnableAlwaysIncludeHeaderText
- Me.dgv1.RowHeadersVisible = False
-
- Clipboard.SetDataObject(dgv1.GetClipboardContent())
-
-
-
- xlApp.Range("B30").Select()
-
- xlSheet.Paste()
-
- xlApp.Visible = True
-
-
- '''' xlApp.ActiveSheet.Paste
- ''''xlApp.CutCopyMode = False
- xlApp.ActiveSheet.ListObjects.Add(Microsoft.Office.Interop.Excel.XlListObjectSourceType.xlSrcRange, xlApp.Range("$B$30:$k$" & dt1.Rows.Count + 30), , Microsoft.Office.Interop.Excel.XlYesNoGuess.xlYes).Name = "表1"
-
-
-
-
- Dim PTCache As Microsoft.Office.Interop.Excel.PivotCache
- Dim PT As Microsoft.Office.Interop.Excel.PivotTable
-
- 'Create the Cache
- PTCache = xlApp.ActiveWorkbook.PivotCaches.Create(SourceType:=Microsoft.Office.Interop.Excel.XlPivotTableSourceType.xlDatabase, SourceData:=xlApp.Range("$B$30:$k$" & dt1.Rows.Count + 30))
-
- 'Select the destination sheet
- xlSheet.Range("b2").Select()
-
- 'Create the Pivot table
- PT = xlSheet.PivotTables.Add(PivotCache:=PTCache, TableDestination:=xlSheet.Range("B2"), TableName:="Pivot1")
-
- xlApp.ActiveWorkbook.ShowPivotTableFieldList = True
-
- 'Adding fields
-
-
-
-
-
- With xlApp.ActiveSheet.PivotTables("Pivot1").PivotFields("料件")
- .Orientation = Microsoft.Office.Core.XlPivotFieldOrientation.xlRowField
- .Position = 1
- End With
-
-
- With xlApp.ActiveSheet.PivotTables("Pivot1").PivotFields("领料月份")
- .Orientation = Microsoft.Office.Core.XlPivotFieldOrientation.xlColumnField
- .Position = 1
- End With
-
- With xlApp.ActiveSheet.PivotTables("Pivot1").PivotFields("手册号")
- .Orientation = Microsoft.Office.Core.XlPivotFieldOrientation.xlColumnField
- .Position = 1
- End With
-
- With xlApp.ActiveSheet.PivotTables("Pivot1").PivotFields("成品")
- .Orientation = Microsoft.Office.Core.XlPivotFieldOrientation.xlColumnField
- .Position = 1
- End With
-
-
-
-
- With xlApp.ActiveSheet.PivotTables("pivot1")
- .AddDataField(xlApp.ActiveSheet.PivotTables("Pivot1").PivotFields("料件耗用"), "耗用合计", Microsoft.Office.Interop.Excel.XlConsolidationFunction.xlSum)
- End With
-
-
- 'With xlApp.ActiveSheet.PivotTables("pivot1")
- ' .AddDataField(xlApp.ActiveSheet.PivotTables("Pivot1").PivotFields("货值"), "货值合计", Microsoft.Office.Interop.Excel.XlConsolidationFunction.xlSum)
- 'End With
-
-
-
- xlApp.Visible = True
- xlApp = Nothing
- xlBook = Nothing
- xlSheet = Nothing
-
-
-
-
-
-
-
- End Sub
-
- Private Sub dgv2_MouseDown(sender As Object, e As MouseEventArgs) Handles dgv2.MouseDown
-
-
-
- End Sub
-
- Private Sub dgv3_CellContentClick(sender As Object, e As DataGridViewCellEventArgs) Handles dgv3.CellContentClick
-
- End Sub
-
- Private Sub dgv3_MouseUp(sender As Object, e As MouseEventArgs) Handles dgv3.MouseUp
-
-
- Dim x As Double = 0
- Dim y As Double = 0
- For i As Integer = 0 To dgv2.SelectedRows.Count - 1
-
- x = x + Math.Round(dgv2.Rows(dgv2.SelectedRows.Item(i).Index).Cells("尺数").Value, 1)
-
-
- Next i
-
- TextBox3.Text = dgv2.SelectedRows.Count
-
- TextBox2.Text = x
-
-
-
-
- End Sub
-
- Private Sub Button16_Click_1(sender As Object, e As EventArgs) Handles Button16.Click
- Frm_wb_out_1.Show()
- End Sub
-
- Private Sub Button17_Click_1(sender As Object, e As EventArgs) Handles Button17.Click
- Frm_Print_report.Show()
- End Sub
-
- Private Sub Button18_Click(sender As Object, e As EventArgs) Handles Button18.Click
-
-
- Dim xlApp As Microsoft.Office.Interop.Excel.Application
- Dim xlBook As Microsoft.Office.Interop.Excel.Workbook
- Dim xlSheet As Microsoft.Office.Interop.Excel.Worksheet
-
-
-
- Dim dt As New DataTable
- Dim file_name As String = ""
- Dim file_name1 As String = ""
- Dim my_weight As Double = 0
- Dim a As Integer = 0
- Dim my_count As Integer = 0
- 'OpenFileDialog1.Multiselect = True
-
-
- If OpenFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
-
- file_name = OpenFileDialog1.FileName
- file_name1 = OpenFileDialog1.SafeFileName
- Else
- Exit Sub
-
- End If
-
-
-
- xlApp = CreateObject("Excel.Application")
- xlApp.Visible = True
- xlApp.DisplayAlerts = False
-
-
-
- 'sql = "delete from rt_bg_io"
- 'cmd.CommandText = sql
- 'cmd.ExecuteNonQuery()
-
-
-
- xlBook = xlApp.Workbooks.Open(file_name,, True)
-
- xlBook.Activate()
-
-
-
- If ListBox1.Items(0) Like "*076*" Then '----------------------------------------------- 蓝皮入库
-
-
- For i = 1 To xlApp.Worksheets.Count
-
- If xlApp.Workbooks(1).Worksheets(i).name = "金威利" Then
- xlSheet = xlApp.Workbooks(1).Worksheets(i)
- xlSheet.Activate()
- Exit For
- End If
-
- Next
-
- xlSheet.Range("a1:q17").Copy()
-
- For y As Integer = 0 To dgv1.Rows.Count - 2
-
- xlApp.Range("a" & 1 + 17 * (y + 1)).Select()
- xlSheet.Paste()
-
- Next y
-
-
- ' Dim MY_DATE As Date = dgv2.Rows(0).Cells("进厂日期").Value
- Dim MY_COUNT1 As Integer = 0
- Dim MY_ITEM As Integer = 0
-
- For y As Integer = 0 To dgv2.Rows.Count - 1
-
-
-
- MY_COUNT1 = MY_COUNT1 - 1
- MY_ITEM = MY_ITEM + 1
-
- xlSheet.Cells(2 + y * 17, 3) = "金威利"
-
- xlSheet.Cells(6 + y * 17, 1) = dgv1.Rows(y).Cells("颜色").Value
- xlSheet.Cells(6 + y * 17, 3) = dgv1.Rows(y).Cells("类别").Value
- xlSheet.Cells(6 + y * 17, 4) = dgv1.Rows(y).Cells("厚度").Value
- xlSheet.Cells(6 + y * 17, 6) = dgv1.Rows(y).Cells("尺数").Value
-
-
- xlSheet.Cells(11 + y * 17, 2) = dgv1.Rows(y).Cells("订单号").Value
- xlSheet.Cells(11 + y * 17, 5) = dgv1.Rows(y).Cells("指令号").Value
- xlSheet.Cells(11 + y * 17, 16) = dgv1.Rows(y).Cells("尺数").Value
-
-
-
- Next
-
-
- End If
-
-
-
-
- Dim yy As Integer = 0
-
-
-
-
-
-
-
-
-
- xlApp = Nothing
- xlBook = Nothing
- xlSheet = Nothing
-
- MsgBox("")
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- End Sub
-
- Private Sub Button31_Click(sender As Object, e As EventArgs) Handles Button31.Click
- Frm_AC.ShowDialog()
- End Sub
-
- Private Sub Button32_Click(sender As Object, e As EventArgs) Handles Button32.Click
- analysis_data_1("A0008", "合成油脂(矿)")
- End Sub
-
- Private Sub Button33_Click(sender As Object, e As EventArgs) Handles Button33.Click
-
- Dim dt As New DataTable
-
- Dim file_name As String = ""
-
- Dim a As Integer = 0
- Dim my_count As Integer = 0
- If OpenFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
- file_name = OpenFileDialog1.FileName
- Else
- Exit Sub
- End If
-
- Dim filepath As String = Me.Button33.Text
-
- Dim sourceFileName As String = file_name
-
-
- Dim address2 As String = "ftp://" & my_ip & ":7788/K3/即时库存/" & OpenFileDialog1.SafeFileName
-
- Dim address3() As String
-
- address3 = Split(address2, "ftp://" & my_ip & ":7788/K3/即时库存/")
- Dim add4 As String
-
- add4 = "d:\k3\" & address3(1)
- add4 = "d:\k3\即时库存\" & OpenFileDialog1.SafeFileName
-
-
- Dim userName As String = "matchy3c"
- Dim password As String = "Lafayette11"
- Dim showUI As Boolean = True
- Dim connectionTimeout As Integer = 500
-
- Dim client As WebClient = New WebClient
- client.Credentials = New NetworkCredential(userName, password)
- ' client.Proxy = GlobalProxySelection.GetEmptyWebProxy()
- client.UploadFile(address2, sourceFileName)
-
-
-
- sql = "delete from rt_realtime_stock" '----
- ' sql = "delete from rt_sys_chem_out " '----化料
- cmd.CommandText = sql
- cmd.ExecuteNonQuery()
-
- sql = "Select * FROM OPENDATASOURCE ('Microsoft.ACE.OLEDB.12.0','Excel 12.0;HDR=Yes;IMEX=1;Database=" & add4 & "')... [车间化料$]"
-
- cmd.CommandText = sql
-
- da.SelectCommand = cmd
- da.Fill(dt)
- ' dgv1.DataSource = dt
-
-
- Dim my_sqlbulk As New SqlBulkCopy(conn)
-
- my_sqlbulk.DestinationTableName = "dbo.rt_realtime_stock"
- my_sqlbulk.WriteToServer(dt)
-
-
- sql = "SELECT cls, CLASS2 AS 海关分类, SUM(qty) AS 数量
- FROM (SELECT CASE WHEN matl_no LIKE '%.s.%' THEN N'保税' ELSE N'国内' END AS cls, RT_realtime_stock.matl_name,
- RT_realtime_stock.qty, RT_SYS_CHEM_MAIN.CLASS2
- FROM RT_realtime_stock LEFT OUTER JOIN
- RT_SYS_CHEM_MAIN ON RT_realtime_stock.matl_name = RT_SYS_CHEM_MAIN.name) AS p
- WHERE (CLASS2 IS NOT NULL) AND (CLASS2 <> '') AND (CLASS2 <> 'PU')
- GROUP BY CLASS2, cls
- ORDER BY 海关分类 DESC"
-
- cmd.CommandText = sql
- dt = New DataTable
- da.SelectCommand = cmd
- da.Fill(dt)
- dgv1.DataSource = dt
-
- dt = New DataTable
-
-
-
-
-
-
-
-
-
-
-
-
-
- sql = "delete from rt_realtime_stock" '----
- ' sql = "delete from rt_sys_chem_out " '----化料
- cmd.CommandText = sql
- cmd.ExecuteNonQuery()
-
-
-
-
- sql = "Select * FROM OPENDATASOURCE ('Microsoft.ACE.OLEDB.12.0','Excel 12.0;HDR=Yes;IMEX=1;Database=" & add4 & "')... [保税仓$]"
-
- cmd.CommandText = sql
-
- da.SelectCommand = cmd
- da.Fill(dt)
- ' dgv2.DataSource = dt
-
-
-
-
- my_sqlbulk.DestinationTableName = "dbo.rt_realtime_stock"
- my_sqlbulk.WriteToServer(dt)
-
-
- sql = "SELECT cls, CLASS2 AS 海关分类, SUM(qty) AS 数量
- FROM (SELECT CASE WHEN matl_no LIKE '%.s.%' THEN N'保税' ELSE N'国内' END AS cls, RT_realtime_stock.matl_name,
- RT_realtime_stock.qty, RT_SYS_CHEM_MAIN.CLASS2
- FROM RT_realtime_stock LEFT OUTER JOIN
- RT_SYS_CHEM_MAIN ON RT_realtime_stock.matl_name = RT_SYS_CHEM_MAIN.name) AS p
- WHERE (CLASS2 IS NOT NULL) AND (CLASS2 <> '') AND (CLASS2 <> 'PU')
- GROUP BY CLASS2, cls
- ORDER BY 海关分类 DESC"
-
- cmd.CommandText = sql
- dt = New DataTable
- da.SelectCommand = cmd
- da.Fill(dt)
- dgv2.DataSource = dt
-
-
-
-
-
-
-
-
-
-
-
-
-
- MsgBox("完成")
-
-
- End Sub
-
- Private Sub dgv2_CellContentClick(sender As Object, e As DataGridViewCellEventArgs) Handles dgv2.CellContentClick
-
- End Sub
-
- Private Sub dgv2_CellMouseClick(sender As Object, e As DataGridViewCellMouseEventArgs) Handles dgv2.CellMouseClick
-
- End Sub
-
- Private Sub Button34_Click(sender As Object, e As EventArgs) Handles Button34.Click
-
-
- sql = " update rt_ship_uz_hg set class='fm7' where name like '%黑色%' and name not like '%action%' and name not like '%PU%' and name not like N'%榔%' "
- cmd.CommandText = sql
- cmd.ExecuteNonQuery()
- sql = " update rt_ship_uz_hg set class='fm8' where name not like '%黑色%' and name not like '%action%' and name not like '%PU%' and name not like N'%榔%' "
- cmd.CommandText = sql
- cmd.ExecuteNonQuery()
- sql = " update rt_ship_uz_hg set class='PU3' where name not like '%黑色%' and (name like '%action%' or name like '%PU%' or name like N'%榔%') "
- cmd.CommandText = sql
- cmd.ExecuteNonQuery()
- sql = " update rt_ship_uz_hg set class='PU5' where name like '%黑色%' and (name like '%action%' or name like '%PU%' or name like N'%榔%') "
- cmd.CommandText = sql
- cmd.ExecuteNonQuery()
-
-
- sql = "select diff from (select no,rank() over (order by cast(no as integer)) as 序号, cast(no as integer)- rank() over (order by cast(no as integer)) as diff from rt_ship_uz_hg where class='fm7' ) as q group by diff order by diff" '-----fm7
- cmd.CommandText = sql
- Dim dt As New DataTable
- da.SelectCommand = cmd
- da.Fill(dt)
-
- Dim begin As Boolean = False
- Dim mystring As String = "牛二层皮7 "
-
- Dim begin_diff As Integer
-
- Dim a As Integer = 0
-
-
- For x As Integer = 0 To dt.Rows.Count - 1
- a = 0
- sql = "select no from (select no,rank() over (order by cast(no as integer)) as 序号, cast(no as integer)- rank() over (order by cast(no as integer)) as diff from rt_ship_uz_hg where class='fm7' ) as p where diff=" & dt.Rows(x).Item("diff") & " order by cast(no as integer) "
- cmd.CommandText = sql
-
-
- mystring = mystring & "第" & cmd.ExecuteScalar & "~"
-
- a = a + 1
- sql = "select top(1) no from (select no,rank() over (order by cast(no as integer)) as 序号, cast(no as integer)- rank() over (order by cast(no as integer)) as diff from rt_ship_uz_hg where class='fm7' ) as p where diff=" & dt.Rows(x).Item("diff") & " order by cast(no as integer) desc"
- cmd.CommandText = sql
-
- mystring = mystring & cmd.ExecuteScalar & "件 / "
-
- Next
-
- If dt.Rows.Count > 0 Then
- ListBox2.Items.Add(mystring)
-
- End If
-
- sql = "select diff from (select no,rank() over (order by cast(no as integer)) as 序号, cast(no as integer)- rank() over (order by cast(no as integer)) as diff from rt_ship_uz_hg where class='fm8' ) as q group by diff order by diff" '-----fm8
- cmd.CommandText = sql
- dt = New DataTable
- da.SelectCommand = cmd
- da.Fill(dt)
-
- mystring = "牛二层皮8 "
-
- For x As Integer = 0 To dt.Rows.Count - 1
-
- sql = "select no from (select no,rank() over (order by cast(no as integer)) as 序号, cast(no as integer)- rank() over (order by cast(no as integer)) as diff from rt_ship_uz_hg where class='fm8' ) as p where diff=" & dt.Rows(x).Item("diff") & " order by cast(no as integer) "
- cmd.CommandText = sql
-
-
- mystring = mystring & "第" & cmd.ExecuteScalar & "~"
-
- sql = "select top(1) no from (select no,rank() over (order by cast(no as integer)) as 序号, cast(no as integer)- rank() over (order by cast(no as integer)) as diff from rt_ship_uz_hg where class='fm8' ) as p where diff=" & dt.Rows(x).Item("diff") & " order by cast(no as integer) desc"
- cmd.CommandText = sql
-
- mystring = mystring & cmd.ExecuteScalar & "件 / "
-
- Next
-
- If dt.Rows.Count <> 0 Then
- ListBox2.Items.Add(mystring)
-
- End If
-
- sql = "select diff from (select no,rank() over (order by cast(no as integer)) as 序号, cast(no as integer)- rank() over (order by cast(no as integer)) as diff from rt_ship_uz_hg where class='pu3' ) as q group by diff order by diff" '-----pu3
- cmd.CommandText = sql
- dt = New DataTable
- da.SelectCommand = cmd
- da.Fill(dt)
-
- mystring = "PU牛二层皮3 "
-
- For x As Integer = 0 To dt.Rows.Count - 1
-
- sql = "select no from (select no,rank() over (order by cast(no as integer)) as 序号, cast(no as integer)- rank() over (order by cast(no as integer)) as diff from rt_ship_uz_hg where class='pu3' ) as p where diff=" & dt.Rows(x).Item("diff") & " order by cast(no as integer) "
- cmd.CommandText = sql
-
- mystring = mystring & "第" & cmd.ExecuteScalar & "~"
-
- sql = "select top(1) no from (select no,rank() over (order by cast(no as integer)) as 序号, cast(no as integer)- rank() over (order by cast(no as integer)) as diff from rt_ship_uz_hg where class='pu3' ) as p where diff=" & dt.Rows(x).Item("diff") & " order by cast(no as integer) desc"
- cmd.CommandText = sql
-
- mystring = mystring & cmd.ExecuteScalar & "件 / "
-
- Next
-
- If dt.Rows.Count <> 0 Then
- ListBox2.Items.Add(mystring)
-
- End If
-
-
- sql = "select diff from (select no,rank() over (order by cast(no as integer)) as 序号, cast(no as integer)- rank() over (order by cast(no as integer)) as diff from rt_ship_uz_hg where class='pu5' ) as q group by diff order by diff" '-----pu5
- cmd.CommandText = sql
- dt = New DataTable
- da.SelectCommand = cmd
- da.Fill(dt)
-
- mystring = "PU牛二层皮5 "
-
- For x As Integer = 0 To dt.Rows.Count - 1
-
- sql = "select no from (select no,rank() over (order by cast(no as integer)) as 序号, cast(no as integer)- rank() over (order by cast(no as integer)) as diff from rt_ship_uz_hg where class='pu5' ) as p where diff=" & dt.Rows(x).Item("diff") & " order by cast(no as integer) "
- cmd.CommandText = sql
-
-
- mystring = mystring & "第" & cmd.ExecuteScalar & "~"
-
-
- sql = "select top(1) no from (select no,rank() over (order by cast(no as integer)) as 序号, cast(no as integer)- rank() over (order by cast(no as integer)) as diff from rt_ship_uz_hg where class='pu5' ) as p where diff=" & dt.Rows(x).Item("diff") & " order by cast(no as integer) desc"
- cmd.CommandText = sql
-
- mystring = mystring & cmd.ExecuteScalar & "件 / "
-
- Next
-
- If dt.Rows.Count <> 0 Then
- ListBox2.Items.Add(mystring)
-
- End If
-
-
-
-
- End Sub
-
- Private Sub Button35_Click(sender As Object, e As EventArgs) Handles Button35.Click
-
-
-
- Dim xlApp As Microsoft.Office.Interop.Excel.Application
- Dim xlBook As Microsoft.Office.Interop.Excel.Workbook
- Dim xlSheet As Microsoft.Office.Interop.Excel.Worksheet
-
-
- Dim dt As New DataTable
- Dim file_name As String = ""
- Dim file_name1 As String = ""
-
-
- ListBox1.Items.Clear()
-
- Dim my_weight As Double = 0
-
-
-
-
-
-
- Dim a As Integer = 0
- Dim my_count As Integer = 0
- 'OpenFileDialog1.Multiselect = True
- If OpenFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
-
- file_name = OpenFileDialog1.FileName
- file_name1 = OpenFileDialog1.SafeFileName
- Else
- Exit Sub
-
- End If
-
-
-
- xlApp = CreateObject("Excel.Application")
- xlApp.Visible = True
- xlApp.DisplayAlerts = False
-
-
-
- xlBook = xlApp.Workbooks.Open(file_name)
- xlBook.Activate()
-
- xlApp.Rows.Item("1:11").delete
-
-
- xlBook.Save()
- ' xlBook.Close()
-
- xlBook.Application.Quit()
- xlApp.Application.Quit()
-
- KillExcel(xlApp)
-
-
-
-
- xlBook = Nothing
- xlApp = Nothing
-
-
-
-
- Dim yy As Integer = 0
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Dim filepath As String = "k3/在制品"
-
- Dim sourceFileName As String = file_name
-
-
- Dim address2 As String = "ftp://" & my_ip & ":7788/" & filepath & "/" & OpenFileDialog1.SafeFileName
-
- Dim address3() As String
-
- address3 = Split(address2, "ftp://" & my_ip & ":7788/")
- Dim add4 As String
-
- add4 = "d:\k3\在制品\" & OpenFileDialog1.SafeFileName
-
-
- Dim userName As String = "matchy3c"
- Dim password As String = "Lafayette11"
- Dim showUI As Boolean = True
- Dim connectionTimeout As Integer = 500
-
-
- ' System.Threading.Thread.Sleep(30000)
-
-
- Dim client As WebClient = New WebClient
- client.Credentials = New NetworkCredential(userName, password)
- 'client.Proxy = GlobalProxySelection.GetEmptyWebProxy()
- client.UploadFile(address2, sourceFileName)
-
-
-
- sql = "delete from rt_inprocess_crust"
- cmd.CommandText = sql
- cmd.ExecuteScalar()
-
-
-
-
-
- sql = "Select * FROM OPENDATASOURCE ('Microsoft.ACE.OLEDB.12.0','Excel 12.0;HDR=Yes;IMEX=1;Database=" & add4 & "')... ['1$']"
- cmd.CommandText = sql
-
- da.SelectCommand = cmd
- da.Fill(dt)
- dgv1.DataSource = dt
-
-
-
- Dim my_sqlbulk As New SqlBulkCopy(conn)
-
- my_sqlbulk.DestinationTableName = "dbo.rt_inprocess_crust"
- my_sqlbulk.WriteToServer(dt)
-
- MsgBox("ok")
-
-
-
-
-
- End Sub
-
- Private Sub KillExcel(ByVal objExcel As Object)
- Try
- If objExcel IsNot Nothing Then
- Dim lProcessIdAddr As Integer
- Dim iPID As Integer
- iPID = GetWindowThreadProcessId(objExcel.Hwnd, lProcessIdAddr)
- System.Diagnostics.Process.GetProcessById(lProcessIdAddr).Kill()
- End If
- Catch ex As Exception
-
- End Try
- End Sub
-
- Private Sub Button36_Click(sender As Object, e As EventArgs) Handles Button36.Click
-
- Dim str = ListBox1.Items(0).ToString
-
-
-
- Select Case True
- Case str Like "*076*"
-
- For x As Integer = 0 To dgv1.Rows.Count - 1
- sql = "update rt_ship_076_1 set deli_no='" & dgv1.Rows(x).Cells("发货单号").Value & "' where order_no =N'" & dgv1.Rows(x).Cells("订单号").Value & "'
- and i_no=N'" & dgv1.Rows(x).Cells("指令号").Value & "'and color=N'" & dgv1.Rows(x).Cells("颜色").Value & "' and thick='" & dgv1.Rows(x).Cells("厚度").Value & "'"
- cmd.CommandText = sql
- cmd.ExecuteScalar()
-
- Next
-
-
- Case str Like "*澳孚*"
-
- For x As Integer = 0 To dgv1.Rows.Count - 1
- sql = "update rt_ship_daily_af set deli_no='" & dgv1.Rows(x).Cells("发货单号").Value & "' where po_no =N'" & dgv1.Rows(x).Cells("订单号").Value & "'
- and work_no=N'" & dgv1.Rows(x).Cells("指令号").Value & "'"
- cmd.CommandText = sql
- cmd.ExecuteScalar()
-
- Next
-
-
-
- Case str Like "*威弘*"
-
- For x As Integer = 0 To dgv1.Rows.Count - 1
- sql = "update rt_ship_daily_wh set deli_no='" & dgv1.Rows(x).Cells("发货单号").Value & "' where order_no =N'" & dgv1.Rows(x).Cells("订单号").Value & "'
- and i_no=N'" & dgv1.Rows(x).Cells("指令号").Value & "'and color=N'" & dgv1.Rows(x).Cells("颜色").Value & "' and thick='" & dgv1.Rows(x).Cells("厚度").Value & "'"
- cmd.CommandText = sql
- cmd.ExecuteScalar()
-
- Next
-
-
-
- Case str Like "*永正发货*"
-
- For x As Integer = 0 To dgv1.Rows.Count - 1
- sql = "update rt_ship_daily_uz_1 set deli_no='" & dgv1.Rows(x).Cells("发货单号").Value & "' where po_no =N'" & dgv1.Rows(x).Cells("订单号").Value & "'
- and order_item=N'" & dgv1.Rows(x).Cells("项次号").Value & "'and name=N'" & dgv1.Rows(x).Cells("品名").Value & "'"
- cmd.CommandText = sql
- cmd.ExecuteScalar()
-
- Next
-
- Case str Like "*极路客*"
-
-
- For x As Integer = 0 To dgv1.Rows.Count - 1
- sql = "update rt_ship_daily_jlk set deli_no='" & dgv1.Rows(x).Cells("发货单号").Value & "' where color =N'" & dgv1.Rows(x).Cells("颜色").Value & "'
- and thick=N'" & dgv1.Rows(x).Cells("厚度").Value & "'"
- cmd.CommandText = sql
- cmd.ExecuteScalar()
-
- Next
-
- Case str Like "*上杰发货*"
-
-
- For x As Integer = 0 To dgv1.Rows.Count - 1
- sql = "update rt_ship_daily_sj set deli_no='" & dgv1.Rows(x).Cells("发货单号").Value & "' where po_no =N'" & dgv1.Rows(x).Cells("订单号").Value & "'
- and order_item=N'" & dgv1.Rows(x).Cells("项次号").Value & "'and name=N'" & dgv1.Rows(x).Cells("品名").Value & "'"
- cmd.CommandText = sql
- cmd.ExecuteScalar()
-
- Next
-
- Case str Like "*SAMIL*"
-
-
- For x As Integer = 0 To dgv1.Rows.Count - 2
- sql = "update rt_ship_daily_samil set deli_no='" & dgv1.Rows(x).Cells("发货单号").Value & "' where po_no =N'" & dgv1.Rows(x).Cells("订单号").Value.ToString.Replace("'", "''") & "'
- and name=N'" & dgv1.Rows(x).Cells("品名").Value & "'"
- cmd.CommandText = sql
- cmd.ExecuteScalar()
-
- Next
-
-
- Case str Like "*亿博*" And Not (str Like "*亿博样*")
-
-
- For x As Integer = 0 To dgv1.Rows.Count - 1
- sql = "update rt_ship_daily_yb set deli_no='" & dgv1.Rows(x).Cells("发货单号").Value & "' where po_no =N'" & dgv1.Rows(x).Cells("订单号").Value & "'
- and name=N'" & dgv1.Rows(x).Cells("品名").Value & "'"
- cmd.CommandText = sql
- cmd.ExecuteScalar()
-
- Next
-
- Case str Like "*亿博*" And (str Like "*华盛*")
-
-
- For x As Integer = 0 To dgv1.Rows.Count - 1
- sql = "update rt_ship_daily_yby_huasheng set deli_no='" & dgv1.Rows(x).Cells("发货单号").Value & "' where po_no =N'" & dgv1.Rows(x).Cells("订单号").Value & "'
- and name=N'" & dgv1.Rows(x).Cells("品名").Value & "'"
- cmd.CommandText = sql
- cmd.ExecuteScalar()
-
- Next
-
- Case str Like "*亿博样*" And Not (str Like "*华盛*")
-
-
- For x As Integer = 0 To dgv1.Rows.Count - 1
- sql = "update rt_ship_daily_yby set deli_no='" & dgv1.Rows(x).Cells("发货单号").Value & "' where po_no =N'" & dgv1.Rows(x).Cells("订单号").Value & "'
- and name=N'" & dgv1.Rows(x).Cells("品名").Value & "'"
- cmd.CommandText = sql
- cmd.ExecuteScalar()
-
- Next
-
- Case str Like "*PEI HAI*"
-
-
- For x As Integer = 0 To dgv1.Rows.Count - 1
- sql = "update rt_ship_daily_xbh set deli_no='" & dgv1.Rows(x).Cells("发货单号").Value & "' where po_no =N'" & dgv1.Rows(x).Cells("订单号").Value & "'
- and name=N'" & dgv1.Rows(x).Cells("品名").Value & "'"
- cmd.CommandText = sql
- cmd.ExecuteScalar()
-
- Next
-
- Case str Like "*EVERGREE*"
-
-
- For x As Integer = 0 To dgv1.Rows.Count - 1
- sql = "update rt_ship_daily_evergree set deli_no='" & dgv1.Rows(x).Cells("发货单号").Value & "' where po_no =N'" & dgv1.Rows(x).Cells("订单号").Value & "'
- and name=N'" & dgv1.Rows(x).Cells("品名").Value & "'"
- cmd.CommandText = sql
- cmd.ExecuteScalar()
-
- Next
-
-
- Case str Like "*PROPERWELL*"
-
-
- For x As Integer = 0 To dgv1.Rows.Count - 1
- sql = "update rt_ship_daily_PROPERWELL set deli_no='" & dgv1.Rows(x).Cells("发货单号").Value & "' where po_no =N'" & dgv1.Rows(x).Cells("订单号").Value & "'
- and name=N'" & dgv1.Rows(x).Cells("品名").Value & "'"
- cmd.CommandText = sql
- cmd.ExecuteScalar()
-
- Next
-
- Case str Like "*STELLA*"
-
-
- For x As Integer = 0 To dgv1.Rows.Count - 1
- sql = "update rt_ship_daily_Stella set deli_no='" & dgv1.Rows(x).Cells("发货单号").Value & "' where po_no =N'" & dgv1.Rows(x).Cells("订单号").Value & "'
- and name=N'" & dgv1.Rows(x).Cells("品名").Value & "'"
- cmd.CommandText = sql
- cmd.ExecuteScalar()
-
- Next
-
-
- Case str Like "*THANH*"
-
-
- For x As Integer = 0 To dgv1.Rows.Count - 1
- sql = "update rt_ship_daily_thanhhu set deli_no='" & dgv1.Rows(x).Cells("发货单号").Value & "' where po_no =N'" & dgv1.Rows(x).Cells("订单号").Value & "'
- and name=N'" & dgv1.Rows(x).Cells("品名").Value & "'"
- cmd.CommandText = sql
- cmd.ExecuteScalar()
-
- Next
-
-
- Case str Like "*锐奇*"
-
-
- For x As Integer = 0 To dgv1.Rows.Count - 1
- sql = "update rt_ship_daily_ruiqi set deli_no='" & dgv1.Rows(x).Cells("发货单号").Value & "' where po_no =N'" & dgv1.Rows(x).Cells("采购号").Value & "'
- and name=N'" & dgv1.Rows(x).Cells("品名").Value & "' and work_no=N'" & dgv1.Rows(x).Cells("订单号").Value & "'"
- cmd.CommandText = sql
- cmd.ExecuteScalar()
-
- Next
-
-
- Case str Like "*穎億*"
-
-
- For x As Integer = 0 To dgv1.Rows.Count - 1
- sql = "update rt_ship_daily_yy set deli_no='" & dgv1.Rows(x).Cells("发货单号").Value & "' where po_no =N'" & dgv1.Rows(x).Cells("订单号").Value & "'
- and name=N'" & dgv1.Rows(x).Cells("品名").Value & "' and work_no=N'" & dgv1.Rows(x).Cells("指令号").Value & "'"
- cmd.CommandText = sql
- cmd.ExecuteScalar()
-
- Next
-
-
-
- End Select
-
-
-
- MsgBox("更新完成")
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- End Sub
- End Class
|