12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172 |
- '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
- 'Imports System.Runtime.InteropServices
-
- Public Class Frm_00_Retan_rcp
-
- ' ' 声明全局变量来存储原始位置和大小
- ' Private originalLocation As Point
- ' Private originalSize As Size
- ' Private isMaximized As Boolean = False ' 用于标记当前是否是放大状态
- ' Private Sub Frm_00_Retan_rcp_Load(sender As Object, e As EventArgs) Handles MyBase.Load
-
-
-
-
- ' ' 记录初始位置和大小
- ' originalLocation = DataGridView1.Location
- ' originalSize = DataGridView1.Size
-
- ' DataGridView1.AllowUserToAddRows = False
-
-
- ' '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(100) date as 日期,name as 品名,selection as 选级,avg(weight) as 重量,no as 流程卡号,rcp_no as 表格编号,spec as 开削 from ht_retanrcp group by name,date,selection,rcp_no,no,spec order by date desc,rcp_no 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
-
-
- ' RefreshDgv1()
-
-
-
- ' DGV1.Columns(0).Width = 120
- ' DGV1.Columns(1).Width = 250
- ' DGV1.Columns(2).Width = 120
-
- ' DGV1.Columns(3).Width = 100
- ' DGV1.Columns(4).Width = 250
- ' DGV1.Columns(5).Width = 300
- ' DGV1.Columns(6).Visible = False
- ' DGV1.RowHeadersWidth = 30
- ' DataGridView1.RowHeadersWidth = 30
- ' DataGridView1.RowTemplate.Height = 30
-
- ' End Sub
-
- ' 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
-
-
-
-
-
- ' 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("请输入卡号", "询问", DGV1.Rows(DGV1.CurrentRow.Index).Cells("流程卡号").Value)
- ' Dim my_weight As Double = InputBox("请输入重量", "询问", DGV1.Rows(DGV1.CurrentRow.Index).Cells("重量").Value)
- ' Dim my_selection As String = InputBox("请输入选级", "询问", DGV1.Rows(DGV1.CurrentRow.Index).Cells("选级").Value)
-
-
-
-
- ' 'frm_01hf_RetanRcp_WB.ShowDialog()
-
-
-
- ' Dim d_no As String = 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) = my_selection
- ' 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 / 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 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()
-
- ' set_grid1()
-
-
- ' 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 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 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) '打印标签
-
-
-
- ' ' 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
- ' txt_bxs.Text = ""
- ' txt_frj.Text = ""
- ' txt_jc.Text = ""
- ' txtjc.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(txtwb_weight.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 & "','" & txtwb_weight.Text & "','" & txttan.Text & "','" & txtoil.Text & "','" & txtdye.Text & "','" & txtaux.Text & "','" & txtbxs.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(txtwb_weight.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(txtwb_weight.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 & "','" & txtwb_weight.Text & "','" & txttan.Text & "','" & txtoil.Text & "','" & txtdye.Text & "','" & txtaux.Text & "','" & txtbxs.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(txtwb_weight.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(txtwb_weight.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 * " & txtwb_weight.Text & ") WHEN retan_cost.coin = '美金' THEN SUM(tblMaterial.PUR_UNIT * retan_cost.percents / 100 * " & txtwb_weight.Text & ") * 29.15 WHEN retan_cost.coin = '人民幣' THEN SUM(tblMaterial.PUR_UNIT * retan_cost.percents / 100 * " & txtwb_weight.Text & ") * 4.4 WHEN retan_cost.coin = '歐元' THEN SUM(tblMaterial.PUR_UNIT * retan_cost.percents / 100 * " & txtwb_weight.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
-
-
-
- ' txt_bxs.Text = t
- ' txt_frj.Text = f
- ' txt_jc.Text = d
- ' txtjc.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
- ' txtsum.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
- ' txtwb_weight.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
- ' txt_bxs.Text = ""
- ' txt_frj.Text = ""
- ' txt_jc.Text = ""
- ' txtjc.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 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 = 100
- ' DataGridView1.Columns(1).Width = 180
- ' DataGridView1.Columns(2).Width = 150
- ' DataGridView1.Columns(3).Width = 120
- ' DataGridView1.Columns(4).Width = 120
- ' DataGridView1.Columns(5).Width = 100
- ' DataGridView1.Columns(6).Width = 280
- ' DataGridView1.Columns("系统品名").Width = 300
- ' DataGridView1.Columns("系统代码").Width = 250
-
- ' For x As Integer = 7 To 16
-
- ' DataGridView1.Columns(x).Visible = False
- ' Next
-
-
-
- ' 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 = ""
- ' txtaux.Text = ""
- ' txtbxs.Text = ""
- ' txtfrj.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 备注, 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, 项次"
-
- ' 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, case when HT_K3_Material.name is null then HT_RetanRcp.chem else HT_K3_Material.name end as 系统品名,
- ' HT_K3_Material.code as 系统代码
- 'FROM HT_K3_Material RIGHT OUTER JOIN
- ' HT_Rcp_ChemName_table ON HT_K3_Material.name = HT_Rcp_ChemName_table.sys_chem_name LEFT OUTER JOIN
- ' 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 ON HT_Rcp_ChemName_table.sys_chem_name = HT_Chem_Main.sys_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 <> '') AND (HT_K3_Material.code NOT LIKE 'ck00006%' OR
- ' HT_K3_Material.code IS NULL)
- '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,
- ' HT_MSDS_File_1.filename,
- ' CASE
- ' WHEN HT_K3_Material.name IS NULL THEN HT_RetanRcp.chem
- ' ELSE HT_K3_Material.name
- ' END AS 系统品名,
- ' HT_K3_Material.code AS 系统代码,
- ' -- 添加进货单价
- ' HT_Chem_In.price AS 进货单价
- 'FROM
- ' HT_K3_Material
- 'RIGHT OUTER JOIN
- ' HT_Rcp_ChemName_table ON HT_K3_Material.name = HT_Rcp_ChemName_table.sys_chem_name
- 'LEFT OUTER JOIN
- ' 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
- 'ON HT_Rcp_ChemName_table.sys_chem_name = HT_Chem_Main.sys_name
- 'RIGHT OUTER JOIN
- ' HT_RetanRcp ON HT_Rcp_ChemName_table.rcp_chem_name = HT_RetanRcp.chem
- '-- 加入进货单价的子查询,连接条件改为系统代码与 HT_Chem_In.no
- 'LEFT OUTER JOIN (
- ' SELECT
- ' code,
- ' price,
- ' no,
- ' ROW_NUMBER() OVER (PARTITION BY code ORDER BY date DESC) AS rn
- ' FROM HT_Chem_In
- ' WHERE date <= DATEADD(DAY, 7, GETDATE()) -- 替换 GETDATE() 为 HT_RetanRcp.date 来动态获取日期
- ') AS HT_Chem_In
- ' ON HT_K3_Material.code = HT_Chem_In.code
- ' AND HT_Chem_In.no = HT_Chem_In.no -- 使用 no 进行匹配
- ' AND HT_Chem_In.rn = 1
- '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 <> '')
- ' AND (HT_K3_Material.code NOT LIKE 'ck00006%' OR HT_K3_Material.code IS NULL)
- 'ORDER BY
- ' HT_RetanRcp.rcp_no DESC, 项次;
- '"
-
-
-
-
-
-
- ' Label20.Text = DGV1.Rows(DGV1.CurrentRow.Index).Cells("品名").Value.ToString
- ' Label21.Text = "开削" & DGV1.Rows(DGV1.CurrentRow.Index).Cells("开削").Value.ToString
-
- ' cmd.CommandText = sql_rcp
- ' da.SelectCommand = cmd
- ' da.Fill(DT2)
-
-
-
-
-
- ' DataGridView1.DataSource = DT2
- ' DataGridView1.RowTemplate.Height = 30
- ' set_grid1()
-
-
-
- ' cal_cost1()
-
-
-
- ' End Sub
-
- ' Private Sub cal_cost()
-
-
- ' ' 使用 LINQ 进行 Group By 操作,并取每个分组中的进货单价
- ' Dim groupedData = From row In DT2.AsEnumerable()
- ' Group row By category = row.Field(Of String)("化工分类") Into Group
- ' Select category,
- ' TotalAmount = Group.Sum(Function(r) If(IsNumeric(r.Field(Of Object)("百分比")), Convert.ToDouble(r.Field(Of Object)("百分比")), 0)),
- ' PurchasePrice = If(Group.Any(Function(r) IsNumeric(r.Field(Of Object)("进货单价"))),
- ' Convert.ToDouble(Group.Select(Function(r) r.Field(Of Object)("进货单价")).FirstOrDefault()),
- ' 0)
-
- ' ' 创建新的 DataTable 来存储分组后的数据
- ' Dim newDataTable As New DataTable()
- ' newDataTable.Columns.Add("Category", GetType(String))
- ' newDataTable.Columns.Add("TotalAmount", GetType(Double))
- ' newDataTable.Columns.Add("PurchasePrice", GetType(Double))
-
- ' ' 将 groupedData 中的数据插入到新的 DataTable 中
- ' For Each item In groupedData
- ' Dim newRow As DataRow = newDataTable.NewRow()
- ' newRow("Category") = item.category
- ' newRow("TotalAmount") = item.TotalAmount
- ' newRow("PurchasePrice") = item.PurchasePrice
- ' newDataTable.Rows.Add(newRow)
- ' Next
-
- ' DataGridView2.DataSource = newDataTable
- ' DataGridView2.ReadOnly = True
- ' DataGridView2.RowHeadersWidth = 20
-
- ' End Sub
-
-
- ' Private Sub cal_cost1()
- ' ' 获取 DataGridView1 中当前选中行的索引
- ' Dim selectedRowIndex As Integer = DGV1.CurrentCell.RowIndex
-
- ' ' 获取 DataGridView1 中选中行的 "重量"
- ' Dim weight As Double = Convert.ToDouble(DGV1.Rows(selectedRowIndex).Cells("重量").Value)
-
- ' ' 在 DataGridView2 的 DataTable 中添加一列用于存储“金额小计”
- ' If Not DataGridView1.DataSource Is Nothing Then
- ' Dim dt2 As DataTable = CType(DataGridView1.DataSource, DataTable)
-
- ' ' 检查是否已添加过金额小计列
- ' If Not dt2.Columns.Contains("Amount") Then
- ' dt2.Columns.Add("Amount", GetType(Double))
- ' End If
-
- ' ' 遍历 DataGridView2 中的每一行,计算金额小计
- ' For Each row As DataRow In dt2.Rows
- ' ' 获取 DataGridView2 中的百分比和进货单价
- ' Dim percentage As Double = Convert.ToDouble(row("百分比"))
-
- ' ' 检查进货单价是否为 DBNull
- ' Dim purchasePrice As Double = 0
- ' If Not IsDBNull(row("进货单价")) Then
- ' purchasePrice = Convert.ToDouble(row("进货单价"))
- ' End If
-
- ' ' 如果进货单价有效,计算金额小计
- ' If purchasePrice > 0 Then
- ' Dim amount As Double = weight * purchasePrice * percentage / 100
- ' row("Amount") = amount ' 将金额小计添加到该行
- ' Else
- ' row("Amount") = 0 ' 如果进货单价无效,则设置金额小计为 0
- ' End If
- ' Next
- ' End If
-
- ' ' 使用 LINQ 进行 Group By 操作,并按化工分类汇总百分比和金额小计
- ' Dim groupedData = From row In DataGridView1.Rows.Cast(Of DataGridViewRow)()
- ' Where row.Cells("化工分类").Value.ToString() <> "水" ' 排除 "水" 分类
- ' Group row By category = row.Cells("化工分类").Value.ToString() Into Group
- ' Select category,
- ' TotalPercentag1 = Group.Sum(Function(r) Convert.ToDouble(r.Cells("百分比").Value)),
- ' TotalAmount1 = Group.Sum(Function(r) Convert.ToDouble(r.Cells("Amount").Value))
-
- ' ' 创建一个新的 DataTable 来存储汇总结果
- ' Dim newDataTable As New DataTable()
- ' newDataTable.Columns.Add("Category", GetType(String)) ' 分类
- ' newDataTable.Columns.Add("TotalPercentage", GetType(Double)) ' 汇总的百分比
- ' newDataTable.Columns.Add("TotalAmount", GetType(Double)) ' 汇总的金额小计
-
- ' ' 将汇总数据添加到 DataTable
- ' For Each item In groupedData
- ' Dim newRow As DataRow = newDataTable.NewRow()
- ' newRow("Category") = item.category
- ' newRow("TotalPercentage") = Math.Round(item.TotalPercentag1, 1) ' 保留1位小数
- ' newRow("TotalAmount") = Math.Floor(item.TotalAmount1) ' 保留整数
- ' newDataTable.Rows.Add(newRow)
- ' Next
-
- ' ' 计算总百分比和总金额
- ' Dim totalPercentage As Double = groupedData.Where(Function(g) g.category <> "").Sum(Function(g) g.TotalPercentag1)
- ' Dim totalAmount As Double = groupedData.Where(Function(g) g.category <> "").Sum(Function(g) g.TotalAmount1)
-
- ' ' 添加总汇总行
- ' Dim totalRow As DataRow = newDataTable.NewRow()
- ' totalRow("Category") = "Total"
- ' totalRow("TotalPercentage") = Math.Round(totalPercentage, 1) ' 保留1位小数
- ' totalRow("TotalAmount") = Math.Floor(totalAmount) ' 保留整数
- ' newDataTable.Rows.Add(totalRow)
-
- ' ' 将结果绑定到 DataGridView3
- ' DataGridView2.DataSource = newDataTable
- ' DataGridView2.ReadOnly = True
- ' DataGridView2.RowHeadersWidth = 20
-
- ' ' 设置最后一行的字体颜色为红色
- ' Dim lastRowIndex As Integer = DataGridView2.Rows.Count - 2
- ' DataGridView2.Rows(lastRowIndex).DefaultCellStyle.ForeColor = Color.Red
- ' DataGridView2.AllowUserToAddRows = False
-
-
- ' ' 设置 TotalAmount 列为右对齐并加上千分位格式
- ' DataGridView2.Columns("TotalAmount").DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight
- ' DataGridView2.Columns("TotalAmount").DefaultCellStyle.Format = "N0"
-
- ' 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
-
- ' 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)
-
-
- ' 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_CellContentClick(sender As Object, e As DataGridViewCellEventArgs) Handles DGV1.CellContentClick
-
- ' End Sub
-
- ' Private Sub Button5_Click(sender As Object, e As EventArgs) Handles btnSaveAs.Click
- ' ' 获取用户输入的日期、流程卡号、片数、批号、重量
- ' Dim inputDate As Date = Date.Now
- ' Dim processCardNo As String = InputBox("请输入流程卡号:")
-
- ' Dim inputQuantity As String = InputBox("请输入片数:")
- ' Dim quantity As Integer
-
- ' ' 尝试将用户输入的值转换为整数
- ' If Integer.TryParse(inputQuantity, quantity) Then
- ' ' 转换成功,quantity 已被赋值
- ' Else
- ' ' 如果转换失败,设置默认值或者根据需要进行处理
- ' quantity = 0 ' 设置为默认值
- ' End If
-
- ' Dim spec As String = InputBox("请输入厚度:")
- ' Dim batchNo As String = InputBox("请输入蓝皮批号:")
-
- ' 'Dim weight As Double = CDbl(InputBox("请输入重量:"))
-
- ' Dim inputweight As String
-
- ' Dim weight As Double
-
- ' ' 尝试将用户输入的值转换为整数
- ' If Integer.TryParse(inputweight, weight) Then
- ' ' 转换成功,weight 已被赋值
- ' Else
- ' ' 如果转换失败,设置默认值或者根据需要进行处理
- ' weight = 0 ' 设置为默认值
- ' End If
-
-
-
- ' Dim name As String = InputBox("请输入工艺名:",, DGV1.Rows(DGV1.CurrentRow.Index).Cells("品名").Value)
- ' ' 生成 rcp_no:根据日期和流水号生成唯一的 rcp_no
- ' Dim rcp_no As String = inputDate & "_" & GetNextSerialNumber()
-
-
-
- ' ' 准备插入数据库的命令
- ' Dim cmd As New SqlCommand()
- ' cmd.Connection = conn ' 假设 conn 是你的 SqlConnection 对象
-
- ' ' 遍历 DataGridView1 中的数据并插入数据库
- ' For Each row As DataGridViewRow In DataGridView1.Rows
-
- ' ' 获取每一行的数据
-
- ' Dim no As String = row.Cells("项次").Value.ToString()
- ' Dim chem As String = row.Cells("化料名称").Value.ToString()
- ' Dim percents As String = row.Cells("百分比").Value.ToString()
- ' Dim time As String = If(IsDBNull(row.Cells("时间").Value), "", row.Cells("时间").Value.ToString())
- ' Dim comment As String = row.Cells("备注").Value.ToString()
-
- ' ' 插入数据到数据库(使用参数化查询)
- ' Dim sql As String = "INSERT INTO ht_retanrcp (item, rcp_no, no, name, date, spec, weight, selection, chem, percents, time, comment)
- ' VALUES (@item, @rcp_no, @no, @name, @retan_date, @spec, @weight, @selection, @chem, @percents, @time, @comment)"
- ' cmd.CommandText = sql
- ' cmd.Parameters.Clear()
- ' cmd.Parameters.AddWithValue("@item", row.Index + 1) ' 使用行号作为 item
- ' cmd.Parameters.AddWithValue("@rcp_no", rcp_no)
- ' cmd.Parameters.AddWithValue("@no", processCardNo)
- ' cmd.Parameters.AddWithValue("@name", name)
- ' cmd.Parameters.AddWithValue("@retan_date", inputDate)
- ' cmd.Parameters.AddWithValue("@spec", spec)
- ' cmd.Parameters.AddWithValue("@weight", weight)
- ' cmd.Parameters.AddWithValue("@selection", batchNo & " " & quantity & "P")
- ' cmd.Parameters.AddWithValue("@chem", chem)
- ' cmd.Parameters.AddWithValue("@percents", percents)
- ' cmd.Parameters.AddWithValue("@time", If(time = "", DBNull.Value, time)) ' 如果 time 为空,插入 DBNull
- ' cmd.Parameters.AddWithValue("@comment", comment)
- ' cmd.Parameters.AddWithValue("@process_card_no", processCardNo)
-
-
- ' cmd.ExecuteNonQuery() ' 执行插入操作
- ' Next
-
- ' MessageBox.Show("数据已成功保存!", "成功", MessageBoxButtons.OK, MessageBoxIcon.Information)
-
- ' RefreshDgv1()
-
-
- ' End Sub
-
- ' Private Function GetNextSerialNumber() As Integer
- ' ' 确保连接是开启的
- ' If conn.State = ConnectionState.Closed Then
- ' conn.Open()
- ' End If
-
- ' ' 创建查询命令
- ' Dim cmd As New SqlCommand("SELECT MAX(CAST(SUBSTRING(rcp_no, 9, LEN(rcp_no)) AS INT)) + 1 FROM ht_retanrcp WHERE rcp_no LIKE @rcp_no_prefix", conn)
- ' cmd.Parameters.AddWithValue("@rcp_no_prefix", DateTime.Now.ToString("yyyyMMdd") & "_")
-
- ' ' 执行查询并返回结果
- ' Dim result As Object = cmd.ExecuteScalar()
-
- ' ' 如果没有找到结果,则返回 1
- ' If result Is DBNull.Value OrElse result Is Nothing Then
- ' Return 1
- ' Else
- ' Return CInt(result)
- ' End If
- ' End Function
-
- ' Private Sub Button5_Click_1(sender As Object, e As EventArgs) Handles Button5.Click '删除’
-
-
- ' If conn.State = ConnectionState.Closed Then
- ' conn.Open()
-
- ' End If
-
- ' cmd.Connection = conn
-
-
- ' Dim msg As MsgBoxResult = MsgBox("确定要删除工艺 '" & DGV1.Rows(DGV1.CurrentCell.RowIndex).Cells("品名").Value & "' ? ", MsgBoxStyle.YesNoCancel)
-
-
- ' If msg = MsgBoxResult.Yes Then
-
-
- ' sql_rcp = "delete from ht_retanrcp where name=N'" & DGV1.Rows(DGV1.CurrentCell.RowIndex).Cells("品名").Value & "' and rcp_no=N'" & DGV1.Rows(DGV1.CurrentCell.RowIndex).Cells("表格编号").Value & "' and date='" & DGV1.Rows(DGV1.CurrentCell.RowIndex).Cells("日期").Value & "'"
- ' cmd.CommandText = sql_rcp
- ' cmd.ExecuteNonQuery()
-
-
-
- ' MsgBox("工艺已删除")
-
-
-
-
- ' Else
-
-
-
-
- ' End If
-
- ' RefreshDgv1()
-
-
- ' conn.Close()
-
-
- ' End Sub
-
- ' Private Sub Button9_Click_1(sender As Object, e As EventArgs) Handles Button9.Click '修改’
-
-
- ' ' 准备插入数据库的命令
- ' Dim cmd As New SqlCommand()
- ' cmd.Connection = conn ' 假设 conn 是你的 SqlConnection 对象
-
- ' If conn.State = ConnectionState.Closed Then
- ' conn.Open()
- ' End If
-
- ' Dim inputDate As Date = InputBox("请输入日期:",, DGV1.Rows(DGV1.CurrentRow.Index).Cells("日期").Value)
- ' Dim processCardNo As String = InputBox("请输入流程卡号及片数:",, DGV1.Rows(DGV1.CurrentRow.Index).Cells("流程卡号").Value)
- ' Dim spec As String = InputBox("请输入开削厚度:",, DGV1.Rows(DGV1.CurrentRow.Index).Cells("开削").Value)
- ' Dim batchNo As String = InputBox("请输入蓝皮批号:",, DGV1.Rows(DGV1.CurrentRow.Index).Cells("选级").Value)
- ' Dim weight As Double = CDbl(InputBox("请输入重量:",, DGV1.Rows(DGV1.CurrentRow.Index).Cells("重量").Value))
- ' Dim name As String = InputBox("请输入工艺名:",, DGV1.Rows(DGV1.CurrentRow.Index).Cells("品名").Value)
- ' ' 生成 rcp_no:根据日期和流水号生成唯一的 rcp_no
-
-
-
-
- ' sql_rcp = "update ht_retanrcp set name=N'" & name & "',date='" & inputDate & "',spec='" & spec & "',weight='" & weight & "',selection=N'" & batchNo & "',no=N'" & processCardNo & "' where name=N'" & DGV1.Rows(DGV1.CurrentCell.RowIndex).Cells("品名").Value & "' and rcp_no=N'" & DGV1.Rows(DGV1.CurrentCell.RowIndex).Cells("表格编号").Value & "' and date='" & DGV1.Rows(DGV1.CurrentCell.RowIndex).Cells("日期").Value & "'"
- ' cmd.CommandText = sql_rcp
- ' cmd.ExecuteNonQuery()
-
- ' MsgBox("更新完成")
- ' RefreshDgv1()
-
-
- ' End Sub
-
- ' ' 刷新 dgv1 数据
- ' Private Sub RefreshDgv1()
- ' Dim connectionString As String = connstring
- ' Dim query As String = "SELECT TOP 200 date AS 日期, name AS 品名, selection AS 选级, AVG(weight) AS 重量, no AS 流程卡号, rcp_no AS 表格编号,spec as 开削 " &
- ' "FROM ht_retanrcp " &
- ' "GROUP BY name, date, selection, rcp_no, no,spec " &
- ' "ORDER BY date DESC, rcp_no DESC"
-
- ' ' 保存当前选中的行和列
- ' Dim selectedRowIndex As Integer = DGV1.CurrentRow?.Index
- ' Dim selectedColumnIndex As Integer = DGV1.CurrentCell?.ColumnIndex
-
- ' Try
- ' Using conn As New SqlConnection(connectionString)
- ' conn.Open()
-
- ' ' 使用 DataAdapter 将数据库数据填充到 DataTable
- ' Using da As New SqlDataAdapter(query, conn)
- ' Dim dt As New DataTable()
- ' da.Fill(dt)
-
- ' ' 将填充的数据绑定到 dgv1
- ' DGV1.DataSource = dt
- ' DGV1.Columns(6).Visible = False
- ' End Using
- ' End Using
-
- ' ' 如果之前有选中行,刷新后重新选中
- ' If selectedRowIndex >= 0 AndAlso selectedRowIndex < DGV1.Rows.Count Then
- ' DGV1.CurrentCell = DGV1.Rows(selectedRowIndex).Cells(selectedColumnIndex)
- ' Else
-
- ' DGV1.CurrentCell = DGV1.Rows(0).Cells(0)
- ' End If
- ' Catch ex As Exception
- ' MessageBox.Show("数据加载失败: " & ex.Message, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error)
- ' End Try
-
-
- ' 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
-
- ' End Sub
-
- ' Private Sub Button23_Click(sender As Object, e As EventArgs) Handles Button23.Click
-
-
- ' If DataGridView1.DataSource Is Nothing Then
-
- ' MsgBox("数据为空")
- ' Exit Sub
-
- ' End If
-
-
- ' If isMaximized Then
- ' ' 恢复原始位置和大小
- ' DataGridView1.Location = originalLocation
- ' DataGridView1.Size = originalSize
- ' ' 更新状态标记为恢复
- ' isMaximized = False
- ' Button23.Text = "放大"
-
-
-
-
- ' Button3.Enabled = True
- ' Button9.Enabled = True
- ' Button5.Enabled = True
- ' btnSaveAs.Enabled = True
-
- ' Else
- ' ' 放大到指定位置和大小
- ' DataGridView1.Location = New Point(17, 68) ' 移动到左上角
- ' DataGridView1.Size = New Size(1800, 650) ' 设置为放大后的大小
-
-
- ' ' 更新状态标记为放大
- ' isMaximized = True
- ' Button23.Text = "恢复"
- ' Button3.Enabled = False
- ' Button9.Enabled = False
- ' Button5.Enabled = False
- ' btnSaveAs.Enabled = False
-
- ' End If
-
- ' ' 将 DataGridView1 移至最上层
- ' DataGridView1.BringToFront()
-
-
- ' End Sub
-
- ' Private Sub Button16_Click(sender As Object, e As EventArgs) Handles Button16.Click '领料
-
-
- ' Dim my_chem As String = ""
-
-
- ' For Each row As DataGridViewRow In DataGridView1.Rows
-
-
-
- ' If row.Cells("类别").Value = "不列印" Then
- ' Continue For
- ' End If
-
- ' Dim cellFont As Font = row.DefaultCellStyle.Font
-
- ' If cellFont IsNot Nothing Then
-
- ' Dim aa As String
- ' aa = ""
- ' Dim fontStyle As FontStyle = cellFont.Style
-
- ' If FontStyle = FontStyle.Strikeout Then
- ' aa = ""
- ' Else
- ' End If
- ' 'fontStyle = cellFont.Style
- ' Else
-
- ' If row.Cells("类别").Value = "不列印" And Not (row.Cells("化料名称").Value Like "水*") Then
- ' my_chem += "项次" & row.Cells("项次").Value & " " & row.Cells("化料名称").Value & vbNewLine
- ' End If
-
- ' End If
-
-
-
-
-
-
-
-
-
- ' Next
-
- ' If Microsoft.VisualBasic.Len(my_chem) > 0 Then
- ' MsgBox("以下化工品名有误:" & vbNewLine & vbNewLine & my_chem)
- ' Exit Sub
- ' End If
-
- ' Dim inputDateString As String = InputBox("请输入日期:", "", DGV1.Rows(DGV1.CurrentRow.Index).Cells("日期").Value.ToString())
-
- ' Dim inputDate As Date
- ' If Not Date.TryParse(inputDateString, inputDate) Then
- ' MessageBox.Show("输入的日期格式无效,请重新输入。", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error)
- ' Exit Sub ' 退出子程序,避免后续报错
- ' End If
-
-
- ' Dim processCardNo As String = InputBox("请输入流程卡号及片数:",, DGV1.Rows(DGV1.CurrentRow.Index).Cells("流程卡号").Value)
-
- ' ' Dim weight As Double = CDbl(InputBox("请输入重量:",, DGV1.Rows(DGV1.CurrentRow.Index).Cells("重量").Value))
-
- ' Dim weightString As String = InputBox("请输入重量:", "", DGV1.Rows(DGV1.CurrentRow.Index).Cells("重量").Value.ToString())
-
- ' Dim weight As Double
- ' If Not Double.TryParse(weightString, weight) Then
- ' MessageBox.Show("输入的重量格式无效,请重新输入。", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error)
- ' Exit Sub ' 退出子程序,防止后续代码执行
- ' End If
-
-
- ' ' 准备插入数据库的命令
- ' Dim cmd As New SqlCommand()
- ' cmd.Connection = conn ' 假设 conn 是你的 SqlConnection 对象
-
- ' If conn.State = ConnectionState.Closed Then
- ' conn.Open()
- ' End If
-
-
- ' ' 遍历 DataGridView1 中的数据并插入数据库
- ' For Each row As DataGridViewRow In DataGridView1.Rows
-
- ' ' 获取每一行的数据
- ' Dim no As String = row.Cells("项次").Value.ToString()
- ' Dim chem As String = row.Cells("系统品名").Value.ToString()
-
- ' Dim percents As String = row.Cells("百分比").Value.ToString()
- ' Dim time As String = If(IsDBNull(row.Cells("时间").Value), "", row.Cells("时间").Value.ToString())
- ' Dim comment As String = row.Cells("备注").Value.ToString()
-
-
-
-
- ' Dim cellFont As Font = row.DefaultCellStyle.Font
- ' ' 获取字体样式
- ' If cellFont IsNot Nothing Then
-
- ' Else
-
-
-
- ' ' 插入数据到数据库(使用参数化查询)
- ' Dim sql As String = "INSERT INTO ht_retan_chem_out (item, rcp_name, chem_name,chem_code,chem_weight, outdate, weight, chem_percent, time, comment,card)
- ' VALUES (@item, @rcp_name, @chem_name,@chem_code,@chem_weight, @out_date, @weight, @percents, @time, @comment,@card)"
- ' cmd.CommandText = sql
- ' cmd.Parameters.Clear()
- ' cmd.Parameters.AddWithValue("@item", no) ' 使用行号作为 item
- ' cmd.Parameters.AddWithValue("@rcp_name", DGV1.Rows(DGV1.CurrentCell.RowIndex).Cells("品名").Value)
- ' cmd.Parameters.AddWithValue("@chem_name", chem)
- ' cmd.Parameters.AddWithValue("@chem_code", row.Cells("系统代码").Value)
- ' cmd.Parameters.AddWithValue("@chem_weight", weight * row.Cells("百分比").Value / 100)
- ' cmd.Parameters.AddWithValue("@out_date", inputDate)
- ' cmd.Parameters.AddWithValue("@weight", weight)
- ' cmd.Parameters.AddWithValue("@percents", percents)
- ' cmd.Parameters.AddWithValue("@time", If(time = "", DBNull.Value, time)) ' 如果 time 为空,插入 DBNull
- ' cmd.Parameters.AddWithValue("@comment", comment)
- ' cmd.Parameters.AddWithValue("@card", processCardNo)
-
-
- ' cmd.ExecuteNonQuery() ' 执行插入操作
-
-
-
- ' End If
-
-
-
- ' Next
-
- ' MessageBox.Show("数据已成功保存!", "成功", MessageBoxButtons.OK, MessageBoxIcon.Information)
-
-
-
- ' conn.Close()
- ' End Sub
- End Class
|