123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978 |
- 'Imports System.Data.SqlClient
- 'Imports Microsoft.Office.Interop.Excel
- 'Imports Microsoft.Office.Interop.Excel.XlBordersIndex
- 'Imports Microsoft.Office.Interop.Excel.Constants.xlConstants
- 'Imports Microsoft.Office.Interop.Excel.XlLineStyle
- 'Imports Microsoft.Office.Core.XlBorderWeight
- 'Imports Microsoft.Office.Core.XlUnderlineStyle
- 'Imports Microsoft.Office.Interop.Excel.XlPageOrientation
- Imports NPOI.XSSF.UserModel
- Imports NPOI.SS.UserModel
- Imports NPOI.POIFS.FileSystem
- Imports System.IO
- Imports System.Data.SqlClient
- 'Imports Microsoft.Office.Core.XlConstants
- Imports Microsoft.Office.Interop.Excel.XlUnderlineStyle
- Imports Microsoft.Office.Interop.Excel.Constants
- Imports Microsoft.Office.Interop.Excel.XlBordersIndex
- Imports Microsoft.Office.Interop.Excel.XlLineStyle
- Imports Microsoft.Office.Interop.Excel.XlBorderWeight
- Imports Microsoft.Office.Interop.Excel.XlPrintLocation
- Imports Microsoft.Office.Interop.Excel.XlPageOrientation
- Imports Microsoft.Office.Interop.Excel.XlPaperSize
- Imports Microsoft.Office.Interop.Excel.XlOrder
- Imports Microsoft.Office.Interop.Excel.XlPrintErrors
- 'Imports Excel = Microsoft.Office.Interop.Excel
- Imports Microsoft.Office.Core
- Imports System.Reflection
- Imports System.ComponentModel
- Imports Microsoft.Office.Interop
- Imports ThoughtWorks.QRCode.Codec.Data
- Imports System.Drawing.Imaging
- Imports NPOI.SS.Formula.Functions
- Imports System.Windows.Forms.VisualStyles.VisualStyleElement
-
-
-
-
-
- Public Class Frm_01HF_RetanRcp
- Dim dt1 As New DataTable
- Dim gWeight() As Double
- Dim gCoin() As String
- Dim gPrice() As Double
- Dim rr As String = ""
- Dim rcp_name As String = ""
- Dim gAddfromOther As Boolean = False
- Dim da As New SqlDataAdapter()
- Dim dr As SqlDataReader
- Dim conn As New SqlConnection
- Dim dt As New System.Data.DataTable
- Dim ds As New DataSet()
- Dim cmd As New SqlCommand
- Dim sql_rcp As String
- Dim sql_print As String
- Dim con As New SqlConnection
- 'Dim msg As String = ""
- Dim colorArray(10) As Color
- Dim card As String = ""
- Dim cust As String = ""
- Dim wb_weight As Double = 0
- Dim thickness As String = ""
- Dim r_type As String = ""
- Dim source As String = ""
- Dim comment As String = ""
- Dim dt_print As DataTable
- Dim color1 As String = ""
- Dim DT2 As New DataTable
-
- Sub ExportToExcel()
- ' 获取输入信息
- Dim my_card As String = InputBox("请输入卡号:", "查询")
- If my_card = "" Then
- MsgBox("操作已取消。", vbInformation, "退出")
- Exit Sub
- End If
-
- Dim my_weight As Double = 0
- Dim weightInput As String = InputBox("请输入重量:", "查询")
- If weightInput = "" OrElse Not IsNumeric(weightInput) OrElse CDbl(weightInput) <= 0 Then
- MsgBox("请输入有效的重量!", vbExclamation, "错误")
- Exit Sub
- Else
- my_weight = CDbl(weightInput)
- End If
-
- Dim d_no As String = InputBox("请输入编号:", "查询")
- If d_no = "" Then
- MsgBox("操作已取消。", vbInformation, "退出")
- Exit Sub
- End If
-
- ' 创建一个新的工作簿
- Dim workbook As New XSSFWorkbook()
- Dim sheet As ISheet = workbook.CreateSheet("Sheet1")
-
- ' 数据示例(例如 DataGridView1 的行数据)
- Dim rowIndex As Integer = 0
- For x As Integer = 0 To DataGridView1.Rows.Count - 2
- If DataGridView1.Rows(x).Cells("类别").Value <> "不列印" Then
- Dim row As IRow = sheet.CreateRow(rowIndex)
- row.CreateCell(0).SetCellValue("卡号: " & my_card)
- row.CreateCell(1).SetCellValue("编号: " & d_no)
- row.CreateCell(2).SetCellValue("重量: " & my_weight)
-
- rowIndex += 1
-
- ' 插入图片(假设图片路径在 p 数组中)
- Dim pictureData As Byte() = File.ReadAllBytes("c:\GHS\1.jpg")
- Dim pictureIndex As Integer = workbook.AddPicture(pictureData, PictureType.JPEG)
-
- ' 创建 DrawingPatriarch
- ' Dim drawing As IDrawingPatriarch = sheet.CreateDrawingPatriarch()
- Dim drawing As XSSFDrawing = CType(sheet.CreateDrawingPatriarch(), XSSFDrawing)
- Dim anchor As IClientAnchor = workbook.GetCreationHelper().CreateClientAnchor()
- anchor.Col1 = 3 ' 图片插入列
- anchor.Row1 = rowIndex ' 图片插入行
-
- ' 插入图片
- drawing.CreatePicture(anchor, pictureIndex)
-
- rowIndex += 1
- End If
- Next
-
- ' 设置输出文件路径
- Dim outputPath As String = "C:\path\to\your\output.xlsx"
- Using fs As New FileStream(outputPath, FileMode.Create, FileAccess.Write)
- workbook.Write(fs)
- End Using
-
- MsgBox("输出完成")
- End Sub
- Private Sub frm_01hf_RetanRcp_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
-
-
-
- Dim type1 As Type = dgv2.GetType()
- Dim pi1 As PropertyInfo = type1.GetProperty("DoubleBuffered", System.Reflection.BindingFlags.Instance Or System.Reflection.BindingFlags.NonPublic)
- pi1.SetValue(dgv2, True, Nothing)
-
-
- dgv2.CausesValidation = False
-
-
- DGV1.ReadOnly = True
-
- 'Me.MdiParent = mdiForm
-
-
- colorArray(0) = Color.FromName("Aquamarine")
- colorArray(1) = Color.FromName("azure")
- colorArray(2) = Color.FromName("beige")
- colorArray(3) = Color.FromName("gainsboro")
- colorArray(4) = Color.FromName("LightBlue")
- colorArray(5) = Color.FromName("LightSalmon")
-
- Button17.Visible = False
-
- dgv2.RowTemplate.Height = 30
- conn.ConnectionString = connstring
- con.ConnectionString = connstring
- con.Open()
- DGV1.RowTemplate.Height = 30
- DataGridView1.RowTemplate.Height = 30
-
- DataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill
- DataGridView1.AutoResizeRows(DataGridViewAutoSizeRowsMode.AllCells)
- ' DataGridView1.RowTemplate.Height = 30
-
-
- cmd.Connection = conn
-
-
-
- sql_rcp = "select top(200) date as 日期,name as 品名,selection as 选级,avg(weight) as 重量,no as 流程卡号,rcp_no as 表格编号 from ht_retanrcp group by name,date,selection,rcp_no,no order by date desc"
- cmd.Connection = conn
- cmd.CommandText = sql_rcp
- da.SelectCommand = cmd
-
- da.Fill(ds)
- DGV1.DataSource = ds.Tables(0)
-
- set_grid()
- dgv2.GridColor = Color.White
- dgv2.AllowUserToAddRows = False
- dgv2.SelectionMode = DataGridViewSelectionMode.FullRowSelect
- con.Close()
-
-
-
- dgv_record.GridColor = Color.White
- dgv_record.AllowUserToAddRows = False
- dgv_record.SelectionMode = DataGridViewSelectionMode.FullRowSelect
-
- ' dgv2.Columns(2).Visible = False
- ' dgv2.Columns(1).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight
-
-
-
- Dim c As Integer = 1
- Dim p(250) As Integer
-
- Dim x As Integer
-
- p(1) = 0
-
- For x = 1 To DGV1.Rows.Count - 2
- If DGV1.Rows(x).Cells(0).Value.ToString <> DGV1.Rows(x - 1).Cells(0).Value.ToString Then
- p(c + 1) = x
- c = c + 1
- End If
- Next
- p(c + 1) = x
- ReDim Preserve p(x)
- If c = 1 Then
- For z As Integer = 0 To x - 1
- DGV1.Rows(z).DefaultCellStyle.BackColor = colorArray(1)
- Next
- Else
- For cc As Integer = 1 To c
- For z As Integer = p(cc) To p(cc + 1) - 1
- DGV1.Rows(z).DefaultCellStyle.BackColor = colorArray(cc Mod 5)
- Next
- Next
- End If
- DGV1.Columns(0).Width = 150
- DGV1.Columns(1).Width = 220
- DGV1.Columns(2).Width = 160
-
- DGV1.Columns(3).Width = 100
- DGV1.Columns(4).Width = 190
- DGV1.Columns(5).Width = 200
- DGV1.RowHeadersWidth = 30
- DataGridView1.RowHeadersWidth = 30
- DataGridView1.RowTemplate.Height = 35
-
- End Sub
- Private Sub ini_content()
-
-
- 'card = FrmWB_OUT.DGV1.Rows(FrmWB_OUT.DGV1.CurrentRow.Index).Cells("卡号").Value
- 'cust = FrmWB_OUT.DGV1.Rows(FrmWB_OUT.DGV1.CurrentRow.Index).Cells("客户").Value
- 'wb_weight = FrmWB_OUT.DGV1.Rows(FrmWB_OUT.DGV1.CurrentRow.Index).Cells("皮重").Value
- 'thickness = FrmWB_OUT.DGV1.Rows(FrmWB_OUT.DGV1.CurrentRow.Index).Cells("厚度").Value
- 'source = FrmWB_OUT.DGV1.Rows(FrmWB_OUT.DGV1.CurrentRow.Index).Cells("皮源").Value
- 'comment = FrmWB_OUT.DGV1.Rows(FrmWB_OUT.DGV1.CurrentRow.Index).Cells("备注").Value.ToString
- 'color1 = FrmWB_OUT.DGV1.Rows(FrmWB_OUT.DGV1.CurrentRow.Index).Cells("颜色").Value
-
- End Sub
-
- Private Sub Button22_Click(sender As Object, e As EventArgs) Handles Button22.Click
-
-
-
- ini_content()
-
-
-
- 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 my_card As String = InputBox("请输入卡号", "询问")
- Dim my_weight As Double = InputBox("请输入重量", "询问")
-
- my_card = my_card
-
-
- 'frm_01hf_RetanRcp_WB.ShowDialog()
-
-
-
- Dim d_no As Double = InputBox("请输入鼓号", "询问")
-
- 'frm_01hf_RetanRcp_WB.ShowDialog()
-
- xlApp = CreateObject("Excel.Application")
-
- xlBook = xlApp.Workbooks.Add
-
-
- xlApp.DisplayAlerts = False
- xlBook.Activate()
- xlBook.Parent.Windows(1).Visible = True
- xlSheet = xlBook.Worksheets.Add
- xlSheet.Activate()
- xlApp.Visible = True
- xlApp.Application.ScreenUpdating = False
- editFormat(xlApp, xlSheet)
- xlApp.Visible = False
-
- xlSheet.Cells(1, 1) = "流程卡号"
- xlSheet.Cells(2, 1) = "打印日期"
- xlSheet.Cells(3, 1) = "皮源"
- xlSheet.Cells(1, 7) = "工艺名稱"
- xlSheet.Cells(2, 6) = "規格"
- xlSheet.Cells(2, 10) = "鼓号"
- xlSheet.Cells(1, 12) = "染色日期"
- xlSheet.Cells(2, 12) = "重量"
- xlSheet.Cells(3, 7) = "备注"
- xlSheet.Cells(2, 12) = "重量"
-
- xlSheet.Cells(3, 4) = comment
- ' xlSheet.Cells(1, 4) = DGV1.Rows(DGV1.CurrentRow.Index).Cells("處方編號").Value
- xlSheet.Cells(2, 4) = String.Format("{0:d}", DateTime.Now)
-
-
-
- xlSheet.Cells(1, 10) = cust & " " & color1 & "--" & DGV1.Rows(DGV1.CurrentRow.Index).Cells("品名").Value
- 'xlSheet.Cells(2, 10) = frm_01hf_RetanRcp_WB.ListBox6.SelectedItem
- 'xlSheet.Cells(2, 11) = frm_01hf_RetanRcp_WB.ListBox5.SelectedItem
- xlSheet.Cells(2, 7) = thickness
- xlSheet.Cells(2, 11) = d_no
- xlSheet.Cells(2, 14) = my_weight & " 公斤"
- xlSheet.Cells(1, 4) = my_card
- xlSheet.Cells(3, 4) = source
- xlSheet.Cells(3, 10) = comment
- xlSheet.Cells(5, 3) = "百分比"
- xlSheet.Cells(5, 5) = "用量(Kgs)"
- xlSheet.Cells(5, 6) = "化 料 名 稱"
- xlSheet.Cells(5, 9) = "时间"
- xlSheet.Cells(5, 10) = "備註"
- xlSheet.Rows("5:5").Select()
- xlApp.Selection.Font.Underline = xlUnderlineStyleSingle
-
-
- For i As Integer = 0 To DataGridView1.Rows.Count - 1
-
-
- xlSheet.Cells(i + 6, 3) = Math.Round(Val(DataGridView1.Rows(i).Cells("百分比").Value), 2)
- xlSheet.Cells(i + 6, 4) = "%"
- xlSheet.Cells(i + 6, 5) = Math.Round(DataGridView1.Rows(i).Cells("百分比").Value * my_weight / 2 / 100, 2)
-
- xlSheet.Cells(i + 6, 6) = DataGridView1.Rows(i).Cells("化料名称").Value
-
- xlSheet.Cells(i + 6, 9) = DataGridView1.Rows(i).Cells("时间").Value
-
- xlSheet.Cells(i + 6, 10) = DataGridView1.Rows(i).Cells("备注").Value
-
- xlSheet.Cells(i + 6, 10).Select()
- With xlApp.Selection
- .Font.Bold = True
- End With
-
- 'xlSheet.Cells(i + 6, 11) = datagridview1.Rows(i).Cells("幣別").Value
- 'xlSheet.Cells(i + 6, 12) = datagridview1.Rows(i).Cells("單價").Value
-
-
- If DataGridView1.Rows(i).Cells("化料名称").Value = "流水洗" Or DataGridView1.Rows(i).Cells("化料名称").Value = "洗水" Or DataGridView1.Rows(i).Cells("化料名称").Value = "排水" Or DataGridView1.Rows(i).Cells("化料名称").Value = "轉動" Or DataGridView1.Rows(i).Cells("化料名称").Value = "自動過夜" Or DataGridView1.Rows(i).Cells("化料名称").Value = "停止" Then
-
- xlSheet.Rows(i + 5 & ":" & i + 5).Select()
- With xlApp.Selection.Borders(xlEdgeBottom)
- .LineStyle = xlNone
- End With
- xlSheet.Rows(i + 6 & ":" & i + 6).Select()
- With xlApp.Selection.Borders(xlEdgeBottom)
- .LineStyle = xlDash
- .Weight = xlHairline
- End With
-
- xlSheet.Cells(i + 6, 3) = ""
- xlSheet.Cells(i + 6, 4) = ""
- xlSheet.Cells(i + 6, 5) = ""
- End If
-
-
-
- If DataGridView1.Rows(i).Cells("时间").Value <> "" Then
- xlSheet.Rows(i + 6 & ":" & i + 6).Select()
- With xlApp.Selection.Borders(xlEdgeBottom)
- .LineStyle = xlContinuous
- .Weight = xlMaximum
- End With
- End If
-
-
-
-
- Next i
-
-
-
- Dim a As Integer = xlApp.Workbooks(1).Worksheets(1).UsedRange.Rows.Count
- Dim b As Integer = xlApp.Workbooks(1).Worksheets(1).UsedRange.Columns.Count
-
- Dim area As String = "A4" & ":" & Chr(b + 64) & a
-
-
- xlSheet.Range(area).Font.Size = 10
- xlSheet.Range(area).Font.Name = "Times New Roman"
- xlApp.Selection.Font.Name = "Times New Roman"
-
- 'xlSheet.Columns("A:O").Select()
- 'With xlApp.Selection
- ' .HorizontalAlignment = Microsoft.Office.Interop.Excel.Constants.xlCenter
- ' .VerticalAlignment = Microsoft.Office.Interop.Excel.Constants.xlCenter
- ' .WrapText = False
- ' .Orientation = 0
- ' .AddIndent = False
- ' .IndentLevel = 0
- ' .ShrinkToFit = False
- ' .ReadingOrder = Microsoft.Office.Core.XlReadingOrder.xlContext
- 'End With
-
- xlSheet.Cells(3, 4).Select()
- With xlApp.Selection
- .HorizontalAlignment = Microsoft.Office.Interop.Excel.Constants.xlLeft
- End With
-
-
-
- For x As Integer = 6 To a
-
-
- If xlSheet.Cells(x, 9).value Is Nothing And xlSheet.Cells(x, 6).value Is Nothing Then
-
- xlSheet.Rows(x).RowHeight = 3
- ' aa = aa + 1
- Else
- xlSheet.Rows(x).RowHeight = 18
-
- End If
-
- Next x
-
-
-
-
- xlSheet.Range("a:a").HorizontalAlignment = Microsoft.Office.Interop.Excel.Constants.xlCenter
- xlSheet.Range("c:c").HorizontalAlignment = Microsoft.Office.Interop.Excel.Constants.xlRight
- xlSheet.Range("e:e ").HorizontalAlignment = Microsoft.Office.Interop.Excel.Constants.xlCenter
-
- xlSheet.Range("g:g").HorizontalAlignment = Microsoft.Office.Interop.Excel.Constants.xlCenter
- xlSheet.Range("c:c").NumberFormatLocal = "G/通用格式"
-
-
-
-
-
- With xlApp.ActiveSheet.PageSetup
- .PrintTitleRows = ""
- .PrintTitleColumns = ""
- End With
- xlSheet.PageSetup.PrintArea = ""
- With xlApp.ActiveSheet.PageSetup
- .TopMargin = xlApp.InchesToPoints(0.2)
- .BottomMargin = xlApp.InchesToPoints(0)
- .LeftMargin = xlApp.InchesToPoints(0)
- .RightMargin = xlApp.InchesToPoints(0)
- .HeaderMargin = xlApp.InchesToPoints(0.511811023622047)
- .FooterMargin = xlApp.InchesToPoints(0.511811023622047)
- '.PaperSize = Microsoft.Office.Interop.Excel.XlPaperSize.xlPaperA4
- .Zoom = False
- .FitToPagesWide = 1
- .FitToPagesTall = 1
- .PrintErrors = Microsoft.Office.Interop.Excel.XlPrintErrors.xlPrintErrorsDisplayed
- End With
- xlApp.Cells.Select()
- With xlApp.Selection.Font
- .Name = "Times New Roman"
- End With
-
-
-
-
-
- xlSheet.Range("f:f").HorizontalAlignment = Microsoft.Office.Interop.Excel.Constants.xlLeft
- xlSheet.Range("j:j").HorizontalAlignment = Microsoft.Office.Interop.Excel.Constants.xlLeft
-
- xlSheet.Range("a1:o3").HorizontalAlignment = Microsoft.Office.Interop.Excel.Constants.xlCenter
- xlApp.Visible = True
-
- xlApp.Application.ScreenUpdating = True
- MsgBox("打印完成")
-
-
- End Sub
- Private Sub DGV1_CellClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DGV1.CellClick
-
-
-
- Label1.Text = ""
- Timer1.Enabled = False
-
- cmdSaveEdit.Visible = False
- cmdCancelEdit.Visible = False
-
-
-
- If gAddfromOther = True Then
-
- Dim msg As MsgBoxResult = MsgBox("確定要從處方 '" & DGV1.Rows(e.RowIndex).Cells("品名").Value & "' 新增? ", MsgBoxStyle.YesNoCancel)
-
- If msg = MsgBoxResult.Yes Then
-
-
- gAddfromOther = False
-
-
- Dim ds As New DataSet
-
- con.Open()
-
- sql_rcp = "select RCP_NO as 處方編號, RCP_NAME as 品名, CREAT_D, LAST_EDITED, LAST_USED from " & rcp & " where rcp_no like '%" & rr & "%' or rcp_name like '%" & rcp_name & "%'"
- cmd.Connection = con
- cmd.CommandText = sql_rcp
- da.SelectCommand = cmd
- da.Fill(ds)
- DGV1.DataSource = ds.Tables(0)
- con.Close()
-
-
- dgv2.Visible = True
- ListBox2.Visible = False
- ListBox3.Visible = False
- ListBox4.Visible = False
- TextBox2.Visible = False
- TextBox3.Visible = False
- TextBox4.Visible = False
-
- Button11.Visible = False
- Button12.Visible = False
- Button13.Visible = False
- Button14.Visible = False
- Button15.Visible = False
-
- cmdAddrcp.Visible = True
- cmdcanceladd.Visible = True
-
-
- ElseIf msg = MsgBoxResult.No Then
- Exit Sub
- Else
- gAddfromOther = False
-
- End If
-
- End If
-
-
-
- End Sub
-
-
-
-
- 'Private Sub dgv2_RowPostPaint(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewRowPostPaintEventArgs)
-
- ' Dim linePen As New Pen(Color.SkyBlue, 2)
-
- ' If e.RowIndex = dgv2.Rows.Count - 1 Then
- ' dgv2.Rows(e.RowIndex).Cells("百分比").Style.ForeColor = Color.White
- ' Dim startX As Integer = IIf(dgv2.RowHeadersVisible, dgv2.RowHeadersWidth, 0)
- ' Dim startY As Integer = e.RowBounds.Top + e.RowBounds.Height - 1
- ' Dim endX As Integer = startX + dgv2.Columns.GetColumnsWidth(DataGridViewElementStates.Visible) - dgv2.HorizontalScrollingOffset - 50
- ' e.Graphics.DrawLine(linePen, startX, startY, endX, startY)
-
- ' Exit Sub
- ' End If
-
- ' If dgv2.Rows(e.RowIndex).Cells("时间").Value.ToString <> "" And (dgv2.Rows(e.RowIndex + 1).Cells("化料名称").Value.ToString = "流水洗" Or dgv2.Rows(e.RowIndex + 1).Cells("化料名称").Value.ToString = "洗水" Or dgv2.Rows(e.RowIndex + 1).Cells("化料名称").Value = "排水") Then
- ' ElseIf dgv2.Rows(e.RowIndex).Cells("时间").Value.ToString <> "" Then
-
- ' Dim startX As Integer = IIf(dgv2.RowHeadersVisible, dgv2.RowHeadersWidth, 0)
- ' Dim startY As Integer = e.RowBounds.Top + e.RowBounds.Height - 1
- ' Dim endX As Integer = startX + dgv2.Columns.GetColumnsWidth(DataGridViewElementStates.Visible) - dgv2.HorizontalScrollingOffset - 50
- ' e.Graphics.DrawLine(linePen, startX, startY, endX, startY)
-
- ' End If
-
- ' If (dgv2.Rows(e.RowIndex).Cells("化料名称").Value.ToString = "流水洗" Or dgv2.Rows(e.RowIndex).Cells("化料名称").Value.ToString = "洗水" Or dgv2.Rows(e.RowIndex).Cells("化料名称").Value = "排水") Then
- ' dgv2.Rows(e.RowIndex).Cells("百分比").Style.ForeColor = Color.White
- ' Dim startX As Integer = IIf(dgv2.RowHeadersVisible, dgv2.RowHeadersWidth, 0)
- ' Dim startY As Integer = e.RowBounds.Top + e.RowBounds.Height - 1
- ' Dim endX As Integer = startX + dgv2.Columns.GetColumnsWidth(DataGridViewElementStates.Visible) - dgv2.HorizontalScrollingOffset - 50
-
- ' e.Graphics.DrawLine(linePen, startX, startY, endX, startY)
-
- ' End If
-
-
- 'End Sub
-
-
- Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
-
-
- gMsg = MsgBox("要插入前方列請按--是" & vbCrLf & "要插入後方列請按--否" & vbCrLf & "或按取消離開", MsgBoxStyle.YesNoCancel)
-
-
- If gMsg <> MsgBoxResult.Cancel Then
- FrmEditChem_Choose.ShowDialog()
- End If
-
-
- End Sub
-
- Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
-
-
- If Not (DataGridView1.Rows(DataGridView1.CurrentRow.Index).DefaultCellStyle.Font Is Nothing) Then
-
- If DataGridView1.Rows(DataGridView1.CurrentRow.Index).DefaultCellStyle.Font.Style = FontStyle.Strikeout Then
- DataGridView1.Rows(DataGridView1.CurrentRow.Index).DefaultCellStyle.Font = New Font(DataGridView1.DefaultCellStyle.Font, FontStyle.Regular)
- Else
- DataGridView1.Rows(DataGridView1.CurrentRow.Index).DefaultCellStyle.Font = New Font(DataGridView1.DefaultCellStyle.Font, FontStyle.Strikeout)
- End If
- Else
- DataGridView1.Rows(DataGridView1.CurrentRow.Index).DefaultCellStyle.Font = New Font(DataGridView1.DefaultCellStyle.Font, FontStyle.Strikeout)
- End If
-
-
-
- Label1.Text = "修改模式"
- Timer1.Enabled = True
-
- cmdSaveEdit.Visible = True
- cmdCancelEdit.Visible = True
-
-
-
-
- End Sub
-
- Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
-
- If DataGridView1.SelectedRows.Count = 0 Then
- MsgBox("請先選擇要修改的項目")
- Exit Sub
- End If
-
- Label1.Text = "修改模式"
- Timer1.Enabled = True
-
- Dim f2 As New FrmEditChem_Choose
-
- f2.Owner = Me
- f2.ShowDialog()
- ' FrmEditChem_Choose.ShowDialog()
- cmdSaveEdit.Visible = True
- cmdCancelEdit.Visible = True
-
-
- DataGridView1.Rows(DataGridView1.CurrentRow.Index).Cells("化料名称").Value = my_chem
-
- DataGridView1.Focus()
-
-
-
-
- End Sub
-
- Private Sub TextBox1_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBox1.KeyUp
-
- Dim rmb As Double = 0
- Dim usd As Double = 0
- Dim euro As Double = 0
- Dim hkd As Double = 0
- Dim dye As Double = 0
- Dim oil As Double = 0
- Dim tan As Double = 0
- Dim x As Double = 0
- Dim kj As Double = 0
- Dim xx As Double = 0
-
- If con.State = ConnectionState.Closed Then
- con.Open()
- End If
-
-
-
- If e.KeyCode <> Keys.Enter Then
- Exit Sub
- End If
-
- Dim sql As String = ""
-
- sql = "select * from tblcurrency where year='" & Year(DateTime.Now) & "' and month='" & Month(DateTime.Now) & "'"
- cmd.CommandText = sql
- cmd.Connection = con
- dr = cmd.ExecuteReader
-
- If dr.Read Then
- rmb = dr("rmb")
- usd = dr("usd")
- hkd = dr("hkd")
- euro = dr("euro")
- dr.Close()
- Else
- dr.Close()
- sql = "select * from tblcurrency order by year desc,month desc"
- cmd.CommandText = sql
- ' dr.Read()
- dr = cmd.ExecuteReader
- dr.Read()
- rmb = dr("rmb")
- usd = dr("usd")
- hkd = dr("hkd")
- euro = dr("euro")
- dr.Close()
- End If
-
-
-
- sql = " SELECT MATLKIND.MATLKIND,SUM(rcp_content.percents / 100 * " & TextBox1.Text & ") as retan,tblMaterial.COIN,SUM(tblMaterial.PUR_UNIT * rcp_content.percents / 100 * " & TextBox1.Text & ") AS retan_cost FROM rcp_content INNER JOIN tblMaterial ON rcp_content.MATL_NO = tblMaterial.MATL_NO INNER JOIN MATLKIND ON tblMaterial.MATL_ID = MATLKIND.MATL_ID WHERE (rcp_content.RCP_NO = '" & DGV1.Rows(DGV1.CurrentRow.Index).Cells("處方編號").Value & "') AND (tblMaterial.COIN IS NOT NULL) GROUP BY tblMaterial.MATL_ID, tblMaterial.COIN, tblMaterial.MATL_ID, MATLKIND.MATLKIND ORDER BY tblMaterial.MATL_ID"
- cmd.CommandText = sql
- dr = cmd.ExecuteReader
- While dr.Read
-
- Select Case dr("matlkind")
- Case "染料"
- Select Case dr("coin")
- Case "RMB"
- dye += dr("retan_cost") * rmb
- Case "USD"
- dye += dr("retan_cost") * usd
- Case "歐元"
- dye += dr("retan_cost") * euro
- Case "港幣"
- dye += dr("retan_cost") * hkd
- Case "台幣"
- dye += dr("retan_cost")
- End Select
-
- Case "植物鞣剂"
- Select Case dr("coin")
- Case "RMB"
- kj += dr("retan_cost") * rmb
- Case "USD"
- kj += dr("retan_cost") * usd
- Case "歐元"
- kj += dr("retan_cost") * euro
- Case "港幣"
- kj += dr("retan_cost") * hkd
- Case "台幣"
- kj += dr("retan_cost")
- End Select
- Case "油脂"
- Select Case dr("coin")
- Case "RMB"
- oil += dr("retan_cost") * rmb
- Case "USD"
- oil += dr("retan_cost") * usd
- Case "歐元"
- oil += dr("retan_cost") * euro
- Case "港幣"
- oil += dr("retan_cost") * hkd
- Case "台幣"
- oil += dr("retan_cost")
- End Select
- Case "單寧", "樹脂", "铬粉"
- Select Case dr("coin")
- Case "RMB"
- tan += dr("retan_cost") * rmb
- Case "USD"
- tan += dr("retan_cost") * usd
- Case "歐元"
- tan += dr("retan_cost") * euro
- Case "港幣"
- tan += dr("retan_cost") * hkd
- Case "台幣"
- tan += dr("retan_cost")
- End Select
- Case "中和剂", "一般化料"
- Select Case dr("coin")
- Case "RMB"
- x += dr("retan_cost") * rmb
- Case "USD"
- x += dr("retan_cost") * usd
- Case "歐元"
- x += dr("retan_cost") * euro
- Case "港幣"
- x += dr("retan_cost") * hkd
- Case "台幣"
- x += dr("retan_cost")
- End Select
- Case Else
- Select Case dr("coin")
- Case "RMB"
- xx += dr("retan_cost") * rmb
- Case "USD"
- xx += dr("retan_cost") * usd
- Case "歐元"
- xx += dr("retan_cost") * euro
- Case "港幣"
- xx += dr("retan_cost") * hkd
- Case "台幣"
- xx += dr("retan_cost")
- End Select
-
- End Select
- End While
-
-
- txttan.Text = Math.Round(tan, 3)
- txtKJ.Text = Math.Round(kj, 3)
- txtoil.Text = Math.Round(oil, 3)
- txtdye.Text = Math.Round(dye, 3)
- txtx.Text = Math.Round(x, 3)
- txtxx.Text = Math.Round(xx, 3)
- txtsum.Text = Math.Round(tan + oil + kj + dye + x + xx, 3)
-
- txtsize.Focus()
-
-
- con.Close()
-
-
-
-
- End Sub
-
- Private Sub txtsize_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles txtsize.KeyUp
-
- If e.KeyCode <> Keys.Enter Then
- Exit Sub
- End If
-
-
- txttan.Text = Math.Round(txttan.Text / txtsize.Text, 3)
- txtoil.Text = Math.Round(txtoil.Text / txtsize.Text, 3)
- txtdye.Text = Math.Round(txtdye.Text / txtsize.Text, 3)
- txtx.Text = Math.Round(txtx.Text / txtsize.Text, 3)
- txtxx.Text = Math.Round(txtxx.Text / txtsize.Text, 3)
- txtKJ.Text = Math.Round(txtKJ.Text / txtsize.Text, 3)
- txtsum.Text = Math.Round(txtsum.Text / txtsize.Text, 3)
-
- End Sub
-
- Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
-
-
- If con.State = ConnectionState.Closed Then
- con.Open()
- End If
-
- Dim rcp1 As String = ""
-
- rcp1 = TextBox18.Text
-
-
- ' rcp1 = InputBox("請輸入要查詢的處方編號或處方名稱")
- If rcp1 = "" Then Exit Sub
- sql_rcp = "select NAME as 品名, date as 日期,selection,no from ht_retanrcp where name like N'%" & rcp1 & "%' group by name,date,selection,no order by name,date desc"
-
- sql_rcp = "select top(200) name as 品名,date as 日期,selection as 选级,avg(weight) as 重量,no as 流程卡号,rcp_no as 表格编号 from ht_retanrcp where name like N'%" & rcp1 & "%' group by name,date,selection,rcp_no,no order by date desc"
- cmd.Connection = con
- cmd.CommandText = sql_rcp
- da.SelectCommand = cmd
-
- Dim dt As New DataTable
- da.Fill(dt)
- DGV1.DataSource = dt
- con.Close()
-
- 'DGV1.Columns(0).Width = 280
- 'DGV1.Columns(1).Width = 140
-
- Dim c As Integer = 1
- Dim p(200) As Integer
-
- Dim x As Integer
-
- p(1) = 0
-
- For x = 1 To DGV1.Rows.Count - 2
- If DGV1.Rows(x).Cells(0).Value.ToString <> DGV1.Rows(x - 1).Cells(0).Value.ToString Then
- p(c + 1) = x
- c = c + 1
- End If
- Next
- p(c + 1) = x
- ReDim Preserve p(x)
- If c = 1 Then
- For z As Integer = 0 To x - 1
- DGV1.Rows(z).DefaultCellStyle.BackColor = colorArray(1)
- Next
- Else
- For cc As Integer = 1 To c
- For z As Integer = p(cc) To p(cc + 1) - 1
- DGV1.Rows(z).DefaultCellStyle.BackColor = colorArray(cc Mod 5)
- Next
- Next
- End If
-
- DGV1.Columns(0).Width = 170
- DGV1.Columns(1).Width = 100
- DGV1.Columns(3).Width = 70
- DGV1.Columns(4).Width = 150
- DGV1.RowHeadersWidth = 30
- DataGridView1.RowHeadersWidth = 30
- DataGridView1.RowTemplate.Height = 26
-
-
-
-
- End Sub
-
- Private Sub DGV1_CellEnter(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DGV1.CellEnter
-
-
-
- 'Dim ds1 As New DataSet
- 'Dim ds2 As New DataSet
- 'Dim cn As New SqlConnection
- 'cn.ConnectionString = connstring
- 'cn.Open()
- 'cmd.Connection = cn
-
-
-
- 'txttan.Text = ""
- 'txtKJ.Text = ""
- 'txtoil.Text = ""
- 'txtdye.Text = ""
- 'txtx.Text = ""
- 'txtxx.Text = ""
- 'txtsum.Text = ""
-
-
- 'Dim dt As New DataTable
-
- 'sql_rcp = "SELECT serial AS 项目, CHEM AS 化料名称, PERCENTAGE AS 百分比, time AS 时间, WEIGHT AS 重量,comment AS 备注 from rt_retan_rcp_detail where rcp_name =N'" & DGV1.Rows(DGV1.CurrentRow.Index).Cells("处方编号").Value & "' order by serial"
-
-
-
- 'cmd.CommandText = sql_rcp
- 'da.SelectCommand = cmd
- 'da.Fill(dt)
- 'dgv2.DataSource = dt
-
- 'set_grid1()
-
- 'rcp = "rt_retan_rcp"
- 'sql_rcp = "select creat_d from " & rcp & " where RCP_NO='" & DGV1.Rows(DGV1.CurrentRow.Index).Cells(0).Value & "'"
- 'cmd.CommandText = sql_rcp
- 'If cmd.ExecuteScalar Is Nothing Then
- 'Else
- ' txtcreate.Text = cmd.ExecuteScalar.ToString
- 'End If
- 'sql_rcp = "select last_used from " & rcp & " where RCP_NO='" & DGV1.Rows(DGV1.CurrentRow.Index).Cells(0).Value & "'"
- 'cmd.CommandText = sql_rcp
- 'If cmd.ExecuteScalar Is Nothing Then
- 'Else
- ' txtuse.Text = cmd.ExecuteScalar.ToString
- 'End If
-
- 'sql_rcp = "select last_edited from " & rcp & " where RCP_NO='" & DGV1.Rows(DGV1.CurrentRow.Index).Cells(0).Value & "'"
- 'cmd.CommandText = sql_rcp
- 'If cmd.ExecuteScalar Is Nothing Then
- 'Else
- ' txtedit.Text = cmd.ExecuteScalar.ToString
- 'End If
-
- 'sql_rcp = "select editor from " & rcp & " where RCP_NO='" & DGV1.Rows(DGV1.CurrentRow.Index).Cells(0).Value & "'"
- 'cmd.CommandText = sql_rcp
- 'If cmd.ExecuteScalar Is Nothing Then
- 'Else
- ' ' txteditor.Text = cmd.ExecuteScalar.ToString
- ' 'End If
-
- ' txteditor.Text = cmd.ExecuteScalar.ToString
- 'End If
- ' sql_rcp = "SELECT rcp_content.ITEM AS 項目, rcp_content.MATL_NO AS 化料編號, tblMaterial.MATL_NAME AS 化料名称, rcp_content.percents AS 百分比, " &
- '" rcp_content.time AS 时间, rcp_content.comment AS 備註, tblMaterial.COIN AS 幣別, tblMaterial.PUR_UNIT AS 單價 " &
- '" FROM " & rcp & " INNER JOIN " &
- '" rcp_content ON " & rcp & ".RCP_NO = rcp_content.RCP_NO INNER JOIN " &
- '" tblMaterial ON rcp_content.MATL_NO = tblMaterial.MATL_NO " &
- '" WHERE rcp_content.RCP_NO='" & DGV1.Rows(DGV1.CurrentRow.Index).Cells(0).Value & "edit' ORDER BY 項目"
-
-
- ' sql_rcp = "SELECT rcp_content.ITEM AS 項目, rcp_content.MATL_NO AS 化料編號, tblMaterial.MATL_NAME AS 化料名称, rcp_content.percents AS 百分比, " &
- ' " rcp_content.time AS 时间, rcp_content.comment AS 備註, tblMaterial.COIN AS 幣別, tblMaterial.PUR_UNIT AS 單價 " &
- '"FROM rcp_content INNER JOIN " &
- ' " tblMaterial ON rcp_content.MATL_NO = tblMaterial.MATL_NO " &
- '"WHERE (rcp_content.RCP_NO='" & DGV1.Rows(DGV1.CurrentRow.Index).Cells(0).Value & "edit') " &
- '" ORDER BY 項目"
-
-
-
-
-
-
-
-
- ' cmd.CommandText = sql_rcp
- ' da.SelectCommand = cmd
- ' da.Fill(ds2)
- ' dgv_record.DataSource = ds2.Tables(0)
-
- ' set_grid2()
-
-
-
-
-
-
- ' sql_rcp = "SELECT MATLKIND.MATLKIND as 類別, tblMaterial.MATL_id as 代號,round(SUM(rcp_content.percents),1) AS 比例 FROM rcp_content INNER JOIN" &
- ' " tblMaterial ON rcp_content.MATL_NO = tblMaterial.MATL_NO INNER JOIN " &
- ' " MATLKIND ON tblMaterial.MATL_ID = MATLKIND.MATL_ID" &
- '" WHERE (rcp_content.RCP_NO='" & DGV1.Rows(DGV1.CurrentRow.Index).Cells(0).Value & "') AND (tblMaterial.COIN IS NOT NULL)" &
- '" GROUP BY tblMaterial.MATL_ID, MATLKIND.MATLKIND" &
- '" ORDER BY tblMaterial.MATL_ID"
- ' Dim ds3 As New DataSet
- ' cmd.CommandText = sql_rcp
- ' da.SelectCommand = cmd
- ' da.Fill(ds3)
- ' dgv_cost.DataSource = ds3.Tables(0)
-
-
-
-
- ' set_grid3()
-
-
-
- ' cn.Close()
-
- End Sub
-
- Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click
-
- Dim con As New SqlConnection
- Dim sql As String
- Dim dr As SqlDataReader
-
- con.ConnectionString = connstring
- con.Open()
- cmd.Connection = con
-
- dgv2.Visible = False
- ListBox2.Visible = True
- ListBox3.Visible = True
- ListBox4.Visible = True
- TextBox2.Visible = True
- TextBox3.Visible = True
- TextBox4.Visible = True
-
- Button11.Visible = True
- Button12.Visible = True
- Button13.Visible = True
- Button14.Visible = True
- Button15.Visible = True
-
-
-
- sql = "select cust_name from customer order by cust_name"
- cmd.CommandText = sql
- dr = cmd.ExecuteReader
-
- While dr.Read
-
- ListBox2.Items.Add(dr("cust_name"))
-
- End While
- dr.Close()
-
- sql = "select prod_name from tblproduct order by prod_name"
- cmd.CommandText = sql
- dr = cmd.ExecuteReader
-
- While dr.Read
-
- ListBox3.Items.Add(dr("prod_name"))
-
- End While
- dr.Close()
-
-
- sql = "select color_name from color order by color_name"
- cmd.CommandText = sql
- dr = cmd.ExecuteReader
-
- While dr.Read
-
- ListBox4.Items.Add(dr("color_name"))
-
- End While
- dr.Close()
-
- Timer1.Enabled = True
-
- End Sub
-
-
- Private Sub TextBox2_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs)
-
- Dim con As New SqlConnection
- Dim sql As String
- Dim dr As SqlDataReader
-
- con.ConnectionString = connstring
- con.Open()
- cmd.Connection = con
-
- ListBox2.Items.Clear()
-
- sql = "select cust_name from customer where cust_name like '%" & TextBox2.Text & "%'"
- cmd.CommandText = sql
- dr = cmd.ExecuteReader
-
- While dr.Read
-
- ListBox2.Items.Add(dr("cust_name"))
-
- End While
- dr.Close()
-
-
- If e.KeyCode = Keys.Enter Then
- If ListBox2.Items.Count = 0 Then Exit Sub
- ListBox2.Focus()
- ListBox2.SelectedIndex = 1
-
- End If
-
-
- End Sub
-
- Private Sub TextBox3_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs)
-
-
- Dim con As New SqlConnection
- Dim sql As String
- Dim dr As SqlDataReader
-
- con.ConnectionString = connstring
- con.Open()
- cmd.Connection = con
-
- ListBox3.Items.Clear()
-
- sql = "select prod_name from tblproduct where prod_name like '%" & TextBox3.Text & "%'"
- cmd.CommandText = sql
- dr = cmd.ExecuteReader
-
- While dr.Read
-
- ListBox3.Items.Add(dr("prod_name"))
-
- End While
- dr.Close()
-
-
- If e.KeyCode = Keys.Enter Then
- If ListBox3.Items.Count = 0 Then Exit Sub
- ListBox3.Focus()
- ListBox3.SelectedIndex = 1
-
- End If
-
- End Sub
-
- Private Sub TextBox4_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs)
-
-
- Dim con As New SqlConnection
- Dim sql As String
- Dim dr As SqlDataReader
-
- con.ConnectionString = connstring
- con.Open()
- cmd.Connection = con
-
- ListBox4.Items.Clear()
-
- sql = "select color_name from color where color_name like '%" & TextBox4.Text & "%'"
- cmd.CommandText = sql
- dr = cmd.ExecuteReader
-
- While dr.Read
-
- ListBox4.Items.Add(dr("color_name"))
-
- End While
- dr.Close()
-
-
- If e.KeyCode = Keys.Enter Then
- If ListBox3.Items.Count = 0 Then Exit Sub
- ListBox4.Focus()
- ListBox4.SelectedIndex = 1
-
- End If
-
-
- End Sub
-
- Private Sub Button14_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
-
- If ListBox2.SelectedIndex = -1 Or ListBox2.SelectedIndex = -1 Or ListBox2.SelectedIndex = -1 Then
-
- MsgBox("請先選擇客戶產品顏色", , "錯誤")
- Exit Sub
-
- End If
-
-
- Dim sql As String = ""
- Dim con As New SqlConnection
- Dim rcp_no As String = ""
-
- Dim cust_no As String = ""
- Dim prod_id As String = ""
- Dim color_no As String = ""
- con.ConnectionString = connstring
- con.Open()
- cmd.Connection = con
-
-
-
- sql = "select id from customer where cust_name='" & ListBox2.SelectedItem & "'"
- cmd.CommandText = sql
- cust_no = cmd.ExecuteScalar
- sql = "select prod_id from tblproduct where prod_name='" & ListBox3.SelectedItem & "'"
- cmd.CommandText = sql
- prod_id = cmd.ExecuteScalar
- sql = "select color_no from color where color_name='" & ListBox4.SelectedItem & "'"
- cmd.CommandText = sql
- color_no = cmd.ExecuteScalar
-
-
-
- sql = "select count(*) from " & rcp & " where substring(rcp_no,4,3)='" & cust_no & "' and substring(rcp_no,1,1)='" & prod_id & "' and substring(rcp_no,7,2)='" & color_no & "'"
- cmd.CommandText = sql
- Dim c As Integer = cmd.ExecuteScalar
-
-
- If c = 0 Then
-
- rr = prod_id & String.Format("{0:D2}", c) & String.Format("{0:D3}", cust_no) & color_no
- Else
-
- rr = prod_id & String.Format("{0:D2}", c + 1) & String.Format("{0:D3}", cust_no) & color_no
-
- End If
-
-
- sql = "select count(*) from " & rcp & " where rcp_no='" & rr & "'"
- cmd.CommandText = sql
- c = cmd.ExecuteScalar
-
-
- rcp_name = ListBox2.SelectedItem & ListBox4.SelectedItem & ListBox3.SelectedItem
-
- rcp_name = InputBox("處方名稱", "詢問", rcp_name)
-
- sql = "select count(*) from " & rcp & " where rcp_no='" & rr & "'"
- cmd.CommandText = sql
- Dim a As Integer = cmd.ExecuteScalar
-
- If a = 0 Then
-
- 'sql = "insert into " & rcp & " (rcp_no,rcp_name,creat_d) values ( '" & rcp_no & "','" & rcp_name & "','" & Now & "')"
- 'cmd.CommandText = sql
- 'Dim b As Integer = cmd.ExecuteScalar()
- 'If b <> 0 Then
- ' MsgBox("新增處方完成")
- ' Exit Sub
-
- 'End If
- Else
- MsgBox("處方編號重覆")
- gAddfromOther = False
- Exit Sub
-
- End If
-
-
- Dim msg As MsgBoxResult
-
- msg = MsgBox("是否要由其他處方修改?", vbYesNoCancel, "詢問")
-
-
- gAddfromOther = True
- Dim my_rcp As String = ""
- my_rcp = InputBox("請輸入處方編號")
-
-
- If my_rcp = "" Then Exit Sub
- sql_rcp = "select RCP_NO as 處方編號, RCP_NAME as 品名, CREAT_D, LAST_EDITED, LAST_USED from " & rcp & " where rcp_no like '%" & my_rcp & "%' or rcp_name like '%" & my_rcp & "%'"
- cmd.CommandText = sql_rcp
- da.SelectCommand = cmd
- Dim ds As New DataSet
- da.Fill(ds)
- DGV1.DataSource = ds.Tables(0)
-
- Timer1.Enabled = True
-
- con.Close()
-
- End Sub
-
- Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
- If Label1.Visible = True Then
- Label1.Visible = False
- Else
- Label1.Visible = True
- End If
- End Sub
-
-
- Private Sub cmdAddrcp_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdAddrcp.Click
-
-
- If conn.State = ConnectionState.Closed Then
- conn.Open()
- End If
-
-
-
- Dim sql As String = ""
-
- sql = "insert into " & rcp & " (rcp_no,rcp_name,creat_d) values ( '" & rr & "','" & rcp_name & "','" & String.Format("{0:d}", DateTime.Now) & "')"
- cmd.CommandText = sql
- cmd.Connection = conn
- Dim b As Integer = cmd.ExecuteNonQuery
-
- If b <> 0 Then
- MsgBox("已新增處方編號:" & rr & vbCrLf & " 處方名稱:" & rcp_name)
- Else
- MsgBox("新增處方失敗")
-
- End If
-
- Dim dt As DataTable
-
- dt = dgv2.DataSource
-
- 'For x As Integer = 0 To dt.Rows.Count - 1
-
- ' cmd.CommandText = "insert into rcp_content (item,matl_no,percents,rcp_no,time,comment) values ('" & dt.Rows(x).Item("項目").ToString & "','" & dt.Rows(x).Item("化料編號").ToString & "','" & dt.Rows(x).Item("百分比").ToString & "','" & rr & "','" & dt.Rows(x).Item("时间").ToString & "','" & dt.Rows(x).Item("備註").ToString & "')"
- ' cmd.ExecuteNonQuery()
-
- 'Next
-
-
- For x As Integer = 0 To dt.Rows.Count - 1
-
- cmd.CommandText = "insert into rcp_content (item,matl_no,percents,rcp_no,time,comment) values ('" & dt.Rows(x).Item("項目").ToString & "','" & dt.Rows(x).Item("化料編號").ToString & "','" & dt.Rows(x).Item("百分比").ToString & "','" & rr & "','" & dt.Rows(x).Item("时间").ToString & "','" & dt.Rows(x).Item("備註").ToString & "')"
- cmd.ExecuteNonQuery()
-
-
- 'cmd.CommandText = "insert into rcp_content (item,matl_no,percents,rcp_no,time,comment) values ('03','X613','1','E00250WD','20','停40轉20停40')"
- 'cmd.ExecuteNonQuery()
- Next
-
-
- cmdAddrcp.Visible = False
- cmdcanceladd.Visible = False
-
- Timer1.Enabled = False
- Label1.Visible = False
-
- conn.Close()
-
-
- End Sub
-
- Private Sub Button15_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
-
-
- dgv2.Visible = True
- ListBox2.Visible = False
- ListBox3.Visible = False
- ListBox4.Visible = False
- TextBox2.Visible = False
- TextBox3.Visible = False
- TextBox4.Visible = False
-
- Button11.Visible = False
- Button12.Visible = False
- Button13.Visible = False
- Button14.Visible = False
- Button15.Visible = False
-
- Button17.Visible = False
-
-
- cmdAddrcp.Visible = False
- cmdcanceladd.Visible = False
-
- Timer1.Enabled = False
- Label1.Visible = False
-
-
-
-
- End Sub
-
- Private Sub Button9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button9.Click '打印标签
-
-
-
- ' ini_content() '取得卡号等相关资讯
-
-
-
- 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 folderPath As String = "\\DS920plus\华峰业务\AA化料文件资料\2024年整理MSDS和ZDHC\MSDS\MSDS总表"
-
-
- Dim my_card As String
- Dim my_weight As Double
- Dim d_no As String
- Do
- my_card = InputBox("请输入卡号:", "查询")
- If my_card = "" Then
- MsgBox("操作已取消。", vbInformation, "退出")
- Exit Sub ' 立即退出子程序
- ElseIf my_card = "" Then
- MsgBox("请重新输入!", vbExclamation, "错误")
- Else
- Exit Do
- End If
- Loop
-
- ' 验证重量输入
- Do
- Dim weightInput As String
- weightInput = InputBox("请输入重量:", "查询")
- If weightInput = "" Then
- MsgBox("操作已取消。", vbInformation, "退出")
- Exit Sub
- ElseIf Not IsNumeric(weightInput) Then
- MsgBox("重量必须是数字,请重新输入!", vbExclamation, "错误")
- ElseIf CDbl(weightInput) <= 0 Then
- MsgBox("重量必须大于0,请重新输入!", vbExclamation, "错误")
- Else
- my_weight = CDbl(weightInput)
- Exit Do
- End If
- Loop
-
- ' 验证编号输入
- Do
- d_no = InputBox("请输入编号:", "查询")
- If d_no = "" Then
- MsgBox("操作已取消。", vbInformation, "退出")
- Exit Sub
- ElseIf d_no Like "*-*" Then
- ' MsgBox("编号格式不正确,请输入类似 'P241129-4' 的编号!", vbExclamation, "错误")
- Else
- Exit Do
- End If
- Loop
-
-
-
-
-
- 'frm_01hf_RetanRcp_WB.ShowDialog()
-
- xlApp = CreateObject("Excel.Application")
-
- xlBook = xlApp.Workbooks.Add
-
-
- xlApp.DisplayAlerts = False
- xlBook.Activate()
- xlBook.Parent.Windows(1).Visible = True
- xlSheet = xlBook.Worksheets.Add
- xlSheet.Activate()
- xlApp.Visible = True
-
- ' DT2.DefaultView.Sort = "分类 "
- 'dt = dt.DefaultView.ToTable()
-
- Dim xx As Integer = 0
- Dim y As Integer = 0
-
- Dim p(10) As String
-
-
- p(1) = "c:\GHS\1.jpg"
- p(2) = "c:\GHS\2.jpg"
- p(3) = "c:\GHS\3.jpg"
- p(4) = "c:\GHS\4.jpg"
- p(5) = "c:\GHS\5.jpg"
- p(6) = "c:\GHS\6.jpg"
- p(7) = "c:\GHS\7.jpg"
- p(8) = "c:\GHS\8.jpg"
- p(9) = "c:\GHS\9.jpg"
-
-
-
- Dim FILE_NAME As String
- Dim FILE_NAME1 As String
-
-
- 'Dim obj As New FolderBrowserDialog
- Dim sPath As String
-
- sPath = "c:\GHS\"
-
-
- Dim dt As DataTable = CType(DataGridView1.DataSource, DataTable)
-
- Dim dv As DataView = dt.DefaultView
- dv.Sort = "类别 ASC, 项次 ASC"
-
- ' 重新绑定排序后的 DataView
- DataGridView1.DataSource = dv
-
- ' DataGridView1.Sort(DataGridView1.Columns("类别"), ListSortDirection.Ascending)
-
- Dim zzz As Integer = 0
-
-
- For x As Integer = 0 To DataGridView1.Rows.Count - 2 '---迴圈
-
- If (DataGridView1.Rows(x).Cells("类别").Value <> "不列印") Then
-
-
- If Not (DataGridView1.Rows(x).DefaultCellStyle.Font Is Nothing) Then
-
- GoTo ok11
-
- End If
-
- ' PictureBox1.Image = MakeQrCode(DGV1.Rows(DGV1.CurrentCell.RowIndex).Cells("品名").Value & vbCrLf & my_card & vbCrLf & color1 & vbCrLf & DataGridView1.Rows(x).Cells("化料名称").Value & vbCrLf & Math.Round(DataGridView1.Rows(x).Cells("百分比").Value * my_weight, 1))
-
- PictureBox1.Image = MakeQrCode("http://192.168.110.164:8888/" & DataGridView1.Rows(x).Cells("filename").Value)
-
- System.Windows.Forms.Clipboard.SetDataObject(PictureBox1.Image, True) '---------------------------------------复制到剪贴板 二维码
-
- If System.Windows.Forms.Clipboard.ContainsImage() Then
- Console.WriteLine("剪贴板包含有效的图片数据")
- Else
- Console.WriteLine("剪贴板中没有图片数据")
- End If
-
- System.Threading.Thread.Sleep(200)
-
- Dim range2 As Excel.Range = xlSheet.Range(xlApp.Cells(y * 13 + 9, 4), xlApp.Cells(y * 13 + 9, 4)) '粘贴图片的位置 二维码
-
-
- xlSheet.Paste(range2, PictureBox1.Image)
-
-
-
-
-
- Dim shape As Excel.Shape = xlApp.Selection.ShapeRange.Item(1)
- shape.ScaleWidth(0.29, Microsoft.Office.Core.MsoTriState.msoFalse, Microsoft.Office.Core.MsoScaleFrom.msoScaleFromTopLeft)
- shape.IncrementLeft(45)
- shape.IncrementTop(-14)
-
- 'PictureBox1.Select()
-
- 'xlApp.Selection.ShapeRange.ScaleWidth(0.29, Microsoft.Office.Core.MsoTriState.msoFalse, Microsoft.Office.Core.MsoScaleFrom.msoScaleFromTopLeft)
- 'xlApp.Selection.ShapeRange.Incrementleft(45)
- 'xlApp.Selection.ShapeRange.Incrementtop(-14)
- ' zzz = zzz + 1
-
-
-
- Dim z1 As Integer = 0
- For z As Integer = 1 To 9
-
- If DataGridView1.Rows(x).Cells("d" & z).Value.ToString <> "" Then
-
- System.Windows.Forms.Clipboard.SetDataObject(p(z), True) '复制到剪贴板
- If z1 < 3 Then
- Dim range1 As Excel.Range = xlSheet.Range(xlApp.Cells(y * 13 + 4, z1 + 1), xlApp.Cells(y * 13 + 4, z1 + 1)) '粘贴图片的位置
-
- range1.Select()
-
- ' xlApp.ActiveSheet.Pictures.Insert(p(z))
-
- ' xlSheet.Paste(range1, p(z))
-
- With xlApp.ActiveSheet.Pictures.Insert(p(z))
- With .ShapeRange
- .LockAspectRatio = Microsoft.Office.Core.MsoTriState.msoTrue
- '.Width = 75
- '.Height = 100
- .ScaleWidth(0.09, Microsoft.Office.Core.MsoTriState.msoFalse, Microsoft.Office.Core.MsoScaleFrom.msoScaleFromTopLeft)
- End With
- '.Left = xlApp.ActiveSheet.Cells(i, 20).Left
- '.Top = xlApp.ActiveSheet.Cells(i, 20).Top
- '.Placement = 1
- '.PrintObject = True
- End With
-
-
- Else
- Dim range1 As Excel.Range = xlSheet.Range(xlApp.Cells(y * 13 + 9, (z1 Mod 3) + 1), xlApp.Cells(y * 13 + 9, (z1 Mod 3) + 1)) '粘贴图片的位置
-
- range1.Select()
-
- ' xlApp.ActiveSheet.Pictures.Insert(p(z))
- 'xlSheet.Paste(range1, p(z))
- With xlApp.ActiveSheet.Pictures.Insert(p(z))
- With .ShapeRange
- .LockAspectRatio = Microsoft.Office.Core.MsoTriState.msoTrue
- ' .Width = 75
- '.Height = 100
- .ScaleWidth(0.09, Microsoft.Office.Core.MsoTriState.msoFalse, Microsoft.Office.Core.MsoScaleFrom.msoScaleFromTopLeft)
- End With
- '.Left = xlApp.ActiveSheet.Cells(i, 20).Left
- '.Top = xlApp.ActiveSheet.Cells(i, 20).Top
- '.Placement = 1
- '.PrintObject = True
- End With
- End If
- 'Dim pic1 As String
- 'pic1 = "圖片 " & zzz + 3
-
- 'xlApp.ActiveSheet.Shapes.Range(pic1).Select
- 'xlApp.Selection.ShapeRange.ScaleWidth(0.09, Microsoft.Office.Core.MsoTriState.msoFalse, Microsoft.Office.Core.MsoScaleFrom.msoScaleFromTopLeft)
- ' xlApp.Selection.ShapeRange.Incrementtop(-1)
- ' y = y + 1
-
- zzz = zzz + 1
- z1 = z1 + 1
- End If
-
-
- Next
-
-
-
- xlSheet.Cells(y * 13 + 1, 5).select
- xlSheet.Cells(y * 13 + 1, 5) = "序号:" & DataGridView1.Rows(x).Cells("项次").Value
- xlSheet.Cells(y * 13 + 1, 4).font.bold = True
- xlSheet.Cells(y * 13 + 1, 1) = "卡号:" & my_card
- xlSheet.Cells(y * 13 + 1, 1).font.bold = True
- xlSheet.Cells(y * 13 + 1, 1).font.bold = True
- xlSheet.Cells(y * 13 + 4, 5) = "鼓号"
- xlSheet.Cells(y * 13 + 5, 5) = d_no
- xlSheet.Cells(y * 13 + 4, 5).font.bold = True
- xlSheet.Cells(y * 13 + 5, 5).font.bold = True
- xlSheet.Cells(y * 13 + 6, 5) = "下鼓重"
- xlSheet.Cells(y * 13 + 7, 5) = my_weight
- xlSheet.Cells(y * 13 + 6, 5).font.bold = True
- xlSheet.Cells(y * 13 + 7, 5).font.bold = True
- xlSheet.Cells(y * 13 + 6, 4) = "百分比"
- xlSheet.Cells(y * 13 + 7, 4) = DataGridView1.Rows(x).Cells("百分比").Value
- xlSheet.Cells(y * 13 + 6, 4).font.bold = True
- xlSheet.Cells(y * 13 + 7, 4).font.bold = True
-
-
-
- ' xlSheet.Cells(y * 13 + 3, 3) = "客户: " & cust
- 'xlSheet.Cells(y * 13 + 4, 3) = "颜色: " & color1
- 'xlSheet.Cells(y * 13 + 5, 3) = "皮源: " & source
- 'xlSheet.Cells(y * 13 + 6, 3) = "皮重: " & wb_weight & "斤"
- ' xlSheet.Cells(y * 12 + 6, 3) = "备注: " & comment
-
-
-
- xlSheet.Cells(y * 13 + 2, 1) = "名称: " & DataGridView1.Rows(x).Cells("化料名称").Value
- xlSheet.Cells(y * 13 + 2, 1).Font.bold = True
- xlSheet.Cells(y * 13 + 2, 1).Font.SIZE = 18
- xlSheet.Cells(y * 13 + 3, 1) = "重量: " & Math.Round(DataGridView1.Rows(x).Cells("百分比").Value * my_weight / 100, 2) & " 公斤"
- xlSheet.Cells(y * 13 + 3, 1).font.bold = True
- xlSheet.Cells(y * 13 + 3, 1).font.SIZE = 18
-
- xlSheet.Cells(y * 13 + 3, 4) = DataGridView1.Rows(x).Cells("化工分类").Value.ToString
- xlSheet.Cells(y * 13 + 3, 4).font.bold = True
- xlSheet.Cells(y * 13 + 3, 4).font.SIZE = 18
-
-
-
- With xlSheet.Range(xlApp.Cells(y * 13 + 2, 1), xlApp.Cells(y * 13 + 3, 5)).Borders(xlEdgeLeft)
- .LineStyle = xlContinuous
- '.ColorIndex = 0
- '.TintAndShade = 0
- .Weight = xlMedium
- End With
-
- With xlSheet.Range(xlApp.Cells(y * 13 + 2, 1), xlApp.Cells(y * 13 + 3, 5)).Borders(xlEdgeRight)
- .LineStyle = xlContinuous
- '.ColorIndex = 0
- '.TintAndShade = 0
- .Weight = xlMedium
- End With
- With xlSheet.Range(xlApp.Cells(y * 13 + 2, 1), xlApp.Cells(y * 13 + 3, 5)).Borders(xlEdgeTop)
- .LineStyle = xlContinuous
- '.ColorIndex = 0
- '.TintAndShade = 0
- .Weight = xlMedium
- End With
- With xlSheet.Range(xlApp.Cells(y * 13 + 2, 1), xlApp.Cells(y * 13 + 3, 5)).Borders(xlEdgeBottom)
- .LineStyle = xlContinuous
- '.ColorIndex = 0
- '.TintAndShade = 0
- .Weight = xlMedium
- End With
-
- xlApp.Range(xlSheet.Cells(y * 13 + 2, 1), xlSheet.Cells(y * 13 + 2, 5)).Select()
- ' xlApp.Range("E2").Activate()
- xlApp.Selection.Merge
-
- 'xlApp.Range(xlSheet.Cells(y * 13 + 13, 2), xlSheet.Cells(y * 13 + 13, 3)).Select()
- '' xlApp.Range("E2").Activate()
- 'xlApp.Selection.Merge
-
-
- 'With xlApp.Selection
- ' .HorizontalAlignment = xlLeft
- ' .VerticalAlignment = xlCenter
- ' .WrapText = False
- ' .Orientation = 0
- ' .AddIndent = False
- ' .IndentLevel = 0
- ' .ShrinkToFit = True
- ' .ReadingOrder = xlContext
- ' .MergeCells = True
- 'End With
-
- 'With xlApp.Selection
- ' .HorizontalAlignment = xlLeft
- ' .VerticalAlignment = xlCenter
- ' .WrapText = False
- ' .Orientation = 0
- ' .AddIndent = False
- ' .IndentLevel = 0
- ' .ShrinkToFit = False
- ' .ReadingOrder = xlContext
- ' .MergeCells = True
- 'End With
- 'With xlApp.Selection
- ' .HorizontalAlignment = xlLeft
- ' .VerticalAlignment = xlCenter
- ' .WrapText = False
- ' .Orientation = 0
- ' .AddIndent = False
- ' .IndentLevel = 0
- ' .ShrinkToFit = True
- ' .ReadingOrder = xlContext
- ' .MergeCells = True
- 'End With
-
- 'xlSheet.Range(xlApp.Cells(y * 13 + 10, 1), xlApp.Cells(y * 13 + 10, 4)).Borders(xlInsideVertical).LineStyle = xlNone
- 'xlSheet.Range(xlApp.Cells(y * 13 + 10, 1), xlApp.Cells(y * 13 + 10, 4)).Borders(xlInsideHorizontal).LineStyle = xlNone
-
-
- xlSheet.Cells(y * 13 + 11, 2) = DGV1.Rows(DGV1.CurrentCell.RowIndex).Cells("品名").Value
- xlSheet.Cells(y * 13 + 13, 2) = "打印时间: " & DateTime.Now
- xlSheet.Cells(y * 13 + 12, 2) = "打印人员: " & "小甘"
- 'Dim range As Excel.Range = xlSheet.Range(xlApp.Cells(y * 13 + 2, 1), xlApp.Cells(y * 13 + 2, 1)) '粘贴图片的位置
-
- 'xlSheet.Paste(range, PictureBox1.Image)
-
- 'Dim pic As String
- 'pic = "picture " & y + 1
-
- 'xlApp.ActiveSheet.Shapes.Range(pic).Select
- 'xlApp.Selection.ShapeRange.ScaleWidth(0.5, Microsoft.Office.Core.MsoTriState.msoFalse, Microsoft.Office.Core.MsoScaleFrom.msoScaleFromTopLeft)
- 'xlApp.Selection.ShapeRange.IncrementTop(2.2553543307)
-
- y = y + 1
- Else
- ok11:
- End If
-
- Next
-
- 'xlApp.ActiveSheet.PageSetup.PrintArea = "$A$1:$E$660"
-
- xlApp.ActiveSheet.PageSetup.PrintArea = "$a$1:$E$" & y * 13
- ' xlSheet.Columns("C:C").ColumnWidth = 10.75
-
-
-
- Dim yy As Integer = 0
- xlApp.ActiveWindow.View = Microsoft.Office.Interop.Excel.XlWindowView.xlPageBreakPreview
-
- For x As Integer = 0 To DataGridView1.Rows.Count - 2
-
- If DataGridView1.Rows(x).Cells("化料名称").Value <> "水" And DataGridView1.Rows(x).Cells("化料名称").Value <> "甲酸 1200kg/桶" And DataGridView1.Rows(x).Cells("化料名称").Value <> "Eusapon OC liq 1000kg/桶" Then
- If yy <> 0 Then
- Dim r As String
- r = "A" & yy * 13 + 1
-
- xlApp.ActiveSheet.HPageBreaks.Add(xlApp.Range(r))
-
- 'xlApp.ActiveSheet.HPageBreaks(yy).Location = xlSheet.Range(r)
-
- 'xlApp.ActiveSheet.HPageBreaks.Add.Range(r)
-
- End If
-
- yy = yy + 1
- End If
-
- Next x
-
- 'For Each shp In xlApp.ActiveSheet.shapes
- ' shp.select
-
- ' xlApp.Selection.ShapeRange.ScaleWidth(0.1, Microsoft.Office.Core.MsoTriState.msoFalse, Microsoft.Office.Core.MsoScaleFrom.msoScaleFromTopLeft)
- 'Next
-
- With xlApp.ActiveSheet.PageSetup
- '.LeftHeader = ""
- '.CenterHeader = ""
- '.RightHeader = ""
- '.LeftFooter = ""
- '.CenterFooter = ""
- '.RightFooter = ""
- .LeftMargin = xlApp.Application.InchesToPoints(0.4)
- .RightMargin = xlApp.Application.InchesToPoints(0.4)
- .TopMargin = xlApp.Application.InchesToPoints(0.5)
- .BottomMargin = xlApp.Application.InchesToPoints(0.5)
- .HeaderMargin = xlApp.Application.InchesToPoints(0)
- .FooterMargin = xlApp.Application.InchesToPoints(0)
- .PrintHeadings = False
- .PrintGridlines = False
- .PrintComments = xlPrintNoComments
- .CenterHorizontally = False
- .CenterVertically = False
- .Orientation = xlLandscape
- .Draft = False
- ' .PaperSize = xlPaperA4
- .FirstPageNumber = xlAutomatic
- .Order = xlDownThenOver
- .BlackAndWhite = False
- .Zoom = 85
- .PrintErrors = xlPrintErrorsDisplayed
- .OddAndEvenPagesHeaderFooter = False
- .DifferentFirstPageHeaderFooter = False
- .ScaleWithDocHeaderFooter = True
- .AlignMarginsHeaderFooter = True
-
- End With
-
-
- DataGridView1.Sort(DataGridView1.Columns("项次"), ListSortDirection.Ascending)
-
- ' DT2.DefaultView.Sort = "项次 "
-
- MsgBox("输出完成")
-
-
-
- End Sub
-
- Private Sub editFormat(ByVal myExcel As Microsoft.Office.Interop.Excel.Application, ByVal xlSheet As Microsoft.Office.Interop.Excel.Worksheet)
-
- xlSheet.Columns("A:A").ColumnWidth = 1
- xlSheet.Columns("B:B").ColumnWidth = 1
- xlSheet.Columns("C:C").ColumnWidth = 8
- xlSheet.Columns("D:D").ColumnWidth = 1.5
- xlSheet.Columns("e:e").ColumnWidth = 9.63
- xlSheet.Columns("f:f").ColumnWidth = 14.25
- xlSheet.Columns("g:g").ColumnWidth = 3
- xlSheet.Columns("h:h").ColumnWidth = 3
- xlSheet.Columns("i:i").ColumnWidth = 3
- xlSheet.Columns("j:j").ColumnWidth = 10
- xlSheet.Columns("k:k").ColumnWidth = 10
- xlSheet.Columns("l:l").ColumnWidth = 4.5
- xlSheet.Columns("m:m").ColumnWidth = 4.5
- xlSheet.Columns("n:n").ColumnWidth = 8.25
- xlSheet.Columns("o:o").ColumnWidth = 6
-
-
- xlSheet.Range("A1:C1").Merge() '----流程卡号
-
- xlSheet.Range("A1:C1").Borders(xlDiagonalDown).LineStyle = xlNone
- xlSheet.Range("A1:C1").Borders(xlDiagonalUp).LineStyle = xlNone
- With xlSheet.Range("A1:C1").Borders(xlEdgeLeft)
- .LineStyle = xlContinuous
- .Weight = xlMedium
- .ColorIndex = xlAutomatic
- End With
- With xlSheet.Range("A1:C1").Borders(xlEdgeTop)
- .LineStyle = xlContinuous
- .Weight = xlMedium
- .ColorIndex = xlAutomatic
- End With
- With xlSheet.Range("A1:C1").Borders(xlEdgeBottom)
- .LineStyle = xlContinuous
- .Weight = xlMedium
- .ColorIndex = xlAutomatic
- End With
- With xlSheet.Range("A1:C1").Borders(xlEdgeRight)
- .LineStyle = xlContinuous
- .Weight = xlMedium
- .ColorIndex = xlAutomatic
- End With
-
-
-
-
- xlSheet.Range("A2:C2").Select() '-------打印日期
- myExcel.Selection.Merge()
- myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone
- myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
- With myExcel.Selection.Borders(xlEdgeLeft)
- .LineStyle = xlContinuous
- .Weight = xlMedium
- .ColorIndex = xlAutomatic
- End With
- With myExcel.Selection.Borders(xlEdgeTop)
- .LineStyle = xlContinuous
- .Weight = xlMedium
- .ColorIndex = xlAutomatic
- End With
- With myExcel.Selection.Borders(xlEdgeBottom)
- .LineStyle = xlContinuous
- .Weight = xlMedium
- .ColorIndex = xlAutomatic
- End With
- With myExcel.Selection.Borders(xlEdgeRight)
- .LineStyle = xlContinuous
- .Weight = xlMedium
- .ColorIndex = xlAutomatic
- End With
-
-
- xlSheet.Range("A3:C3").Select() '-----皮源
- myExcel.Selection.Merge()
- myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone
- myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
- With myExcel.Selection.Borders(xlEdgeLeft)
- .LineStyle = xlContinuous
- .Weight = xlMedium
- .ColorIndex = xlAutomatic
- End With
- With myExcel.Selection.Borders(xlEdgeTop)
- .LineStyle = xlContinuous
- .Weight = xlMedium
- .ColorIndex = xlAutomatic
- End With
- With myExcel.Selection.Borders(xlEdgeBottom)
- .LineStyle = xlContinuous
- .Weight = xlMedium
- .ColorIndex = xlAutomatic
- End With
- With myExcel.Selection.Borders(xlEdgeRight)
- .LineStyle = xlContinuous
- .Weight = xlMedium
- .ColorIndex = xlAutomatic
- End With
-
-
-
- xlSheet.Range("d1:f1").Select() '-------流程卡号1
- myExcel.Selection.Merge()
- myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone
- myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
- With myExcel.Selection.Borders(xlEdgeLeft)
- .LineStyle = xlContinuous
- .Weight = xlMedium
- .ColorIndex = xlAutomatic
- End With
- With myExcel.Selection.Borders(xlEdgeTop)
- .LineStyle = xlContinuous
- .Weight = xlMedium
- .ColorIndex = xlAutomatic
- End With
- With myExcel.Selection.Borders(xlEdgeBottom)
- .LineStyle = xlContinuous
- .Weight = xlMedium
- .ColorIndex = xlAutomatic
- End With
- With myExcel.Selection.Borders(xlEdgeRight)
- .LineStyle = xlContinuous
- .Weight = xlMedium
- .ColorIndex = xlAutomatic
- End With
-
-
-
-
-
-
- xlSheet.Range("d2:e2").Select() '--------打印日期1
- myExcel.Selection.Merge()
- myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone
- myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
- With myExcel.Selection.Borders(xlEdgeLeft)
- .LineStyle = xlContinuous
- .Weight = xlMedium
- .ColorIndex = xlAutomatic
- End With
- With myExcel.Selection.Borders(xlEdgeTop)
- .LineStyle = xlContinuous
- .Weight = xlMedium
- .ColorIndex = xlAutomatic
- End With
- With myExcel.Selection.Borders(xlEdgeBottom)
- .LineStyle = xlContinuous
- .Weight = xlMedium
- .ColorIndex = xlAutomatic
- End With
- With myExcel.Selection.Borders(xlEdgeRight)
- .LineStyle = xlContinuous
- .Weight = xlMedium
- .ColorIndex = xlAutomatic
- End With
-
-
-
- xlSheet.Range("f2:f2").Select() '--------规格1
- myExcel.Selection.Merge()
- myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone
- myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
- With myExcel.Selection.Borders(xlEdgeLeft)
- .LineStyle = xlContinuous
- .Weight = xlMedium
- .ColorIndex = xlAutomatic
- End With
- With myExcel.Selection.Borders(xlEdgeTop)
- .LineStyle = xlContinuous
- .Weight = xlMedium
- .ColorIndex = xlAutomatic
- End With
- With myExcel.Selection.Borders(xlEdgeBottom)
- .LineStyle = xlContinuous
- .Weight = xlMedium
- .ColorIndex = xlAutomatic
- End With
- With myExcel.Selection.Borders(xlEdgeRight)
- .LineStyle = xlContinuous
- .Weight = xlMedium
- .ColorIndex = xlAutomatic
- End With
-
- xlSheet.Range("j2:j2").Select() '--------鼓号1
- myExcel.Selection.Merge()
- myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone
- myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
- With myExcel.Selection.Borders(xlEdgeLeft)
- .LineStyle = xlContinuous
- .Weight = xlMedium
- .ColorIndex = xlAutomatic
- End With
- With myExcel.Selection.Borders(xlEdgeTop)
- .LineStyle = xlContinuous
- .Weight = xlMedium
- .ColorIndex = xlAutomatic
- End With
- With myExcel.Selection.Borders(xlEdgeBottom)
- .LineStyle = xlContinuous
- .Weight = xlMedium
- .ColorIndex = xlAutomatic
- End With
- With myExcel.Selection.Borders(xlEdgeRight)
- .LineStyle = xlContinuous
- .Weight = xlMedium
- .ColorIndex = xlAutomatic
- End With
-
-
-
-
- xlSheet.Range("d3:f3").Select() '-------皮源
- myExcel.Selection.Merge()
- myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone
- myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
- With myExcel.Selection.Borders(xlEdgeLeft)
- .LineStyle = xlContinuous
- .Weight = xlMedium
- .ColorIndex = xlAutomatic
- End With
- With myExcel.Selection.Borders(xlEdgeTop)
- .LineStyle = xlContinuous
- .Weight = xlMedium
- .ColorIndex = xlAutomatic
- End With
- With myExcel.Selection.Borders(xlEdgeBottom)
- .LineStyle = xlContinuous
- .Weight = xlMedium
- .ColorIndex = xlAutomatic
- End With
- With myExcel.Selection.Borders(xlEdgeRight)
- .LineStyle = xlContinuous
- .Weight = xlMedium
- .ColorIndex = xlAutomatic
- End With
-
-
- xlSheet.Range("g3:i3").Select() '-------备注
- myExcel.Selection.Merge()
- myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone
- myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
- With myExcel.Selection.Borders(xlEdgeLeft)
- .LineStyle = xlContinuous
- .Weight = xlMedium
- .ColorIndex = xlAutomatic
- End With
- With myExcel.Selection.Borders(xlEdgeTop)
- .LineStyle = xlContinuous
- .Weight = xlMedium
- .ColorIndex = xlAutomatic
- End With
- With myExcel.Selection.Borders(xlEdgeBottom)
- .LineStyle = xlContinuous
- .Weight = xlMedium
- .ColorIndex = xlAutomatic
- End With
- With myExcel.Selection.Borders(xlEdgeRight)
- .LineStyle = xlContinuous
- .Weight = xlMedium
- .ColorIndex = xlAutomatic
- End With
-
- xlSheet.Range("j3:o3").Select() '-------备注
- myExcel.Selection.Merge()
- myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone
- myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
- With myExcel.Selection.Borders(xlEdgeLeft)
- .LineStyle = xlContinuous
- .Weight = xlMedium
- .ColorIndex = xlAutomatic
- End With
- With myExcel.Selection.Borders(xlEdgeTop)
- .LineStyle = xlContinuous
- .Weight = xlMedium
- .ColorIndex = xlAutomatic
- End With
- With myExcel.Selection.Borders(xlEdgeBottom)
- .LineStyle = xlContinuous
- .Weight = xlMedium
- .ColorIndex = xlAutomatic
- End With
- With myExcel.Selection.Borders(xlEdgeRight)
- .LineStyle = xlContinuous
- .Weight = xlMedium
- .ColorIndex = xlAutomatic
- End With
-
-
-
- xlSheet.Range("g1:i1").Select() '--------工艺名称
- myExcel.Selection.Merge()
- myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone
- myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
- With myExcel.Selection.Borders(xlEdgeLeft)
- .LineStyle = xlContinuous
- .Weight = xlMedium
- .ColorIndex = xlAutomatic
- End With
- With myExcel.Selection.Borders(xlEdgeTop)
- .LineStyle = xlContinuous
- .Weight = xlMedium
- .ColorIndex = xlAutomatic
- End With
- With myExcel.Selection.Borders(xlEdgeBottom)
- .LineStyle = xlContinuous
- .Weight = xlMedium
- .ColorIndex = xlAutomatic
- End With
- With myExcel.Selection.Borders(xlEdgeRight)
- .LineStyle = xlContinuous
- .Weight = xlMedium
- .ColorIndex = xlAutomatic
- End With
-
-
-
-
-
-
- xlSheet.Range("g2:i2").Select() '-------规格1
- myExcel.Selection.Merge()
- myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone
- myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
- With myExcel.Selection.Borders(xlEdgeLeft)
- .LineStyle = xlContinuous
- .Weight = xlMedium
- .ColorIndex = xlAutomatic
- End With
- With myExcel.Selection.Borders(xlEdgeTop)
- .LineStyle = xlContinuous
- .Weight = xlMedium
- .ColorIndex = xlAutomatic
- End With
- With myExcel.Selection.Borders(xlEdgeBottom)
- .LineStyle = xlContinuous
- .Weight = xlMedium
- .ColorIndex = xlAutomatic
- End With
- With myExcel.Selection.Borders(xlEdgeRight)
- .LineStyle = xlContinuous
- .Weight = xlMedium
- .ColorIndex = xlAutomatic
- End With
-
-
- xlSheet.Range("j1:o1").Select() '------工艺名称1
- myExcel.Selection.Merge()
- myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone
- myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
- With myExcel.Selection.Borders(xlEdgeLeft)
- .LineStyle = xlContinuous
- .Weight = xlMedium
- .ColorIndex = xlAutomatic
- End With
- With myExcel.Selection.Borders(xlEdgeTop)
- .LineStyle = xlContinuous
- .Weight = xlMedium
- .ColorIndex = xlAutomatic
- End With
- With myExcel.Selection.Borders(xlEdgeBottom)
- .LineStyle = xlContinuous
- .Weight = xlMedium
- .ColorIndex = xlAutomatic
- End With
- With myExcel.Selection.Borders(xlEdgeRight)
- .LineStyle = xlContinuous
- .Weight = xlMedium
- .ColorIndex = xlAutomatic
- End With
-
-
- xlSheet.Range("J2:j2").Select() '------
- myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone
- myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
- With myExcel.Selection.Borders(xlEdgeLeft)
- .LineStyle = xlContinuous
- .Weight = xlMedium
- .ColorIndex = xlAutomatic
- End With
- With myExcel.Selection.Borders(xlEdgeTop)
- .LineStyle = xlContinuous
- .Weight = xlMedium
- .ColorIndex = xlAutomatic
- End With
- With myExcel.Selection.Borders(xlEdgeBottom)
- .LineStyle = xlContinuous
- .Weight = xlMedium
- .ColorIndex = xlAutomatic
- End With
- With myExcel.Selection.Borders(xlEdgeRight)
- .LineStyle = xlContinuous
- .Weight = xlMedium
- .ColorIndex = xlAutomatic
- End With
- With myExcel.Selection.Borders(xlInsideVertical)
- .LineStyle = xlContinuous
- .Weight = xlMedium
- .ColorIndex = xlAutomatic
- End With
-
-
- xlSheet.Range("k2:K2").Select() '------
- myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone
- myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
- With myExcel.Selection.Borders(xlEdgeLeft)
- .LineStyle = xlContinuous
- .Weight = xlMedium
- .ColorIndex = xlAutomatic
- End With
- With myExcel.Selection.Borders(xlEdgeTop)
- .LineStyle = xlContinuous
- .Weight = xlMedium
- .ColorIndex = xlAutomatic
- End With
- With myExcel.Selection.Borders(xlEdgeBottom)
- .LineStyle = xlContinuous
- .Weight = xlMedium
- .ColorIndex = xlAutomatic
- End With
- With myExcel.Selection.Borders(xlEdgeRight)
- .LineStyle = xlContinuous
- .Weight = xlMedium
- .ColorIndex = xlAutomatic
- End With
- With myExcel.Selection.Borders(xlInsideVertical)
- .LineStyle = xlContinuous
- .Weight = xlMedium
- .ColorIndex = xlAutomatic
- End With
-
-
- xlSheet.Range("l2:m2").Select() '----------重量
- myExcel.Selection.Merge()
- myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone
- myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
- With myExcel.Selection.Borders(xlEdgeLeft)
- .LineStyle = xlContinuous
- .Weight = xlMedium
- .ColorIndex = xlAutomatic
- End With
- With myExcel.Selection.Borders(xlEdgeTop)
- .LineStyle = xlContinuous
- .Weight = xlMedium
- .ColorIndex = xlAutomatic
- End With
- With myExcel.Selection.Borders(xlEdgeBottom)
- .LineStyle = xlContinuous
- .Weight = xlMedium
- .ColorIndex = xlAutomatic
- End With
- With myExcel.Selection.Borders(xlEdgeRight)
- .LineStyle = xlContinuous
- .Weight = xlMedium
- .ColorIndex = xlAutomatic
- End With
-
-
-
-
- xlSheet.Range("n1:o1").Select() '--------
- myExcel.Selection.Merge()
- myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone
- myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
- With myExcel.Selection.Borders(xlEdgeLeft)
- .LineStyle = xlContinuous
- .Weight = xlMedium
- .ColorIndex = xlAutomatic
- End With
- With myExcel.Selection.Borders(xlEdgeTop)
- .LineStyle = xlContinuous
- .Weight = xlMedium
- .ColorIndex = xlAutomatic
- End With
- With myExcel.Selection.Borders(xlEdgeBottom)
- .LineStyle = xlContinuous
- .Weight = xlMedium
- .ColorIndex = xlAutomatic
- End With
- With myExcel.Selection.Borders(xlEdgeRight)
- .LineStyle = xlContinuous
- .Weight = xlMedium
- .ColorIndex = xlAutomatic
- End With
-
-
-
-
-
-
- xlSheet.Range("n2:o2").Select() '-------重量
- myExcel.Selection.Merge()
- myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone
- myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
- With myExcel.Selection.Borders(xlEdgeLeft)
- .LineStyle = xlContinuous
- .Weight = xlMedium
- .ColorIndex = xlAutomatic
- End With
- With myExcel.Selection.Borders(xlEdgeTop)
- .LineStyle = xlContinuous
- .Weight = xlMedium
- .ColorIndex = xlAutomatic
- End With
- With myExcel.Selection.Borders(xlEdgeBottom)
- .LineStyle = xlContinuous
- .Weight = xlMedium
- .ColorIndex = xlAutomatic
- End With
- With myExcel.Selection.Borders(xlEdgeRight)
- .LineStyle = xlContinuous
- .Weight = xlMedium
- .ColorIndex = xlAutomatic
- End With
-
-
-
- End Sub
-
-
- Private Sub cmdCancelEdit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdCancelEdit.Click
-
- 'For x As Integer = 0 To dgv2.Rows.Count - 1
- ' dgv2.Rows(x).DefaultCellStyle.Font = New Font(dgv2.DefaultCellStyle.Font, FontStyle.Regular)
- ' dgv2.Rows(x).Cells("百分比").Style.BackColor = Color.White
- ' dgv2.Rows(x).Cells("化料編號").Style.BackColor = Color.White
- ' dgv2.Rows(x).Cells("化料名称").Style.BackColor = Color.White
- ' dgv2.Rows(x).Cells("时间").Style.BackColor = Color.White
- ' dgv2.Rows(x).Cells("備註").Style.BackColor = Color.White
- 'Next
-
- cmdSaveEdit.Visible = False
- cmdCancelEdit.Visible = False
- Timer1.Enabled = False
- Label1.Visible = False
-
- End Sub
-
-
- Private Sub cmdSaveEdit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdSaveEdit.Click
-
-
- ' dgv2.Rows(dgv2.SelectedRows(0).Index).Selected = False
-
-
-
- Dim edited As Boolean = False
-
-
- Dim cmd1 As New SqlCommand
- cmd1.Connection = con
- If con.State = ConnectionState.Closed Then
- con.Open()
- End If
-
- '----------判斷是否修改
- For x As Integer = 0 To dgv2.Rows.Count - 1
- If DataGridView1.Rows(x).Cells("项次").Style.BackColor.Name <> "0" Or Not (DataGridView1.Rows(x).DefaultCellStyle.Font Is Nothing) Then
- edited = True
- Exit For
- End If
- If DataGridView1.Rows(x).Cells("百分比").Style.BackColor.Name <> "0" Or Not (DataGridView1.Rows(x).DefaultCellStyle.Font Is Nothing) Then
- edited = True
- Exit For
- End If
-
- If DataGridView1.Rows(x).Cells("化料名称").Style.BackColor.Name <> "0" Or Not (DataGridView1.Rows(x).DefaultCellStyle.Font Is Nothing) Then
- edited = True
- Exit For
- End If
- If DataGridView1.Rows(x).Cells("时间").Style.BackColor.Name <> "0" Or Not (DataGridView1.Rows(x).DefaultCellStyle.Font Is Nothing) Then
- edited = True
- Exit For
- End If
- If DataGridView1.Rows(x).Cells("备注").Style.BackColor.Name <> "0" Or Not (DataGridView1.Rows(x).DefaultCellStyle.Font Is Nothing) Then
- edited = True
- Exit For
- End If
- Next
- '-------------------------------------------------
-
- If edited = True Then
-
- 'sql_rcp = "delete from rt_retan_rcp where tech=N'" & DGV1.Rows(DGV1.CurrentRow.Index).Cells(0).Value & "' and rcp_name='" & DGV1.Rows(DGV1.CurrentRow.Index).Cells(1).Value & "'"
- 'cmd.CommandText = sql_rcp
- 'cmd.Connection = conn
- 'If conn.State = ConnectionState.Closed Then
- ' conn.Open()
- 'End If
- 'cmd.ExecuteNonQuery()
-
- '''sql_rcp = "delete from ht_retanrcp where rcp_no=N'" & DGV1.Rows(DGV1.CurrentRow.Index).Cells(5).Value & "'"
- '''cmd.CommandText = sql_rcp
- '''cmd.Connection = conn
-
- '''If conn.State = ConnectionState.Closed Then
- ''' conn.Open()
- '''End If
- '''dr = cmd.ExecuteReader
-
-
- ''-----------舊記錄存檔
- 'While dr.Read()
- ' sql_rcp = "insert into rcp_content (item,matl_no,percents,rcp_no,time,comment) values('" & dr("item") & "','" & dr("matl_no") & "','" & dr("percents") & "','" & dr("rcp_no") & "edit','" & dr("time") & "',N'" & dr("comment") & "')"
- ' cmd1.CommandText = sql_rcp
- ' cmd1.ExecuteNonQuery()
- 'End While
-
-
- 'Dim gUserName As String = "matchy"
-
- 'sql_rcp = "update " & rcp & " set last_edited ='" & Now.ToString & "',editor='" & gUserName & "' where rcp_no='" & DGV1.Rows(DGV1.CurrentRow.Index).Cells(0).Value & "'"
- 'cmd1.CommandText = sql_rcp
- 'cmd1.ExecuteNonQuery()
-
-
- End If
-
-
-
- '-----------將現有處方明細先刪除
- 'sql_rcp = "delete from rcp_content where rcp_no='" & DGV1.Rows(DGV1.CurrentRow.Index).Cells(0).Value & "'"
- 'cmd1.CommandText = sql_rcp
- 'cmd1.ExecuteNonQuery()
-
-
-
-
- '-----------加入新修改之處方明細
- Dim y As Integer = 1
- For x As Integer = 0 To DataGridView1.Rows.Count - 1
-
-
- If (DataGridView1.Rows(x).DefaultCellStyle.Font Is Nothing) Then
- sql_rcp = "insert into ht_retanrcp1 (item,name,chem,percents,time,comment) values('" & y & "',N'" & DGV1.Rows(DGV1.CurrentCell.RowIndex).Cells("品名").Value & "',N'" & DataGridView1.Rows(x).Cells("化料名称").Value & "','" & DataGridView1.Rows(x).Cells("百分比").Value & "','" & DataGridView1.Rows(x).Cells("时间").Value & "',N'" & DataGridView1.Rows(x).Cells("备注").Value & "')"
- cmd1.CommandText = sql_rcp
- cmd1.ExecuteNonQuery()
-
- y = y + 1
- End If
-
-
- Next
-
-
- MsgBox("修改完成")
-
- cmdSaveEdit.Visible = False
- cmdCancelEdit.Visible = False
- Timer1.Enabled = False
- Label1.Visible = False
- conn.Close()
- con.Close()
- End Sub
-
- Private Sub cmdcanceladd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdcanceladd.Click
-
- End Sub
-
- Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
- If dgv_record.Visible = False Then
- dgv_record.BringToFront()
- dgv_record.Visible = True
- Else
- dgv_record.Visible = False
-
- End If
- End Sub
-
-
- Private Sub dgv_record_RowPostPaint(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewRowPostPaintEventArgs) Handles dgv_record.RowPostPaint
- Dim linePen As New Pen(Color.SkyBlue, 2)
-
- If e.RowIndex = dgv_record.Rows.Count - 1 Then
- dgv_record.Rows(e.RowIndex).Cells("百分比").Style.ForeColor = Color.White
- Dim startX As Integer = IIf(dgv_record.RowHeadersVisible, dgv_record.RowHeadersWidth, 0)
- Dim startY As Integer = e.RowBounds.Top + e.RowBounds.Height - 1
- Dim endX As Integer = startX + dgv2.Columns.GetColumnsWidth(DataGridViewElementStates.Visible) - dgv_record.HorizontalScrollingOffset
- e.Graphics.DrawLine(linePen, startX, startY, endX, startY)
-
- Exit Sub
- End If
-
- If dgv_record.Rows(e.RowIndex).Cells("時间").Value.ToString <> "" And (dgv_record.Rows(e.RowIndex + 1).Cells("化料名称").Value.ToString = "流水洗" Or dgv_record.Rows(e.RowIndex + 1).Cells("化料名称").Value.ToString = "洗水" Or dgv_record.Rows(e.RowIndex + 1).Cells("化料名称").Value = "排水") Then
- ElseIf dgv_record.Rows(e.RowIndex).Cells("時间").Value.ToString <> "" Then
-
- Dim startX As Integer = IIf(dgv2.RowHeadersVisible, dgv_record.RowHeadersWidth, 0)
- Dim startY As Integer = e.RowBounds.Top + e.RowBounds.Height - 1
- Dim endX As Integer = startX + dgv_record.Columns.GetColumnsWidth(DataGridViewElementStates.Visible) - dgv_record.HorizontalScrollingOffset
- e.Graphics.DrawLine(linePen, startX, startY, endX, startY)
-
- End If
-
- If (dgv_record.Rows(e.RowIndex).Cells("化料名称").Value.ToString = "流水洗" Or dgv_record.Rows(e.RowIndex).Cells("化料名称").Value.ToString = "洗水" Or dgv_record.Rows(e.RowIndex).Cells("化料名称").Value = "排水") Then
- dgv_record.Rows(e.RowIndex).Cells("百分比").Style.ForeColor = Color.White
- Dim startX As Integer = IIf(dgv_record.RowHeadersVisible, dgv_record.RowHeadersWidth, 0)
- Dim startY As Integer = e.RowBounds.Top + e.RowBounds.Height - 1
- Dim endX As Integer = startX + dgv_record.Columns.GetColumnsWidth(DataGridViewElementStates.Visible) - dgv_record.HorizontalScrollingOffset
- e.Graphics.DrawLine(linePen, startX, startY, endX, startY)
- End If
-
- End Sub
-
- Private Sub GroupBox2_Enter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles GroupBox2.Enter
-
- End Sub
-
- Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
- TextBox9.Text = ""
- TextBox6.Text = ""
- TextBox8.Text = ""
- TextBox7.Text = ""
- TextBox10.Text = ""
- TextBox5.Text = ""
- If conn.State = ConnectionState.Closed Then
- conn.ConnectionString = connstring
- conn.Open()
- End If
- cmd.Connection = conn
- Dim sql As String
-
- sql = "select * from retan_cost where pid='" & TXT_PID.Text & "'"
- cmd.CommandText = sql
- dr = cmd.ExecuteReader()
-
- If dr.Read Then
- Dim my_msg As MsgBoxResult
- my_msg = MsgBox("資料已存在,是否繼續?", MsgBoxStyle.YesNo)
- If my_msg = MsgBoxResult.No Then
- dr.Close()
- Exit Sub
- End If
- Else
- End If
- dr.Close()
-
-
- Dim io_no As String = ""
- Dim io_count As Integer = 0
- Dim my_weight As Integer = 0
- Dim my_piece As Integer = 0
- Dim matl_id As String
-
- sql = "select weight,piece from production where production_id='" & TXT_PID.Text & "'"
- cmd.CommandText = sql
- dr = cmd.ExecuteReader
-
- dr.Read()
- my_piece = dr("piece")
- dr.Close()
-
- sql = "select count(*) as my_count from material_io where left(io_no,1)='w' and substring(io_no,2,6)='" & String.Format("{0:yyMMdd}", DateTimePicker1.Value) & "'"
- cmd.CommandText = sql
- io_count = cmd.ExecuteScalar
-
- io_no = "W" & String.Format("{0:yyMMdd}", DateTimePicker1.Value) & Chr(io_count + 65)
-
- sql = "insert into material_io (io_no,rcp_no,weight,pieces,department) values ('" & io_no & "','" & DGV1.Rows(DGV1.CurrentRow.Index).Cells(0).Value & "','" & Math.Round(Double.Parse(TextBox1.Text) * my_piece, 0) & "','" & my_piece & "','染色')"
- cmd.CommandText = sql
- cmd.ExecuteNonQuery()
-
- For x As Integer = 0 To dgv2.RowCount - 1
- sql = "select matl_id from tblmaterial where matl_no='" & dgv2.Rows(x).Cells(2).Value & "'"
- cmd.CommandText = sql
- dr = cmd.ExecuteReader
- dr.Read()
- matl_id = dr("matl_id").ToString
- dr.Close()
- If (dgv2.Rows(x).DefaultCellStyle.Font Is Nothing) Then
- sql = "insert into retan_cost (pid,item,matl_no,percents,time,comment,coin,price,weight,tannie,oil,dye,aux,other,date,rcp_no,w_no) values ('" & TXT_PID.Text & "','" & x + 1 & "','" & dgv2.Rows(x).Cells(2).Value & "','" & dgv2.Rows(x).Cells(1).Value & "','" & dgv2.Rows(x).Cells(4).Value & "','" & dgv2.Rows(x).Cells(5).Value & "','" & dgv2.Rows(x).Cells(6).Value & "','" & dgv2.Rows(x).Cells(7).Value & "','" & TextBox1.Text & "','" & txttan.Text & "','" & txtoil.Text & "','" & txtdye.Text & "','" & txtx.Text & "','" & txtxx.Text & "','" & String.Format("{0:d}", DateTimePicker1.Value) & "','" & DGV1.Rows(DGV1.CurrentRow.Index).Cells(0).Value & "','" & io_no & "')"
- cmd.CommandText = sql
- cmd.ExecuteNonQuery()
- If matl_id <> "" Then
- Dim id As Integer = 0
- sql = "select top (1) id from retan_cost order by id desc "
- cmd.CommandText = sql
- id = cmd.ExecuteScalar
- sql = "insert into matl_io_detail (io_no,matl_no,quantity,id1) values ('" & io_no & "','" & dgv2.Rows(x).Cells(2).Value & "','" & Double.Parse(TextBox1.Text) * my_piece * dgv2.Rows(x).Cells(1).Value / 100 & "','" & id & "')"
- cmd.CommandText = sql
- cmd.ExecuteNonQuery()
-
- chem_balance(dgv2.Rows(x).Cells(2).Value, Double.Parse(TextBox1.Text) * my_piece * dgv2.Rows(x).Cells(1).Value / 100, x, id)
-
- End If
-
- Else
- If dgv2.Rows(x).DefaultCellStyle.Font.Style <> FontStyle.Strikeout Then
- sql = "insert into retan_cost (pid,item,matl_no,percents,time,comment,coin,price,weight,tannie,oil,dye,aux,other,date,rcp_no,w_no) values ('" & TXT_PID.Text & "','" & x + 1 & "','" & dgv2.Rows(x).Cells(2).Value & "','" & dgv2.Rows(x).Cells(1).Value & "','" & dgv2.Rows(x).Cells(4).Value & "','" & dgv2.Rows(x).Cells(5).Value & "','" & dgv2.Rows(x).Cells(6).Value & "','" & dgv2.Rows(x).Cells(7).Value & "','" & TextBox1.Text & "','" & txttan.Text & "','" & txtoil.Text & "','" & txtdye.Text & "','" & txtx.Text & "','" & txtxx.Text & "','" & String.Format("{0:d}", DateTimePicker1.Value) & "','" & DGV1.Rows(DGV1.CurrentRow.Index).Cells(0).Value & "','" & io_no & "')"
- cmd.CommandText = sql
- cmd.ExecuteNonQuery()
- If matl_id <> "" Then
- Dim id As Integer = 0
- sql = "select top (1) id from retan_cost "
- cmd.CommandText = sql
- id = cmd.ExecuteScalar
- sql = "insert into matl_io_detail (io_no,matl_no,quantity,id1) values ('" & io_no & "','" & dgv2.Rows(x).Cells(2).Value & "','" & Double.Parse(TextBox1.Text) * my_piece * dgv2.Rows(x).Cells(1).Value / 100 & "','" & id & "')"
- cmd.CommandText = sql
- cmd.ExecuteNonQuery()
-
- chem_balance(dgv2.Rows(x).Cells(2).Value, Double.Parse(TextBox1.Text) * my_piece * dgv2.Rows(x).Cells(1).Value / 100, x, id)
-
- End If
- End If
- End If
-
- Next
- conn.Close()
-
- save_cost()
-
- MsgBox("作業完成")
-
-
- End Sub
- Private Function chem_balance(ByVal matl_no As String, ByVal quantity As Double, ByVal x As Integer, ByVal id As Integer)
- Dim conn5 As New SqlConnection
- Dim dt1 As New DataTable
- Dim sql As String = ""
-
- sql = "select top (1) lot_no,coin,price,quantity, w from tblchem_lot where matl_no='" & matl_no & "' and quantity-w<>0"
- cmd.CommandText = sql
- da.Fill(dt1)
- If dt1.Rows.Count = 0 Then
-
- Dim dt2 As New DataTable
- sql = "select top (1) lot_no,coin,price,quantity, w from tblchem_lot where matl_no='" & matl_no & "'"
- cmd.CommandText = sql
- da.Fill(dt2)
- If dt2.Rows.Count = 0 Then
- sql = "insert into tblchem_lot (matl_no,lot_no,quantity,coin,price) values ('" & matl_no & "','120229','" & 0 & "','" & "NTD" & "','" & 0 & "')"
- cmd.CommandText = sql
- cmd.ExecuteScalar()
- sql = "insert into tblchem_lot_io (lot_no,matl_no,quantity,io_type,coin,price,id) values ('" & dt2.Rows(0).Item("lot_no") & "','" & matl_no & "','" & quantity & "','" & "領料" & "','" & dt2.Rows(0).Item("coin") & "','" & dt2.Rows(0).Item("price") & "','" & id & "')"
- cmd.CommandText = sql
- dr = cmd.ExecuteScalar
- sql = "update tblchem_lot set w=w+'" & quantity & "' where lot_no='" & dt2.Rows(0).Item("lot_no") & "' and quantity ='" & dt2.Rows(0).Item("quantity") & "' and matl_no='" & matl_no & "'"
- cmd.CommandText = sql
- dr = cmd.ExecuteScalar
-
- Else
- sql = "insert into tblchem_lot_io (lot_no,matl_no,quantity,io_type,coin,price,id) values ('" & dt2.Rows(0).Item("lot_no") & "','" & matl_no & "','" & quantity & "','" & "領料" & "','" & dt2.Rows(0).Item("coin") & "','" & dt2.Rows(0).Item("price") & "','" & id & "')"
- cmd.CommandText = sql
- dr = cmd.ExecuteScalar
- sql = "update tblchem_lot set w=w+'" & quantity & "' where lot_no='" & dt2.Rows(0).Item("lot_no") & "' and quantity ='" & dt2.Rows(0).Item("quantity") & "' and matl_no='" & matl_no & "'"
- cmd.CommandText = sql
- dr = cmd.ExecuteScalar
- End If
- '
- End If
- If dt1.Rows(0).Item("quantity") - dt1.Rows(0).Item("w") - quantity > 0 Then
- sql = "insert into tblchem_lot_io (lot_no,matl_no,quantity,io_type,coin,price,id) values ('" & dt1.Rows(0).Item("lot_no") & "','" & matl_no & "','" & quantity & "','" & "領料" & "','" & dt1.Rows(0).Item("coin") & "','" & dt1.Rows(0).Item("price") & "','" & id & "')"
- cmd.CommandText = sql
- dr = cmd.ExecuteScalar
- sql = "update tblchem_lot set w=w+'" & quantity & "' where lot_no='" & dt1.Rows(0).Item("lot_no") & "' and quantity ='" & dt1.Rows(0).Item("quantity") & "' and matl_no='" & matl_no & "'"
- cmd.CommandText = sql
- dr = cmd.ExecuteScalar
- Else
-
-
- If dt1.Rows(0).Item("quantity") - dt1.Rows(0).Item("w") > 0 Then
- sql = "insert into tblchem_lot_io (lot_no,matl_no,quantity,io_type,coin,price,id) values ('" & dt1.Rows(0).Item("lot_no") & "','" & matl_no & "','" & dt1.Rows(0).Item("quantity") - dt1.Rows(0).Item("w") & "','" & "領料" & "','" & dt1.Rows(0).Item("coin") & "','" & dt1.Rows(0).Item("price") & "','" & id & "')"
- cmd.CommandText = sql
- dr = cmd.ExecuteScalar
-
- sql = "update tblchem_lot set w=w+'" & dt1.Rows(0).Item("quantity") - dt1.Rows(0).Item("w") & "' where lot_no='" & dt1.Rows(0).Item("lot_no") & "' and quantity ='" & dt1.Rows(0).Item("quantity") & "'"
- cmd.CommandText = sql
- dr = cmd.ExecuteScalar
-
-
- chem_balance(matl_no, quantity - (dt1.Rows(0).Item("quantity") - dt1.Rows(0).Item("w")), x + 1, id)
- Else
-
- sql = "insert into tblchem_lot_io (lot_no,matl_no,quantity,io_type,coin,price,id) values ('" & dt1.Rows(0).Item("lot_no") & "','" & matl_no & "','" & dt1.Rows(0).Item("quantity") - dt1.Rows(0).Item("w") & "','" & "領料" & "','" & dt1.Rows(0).Item("coin") & "','" & dt1.Rows(0).Item("price") & "','" & id & "')"
- cmd.CommandText = sql
- dr = cmd.ExecuteScalar
-
- sql = "update tblchem_lot set w=w+'" & dt1.Rows(0).Item("quantity") - dt1.Rows(0).Item("w") & "' where lot_no='" & dt1.Rows(0).Item("lot_no") & "' and quantity ='" & dt1.Rows(0).Item("quantity") & "'"
- cmd.CommandText = sql
- dr = cmd.ExecuteScalar
-
- End If
-
- End If
- End Function
-
- Private Sub save_cost()
-
-
- If conn.State = ConnectionState.Closed Then
- conn.ConnectionString = connstring
- conn.Open()
-
- End If
-
- cmd.Connection = conn
-
- Dim sql As String
- sql = "SELECT SUM(cost) AS cost, MATL_ID FROM (SELECT TOP (100) PERCENT tblMaterial.MATL_ID, CASE WHEN retan_cost.coin = '台幣' THEN SUM(tblMaterial.PUR_UNIT * retan_cost.percents / 100 * " & TextBox1.Text & ") WHEN retan_cost.coin = '美金' THEN SUM(tblMaterial.PUR_UNIT * retan_cost.percents / 100 * " & TextBox1.Text & ") * 29.15 WHEN retan_cost.coin = '人民幣' THEN SUM(tblMaterial.PUR_UNIT * retan_cost.percents / 100 * " & TextBox1.Text & ") * 4.4 WHEN retan_cost.coin = '歐元' THEN SUM(tblMaterial.PUR_UNIT * retan_cost.percents / 100 * " & TextBox1.Text & ") * 38.97 END AS cost FROM RETAN_COST INNER JOIN tblMaterial ON RETAN_COST.MATL_NO = tblMaterial.MATL_NO WHERE (RETAN_COST.PID = '" & TXT_PID.Text & "') AND (tblMaterial.MATL_ID IS NOT NULL) GROUP BY tblMaterial.MATL_ID, RETAN_COST.COIN ORDER BY tblMaterial.MATL_ID) AS derivedtbl_1 GROUP BY MATL_ID"
-
- cmd.CommandText = sql
- dr = cmd.ExecuteReader
-
- Dim t As Double = 0
- Dim x As Double = 0
- Dim f As Double = 0
- Dim d As Double = 0
- Dim xx As Double = 0
-
- While dr.Read()
- Select Case dr("matl_id")
- Case "T"
- t = dr("cost")
- Case "X"
- x = dr("cost")
- Case "D"
- d = dr("cost")
- Case "F"
- f = dr("cost")
- Case Else
- xx = dr("cost")
- End Select
-
- End While
- dr.Close()
-
-
- Dim total As Double = t + x + f + d + xx
-
-
-
- TextBox9.Text = t
- TextBox6.Text = f
- TextBox8.Text = d
- TextBox7.Text = x
- TextBox10.Text = xx
- TextBox5.Text = total
-
-
-
- End Sub
-
-
- Private Sub TXT_PID_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TXT_PID.KeyUp
- Dim sql As String = ""
- Dim dr2 As SqlDataReader
-
- sql = "select article from leather_io where production_id='" & TXT_PID.Text & "'"
- cmd.CommandText = sql
- cmd.Connection = conn
-
- If conn.State = ConnectionState.Closed Then
- conn.Open()
- End If
-
- dr2 = cmd.ExecuteReader
-
- If dr2.Read Then
- TextBox11.Text = dr2("article")
- End If
- dr2.Close()
- conn.Close()
-
-
-
-
- sql = "select weight/piece as my_avg from production where production_id='" & TXT_PID.Text & "'"
- cmd.CommandText = sql
- cmd.Connection = conn
-
- If conn.State = ConnectionState.Closed Then
- conn.Open()
- End If
-
- dr2 = cmd.ExecuteReader
-
- If dr2.Read Then
- TextBox1.Text = dr2("my_avg")
- End If
- dr2.Close()
- conn.Close()
-
-
-
-
-
-
-
- End Sub
-
- Private Sub Button10_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button10.Click
-
-
- Dim sql As String = ""
-
- cmd.Connection = conn
- If conn.State = ConnectionState.Closed Then
- conn.Open()
- End If
-
- ListBox2.Visible = True
- ListBox3.Visible = True
- ListBox4.Visible = True
- TextBox2.Visible = True
- TextBox3.Visible = True
- TextBox4.Visible = True
-
- 'Button11.Visible = True
- 'Button12.Visible = True
- 'Button13.Visible = True
- 'Button14.Visible = True
- Button15.Visible = True
- sql = "select cust_name from customer order by cust_name"
- cmd.CommandText = sql
- dr = cmd.ExecuteReader
-
- While dr.Read
-
- ListBox2.Items.Add(dr("cust_name"))
-
- End While
- dr.Close()
-
- sql = "select prod_name from tblproduct order by prod_name"
- cmd.CommandText = sql
- dr = cmd.ExecuteReader
-
- While dr.Read
-
- ListBox3.Items.Add(dr("prod_name"))
-
- End While
- dr.Close()
-
-
- sql = "select color_name from color order by color_name"
- cmd.CommandText = sql
- dr = cmd.ExecuteReader
-
- While dr.Read
-
- ListBox4.Items.Add(dr("color_name"))
-
- End While
- dr.Close()
-
-
- Button17.Visible = True
-
-
-
- conn.Close()
- End Sub
-
- Private Sub Button17_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button17.Click
- Dim sql As String = ""
- Dim cust_no As String = ""
- Dim prod_id As String = ""
- Dim color_no As String = ""
-
-
- If cmd.Connection.State = ConnectionState.Closed Then
- conn.Open()
- End If
-
- sql = "select id from customer where cust_name='" & ListBox2.SelectedItem & "'"
- cmd.CommandText = sql
- cust_no = cmd.ExecuteScalar
- sql = "select prod_id from tblproduct where prod_name='" & ListBox3.SelectedItem & "'"
- cmd.CommandText = sql
- prod_id = cmd.ExecuteScalar
- sql = "select color_no from color where color_name='" & ListBox4.SelectedItem & "'"
- cmd.CommandText = sql
- color_no = cmd.ExecuteScalar
-
-
-
- sql = "select count(*) from " & rcp & " where substring(rcp_no,4,3)='" & cust_no & "' and substring(rcp_no,1,1)='" & prod_id & "' and substring(rcp_no,7,2)='" & color_no & "'"
- cmd.CommandText = sql
- Dim c As Integer = cmd.ExecuteScalar
-
-
- If c = 0 Then
-
- rr = prod_id & String.Format("{0:D2}", c) & String.Format("{0:D3}", cust_no) & color_no
- Else
-
- rr = prod_id & String.Format("{0:D2}", c + 1) & String.Format("{0:D3}", cust_no) & color_no
-
- End If
-
-
- sql = "select count(*) from " & rcp & " where rcp_no='" & rr & "'"
- cmd.CommandText = sql
- c = cmd.ExecuteScalar
-
- If c <> 0 Then
- MsgBox("重覆")
- Exit Sub
-
- End If
-
-
- rcp_name = ListBox2.SelectedItem & ListBox4.SelectedItem & ListBox3.SelectedItem
-
- rcp_name = InputBox("處方名稱", "詢問", rcp_name)
-
-
-
- sql = "insert into " & rcp & " (rcp_no,rcp_name,creat_d) values ( '" & rr & "',N'" & rcp_name & "','" & String.Format("{0:d}", DateTime.Now) & "')"
- cmd.CommandText = sql
- cmd.ExecuteNonQuery()
-
-
- For x As Integer = 0 To dgv2.RowCount - 1
-
-
- If (dgv2.Rows(x).DefaultCellStyle.Font Is Nothing) Then
-
-
- Dim item As String = ""
-
- If x <= 8 Then
- item = "0" & x + 1
- Else
- item = x + 1
-
- End If
-
-
- sql = "insert into rcp_content (item,matl_no,percents,time,comment,rcp_no) values ('" & item & "','" & dgv2.Rows(x).Cells(2).Value & "','" & dgv2.Rows(x).Cells(1).Value & "','" & dgv2.Rows(x).Cells(4).Value & "',N'" & dgv2.Rows(x).Cells(5).Value & "','" & rr & "')"
- cmd.CommandText = sql
- cmd.ExecuteNonQuery()
-
- Else
-
- If dgv2.Rows(x).DefaultCellStyle.Font.Style <> FontStyle.Strikeout Then
-
-
- Dim item As String = ""
-
- If Microsoft.VisualBasic.Len(x) = 1 Then
- item = "0" & x + 1
- Else
- item = x + 1
-
- End If
-
-
- sql = "insert into rcp_content (item,matl_no,percents,time,comment,rcp_no) values ('" & item & "','" & dgv2.Rows(x).Cells(2).Value & "','" & dgv2.Rows(x).Cells(1).Value & "','" & dgv2.Rows(x).Cells(4).Value & "',N'" & dgv2.Rows(x).Cells(5).Value & "','" & rr & "')"
- cmd.CommandText = sql
- cmd.ExecuteNonQuery()
-
-
- End If
-
- End If
-
- Next
- MsgBox("處方" & rr & rcp_name & "新增完成")
- conn.Close()
-
- Button17.Visible = False
-
- ListBox2.Visible = False
- ListBox3.Visible = False
- ListBox4.Visible = False
- TextBox2.Visible = False
- TextBox3.Visible = False
- TextBox4.Visible = False
-
-
-
- End Sub
-
- Private Sub Button18_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button18.Click
-
- Dim rcp_name As String = ""
- Dim sql As String = ""
-
- If conn.State = ConnectionState.Closed Then
- conn.Open()
-
- End If
-
- rcp_name = InputBox("輸入新的處方名", DGV1.Rows(DGV1.CurrentRow.Index).Cells(1).Value)
-
-
- sql = "update " & rcp & " set rcp_name=N'" & rcp_name & "' where rcp_no='" & DGV1.Rows(DGV1.CurrentRow.Index).Cells(0).Value & "'"
-
- cmd.Connection = conn
- cmd.CommandText = sql
- cmd.ExecuteScalar()
- conn.Close()
-
-
-
-
-
-
- End Sub
-
- Private Sub RadioButton2_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton2.CheckedChanged
-
- 'If RadioButton2.Checked = True Then
- ' rcp = "rcp_main"
- ' rcp1 = "rcp_content"
- 'Else
- ' rcp = "prescription_main"
- ' rcp1 = "prescription_content"
-
- 'End If
-
- End Sub
-
- Private Sub Button19_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button19.Click
- TextBox9.Text = ""
- TextBox6.Text = ""
- TextBox8.Text = ""
- TextBox7.Text = ""
- TextBox10.Text = ""
- TextBox5.Text = ""
- save_cost()
- ' ''Dim conn5 As New SqlConnection
- ' ''Dim dt1 As New DataTable
-
- ' ''If matl_no = "G300" Then
- ' '' Dim aa As String = ""
- ' '' aa = "asdfasf"
-
- ' ''End If
- ' ''Sql = "select top (1) lot_no,coin,price,quantity, w from tblchem_lot where matl_no='" & matl_no & "' and quantity-w>0 order by lot_no"
- ' ''cmd.CommandText = Sql
- ' ''da.Fill(dt1)
- ' ''If dt1.Rows.Count = 0 Then
- ' '' ListBox1.Items.Add(matl_no)
- ' '' Dim dt2 As New DataTable
- ' '' Sql = "select top (1) lot_no,coin,price,quantity, w from tblchem_lot where matl_no='" & matl_no & "' order by lot_no desc"
- ' '' cmd.CommandText = Sql
- ' '' da.Fill(dt2)
- ' '' If dt2.Rows.Count = 0 Then
- ' '' Sql = "insert into tblchem_lot (matl_no,lot_no,quantity,coin,price) values ('" & matl_no & "','120229','" & "0" & "','" & "NTD" & "','" & 0 & "')"
- ' '' cmd.CommandText = Sql
- ' '' cmd.ExecuteScalar()
- ' '' Sql = "insert into tblchem_lot_io (lot_no,matl_no,quantity,io_type,coin,price,id) values ('120229'" & ",'" & matl_no & "','" & quantity & "','" & "領料" & "','ntd','0','" & id & "')"
- ' '' cmd.CommandText = Sql
- ' '' dr = cmd.ExecuteScalar
- ' '' Sql = "update tblchem_lot set w=w+'" & quantity & "' where lot_no='120229' and matl_no='" & matl_no & "'"
- ' '' cmd.CommandText = Sql
- ' '' dr = cmd.ExecuteScalar
- ' '' Else
-
- ' '' Sql = "insert into tblchem_lot_io (lot_no,matl_no,quantity,io_type,coin,price,id) values ('" & dt2.Rows(0).Item("lot_no") & "','" & matl_no & "','" & quantity & "','" & "領料" & "','" & dt2.Rows(0).Item("coin") & "','" & dt2.Rows(0).Item("price") & "','" & id & "')"
- ' '' cmd.CommandText = Sql
- ' '' dr = cmd.ExecuteScalar
- ' '' Sql = "update tblchem_lot set w=w+'" & quantity & "' where lot_no='" & dt2.Rows(0).Item("lot_no") & "' and quantity ='" & dt2.Rows(0).Item("quantity") & "' and matl_no='" & matl_no & "'"
- ' '' cmd.CommandText = Sql
- ' '' dr = cmd.ExecuteScalar
- ' '' End If
- ' '' Exit Sub
- ' ''End If
- ' ''If dt1.Rows(0).Item("quantity") - dt1.Rows(0).Item("w") - quantity > 0 Then
- ' '' Sql = "insert into tblchem_lot_io (lot_no,matl_no,quantity,io_type,coin,price,id) values ('" & dt1.Rows(0).Item("lot_no") & "','" & matl_no & "','" & quantity & "','" & "領料" & "','" & dt1.Rows(0).Item("coin") & "','" & dt1.Rows(0).Item("price") & "','" & id & "')"
- ' '' cmd.CommandText = Sql
- ' '' dr = cmd.ExecuteScalar
- ' '' Sql = "update tblchem_lot set w=w+'" & quantity & "' where lot_no='" & dt1.Rows(0).Item("lot_no") & "' and quantity ='" & dt1.Rows(0).Item("quantity") & "' and matl_no='" & matl_no & "'"
- ' '' cmd.CommandText = Sql
- ' '' dr = cmd.ExecuteScalar
- ' ''Else
-
-
- ' '' If dt1.Rows(0).Item("quantity") - dt1.Rows(0).Item("w") > 0 Then
-
- ' '' Sql = "insert into tblchem_lot_io (lot_no,matl_no,quantity,io_type,coin,price,id) values ('" & dt1.Rows(0).Item("lot_no") & "','" & matl_no & "','" & dt1.Rows(0).Item("quantity") - dt1.Rows(0).Item("w") & "','" & "領料" & "','" & dt1.Rows(0).Item("coin") & "','" & dt1.Rows(0).Item("price") & "','" & id & "')"
- ' '' cmd.CommandText = Sql
- ' '' dr = cmd.ExecuteScalar
- ' '' Sql = "update tblchem_lot set w=w+'" & dt1.Rows(0).Item("quantity") - dt1.Rows(0).Item("w") & "' where lot_no='" & dt1.Rows(0).Item("lot_no") & "' and quantity ='" & dt1.Rows(0).Item("quantity") & "'"
- ' '' cmd.CommandText = Sql
- ' '' dr = cmd.ExecuteScalar
-
- ' '' chem_balance(matl_no, quantity - (dt1.Rows(0).Item("quantity") - dt1.Rows(0).Item("w")), x + 1, id)
- ' '' Else
- ' '' Sql = "insert into tblchem_lot_io (lot_no,matl_no,quantity,io_type,coin,price,id) values ('" & dt1.Rows(0).Item("lot_no") & "','" & matl_no & "','" & dt1.Rows(0).Item("quantity") - dt1.Rows(0).Item("w") & "','" & "領料" & "','" & dt1.Rows(0).Item("coin") & "','" & dt1.Rows(0).Item("price") & "','" & id & "')"
- ' '' cmd.CommandText = Sql
- ' '' dr = cmd.ExecuteScalar
-
- ' '' Sql = "update tblchem_lot set w=w+'" & dt1.Rows(0).Item("quantity") - dt1.Rows(0).Item("w") & "' where lot_no='" & dt1.Rows(0).Item("lot_no") & "' and quantity ='" & dt1.Rows(0).Item("quantity") & "'"
- ' '' cmd.CommandText = Sql
- ' '' dr = cmd.ExecuteScalar
-
- ' '' End If
-
- ' ''End If
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- End Sub
-
- Private Sub Button20_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button20.Click
-
-
- Dim rcp_name As String = ""
- Dim sql As String = ""
-
- If conn.State = ConnectionState.Closed Then
- conn.Open()
-
- End If
-
-
- sql = "delete from " & rcp & " where rcp_no='" & DGV1.Rows(DGV1.CurrentRow.Index).Cells(0).Value & "'"
- cmd.Connection = conn
- cmd.CommandText = sql
- cmd.ExecuteScalar()
-
-
- 'sql = "delete from " & rcp1 & " where rcp_no='" & DGV1.Rows(DGV1.CurrentRow.Index).Cells(0).Value & "'"
- 'cmd.Connection = conn
- 'cmd.CommandText = sql
- 'cmd.ExecuteScalar()
-
-
- conn.Close()
-
-
- End Sub
-
-
-
- Private Sub TextBox1_TextChanged(sender As Object, e As EventArgs) Handles TextBox1.TextChanged
-
- End Sub
-
- Private Sub Button14_Click_1(sender As Object, e As EventArgs) Handles Button14.Click
-
- If ListBox2.SelectedIndex = -1 Or ListBox2.SelectedIndex = -1 Or ListBox2.SelectedIndex = -1 Then
-
- MsgBox("請先選擇客戶產品顏色", , "錯誤")
- Exit Sub
-
- End If
-
-
- Dim sql As String = ""
- Dim con As New SqlConnection
- Dim rcp_no As String = ""
-
- Dim cust_no As String = ""
- Dim prod_id As String = ""
- Dim color_no As String = ""
- con.ConnectionString = connstring
- con.Open()
- cmd.Connection = con
-
-
-
- sql = "select id from customer where cust_name='" & ListBox2.SelectedItem & "'"
- cmd.CommandText = sql
- cust_no = cmd.ExecuteScalar
- sql = "select prod_id from tblproduct where prod_name='" & ListBox3.SelectedItem & "'"
- cmd.CommandText = sql
- prod_id = cmd.ExecuteScalar
- sql = "select color_no from color where color_name='" & ListBox4.SelectedItem & "'"
- cmd.CommandText = sql
- color_no = cmd.ExecuteScalar
-
-
-
- sql = "select count(*) from prescription_main where substring(rcp_no,4,3)='" & cust_no & "' and substring(rcp_no,1,1)='" & prod_id & "' and substring(rcp_no,7,2)='" & color_no & "'"
- cmd.CommandText = sql
- Dim c As Integer = cmd.ExecuteScalar
-
-
- If c = 0 Then
-
- rr = prod_id & String.Format("{0:D2}", c) & String.Format("{0:D3}", cust_no) & color_no
- Else
-
- rr = prod_id & String.Format("{0:D2}", c + 1) & String.Format("{0:D3}", cust_no) & color_no
-
- End If
-
-
- sql = "select count(*) from prescription_main where rcp_no='" & rr & "'"
- cmd.CommandText = sql
- c = cmd.ExecuteScalar
-
-
- rcp_name = ListBox2.SelectedItem & ListBox4.SelectedItem & ListBox3.SelectedItem
-
- rcp_name = InputBox("處方名稱", "詢問", rcp_name)
-
- sql = "select count(*) from prescription_main where rcp_no='" & rr & "'"
- cmd.CommandText = sql
- Dim a As Integer = cmd.ExecuteScalar
-
- If a = 0 Then
-
- 'sql = "insert into prescription_main (rcp_no,rcp_name,creat_d) values ( '" & rcp_no & "','" & rcp_name & "','" & Now & "')"
- 'cmd.CommandText = sql
- 'Dim b As Integer = cmd.ExecuteScalar()
- 'If b <> 0 Then
- ' MsgBox("新增處方完成")
- ' Exit Sub
-
- 'End If
- Else
- MsgBox("處方編號重覆")
- gAddfromOther = False
- Exit Sub
-
- End If
-
-
- Dim msg As MsgBoxResult
-
- msg = MsgBox("是否要由其他處方修改?", vbYesNoCancel, "詢問")
-
-
- gAddfromOther = True
- Dim my_rcp As String = ""
- my_rcp = InputBox("請輸入處方編號")
-
-
- If my_rcp = "" Then Exit Sub
- sql_rcp = "select RCP_NO as 處方編號, RCP_NAME as 品名, CREAT_D, LAST_EDITED, LAST_USED from prescription_main where rcp_no like '%" & my_rcp & "%' or rcp_name like '%" & my_rcp & "%'"
- cmd.CommandText = sql_rcp
- da.SelectCommand = cmd
- Dim ds As New DataSet
- da.Fill(ds)
- DGV1.DataSource = ds.Tables(0)
-
- Timer1.Enabled = True
-
- con.Close()
-
-
- End Sub
-
- Private Sub dgv_cost_CellEnter(sender As Object, e As DataGridViewCellEventArgs) Handles dgv_cost.CellEnter
-
-
- Dim ds1 As New DataSet
- Dim ds2 As New DataSet
- Dim cn As New SqlConnection
- cn.ConnectionString = connstring
- cn.Open()
- cmd.Connection = cn
-
-
- sql_rcp = "select rcp_content.ITEM AS 項目,rcp_content.MATL_NO AS 編號,tblMaterial.MATL_NAME AS 品名,rcp_content.percents AS 比例 " &
- " FROM " & rcp & " INNER JOIN rcp_content ON " & rcp & ".RCP_NO = rcp_content.RCP_NO INNER JOIN " &
- " tblMaterial ON rcp_content.MATL_NO = tblMaterial.MATL_NO WHERE rcp_content.RCP_NO='" & DGV1.Rows(DGV1.CurrentRow.Index).Cells(0).Value & "' and tblMaterial.MATL_ID='" & dgv_cost.Rows(dgv_cost.CurrentRow.Index).Cells(1).Value & "' order by rcp_content.item"
-
-
-
- cmd.CommandText = sql_rcp
- da.SelectCommand = cmd
- da.Fill(ds2)
- dgv_chem_detail.DataSource = ds2.Tables(0)
-
- dgv_chem_detail.Columns(0).Width = 38
- dgv_chem_detail.Columns(1).Width = 50
- dgv_chem_detail.Columns(2).Width = 80
- dgv_chem_detail.Columns(3).Width = 50
-
-
-
-
-
-
- End Sub
- Private Sub set_grid()
-
- DGV1.Columns(0).Width = 280
- DGV1.Columns(1).Width = 140
- 'DGV1.Columns(2).Visible = False
- 'DGV1.Columns(3).Visible = False
- 'DGV1.Columns(4).Visible = False
- 'DGV1.RowHeadersVisible = False
-
- 'If gUserName <> "matchy" Then
- ' dgv2.Columns(6).Visible = False
- ' dgv2.Columns(7).Visible = False
- 'End If
-
-
-
-
-
- End Sub
-
- Private Sub set_grid1()
-
- 'dgv2.Columns(0).Width = 70
- 'dgv2.Columns(1).Width = 350
- 'dgv2.Columns(2).Width = 80
- 'dgv2.Columns(3).Width = 80
- 'dgv2.Columns(4).Width = 300
- ' dgv2.Columns(5).Visible = False
- 'dgv2.Columns(5).Width = 150
- 'dgv2.Columns(6).Width = 59
- 'dgv2.Columns(7).Width = 60
- 'dgv2.Columns(8).Width = 50
- 'dgv2.Columns(9).Width = 200
-
- 'If gUserName <> "matchy" Then
-
- ' dgv2.Columns(5).Width = 207
- ' dgv2.Columns(6).Visible = False
- ' dgv2.Columns(7).Visible = False
-
- 'End If
- DataGridView1.Columns(0).Width = 70
- DataGridView1.Columns(1).Width = 150
- DataGridView1.Columns(2).Width = 150
- DataGridView1.Columns(3).Width = 80
- DataGridView1.Columns(4).Width = 100
- DataGridView1.Columns(5).Width = 100
- DataGridView1.Columns(6).Width = 240
-
-
-
- End Sub
- Private Sub set_grid2()
-
- dgv_record.Columns(0).Width = 38
- dgv_record.Columns(1).Width = 58
- dgv_record.Columns(2).Width = 150
- dgv_record.Columns(3).Width = 50
- dgv_record.Columns(4).Width = 44
- dgv_record.Columns(5).Width = 87
- dgv_record.Columns(6).Width = 59
- dgv_record.Columns(7).Width = 60
-
-
-
- 'If gUserName <> "matchy" Then
- ' dgv_record.Columns(6).Visible = False
- ' dgv_record.Columns(7).Visible = False
- 'End If
-
- End Sub
- Private Sub set_grid3()
-
- dgv_cost.Columns(0).Width = 60
- dgv_cost.Columns(1).Width = 60
- 'dgv_cost.Columns(2).Width = 60
- 'dgv_cost.Columns(3).Width = 60
-
-
-
-
-
- End Sub
-
-
-
- Private Sub DGV1_CellMouseUp(sender As Object, e As DataGridViewCellMouseEventArgs) Handles DGV1.CellMouseUp
-
- Dim ds1 As New DataSet
- Dim ds2 As New DataSet
- Dim cn As New SqlConnection
-
- DT2.Clear()
-
- cn.ConnectionString = connstring
- cn.Open()
- cmd.Connection = cn
-
-
-
- txttan.Text = ""
- txtKJ.Text = ""
- txtoil.Text = ""
- txtdye.Text = ""
- txtx.Text = ""
- txtxx.Text = ""
- txtsum.Text = ""
-
-
-
-
-
-
- sql_rcp = "SELECT HT_RetanRcp.item AS 项次, HT_RetanRcp.chem AS 化料名称, CASE WHEN type1 IS NULL THEN '' ELSE HT_Chem_Main.type1 END AS 化工分类, CASE WHEN type2 IS NULL THEN N'不列印' ELSE HT_Chem_Main.type2 END AS 类别, HT_RetanRcp.percents AS 百分比, HT_RetanRcp.time AS 时间, HT_RetanRcp.comment AS 备注 FROM HT_Chem_Main RIGHT OUTER JOIN HT_Rcp_ChemName_table ON HT_Chem_Main.sys_name = HT_Rcp_ChemName_table.sys_chem_name RIGHT OUTER JOIN HT_RetanRcp ON HT_Rcp_ChemName_table.rcp_chem_name = HT_RetanRcp.chem where HT_RetanRcp.name =N'" & DGV1.Rows(DGV1.CurrentRow.Index).Cells("品名").Value & "' and HT_RetanRcp.date =N'" & DGV1.Rows(DGV1.CurrentRow.Index).Cells("日期").Value & "'and HT_RetanRcp.selection =N'" & DGV1.Rows(DGV1.CurrentRow.Index).Cells("选级").Value & "'and HT_RetanRcp.no =N'" & DGV1.Rows(DGV1.CurrentRow.Index).Cells("流程卡号").Value & "' and HT_RetanRcp.chem<>'' ORDER BY HT_RetanRcp.rcp_no DESC, 项次"
-
- sql_rcp = "SELECT HT_RetanRcp.item AS 项次, HT_RetanRcp.chem AS 化料名称, CASE WHEN type1 IS NULL THEN '' ELSE HT_Chem_Main.type1 END AS 化工分类, CASE WHEN type2 IS NULL THEN N'不列印' ELSE HT_Chem_Main.type2 END AS 类别, HT_RetanRcp.percents AS 百分比, HT_RetanRcp.time AS 时间, HT_RetanRcp.comment AS 备注, HT_Chem_Main.d1, HT_Chem_Main.d2,
- HT_Chem_Main.d3, HT_Chem_Main.d4, HT_Chem_Main.d5, HT_Chem_Main.d6, HT_Chem_Main.d7, HT_Chem_Main.d8, HT_Chem_Main.d9 FROM HT_Chem_Main RIGHT OUTER JOIN HT_Rcp_ChemName_table ON HT_Chem_Main.sys_name = HT_Rcp_ChemName_table.sys_chem_name RIGHT OUTER JOIN
- HT_RetanRcp ON HT_Rcp_ChemName_table.rcp_chem_name = HT_RetanRcp.chem WHERE HT_RetanRcp.name =N'" & DGV1.Rows(DGV1.CurrentRow.Index).Cells("品名").Value & "' and HT_RetanRcp.date =N'" & DGV1.Rows(DGV1.CurrentRow.Index).Cells("日期").Value & "'and HT_RetanRcp.selection =N'" & DGV1.Rows(DGV1.CurrentRow.Index).Cells("选级").Value & "'and HT_RetanRcp.no =N'" & DGV1.Rows(DGV1.CurrentRow.Index).Cells("流程卡号").Value & "' and (HT_RetanRcp.chem <> '')
- ORDER BY HT_RetanRcp.rcp_no DESC, 项次"
-
-
- 'sql_rcp = "SELECT TOP (200) RT_RETAN_RCP_DETAIL.serial AS 项次, RT_RETAN_RCP_DETAIL.CHEM AS 化料名称, RT_RETAN_RCP_DETAIL.PERCENTAGE AS 百分比, RT_RETAN_RCP_DETAIL.time AS 时间, RT_RETAN_RCP_DETAIL.comment AS 备注, RT_RETAN_RCP_DETAIL.CLASS AS 分类, RT_CHEM_MSDS.D1, RT_CHEM_MSDS.D2, RT_CHEM_MSDS.D3, RT_CHEM_MSDS.D4, RT_CHEM_MSDS.D5, RT_CHEM_MSDS.D6, RT_CHEM_MSDS.D7, RT_CHEM_MSDS.D8, RT_CHEM_MSDS.D9,RT_CHEM_MSDS.type as class FROM RT_RETAN_RCP_DETAIL LEFT OUTER JOIN RT_CHEM_MSDS ON RT_RETAN_RCP_DETAIL.CHEM = RT_CHEM_MSDS.SYS_NAME where rcp_name =N'" & DGV1.Rows(DGV1.CurrentRow.Index).Cells("处方名称").Value & "' ORDER BY 项次"
-
-
-
- 'sql_print = "SELECT TOP (200) RT_RETAN_RCP_DETAIL.serial AS 项次, RT_RETAN_RCP_DETAIL.CHEM AS 化料名称, RT_RETAN_RCP_DETAIL.PERCENTAGE AS 百分比, RT_RETAN_RCP_DETAIL.time AS 时间, RT_RETAN_RCP_DETAIL.comment AS 备注, RT_RETAN_RCP_DETAIL.CLASS AS 分类, RT_CHEM_MSDS.D1, RT_CHEM_MSDS.D2, RT_CHEM_MSDS.D3, RT_CHEM_MSDS.D4, RT_CHEM_MSDS.D5, RT_CHEM_MSDS.D6, RT_CHEM_MSDS.D7, RT_CHEM_MSDS.D8, RT_CHEM_MSDS.D9,RT_CHEM_MSDS.type as class FROM RT_RETAN_RCP_DETAIL LEFT OUTER JOIN RT_CHEM_MSDS ON RT_RETAN_RCP_DETAIL.CHEM = RT_CHEM_MSDS.SYS_NAME where rcp_name =N'" & DGV1.Rows(DGV1.CurrentRow.Index).Cells("处方名称").Value & "' and comment<>'' and comment<>N'自打' ORDER BY 备注,项次,化料名称"
- 'cmd.CommandText = sql_print
- 'dt_print = New DataTable
- 'da.SelectCommand = cmd
- 'da.Fill(dt_print)
-
-
- sql_rcp = "SELECT HT_RetanRcp.item AS 项次, HT_RetanRcp.chem AS 化料名称, CASE WHEN type1 IS NULL THEN '' ELSE HT_Chem_Main.type1 END AS 化工分类, CASE WHEN type2 IS NULL THEN N'不列印' ELSE HT_Chem_Main.type2 END AS 类别,
- HT_RetanRcp.percents AS 百分比, HT_RetanRcp.time AS 时间, HT_RetanRcp.comment AS 备注, HT_Chem_Main.d1, HT_Chem_Main.d2, HT_Chem_Main.d3, HT_Chem_Main.d4, HT_Chem_Main.d5, HT_Chem_Main.d6, HT_Chem_Main.d7,
- HT_Chem_Main.d8, HT_Chem_Main.d9, HT_MSDS_File_1.filename
- FROM HT_Chem_Main LEFT OUTER JOIN
- (SELECT filename, SUBSTRING(filename, 1, CHARINDEX('_', filename) - 1) AS no
- FROM HT_MSDS_File) AS HT_MSDS_File_1 ON HT_Chem_Main.no = HT_MSDS_File_1.no RIGHT OUTER JOIN
- HT_Rcp_ChemName_table ON HT_Chem_Main.sys_name = HT_Rcp_ChemName_table.sys_chem_name RIGHT OUTER JOIN
- HT_RetanRcp ON HT_Rcp_ChemName_table.rcp_chem_name = HT_RetanRcp.chem
- WHERE HT_RetanRcp.name =N'" & DGV1.Rows(DGV1.CurrentRow.Index).Cells("品名").Value & "' and HT_RetanRcp.date =N'" & DGV1.Rows(DGV1.CurrentRow.Index).Cells("日期").Value & "'and HT_RetanRcp.selection =N'" & DGV1.Rows(DGV1.CurrentRow.Index).Cells("选级").Value & "'and HT_RetanRcp.no =N'" & DGV1.Rows(DGV1.CurrentRow.Index).Cells("流程卡号").Value & "' and (HT_RetanRcp.chem <> '')
- ORDER BY HT_RetanRcp.rcp_no DESC, 项次"
-
-
- Label20.Text = DGV1.Rows(DGV1.CurrentRow.Index).Cells("品名").Value.ToString
-
- cmd.CommandText = sql_rcp
- da.SelectCommand = cmd
- da.Fill(DT2)
- ' dgv2.DataSource = dt_print
- DataGridView1.DataSource = DT2
- DataGridView1.RowTemplate.Height = 24
- set_grid1()
-
- End Sub
-
-
-
- Private Sub dgv2_RowPostPaint(sender As Object, e As DataGridViewRowPostPaintEventArgs) Handles dgv2.RowPostPaint
-
- Dim linePen As New Pen(Color.Aquamarine, 2)
-
- If e.RowIndex = dgv2.Rows.Count - 1 Then
- dgv2.Rows(e.RowIndex).Cells("百分比").Style.ForeColor = Color.White
- Dim startX As Integer = IIf(dgv2.RowHeadersVisible, dgv2.RowHeadersWidth, 0)
- Dim startY As Integer = e.RowBounds.Top + e.RowBounds.Height - 1
- Dim endX As Integer = startX + dgv2.Columns.GetColumnsWidth(DataGridViewElementStates.Visible) - dgv2.HorizontalScrollingOffset - 100
- e.Graphics.DrawLine(linePen, startX, startY, endX, startY)
-
- Exit Sub
- End If
-
- If dgv2.Rows(e.RowIndex).Cells("时间").Value.ToString <> "" And (dgv2.Rows(e.RowIndex + 1).Cells("化料名称").Value.ToString = "流水洗" Or dgv2.Rows(e.RowIndex + 1).Cells("化料名称").Value.ToString = "洗水" Or dgv2.Rows(e.RowIndex + 1).Cells("化料名称").Value = "排水") Then
- ElseIf dgv2.Rows(e.RowIndex).Cells("时间").Value.ToString <> "" Then
-
- Dim startX As Integer = IIf(dgv2.RowHeadersVisible, dgv2.RowHeadersWidth, 0)
- Dim startY As Integer = e.RowBounds.Top + e.RowBounds.Height - 1
- Dim endX As Integer = startX + dgv2.Columns.GetColumnsWidth(DataGridViewElementStates.Visible) - dgv2.HorizontalScrollingOffset - 100
- e.Graphics.DrawLine(linePen, startX, startY, endX, startY)
-
- End If
-
- If (dgv2.Rows(e.RowIndex).Cells("化料名称").Value.ToString = "流水洗" Or dgv2.Rows(e.RowIndex).Cells("化料名称").Value.ToString = "洗水" Or dgv2.Rows(e.RowIndex).Cells("化料名称").Value = "排水") Then
- dgv2.Rows(e.RowIndex).Cells("百分比").Style.ForeColor = Color.White
- Dim startX As Integer = IIf(dgv2.RowHeadersVisible, dgv2.RowHeadersWidth, 0)
- Dim startY As Integer = e.RowBounds.Top + e.RowBounds.Height - 1
- Dim endX As Integer = startX + dgv2.Columns.GetColumnsWidth(DataGridViewElementStates.Visible) - dgv2.HorizontalScrollingOffset - 100
-
- e.Graphics.DrawLine(linePen, startX, startY, endX, startY)
-
- End If
-
-
- End Sub
-
-
- Private Sub DataGridView1_RowPostPaint(sender As Object, e As DataGridViewRowPostPaintEventArgs) Handles DataGridView1.RowPostPaint
-
-
- If e.RowIndex + 1 > DataGridView1.Rows.Count - 1 Then Exit Sub
-
-
-
- If DataGridView1.Rows(e.RowIndex + 1).Cells("化料名称").Value Is Nothing Then Exit Sub
-
- Dim linePen As New Pen(Color.Red, 2)
-
- If e.RowIndex = DataGridView1.Rows.Count - 1 Then
- DataGridView1.Rows(e.RowIndex).Cells("百分比").Style.ForeColor = Color.White
- Dim startX As Integer = IIf(DataGridView1.RowHeadersVisible, DataGridView1.RowHeadersWidth, 0)
- Dim startY As Integer = e.RowBounds.Top + e.RowBounds.Height - 1
- Dim endX As Integer = startX + DataGridView1.Columns.GetColumnsWidth(DataGridViewElementStates.Visible) - DataGridView1.HorizontalScrollingOffset - 10
- e.Graphics.DrawLine(linePen, startX, startY, endX, startY)
-
- Exit Sub
- End If
-
- If DataGridView1.Rows(e.RowIndex).Cells("时间").Value.ToString <> "" Then
-
- Dim startX As Integer = IIf(DataGridView1.RowHeadersVisible, DataGridView1.RowHeadersWidth, 0)
- Dim startY As Integer = e.RowBounds.Top + e.RowBounds.Height - 1
- Dim endX As Integer = startX + DataGridView1.Columns.GetColumnsWidth(DataGridViewElementStates.Visible) - DataGridView1.HorizontalScrollingOffset - 10
- e.Graphics.DrawLine(linePen, startX, startY, endX, startY)
-
- End If
-
- 'If (DataGridView1.Rows(e.RowIndex).Cells("化料名称").Value.ToString = "流水洗" Or DataGridView1.Rows(e.RowIndex).Cells("化料名称").Value.ToString = "洗水" Or DataGridView1.Rows(e.RowIndex).Cells("化料名称").Value = "排水") Then
- ' DataGridView1.Rows(e.RowIndex).Cells("百分比").Style.ForeColor = Color.White
- ' Dim startX As Integer = IIf(DataGridView1.RowHeadersVisible, DataGridView1.RowHeadersWidth, 0)
- ' Dim startY As Integer = e.RowBounds.Top + e.RowBounds.Height - 1
- ' Dim endX As Integer = startX + DataGridView1.Columns.GetColumnsWidth(DataGridViewElementStates.Visible) - DataGridView1.HorizontalScrollingOffset - 10
-
- ' e.Graphics.DrawLine(linePen, startX, startY, endX, startY)
-
- 'End If
-
-
- End Sub
-
-
-
- Private Sub Button24_Click(sender As Object, e As EventArgs) Handles Button24.Click 'msds
-
-
-
- cmd.Connection = conn
-
-
- If conn.State = ConnectionState.Closed Then
- conn.Open()
-
- End If
-
-
- Dim sql As String
- Dim folderPath As String = "\\DS920plus\华峰业务\AA化料文件资料\2024年整理MSDS和ZDHC\MSDS\MSDS总表"
-
- ' 检查文件夹是否存在
- If Directory.Exists(folderPath) Then
- ' 获取文件夹内所有文件的路径
- Dim files As String() = Directory.GetFiles(folderPath)
-
- ' 遍历文件数组并输出文件名
- For Each file As String In files
- ' 输出文件名
- Console.WriteLine(Path.GetFileName(file))
-
- sql = "insert into ht_msds_file (filename) values (N'" & Path.GetFileName(file) & "')"
- cmd.CommandText = sql
- cmd.ExecuteScalar()
-
- Next
- Else
- Console.WriteLine("目录不存在!")
- End If
-
- MsgBox("")
-
- End Sub
-
- Private Sub DGV1_CellContentClick(sender As Object, e As DataGridViewCellEventArgs) Handles DGV1.CellContentClick
-
- End Sub
- Sub InsertImageWithNPOI(start_row As Integer, start_column As Integer)
- ' 创建 NPOI 工作簿和工作表
- Dim workbook As New XSSFWorkbook()
- Dim sheet As XSSFSheet = workbook.CreateSheet("Sheet1")
-
- ' 图片数据
- Dim pictureData As Byte() = Nothing
- Using ms As New MemoryStream()
- ' 从 PictureBox1 中获取图片
- PictureBox1.Image.Save(ms, Imaging.ImageFormat.Png)
- pictureData = ms.ToArray()
- End Using
-
- ' 将图片添加到工作簿中
- Dim pictureIndex As Integer = workbook.AddPicture(pictureData, PictureType.PNG)
-
- ' 创建绘图对象
- Dim drawing As XSSFDrawing = sheet.CreateDrawingPatriarch()
-
- ' 创建图片锚点
- Dim anchor As IClientAnchor = workbook.GetCreationHelper().CreateClientAnchor()
- anchor.Col1 = start_column ' 起始列(从 0 开始计数)
- anchor.Row1 = start_row ' 起始行(从 0 开始计数)
- anchor.Col2 = start_column ' 结束列
- anchor.Row2 = start_row ' 结束行
-
- ' 插入图片
- Dim picture As IPicture = drawing.CreatePicture(anchor, pictureIndex)
-
- ' 调整图片大小
- picture.Resize(0.29) ' 设置缩放比例,例如 0.29 表示缩放为原大小的 29%
-
- ' 保存文件
- Dim saveFilePath As String = "c:\GHS\output.xlsx"
- Using fs As New FileStream(saveFilePath, FileMode.Create, FileAccess.Write)
- workbook.Write(fs)
- End Using
-
- ' MsgBox("图片插入完成!")
- End Sub
- Private Sub Button25_Click(sender As Object, e As EventArgs) Handles Button25.Click
-
-
- End Sub
- Function ImageToByteArray(image As Image) As Byte()
- Using ms As New MemoryStream()
- image.Save(ms, ImageFormat.Png)
- Return ms.ToArray()
- End Using
- End Function
-
- Private Sub Button26_Click(sender As Object, e As EventArgs) Handles Button26.Click
-
- Dim my_card As String
- Dim my_weight As Double
- Dim d_no As String
- Do
- my_card = InputBox("请输入卡号:", "查询", DGV1.Rows(DGV1.CurrentCell.RowIndex).Cells(4).Value)
- If my_card = "" Then
- MsgBox("操作已取消。", vbInformation, "退出")
- Exit Sub ' 立即退出子程序
- ElseIf my_card = "" Then
- MsgBox("请重新输入!", vbExclamation, "错误")
- Else
- Exit Do
- End If
- Loop
-
- ' 验证重量输入
- Do
- Dim weightInput As String
- weightInput = InputBox("请输入重量:", "查询", DGV1.Rows(DGV1.CurrentCell.RowIndex).Cells(3).Value)
- If weightInput = "" Then
- MsgBox("操作已取消。", vbInformation, "退出")
- Exit Sub
- ElseIf Not IsNumeric(weightInput) Then
- MsgBox("重量必须是数字,请重新输入!", vbExclamation, "错误")
- ElseIf CDbl(weightInput) <= 0 Then
- MsgBox("重量必须大于0,请重新输入!", vbExclamation, "错误")
- Else
- my_weight = CDbl(weightInput)
- Exit Do
- End If
- Loop
-
- ' 验证编号输入
- Do
- d_no = InputBox("请输入编号:", "查询", 10)
- If d_no = "" Then
- MsgBox("操作已取消。", vbInformation, "退出")
- Exit Sub
- ElseIf d_no Like "*-*" Then
- ' MsgBox("编号格式不正确,请输入类似 'P241129-4' 的编号!", vbExclamation, "错误")
- Else
- Exit Do
- End If
- Loop
-
-
-
-
-
- ' 图片路径(假设图片名为 1.jpg 到 9.jpg)
- Dim imagePaths As String() = {
- "C:\GHS\1.jpg", "C:\GHS\2.jpg", "C:\GHS\3.jpg",
- "C:\GHS\4.jpg", "C:\GHS\5.jpg", "C:\GHS\6.jpg",
- "C:\GHS\7.jpg", "C:\GHS\8.jpg", "C:\GHS\9.jpg"
- }
- Dim dataTable As New DataTable()
- dataTable = DataGridView1.DataSource
- ' 创建 Excel 工作簿
- Dim workbook As IWorkbook = New XSSFWorkbook()
- Dim sheet As ISheet = workbook.CreateSheet("Chemicals")
-
- ' 创建隐藏的图片库工作表
- Dim imageSheet As ISheet = workbook.CreateSheet("ImageLibrary")
- '' workbook.SetSheetHidden(workbook.GetSheetIndex("ImageLibrary"), SheetState.Hidden)
-
- ' 加载图片到图片库
- Dim drawing As IDrawing = imageSheet.CreateDrawingPatriarch()
- For i As Integer = 0 To imagePaths.Length - 1
- Dim imagePath As String = imagePaths(i)
- If File.Exists(imagePath) Then
- Dim bytes As Byte() = File.ReadAllBytes(imagePath)
- Dim pictureIdx As Integer = workbook.AddPicture(bytes, PictureType.JPEG)
- ' 插入图片到隐藏工作表
- Dim anchor As IClientAnchor = workbook.GetCreationHelper().CreateClientAnchor()
- anchor.Col1 = i + 2 ' 每张图片占一列
- anchor.Row1 = 0
- anchor.AnchorType = AnchorType.DontMoveAndResize
- Dim picture As IPicture = drawing.CreatePicture(anchor, pictureIdx)
- picture.Resize(1)
- End If
- Next
-
-
-
-
- For col As Integer = 0 To 5
- sheet.SetColumnWidth(col, 10 * 256) ' 图片列宽度
- Next
-
- ' 初始行位置
- Dim currentRow As Integer = 0
-
- Dim my_item As Integer
-
-
-
-
- dataTable.DefaultView.Sort = "类别 ASC, 项次 ASC"
-
- Dim sortedTable As DataTable = dataTable.DefaultView.ToTable()
-
- ProgressBar1.Visible = True
- ProgressBar1.Minimum = 0
- ProgressBar1.Maximum = sortedTable.Rows.Count ' 假设 dt 是一个 DataTable
- ProgressBar1.Value = 0 ' 初始进度为 0
-
-
- ' 遍历 DataTable 的每一行
- For Each row As DataRow In sortedTable.Rows
-
- ProgressBar1.Value += 1
- Application.DoEvents()
-
- If row("类别") <> "不列印" Then
- '生成二维码图片
- Dim qrCodeImage As Image = MakeQrCode("http://192.168.110.164:8888/" & row("filename"))
- Dim imageBytes As Byte() = ImageToByteArray(qrCodeImage)
-
- ' 插入二维码图片到第4列
- Dim drawingQrCode As IDrawing = sheet.CreateDrawingPatriarch()
- Dim anchorQrCode As IClientAnchor = workbook.GetCreationHelper().CreateClientAnchor()
- anchorQrCode.Col1 = 4 ' 第4列
- anchorQrCode.Row1 = currentRow + 7 ' 当前行
- anchorQrCode.Col2 = 5 ' 跨1列
- anchorQrCode.Row2 = currentRow + 11 ' 占用4行
-
- Dim qrPictureIdx As Integer = workbook.AddPicture(imageBytes, PictureType.PNG)
- Dim qrPicture As IPicture = drawingQrCode.CreatePicture(anchorQrCode, qrPictureIdx)
- qrPicture.Resize(1) ' 缩放二维码
-
- ' 写入化工信息
-
-
- 'sheet.CreateRow(currentRow).CreateCell(3).SetCellValue($"卡号:{my_card}")
- 'sheet.CreateRow(currentRow).CreateCell(7).SetCellValue($"项次:{row("项次")}")
-
- ' 创建行并插入数据
- Dim rowToInsert = sheet.CreateRow(currentRow) ' 只创建一行
-
- ' 在第 4 列插入卡号
- rowToInsert.CreateCell(0).SetCellValue($"卡号:{my_card}")
-
- ' 在第 8 列插入项次
- rowToInsert.CreateCell(4).SetCellValue($"项次:{row("项次")}")
-
-
- Dim cellStyle As ICellStyle = workbook.CreateCellStyle()
- Dim font As IFont = workbook.CreateFont()
- font.FontHeightInPoints = 18 ' 设置字体大小为 18
- cellStyle.SetFont(font) ' 将字体应用到样式
-
- 'sheet.CreateRow(currentRow + 1).CreateCell(0).SetCellValue($"化料名称:{row("化料名称")}")
- Dim row1 = sheet.CreateRow(currentRow + 1)
- row1.CreateCell(0).SetCellValue($"化料名称:{row("化料名称")}")
- row1.Cells(0).CellStyle = cellStyle ' 应用样式
- sheet.AddMergedRegion(New NPOI.SS.Util.CellRangeAddress(currentRow + 1, currentRow + 1, 0, 4))
-
-
-
-
- Dim row2 = sheet.CreateRow(currentRow + 2)
- row2.CreateCell(0).SetCellValue($"重量:{row("百分比") * my_weight / 100}")
- row2.CreateCell(3).SetCellValue($"{row("化工分类")}")
-
- row2.Cells(0).CellStyle = cellStyle ' 应用样式
- row2.Cells(1).CellStyle = cellStyle ' 应用样式
-
- Dim row3 = sheet.CreateRow(currentRow + 3)
- row3.CreateCell(4).SetCellValue($"鼓号")
- Dim row4 = sheet.CreateRow(currentRow + 4)
- row4.CreateCell(4).SetCellValue($"{d_no}")
- Dim row5 = sheet.CreateRow(currentRow + 5)
- row5.CreateCell(3).SetCellValue("百分比")
- row5.CreateCell(4).SetCellValue("下鼓重")
- Dim row6 = sheet.CreateRow(currentRow + 6)
- row6.CreateCell(3).SetCellValue($"{row("百分比")}")
- row6.CreateCell(4).SetCellValue($"{my_weight}")
-
- Dim row7 = sheet.CreateRow(currentRow + 10)
- row7.CreateCell(1).SetCellValue($"{DGV1.Rows(DGV1.CurrentCell.RowIndex).Cells(1).Value}")
-
- 'Dim row8 = sheet.CreateRow(currentRow + 11)
- 'row8.CreateCell(3).SetCellValue($"{row("百分比")}")
-
- Dim row9 = sheet.CreateRow(currentRow + 12)
- row9.CreateCell(1).SetCellValue($"打印时间:{DateTime.Now}")
-
-
-
-
-
- sheet.AddMergedRegion(New NPOI.SS.Util.CellRangeAddress(currentRow + 2, currentRow + 2, 0, 2))
- sheet.AddMergedRegion(New NPOI.SS.Util.CellRangeAddress(currentRow + 2, currentRow + 2, 3, 4))
-
-
- ' 创建一个字体和边框样式
- Dim cellStyle1 As ICellStyle = workbook.CreateCellStyle()
-
- ' 设置外边框为粗线
- cellStyle.BorderTop = BorderStyle.Double
- cellStyle.BorderRight = BorderStyle.Double
- cellStyle.BorderBottom = BorderStyle.Double
- cellStyle.BorderLeft = BorderStyle.Double
-
- ' 为 A2:E3 区域设置边框
-
-
- ' 设置粗外框
- For rowX As Integer = currentRow + 1 To currentRow + 2 ' 行索引从 1 开始
- For col As Integer = 0 To 4 ' 列索引从 0 到 4 (A 到 E)
- Dim cell As ICell = sheet.GetRow(rowX).GetCell(col)
- If cell Is Nothing Then
- cell = sheet.GetRow(rowX).CreateCell(col)
- End If
- cell.CellStyle = cellStyle ' 应用样式
- Next
- Next
-
-
-
- ' 插入 d1-d9 对应的图片
- Dim rowStart As Integer = currentRow ' 图片从当前行开始
- Dim colStart1 As Integer = 0
- Dim colStart As Integer = 0 ' d1-d9 的起始列
- Dim imgPerRow As Integer = 3 ' 每行放3张图片
-
- Dim row_start As Integer = 0
- For i As Integer = 1 To 9
- Dim colName As String = "d" & i
- If row(colName).ToString() = "√" Then
- row_start += 1
- Dim imagePath As String = $"C:\GHS\{i}.jpg" ' 假设图片路径为 C:\GHS\1.jpg 到 C:\GHS\9.jpg
- If File.Exists(imagePath) Then
- Dim bytes As Byte() = File.ReadAllBytes(imagePath)
- Dim pictureIdx As Integer = workbook.AddPicture(bytes, PictureType.JPEG)
-
- Dim drawingMain As IDrawing = sheet.CreateDrawingPatriarch()
- Dim anchor As IClientAnchor = workbook.GetCreationHelper().CreateClientAnchor()
- anchor.Col1 = colStart
- anchor.Row1 = rowStart + 3 ' 图片放在二维码下方,开始于第5行
- anchor.Col2 = colStart + 1 ' 图片跨2列
- anchor.Row2 = rowStart + 8 ' 图片占用5行
-
- ' 设置偏移量(像素)
- anchor.Dx1 = 200 ' 左上角水平偏移(单位:EMU)
- anchor.Dy1 = 0 ' 左上角垂直偏移
- anchor.Dx2 = 500 ' 右下角水平偏移
- anchor.Dy2 = 0 ' 右下角垂直偏移
-
-
-
- ' 设置锚点类型,图片不随单元格变化
- anchor.AnchorType = AnchorType.DontMoveAndResize
- Dim picture As IPicture = drawingMain.CreatePicture(anchor, pictureIdx)
- picture.Resize(1) ' 缩放比例
-
- ' 更新列位置
- colStart += 1
- If colStart >= imgPerRow Then
- colStart1 = 1
- colStart = 0 ' 回到第一列
- rowStart += 5 ' 换行后行数增加5
- End If
- End If
- End If
- Next
-
- If colStart1 = 1 Then rowStart -= 5
- ' 更新当前行位置,确保下一个化工占用新行
- currentRow = rowStart + 13 ' 增加行数以容纳二维码和图片
-
- ' 插入换页符
- sheet.SetRowBreak(currentRow - 1)
- End If
- Next
-
-
-
-
- ' 保存文件
- ' Dim filePath As String = $"卡号标签_{DateTime.Now.ToString("yyyyMMdd_HHmmss")}.xlsx"
- Dim filePath As String = $"卡号标签_{my_card}.xlsx"
-
- Using fs As New FileStream(filePath, FileMode.Create, FileAccess.Write)
- workbook.Write(fs)
- End Using
-
- ' 打开文件
- If File.Exists(filePath) Then
- Process.Start(New ProcessStartInfo With {
- .FileName = filePath,
- .UseShellExecute = True
- })
- End If
-
-
- ProgressBar1.Visible = False
-
-
- End Sub
-
- Private Sub DGV1_SelectionChanged(sender As Object, e As EventArgs) Handles DGV1.SelectionChanged
-
- End Sub
- End Class
|