暫無描述
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Frm_01HF_Retan_Rcp.vb 166KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172
  1. 'Imports NPOI.XSSF.UserModel
  2. 'Imports NPOI.SS.UserModel
  3. 'Imports NPOI.POIFS.FileSystem
  4. 'Imports System.IO
  5. 'Imports System.Data.SqlClient
  6. ''Imports Microsoft.Office.Core.XlConstants
  7. 'Imports Microsoft.Office.Interop.Excel.XlUnderlineStyle
  8. 'Imports Microsoft.Office.Interop.Excel.Constants
  9. 'Imports Microsoft.Office.Interop.Excel.XlBordersIndex
  10. 'Imports Microsoft.Office.Interop.Excel.XlLineStyle
  11. 'Imports Microsoft.Office.Interop.Excel.XlBorderWeight
  12. 'Imports Microsoft.Office.Interop.Excel.XlPrintLocation
  13. 'Imports Microsoft.Office.Interop.Excel.XlPageOrientation
  14. 'Imports Microsoft.Office.Interop.Excel.XlPaperSize
  15. 'Imports Microsoft.Office.Interop.Excel.XlOrder
  16. 'Imports Microsoft.Office.Interop.Excel.XlPrintErrors
  17. ''Imports Excel = Microsoft.Office.Interop.Excel
  18. 'Imports Microsoft.Office.Core
  19. 'Imports System.Reflection
  20. 'Imports System.ComponentModel
  21. 'Imports Microsoft.Office.Interop
  22. 'Imports ThoughtWorks.QRCode.Codec.Data
  23. 'Imports System.Drawing.Imaging
  24. 'Imports NPOI.SS.Formula.Functions
  25. 'Imports System.Windows.Forms.VisualStyles.VisualStyleElement
  26. 'Imports System.Runtime.InteropServices
  27. Public Class Frm_00_Retan_rcp
  28. ' ' 声明全局变量来存储原始位置和大小
  29. ' Private originalLocation As Point
  30. ' Private originalSize As Size
  31. ' Private isMaximized As Boolean = False ' 用于标记当前是否是放大状态
  32. ' Private Sub Frm_00_Retan_rcp_Load(sender As Object, e As EventArgs) Handles MyBase.Load
  33. ' ' 记录初始位置和大小
  34. ' originalLocation = DataGridView1.Location
  35. ' originalSize = DataGridView1.Size
  36. ' DataGridView1.AllowUserToAddRows = False
  37. ' 'Dim type1 As Type = dgv2.GetType()
  38. ' 'Dim pi1 As PropertyInfo = type1.GetProperty("DoubleBuffered", System.Reflection.BindingFlags.Instance Or System.Reflection.BindingFlags.NonPublic)
  39. ' 'pi1.SetValue(dgv2, True, Nothing)
  40. ' dgv2.CausesValidation = False
  41. ' DGV1.ReadOnly = True
  42. ' 'Me.MdiParent = mdiForm
  43. ' colorArray(0) = Color.FromName("Aquamarine")
  44. ' colorArray(1) = Color.FromName("azure")
  45. ' colorArray(2) = Color.FromName("beige")
  46. ' colorArray(3) = Color.FromName("gainsboro")
  47. ' colorArray(4) = Color.FromName("LightBlue")
  48. ' colorArray(5) = Color.FromName("LightSalmon")
  49. ' Button17.Visible = False
  50. ' dgv2.RowTemplate.Height = 30
  51. ' conn.ConnectionString = connstring
  52. ' con.ConnectionString = connstring
  53. ' con.Open()
  54. ' DGV1.RowTemplate.Height = 30
  55. ' DataGridView1.RowTemplate.Height = 30
  56. ' '’ DataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill
  57. ' DataGridView1.AutoResizeRows(DataGridViewAutoSizeRowsMode.AllCells)
  58. ' ' DataGridView1.RowTemplate.Height = 30
  59. ' cmd.Connection = conn
  60. ' 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"
  61. ' cmd.Connection = conn
  62. ' cmd.CommandText = sql_rcp
  63. ' da.SelectCommand = cmd
  64. ' da.Fill(ds)
  65. ' DGV1.DataSource = ds.Tables(0)
  66. ' set_grid()
  67. ' dgv2.GridColor = Color.White
  68. ' dgv2.AllowUserToAddRows = False
  69. ' dgv2.SelectionMode = DataGridViewSelectionMode.FullRowSelect
  70. ' con.Close()
  71. ' dgv_record.GridColor = Color.White
  72. ' dgv_record.AllowUserToAddRows = False
  73. ' dgv_record.SelectionMode = DataGridViewSelectionMode.FullRowSelect
  74. ' ' dgv2.Columns(2).Visible = False
  75. ' ' dgv2.Columns(1).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight
  76. ' RefreshDgv1()
  77. ' DGV1.Columns(0).Width = 120
  78. ' DGV1.Columns(1).Width = 250
  79. ' DGV1.Columns(2).Width = 120
  80. ' DGV1.Columns(3).Width = 100
  81. ' DGV1.Columns(4).Width = 250
  82. ' DGV1.Columns(5).Width = 300
  83. ' DGV1.Columns(6).Visible = False
  84. ' DGV1.RowHeadersWidth = 30
  85. ' DataGridView1.RowHeadersWidth = 30
  86. ' DataGridView1.RowTemplate.Height = 30
  87. ' End Sub
  88. ' Dim dt1 As New DataTable
  89. ' Dim gWeight() As Double
  90. ' Dim gCoin() As String
  91. ' Dim gPrice() As Double
  92. ' Dim rr As String = ""
  93. ' Dim rcp_name As String = ""
  94. ' Dim gAddfromOther As Boolean = False
  95. ' Dim da As New SqlDataAdapter()
  96. ' Dim dr As SqlDataReader
  97. ' Dim conn As New SqlConnection
  98. ' Dim dt As New System.Data.DataTable
  99. ' Dim ds As New DataSet()
  100. ' Dim cmd As New SqlCommand
  101. ' Dim sql_rcp As String
  102. ' Dim sql_print As String
  103. ' Dim con As New SqlConnection
  104. ' 'Dim msg As String = ""
  105. ' Dim colorArray(10) As Color
  106. ' Dim card As String = ""
  107. ' Dim cust As String = ""
  108. ' Dim wb_weight As Double = 0
  109. ' Dim thickness As String = ""
  110. ' Dim r_type As String = ""
  111. ' Dim source As String = ""
  112. ' Dim comment As String = ""
  113. ' Dim dt_print As DataTable
  114. ' Dim color1 As String = ""
  115. ' Dim DT2 As New DataTable
  116. ' Sub ExportToExcel()
  117. ' ' 获取输入信息
  118. ' Dim my_card As String = InputBox("请输入卡号:", "查询")
  119. ' If my_card = "" Then
  120. ' MsgBox("操作已取消。", vbInformation, "退出")
  121. ' Exit Sub
  122. ' End If
  123. ' Dim my_weight As Double = 0
  124. ' Dim weightInput As String = InputBox("请输入重量:", "查询")
  125. ' If weightInput = "" OrElse Not IsNumeric(weightInput) OrElse CDbl(weightInput) <= 0 Then
  126. ' MsgBox("请输入有效的重量!", vbExclamation, "错误")
  127. ' Exit Sub
  128. ' Else
  129. ' my_weight = CDbl(weightInput)
  130. ' End If
  131. ' Dim d_no As String = InputBox("请输入编号:", "查询")
  132. ' If d_no = "" Then
  133. ' MsgBox("操作已取消。", vbInformation, "退出")
  134. ' Exit Sub
  135. ' End If
  136. ' ' 创建一个新的工作簿
  137. ' Dim workbook As New XSSFWorkbook()
  138. ' Dim sheet As ISheet = workbook.CreateSheet("Sheet1")
  139. ' ' 数据示例(例如 DataGridView1 的行数据)
  140. ' Dim rowIndex As Integer = 0
  141. ' For x As Integer = 0 To DataGridView1.Rows.Count - 2
  142. ' If DataGridView1.Rows(x).Cells("类别").Value <> "不列印" Then
  143. ' Dim row As IRow = sheet.CreateRow(rowIndex)
  144. ' row.CreateCell(0).SetCellValue("卡号: " & my_card)
  145. ' row.CreateCell(1).SetCellValue("编号: " & d_no)
  146. ' row.CreateCell(2).SetCellValue("重量: " & my_weight)
  147. ' rowIndex += 1
  148. ' ' 插入图片(假设图片路径在 p 数组中)
  149. ' Dim pictureData As Byte() = File.ReadAllBytes("c:\GHS\1.jpg")
  150. ' Dim pictureIndex As Integer = workbook.AddPicture(pictureData, PictureType.JPEG)
  151. ' ' 创建 DrawingPatriarch
  152. ' ' Dim drawing As IDrawingPatriarch = sheet.CreateDrawingPatriarch()
  153. ' Dim drawing As XSSFDrawing = CType(sheet.CreateDrawingPatriarch(), XSSFDrawing)
  154. ' Dim anchor As IClientAnchor = workbook.GetCreationHelper().CreateClientAnchor()
  155. ' anchor.Col1 = 3 ' 图片插入列
  156. ' anchor.Row1 = rowIndex ' 图片插入行
  157. ' ' 插入图片
  158. ' drawing.CreatePicture(anchor, pictureIndex)
  159. ' rowIndex += 1
  160. ' End If
  161. ' Next
  162. ' ' 设置输出文件路径
  163. ' Dim outputPath As String = "C:\path\to\your\output.xlsx"
  164. ' Using fs As New FileStream(outputPath, FileMode.Create, FileAccess.Write)
  165. ' workbook.Write(fs)
  166. ' End Using
  167. ' MsgBox("输出完成")
  168. ' End Sub
  169. ' Private Sub frm_01hf_RetanRcp_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  170. ' End Sub
  171. ' Private Sub ini_content()
  172. ' 'card = FrmWB_OUT.DGV1.Rows(FrmWB_OUT.DGV1.CurrentRow.Index).Cells("卡号").Value
  173. ' 'cust = FrmWB_OUT.DGV1.Rows(FrmWB_OUT.DGV1.CurrentRow.Index).Cells("客户").Value
  174. ' 'wb_weight = FrmWB_OUT.DGV1.Rows(FrmWB_OUT.DGV1.CurrentRow.Index).Cells("皮重").Value
  175. ' 'thickness = FrmWB_OUT.DGV1.Rows(FrmWB_OUT.DGV1.CurrentRow.Index).Cells("厚度").Value
  176. ' 'source = FrmWB_OUT.DGV1.Rows(FrmWB_OUT.DGV1.CurrentRow.Index).Cells("皮源").Value
  177. ' 'comment = FrmWB_OUT.DGV1.Rows(FrmWB_OUT.DGV1.CurrentRow.Index).Cells("备注").Value.ToString
  178. ' 'color1 = FrmWB_OUT.DGV1.Rows(FrmWB_OUT.DGV1.CurrentRow.Index).Cells("颜色").Value
  179. ' End Sub
  180. ' Private Sub Button22_Click(sender As Object, e As EventArgs) Handles Button22.Click
  181. ' ini_content()
  182. ' Dim xlApp As Microsoft.Office.Interop.Excel.Application
  183. ' Dim xlBook As Microsoft.Office.Interop.Excel.Workbook
  184. ' Dim xlSheet As Microsoft.Office.Interop.Excel.Worksheet
  185. ' Dim my_card As String = InputBox("请输入卡号", "询问", DGV1.Rows(DGV1.CurrentRow.Index).Cells("流程卡号").Value)
  186. ' Dim my_weight As Double = InputBox("请输入重量", "询问", DGV1.Rows(DGV1.CurrentRow.Index).Cells("重量").Value)
  187. ' Dim my_selection As String = InputBox("请输入选级", "询问", DGV1.Rows(DGV1.CurrentRow.Index).Cells("选级").Value)
  188. ' 'frm_01hf_RetanRcp_WB.ShowDialog()
  189. ' Dim d_no As String = InputBox("请输入鼓号", "询问")
  190. ' 'frm_01hf_RetanRcp_WB.ShowDialog()
  191. ' xlApp = CreateObject("Excel.Application")
  192. ' xlBook = xlApp.Workbooks.Add
  193. ' xlApp.DisplayAlerts = False
  194. ' xlBook.Activate()
  195. ' xlBook.Parent.Windows(1).Visible = True
  196. ' xlSheet = xlBook.Worksheets.Add
  197. ' xlSheet.Activate()
  198. ' xlApp.Visible = True
  199. ' xlApp.Application.ScreenUpdating = False
  200. ' editFormat(xlApp, xlSheet)
  201. ' xlApp.Visible = False
  202. ' xlSheet.Cells(1, 1) = "流程卡号"
  203. ' xlSheet.Cells(2, 1) = "打印日期"
  204. ' xlSheet.Cells(3, 1) = "皮源"
  205. ' xlSheet.Cells(1, 7) = "工艺名稱"
  206. ' xlSheet.Cells(2, 6) = "規格"
  207. ' xlSheet.Cells(2, 10) = "鼓号"
  208. ' xlSheet.Cells(1, 12) = "染色日期"
  209. ' xlSheet.Cells(2, 12) = "重量"
  210. ' xlSheet.Cells(3, 7) = "备注"
  211. ' xlSheet.Cells(2, 12) = "重量"
  212. ' xlSheet.Cells(3, 4) = comment
  213. ' ' xlSheet.Cells(1, 4) = DGV1.Rows(DGV1.CurrentRow.Index).Cells("處方編號").Value
  214. ' xlSheet.Cells(2, 4) = String.Format("{0:d}", DateTime.Now)
  215. ' xlSheet.Cells(1, 10) = cust & " " & color1 & "--" & DGV1.Rows(DGV1.CurrentRow.Index).Cells("品名").Value
  216. ' 'xlSheet.Cells(2, 10) = frm_01hf_RetanRcp_WB.ListBox6.SelectedItem
  217. ' 'xlSheet.Cells(2, 11) = frm_01hf_RetanRcp_WB.ListBox5.SelectedItem
  218. ' xlSheet.Cells(2, 7) = thickness
  219. ' xlSheet.Cells(2, 11) = d_no
  220. ' xlSheet.Cells(2, 14) = my_weight & " 公斤"
  221. ' xlSheet.Cells(1, 4) = my_card
  222. ' xlSheet.Cells(3, 4) = my_selection
  223. ' xlSheet.Cells(3, 10) = comment
  224. ' xlSheet.Cells(5, 3) = "百分比"
  225. ' xlSheet.Cells(5, 5) = "用量(Kgs)"
  226. ' xlSheet.Cells(5, 6) = "化 料 名 稱"
  227. ' xlSheet.Cells(5, 9) = "时间"
  228. ' xlSheet.Cells(5, 10) = "備註"
  229. ' xlSheet.Rows("5:5").Select()
  230. ' xlApp.Selection.Font.Underline = xlUnderlineStyleSingle
  231. ' For i As Integer = 0 To DataGridView1.Rows.Count - 1
  232. ' xlSheet.Cells(i + 6, 3) = Math.Round(Val(DataGridView1.Rows(i).Cells("百分比").Value), 2)
  233. ' xlSheet.Cells(i + 6, 4) = "%"
  234. ' xlSheet.Cells(i + 6, 5) = Math.Round(DataGridView1.Rows(i).Cells("百分比").Value * my_weight / 100, 2)
  235. ' xlSheet.Cells(i + 6, 6) = DataGridView1.Rows(i).Cells("化料名称").Value
  236. ' xlSheet.Cells(i + 6, 9) = DataGridView1.Rows(i).Cells("时间").Value
  237. ' xlSheet.Cells(i + 6, 10) = DataGridView1.Rows(i).Cells("备注").Value
  238. ' xlSheet.Cells(i + 6, 10).Select()
  239. ' With xlApp.Selection
  240. ' .Font.Bold = True
  241. ' End With
  242. ' 'xlSheet.Cells(i + 6, 11) = datagridview1.Rows(i).Cells("幣別").Value
  243. ' 'xlSheet.Cells(i + 6, 12) = datagridview1.Rows(i).Cells("單價").Value
  244. ' 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
  245. ' xlSheet.Rows(i + 5 & ":" & i + 5).Select()
  246. ' With xlApp.Selection.Borders(xlEdgeBottom)
  247. ' .LineStyle = xlNone
  248. ' End With
  249. ' xlSheet.Rows(i + 6 & ":" & i + 6).Select()
  250. ' With xlApp.Selection.Borders(xlEdgeBottom)
  251. ' .LineStyle = xlDash
  252. ' .Weight = xlHairline
  253. ' End With
  254. ' xlSheet.Cells(i + 6, 3) = ""
  255. ' xlSheet.Cells(i + 6, 4) = ""
  256. ' xlSheet.Cells(i + 6, 5) = ""
  257. ' End If
  258. ' If DataGridView1.Rows(i).Cells("时间").Value <> "" Then
  259. ' xlSheet.Rows(i + 6 & ":" & i + 6).Select()
  260. ' With xlApp.Selection.Borders(xlEdgeBottom)
  261. ' .LineStyle = xlContinuous
  262. ' .Weight = xlMaximum
  263. ' End With
  264. ' End If
  265. ' Next i
  266. ' Dim a As Integer = xlApp.Workbooks(1).Worksheets(1).UsedRange.Rows.Count
  267. ' Dim b As Integer = xlApp.Workbooks(1).Worksheets(1).UsedRange.Columns.Count
  268. ' Dim area As String = "A4" & ":" & Chr(b + 64) & a
  269. ' xlSheet.Range(area).Font.Size = 10
  270. ' xlSheet.Range(area).Font.Name = "Times New Roman"
  271. ' xlApp.Selection.Font.Name = "Times New Roman"
  272. ' 'xlSheet.Columns("A:O").Select()
  273. ' 'With xlApp.Selection
  274. ' ' .HorizontalAlignment = Microsoft.Office.Interop.Excel.Constants.xlCenter
  275. ' ' .VerticalAlignment = Microsoft.Office.Interop.Excel.Constants.xlCenter
  276. ' ' .WrapText = False
  277. ' ' .Orientation = 0
  278. ' ' .AddIndent = False
  279. ' ' .IndentLevel = 0
  280. ' ' .ShrinkToFit = False
  281. ' ' .ReadingOrder = Microsoft.Office.Core.XlReadingOrder.xlContext
  282. ' 'End With
  283. ' xlSheet.Cells(3, 4).Select()
  284. ' With xlApp.Selection
  285. ' .HorizontalAlignment = Microsoft.Office.Interop.Excel.Constants.xlLeft
  286. ' End With
  287. ' For x As Integer = 6 To a
  288. ' If xlSheet.Cells(x, 9).value Is Nothing And xlSheet.Cells(x, 6).value Is Nothing Then
  289. ' xlSheet.Rows(x).RowHeight = 3
  290. ' ' aa = aa + 1
  291. ' Else
  292. ' xlSheet.Rows(x).RowHeight = 18
  293. ' End If
  294. ' Next x
  295. ' xlSheet.Range("a:a").HorizontalAlignment = Microsoft.Office.Interop.Excel.Constants.xlCenter
  296. ' xlSheet.Range("c:c").HorizontalAlignment = Microsoft.Office.Interop.Excel.Constants.xlRight
  297. ' xlSheet.Range("e:e ").HorizontalAlignment = Microsoft.Office.Interop.Excel.Constants.xlCenter
  298. ' xlSheet.Range("g:g").HorizontalAlignment = Microsoft.Office.Interop.Excel.Constants.xlCenter
  299. ' xlSheet.Range("c:c").NumberFormatLocal = "G/通用格式"
  300. ' With xlApp.ActiveSheet.PageSetup
  301. ' .PrintTitleRows = ""
  302. ' .PrintTitleColumns = ""
  303. ' End With
  304. ' xlSheet.PageSetup.PrintArea = ""
  305. ' With xlApp.ActiveSheet.PageSetup
  306. ' .TopMargin = xlApp.InchesToPoints(0.2)
  307. ' .BottomMargin = xlApp.InchesToPoints(0)
  308. ' .LeftMargin = xlApp.InchesToPoints(0)
  309. ' .RightMargin = xlApp.InchesToPoints(0)
  310. ' .HeaderMargin = xlApp.InchesToPoints(0.511811023622047)
  311. ' .FooterMargin = xlApp.InchesToPoints(0.511811023622047)
  312. ' '.PaperSize = Microsoft.Office.Interop.Excel.XlPaperSize.xlPaperA4
  313. ' .Zoom = False
  314. ' .FitToPagesWide = 1
  315. ' .FitToPagesTall = 1
  316. ' .PrintErrors = Microsoft.Office.Interop.Excel.XlPrintErrors.xlPrintErrorsDisplayed
  317. ' End With
  318. ' xlApp.Cells.Select()
  319. ' With xlApp.Selection.Font
  320. ' .Name = "Times New Roman"
  321. ' End With
  322. ' xlSheet.Range("f:f").HorizontalAlignment = Microsoft.Office.Interop.Excel.Constants.xlLeft
  323. ' xlSheet.Range("j:j").HorizontalAlignment = Microsoft.Office.Interop.Excel.Constants.xlLeft
  324. ' xlSheet.Range("a1:o3").HorizontalAlignment = Microsoft.Office.Interop.Excel.Constants.xlCenter
  325. ' xlApp.Visible = True
  326. ' xlApp.Application.ScreenUpdating = True
  327. ' MsgBox("打印完成")
  328. ' End Sub
  329. ' Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  330. ' gMsg = MsgBox("要插入前方列請按--是" & vbCrLf & "要插入後方列請按--否" & vbCrLf & "或按取消離開", MsgBoxStyle.YesNoCancel)
  331. ' If gMsg <> MsgBoxResult.Cancel Then
  332. ' FrmEditChem_Choose.ShowDialog()
  333. ' set_grid1()
  334. ' End If
  335. ' End Sub
  336. ' Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
  337. ' If Not (DataGridView1.Rows(DataGridView1.CurrentRow.Index).DefaultCellStyle.Font Is Nothing) Then
  338. ' If DataGridView1.Rows(DataGridView1.CurrentRow.Index).DefaultCellStyle.Font.Style = FontStyle.Strikeout Then
  339. ' DataGridView1.Rows(DataGridView1.CurrentRow.Index).DefaultCellStyle.Font = New Font(DataGridView1.DefaultCellStyle.Font, FontStyle.Regular)
  340. ' Else
  341. ' DataGridView1.Rows(DataGridView1.CurrentRow.Index).DefaultCellStyle.Font = New Font(DataGridView1.DefaultCellStyle.Font, FontStyle.Strikeout)
  342. ' End If
  343. ' Else
  344. ' DataGridView1.Rows(DataGridView1.CurrentRow.Index).DefaultCellStyle.Font = New Font(DataGridView1.DefaultCellStyle.Font, FontStyle.Strikeout)
  345. ' End If
  346. ' Label1.Text = "修改模式"
  347. ' Timer1.Enabled = True
  348. ' cmdSaveEdit.Visible = True
  349. ' cmdCancelEdit.Visible = True
  350. ' End Sub
  351. ' Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
  352. ' If DataGridView1.SelectedRows.Count = 0 Then
  353. ' MsgBox("請先選擇要修改的項目")
  354. ' Exit Sub
  355. ' End If
  356. ' Label1.Text = "修改模式"
  357. ' Timer1.Enabled = True
  358. ' Dim f2 As New FrmEditChem_Choose
  359. ' f2.Owner = Me
  360. ' f2.ShowDialog()
  361. ' ' FrmEditChem_Choose.ShowDialog()
  362. ' cmdSaveEdit.Visible = True
  363. ' cmdCancelEdit.Visible = True
  364. ' DataGridView1.Rows(DataGridView1.CurrentRow.Index).Cells("化料名称").Value = my_chem
  365. ' DataGridView1.Focus()
  366. ' End Sub
  367. ' Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
  368. ' If con.State = ConnectionState.Closed Then
  369. ' con.Open()
  370. ' End If
  371. ' Dim rcp1 As String = ""
  372. ' rcp1 = TextBox18.Text
  373. ' ' rcp1 = InputBox("請輸入要查詢的處方編號或處方名稱")
  374. ' If rcp1 = "" Then Exit Sub
  375. ' 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"
  376. ' 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"
  377. ' cmd.Connection = con
  378. ' cmd.CommandText = sql_rcp
  379. ' da.SelectCommand = cmd
  380. ' Dim dt As New DataTable
  381. ' da.Fill(dt)
  382. ' DGV1.DataSource = dt
  383. ' con.Close()
  384. ' 'DGV1.Columns(0).Width = 280
  385. ' 'DGV1.Columns(1).Width = 140
  386. ' Dim c As Integer = 1
  387. ' Dim p(200) As Integer
  388. ' Dim x As Integer
  389. ' p(1) = 0
  390. ' For x = 1 To DGV1.Rows.Count - 2
  391. ' If DGV1.Rows(x).Cells(0).Value.ToString <> DGV1.Rows(x - 1).Cells(0).Value.ToString Then
  392. ' p(c + 1) = x
  393. ' c = c + 1
  394. ' End If
  395. ' Next
  396. ' p(c + 1) = x
  397. ' ReDim Preserve p(x)
  398. ' If c = 1 Then
  399. ' For z As Integer = 0 To x - 1
  400. ' DGV1.Rows(z).DefaultCellStyle.BackColor = colorArray(1)
  401. ' Next
  402. ' Else
  403. ' For cc As Integer = 1 To c
  404. ' For z As Integer = p(cc) To p(cc + 1) - 1
  405. ' DGV1.Rows(z).DefaultCellStyle.BackColor = colorArray(cc Mod 5)
  406. ' Next
  407. ' Next
  408. ' End If
  409. ' 'DGV1.Columns(0).Width = 170
  410. ' 'DGV1.Columns(1).Width = 100
  411. ' 'DGV1.Columns(3).Width = 70
  412. ' 'DGV1.Columns(4).Width = 150
  413. ' 'DGV1.RowHeadersWidth = 30
  414. ' 'DataGridView1.RowHeadersWidth = 30
  415. ' 'DataGridView1.RowTemplate.Height = 26
  416. ' End Sub
  417. ' Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click
  418. ' Dim con As New SqlConnection
  419. ' Dim sql As String
  420. ' Dim dr As SqlDataReader
  421. ' con.ConnectionString = connstring
  422. ' con.Open()
  423. ' cmd.Connection = con
  424. ' dgv2.Visible = False
  425. ' ListBox2.Visible = True
  426. ' ListBox3.Visible = True
  427. ' ListBox4.Visible = True
  428. ' TextBox2.Visible = True
  429. ' TextBox3.Visible = True
  430. ' TextBox4.Visible = True
  431. ' Button11.Visible = True
  432. ' Button12.Visible = True
  433. ' Button13.Visible = True
  434. ' Button14.Visible = True
  435. ' Button15.Visible = True
  436. ' sql = "select cust_name from customer order by cust_name"
  437. ' cmd.CommandText = sql
  438. ' dr = cmd.ExecuteReader
  439. ' While dr.Read
  440. ' ListBox2.Items.Add(dr("cust_name"))
  441. ' End While
  442. ' dr.Close()
  443. ' sql = "select prod_name from tblproduct order by prod_name"
  444. ' cmd.CommandText = sql
  445. ' dr = cmd.ExecuteReader
  446. ' While dr.Read
  447. ' ListBox3.Items.Add(dr("prod_name"))
  448. ' End While
  449. ' dr.Close()
  450. ' sql = "select color_name from color order by color_name"
  451. ' cmd.CommandText = sql
  452. ' dr = cmd.ExecuteReader
  453. ' While dr.Read
  454. ' ListBox4.Items.Add(dr("color_name"))
  455. ' End While
  456. ' dr.Close()
  457. ' Timer1.Enabled = True
  458. ' End Sub
  459. ' Private Sub TextBox2_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs)
  460. ' Dim con As New SqlConnection
  461. ' Dim sql As String
  462. ' Dim dr As SqlDataReader
  463. ' con.ConnectionString = connstring
  464. ' con.Open()
  465. ' cmd.Connection = con
  466. ' ListBox2.Items.Clear()
  467. ' sql = "select cust_name from customer where cust_name like '%" & TextBox2.Text & "%'"
  468. ' cmd.CommandText = sql
  469. ' dr = cmd.ExecuteReader
  470. ' While dr.Read
  471. ' ListBox2.Items.Add(dr("cust_name"))
  472. ' End While
  473. ' dr.Close()
  474. ' If e.KeyCode = Keys.Enter Then
  475. ' If ListBox2.Items.Count = 0 Then Exit Sub
  476. ' ListBox2.Focus()
  477. ' ListBox2.SelectedIndex = 1
  478. ' End If
  479. ' End Sub
  480. ' Private Sub TextBox3_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs)
  481. ' Dim con As New SqlConnection
  482. ' Dim sql As String
  483. ' Dim dr As SqlDataReader
  484. ' con.ConnectionString = connstring
  485. ' con.Open()
  486. ' cmd.Connection = con
  487. ' ListBox3.Items.Clear()
  488. ' sql = "select prod_name from tblproduct where prod_name like '%" & TextBox3.Text & "%'"
  489. ' cmd.CommandText = sql
  490. ' dr = cmd.ExecuteReader
  491. ' While dr.Read
  492. ' ListBox3.Items.Add(dr("prod_name"))
  493. ' End While
  494. ' dr.Close()
  495. ' If e.KeyCode = Keys.Enter Then
  496. ' If ListBox3.Items.Count = 0 Then Exit Sub
  497. ' ListBox3.Focus()
  498. ' ListBox3.SelectedIndex = 1
  499. ' End If
  500. ' End Sub
  501. ' Private Sub TextBox4_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs)
  502. ' Dim con As New SqlConnection
  503. ' Dim sql As String
  504. ' Dim dr As SqlDataReader
  505. ' con.ConnectionString = connstring
  506. ' con.Open()
  507. ' cmd.Connection = con
  508. ' ListBox4.Items.Clear()
  509. ' sql = "select color_name from color where color_name like '%" & TextBox4.Text & "%'"
  510. ' cmd.CommandText = sql
  511. ' dr = cmd.ExecuteReader
  512. ' While dr.Read
  513. ' ListBox4.Items.Add(dr("color_name"))
  514. ' End While
  515. ' dr.Close()
  516. ' If e.KeyCode = Keys.Enter Then
  517. ' If ListBox3.Items.Count = 0 Then Exit Sub
  518. ' ListBox4.Focus()
  519. ' ListBox4.SelectedIndex = 1
  520. ' End If
  521. ' End Sub
  522. ' Private Sub Button14_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
  523. ' If ListBox2.SelectedIndex = -1 Or ListBox2.SelectedIndex = -1 Or ListBox2.SelectedIndex = -1 Then
  524. ' MsgBox("請先選擇客戶產品顏色", , "錯誤")
  525. ' Exit Sub
  526. ' End If
  527. ' Dim sql As String = ""
  528. ' Dim con As New SqlConnection
  529. ' Dim rcp_no As String = ""
  530. ' Dim cust_no As String = ""
  531. ' Dim prod_id As String = ""
  532. ' Dim color_no As String = ""
  533. ' con.ConnectionString = connstring
  534. ' con.Open()
  535. ' cmd.Connection = con
  536. ' sql = "select id from customer where cust_name='" & ListBox2.SelectedItem & "'"
  537. ' cmd.CommandText = sql
  538. ' cust_no = cmd.ExecuteScalar
  539. ' sql = "select prod_id from tblproduct where prod_name='" & ListBox3.SelectedItem & "'"
  540. ' cmd.CommandText = sql
  541. ' prod_id = cmd.ExecuteScalar
  542. ' sql = "select color_no from color where color_name='" & ListBox4.SelectedItem & "'"
  543. ' cmd.CommandText = sql
  544. ' color_no = cmd.ExecuteScalar
  545. ' 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 & "'"
  546. ' cmd.CommandText = sql
  547. ' Dim c As Integer = cmd.ExecuteScalar
  548. ' If c = 0 Then
  549. ' rr = prod_id & String.Format("{0:D2}", c) & String.Format("{0:D3}", cust_no) & color_no
  550. ' Else
  551. ' rr = prod_id & String.Format("{0:D2}", c + 1) & String.Format("{0:D3}", cust_no) & color_no
  552. ' End If
  553. ' sql = "select count(*) from " & rcp & " where rcp_no='" & rr & "'"
  554. ' cmd.CommandText = sql
  555. ' c = cmd.ExecuteScalar
  556. ' rcp_name = ListBox2.SelectedItem & ListBox4.SelectedItem & ListBox3.SelectedItem
  557. ' rcp_name = InputBox("處方名稱", "詢問", rcp_name)
  558. ' sql = "select count(*) from " & rcp & " where rcp_no='" & rr & "'"
  559. ' cmd.CommandText = sql
  560. ' Dim a As Integer = cmd.ExecuteScalar
  561. ' If a = 0 Then
  562. ' 'sql = "insert into " & rcp & " (rcp_no,rcp_name,creat_d) values ( '" & rcp_no & "','" & rcp_name & "','" & Now & "')"
  563. ' 'cmd.CommandText = sql
  564. ' 'Dim b As Integer = cmd.ExecuteScalar()
  565. ' 'If b <> 0 Then
  566. ' ' MsgBox("新增處方完成")
  567. ' ' Exit Sub
  568. ' 'End If
  569. ' Else
  570. ' MsgBox("處方編號重覆")
  571. ' gAddfromOther = False
  572. ' Exit Sub
  573. ' End If
  574. ' Dim msg As MsgBoxResult
  575. ' msg = MsgBox("是否要由其他處方修改?", vbYesNoCancel, "詢問")
  576. ' gAddfromOther = True
  577. ' Dim my_rcp As String = ""
  578. ' my_rcp = InputBox("請輸入處方編號")
  579. ' If my_rcp = "" Then Exit Sub
  580. ' 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 & "%'"
  581. ' cmd.CommandText = sql_rcp
  582. ' da.SelectCommand = cmd
  583. ' Dim ds As New DataSet
  584. ' da.Fill(ds)
  585. ' DGV1.DataSource = ds.Tables(0)
  586. ' Timer1.Enabled = True
  587. ' con.Close()
  588. ' End Sub
  589. ' Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
  590. ' If Label1.Visible = True Then
  591. ' Label1.Visible = False
  592. ' Else
  593. ' Label1.Visible = True
  594. ' End If
  595. ' End Sub
  596. ' Private Sub cmdAddrcp_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdAddrcp.Click
  597. ' If conn.State = ConnectionState.Closed Then
  598. ' conn.Open()
  599. ' End If
  600. ' Dim sql As String = ""
  601. ' sql = "insert into " & rcp & " (rcp_no,rcp_name,creat_d) values ( '" & rr & "','" & rcp_name & "','" & String.Format("{0:d}", DateTime.Now) & "')"
  602. ' cmd.CommandText = sql
  603. ' cmd.Connection = conn
  604. ' Dim b As Integer = cmd.ExecuteNonQuery
  605. ' If b <> 0 Then
  606. ' MsgBox("已新增處方編號:" & rr & vbCrLf & " 處方名稱:" & rcp_name)
  607. ' Else
  608. ' MsgBox("新增處方失敗")
  609. ' End If
  610. ' Dim dt As DataTable
  611. ' dt = dgv2.DataSource
  612. ' 'For x As Integer = 0 To dt.Rows.Count - 1
  613. ' ' 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 & "')"
  614. ' ' cmd.ExecuteNonQuery()
  615. ' 'Next
  616. ' For x As Integer = 0 To dt.Rows.Count - 1
  617. ' 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 & "')"
  618. ' cmd.ExecuteNonQuery()
  619. ' 'cmd.CommandText = "insert into rcp_content (item,matl_no,percents,rcp_no,time,comment) values ('03','X613','1','E00250WD','20','停40轉20停40')"
  620. ' 'cmd.ExecuteNonQuery()
  621. ' Next
  622. ' cmdAddrcp.Visible = False
  623. ' cmdcanceladd.Visible = False
  624. ' Timer1.Enabled = False
  625. ' Label1.Visible = False
  626. ' conn.Close()
  627. ' End Sub
  628. ' Private Sub Button15_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
  629. ' dgv2.Visible = True
  630. ' ListBox2.Visible = False
  631. ' ListBox3.Visible = False
  632. ' ListBox4.Visible = False
  633. ' TextBox2.Visible = False
  634. ' TextBox3.Visible = False
  635. ' TextBox4.Visible = False
  636. ' Button11.Visible = False
  637. ' Button12.Visible = False
  638. ' Button13.Visible = False
  639. ' Button14.Visible = False
  640. ' Button15.Visible = False
  641. ' Button17.Visible = False
  642. ' cmdAddrcp.Visible = False
  643. ' cmdcanceladd.Visible = False
  644. ' Timer1.Enabled = False
  645. ' Label1.Visible = False
  646. ' End Sub
  647. ' Private Sub Button9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) '打印标签
  648. ' ' ini_content() '取得卡号等相关资讯
  649. ' Dim xlApp As Microsoft.Office.Interop.Excel.Application
  650. ' Dim xlBook As Microsoft.Office.Interop.Excel.Workbook
  651. ' Dim xlSheet As Microsoft.Office.Interop.Excel.Worksheet
  652. ' Dim folderPath As String = "\\DS920plus\华峰业务\AA化料文件资料\2024年整理MSDS和ZDHC\MSDS\MSDS总表"
  653. ' Dim my_card As String
  654. ' Dim my_weight As Double
  655. ' Dim d_no As String
  656. ' Do
  657. ' my_card = InputBox("请输入卡号:", "查询")
  658. ' If my_card = "" Then
  659. ' MsgBox("操作已取消。", vbInformation, "退出")
  660. ' Exit Sub ' 立即退出子程序
  661. ' ElseIf my_card = "" Then
  662. ' MsgBox("请重新输入!", vbExclamation, "错误")
  663. ' Else
  664. ' Exit Do
  665. ' End If
  666. ' Loop
  667. ' ' 验证重量输入
  668. ' Do
  669. ' Dim weightInput As String
  670. ' weightInput = InputBox("请输入重量:", "查询")
  671. ' If weightInput = "" Then
  672. ' MsgBox("操作已取消。", vbInformation, "退出")
  673. ' Exit Sub
  674. ' ElseIf Not IsNumeric(weightInput) Then
  675. ' MsgBox("重量必须是数字,请重新输入!", vbExclamation, "错误")
  676. ' ElseIf CDbl(weightInput) <= 0 Then
  677. ' MsgBox("重量必须大于0,请重新输入!", vbExclamation, "错误")
  678. ' Else
  679. ' my_weight = CDbl(weightInput)
  680. ' Exit Do
  681. ' End If
  682. ' Loop
  683. ' ' 验证编号输入
  684. ' Do
  685. ' d_no = InputBox("请输入编号:", "查询")
  686. ' If d_no = "" Then
  687. ' MsgBox("操作已取消。", vbInformation, "退出")
  688. ' Exit Sub
  689. ' ElseIf d_no Like "*-*" Then
  690. ' ' MsgBox("编号格式不正确,请输入类似 'P241129-4' 的编号!", vbExclamation, "错误")
  691. ' Else
  692. ' Exit Do
  693. ' End If
  694. ' Loop
  695. ' 'frm_01hf_RetanRcp_WB.ShowDialog()
  696. ' xlApp = CreateObject("Excel.Application")
  697. ' xlBook = xlApp.Workbooks.Add
  698. ' xlApp.DisplayAlerts = False
  699. ' xlBook.Activate()
  700. ' xlBook.Parent.Windows(1).Visible = True
  701. ' xlSheet = xlBook.Worksheets.Add
  702. ' xlSheet.Activate()
  703. ' xlApp.Visible = True
  704. ' ' DT2.DefaultView.Sort = "分类 "
  705. ' 'dt = dt.DefaultView.ToTable()
  706. ' Dim xx As Integer = 0
  707. ' Dim y As Integer = 0
  708. ' Dim p(10) As String
  709. ' p(1) = "c:\GHS\1.jpg"
  710. ' p(2) = "c:\GHS\2.jpg"
  711. ' p(3) = "c:\GHS\3.jpg"
  712. ' p(4) = "c:\GHS\4.jpg"
  713. ' p(5) = "c:\GHS\5.jpg"
  714. ' p(6) = "c:\GHS\6.jpg"
  715. ' p(7) = "c:\GHS\7.jpg"
  716. ' p(8) = "c:\GHS\8.jpg"
  717. ' p(9) = "c:\GHS\9.jpg"
  718. ' Dim FILE_NAME As String
  719. ' Dim FILE_NAME1 As String
  720. ' 'Dim obj As New FolderBrowserDialog
  721. ' Dim sPath As String
  722. ' sPath = "c:\GHS\"
  723. ' Dim dt As DataTable = CType(DataGridView1.DataSource, DataTable)
  724. ' Dim dv As DataView = dt.DefaultView
  725. ' dv.Sort = "类别 ASC, 项次 ASC"
  726. ' ' 重新绑定排序后的 DataView
  727. ' DataGridView1.DataSource = dv
  728. ' ' DataGridView1.Sort(DataGridView1.Columns("类别"), ListSortDirection.Ascending)
  729. ' Dim zzz As Integer = 0
  730. ' For x As Integer = 0 To DataGridView1.Rows.Count - 2 '---迴圈
  731. ' If (DataGridView1.Rows(x).Cells("类别").Value <> "不列印") Then
  732. ' If Not (DataGridView1.Rows(x).DefaultCellStyle.Font Is Nothing) Then
  733. ' GoTo ok11
  734. ' End If
  735. ' ' 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))
  736. ' PictureBox1.Image = MakeQrCode("http://192.168.110.164:8888/" & DataGridView1.Rows(x).Cells("filename").Value)
  737. ' System.Windows.Forms.Clipboard.SetDataObject(PictureBox1.Image, True) '---------------------------------------复制到剪贴板 二维码
  738. ' If System.Windows.Forms.Clipboard.ContainsImage() Then
  739. ' Console.WriteLine("剪贴板包含有效的图片数据")
  740. ' Else
  741. ' Console.WriteLine("剪贴板中没有图片数据")
  742. ' End If
  743. ' System.Threading.Thread.Sleep(200)
  744. ' Dim range2 As Excel.Range = xlSheet.Range(xlApp.Cells(y * 13 + 9, 4), xlApp.Cells(y * 13 + 9, 4)) '粘贴图片的位置 二维码
  745. ' xlSheet.Paste(range2, PictureBox1.Image)
  746. ' Dim shape As Excel.Shape = xlApp.Selection.ShapeRange.Item(1)
  747. ' shape.ScaleWidth(0.29, Microsoft.Office.Core.MsoTriState.msoFalse, Microsoft.Office.Core.MsoScaleFrom.msoScaleFromTopLeft)
  748. ' shape.IncrementLeft(45)
  749. ' shape.IncrementTop(-14)
  750. ' 'PictureBox1.Select()
  751. ' 'xlApp.Selection.ShapeRange.ScaleWidth(0.29, Microsoft.Office.Core.MsoTriState.msoFalse, Microsoft.Office.Core.MsoScaleFrom.msoScaleFromTopLeft)
  752. ' 'xlApp.Selection.ShapeRange.Incrementleft(45)
  753. ' 'xlApp.Selection.ShapeRange.Incrementtop(-14)
  754. ' ' zzz = zzz + 1
  755. ' Dim z1 As Integer = 0
  756. ' For z As Integer = 1 To 9
  757. ' If DataGridView1.Rows(x).Cells("d" & z).Value.ToString <> "" Then
  758. ' System.Windows.Forms.Clipboard.SetDataObject(p(z), True) '复制到剪贴板
  759. ' If z1 < 3 Then
  760. ' Dim range1 As Excel.Range = xlSheet.Range(xlApp.Cells(y * 13 + 4, z1 + 1), xlApp.Cells(y * 13 + 4, z1 + 1)) '粘贴图片的位置
  761. ' range1.Select()
  762. ' ' xlApp.ActiveSheet.Pictures.Insert(p(z))
  763. ' ' xlSheet.Paste(range1, p(z))
  764. ' With xlApp.ActiveSheet.Pictures.Insert(p(z))
  765. ' With .ShapeRange
  766. ' .LockAspectRatio = Microsoft.Office.Core.MsoTriState.msoTrue
  767. ' '.Width = 75
  768. ' '.Height = 100
  769. ' .ScaleWidth(0.09, Microsoft.Office.Core.MsoTriState.msoFalse, Microsoft.Office.Core.MsoScaleFrom.msoScaleFromTopLeft)
  770. ' End With
  771. ' '.Left = xlApp.ActiveSheet.Cells(i, 20).Left
  772. ' '.Top = xlApp.ActiveSheet.Cells(i, 20).Top
  773. ' '.Placement = 1
  774. ' '.PrintObject = True
  775. ' End With
  776. ' Else
  777. ' 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)) '粘贴图片的位置
  778. ' range1.Select()
  779. ' ' xlApp.ActiveSheet.Pictures.Insert(p(z))
  780. ' 'xlSheet.Paste(range1, p(z))
  781. ' With xlApp.ActiveSheet.Pictures.Insert(p(z))
  782. ' With .ShapeRange
  783. ' .LockAspectRatio = Microsoft.Office.Core.MsoTriState.msoTrue
  784. ' ' .Width = 75
  785. ' '.Height = 100
  786. ' .ScaleWidth(0.09, Microsoft.Office.Core.MsoTriState.msoFalse, Microsoft.Office.Core.MsoScaleFrom.msoScaleFromTopLeft)
  787. ' End With
  788. ' '.Left = xlApp.ActiveSheet.Cells(i, 20).Left
  789. ' '.Top = xlApp.ActiveSheet.Cells(i, 20).Top
  790. ' '.Placement = 1
  791. ' '.PrintObject = True
  792. ' End With
  793. ' End If
  794. ' 'Dim pic1 As String
  795. ' 'pic1 = "圖片 " & zzz + 3
  796. ' 'xlApp.ActiveSheet.Shapes.Range(pic1).Select
  797. ' 'xlApp.Selection.ShapeRange.ScaleWidth(0.09, Microsoft.Office.Core.MsoTriState.msoFalse, Microsoft.Office.Core.MsoScaleFrom.msoScaleFromTopLeft)
  798. ' ' xlApp.Selection.ShapeRange.Incrementtop(-1)
  799. ' ' y = y + 1
  800. ' zzz = zzz + 1
  801. ' z1 = z1 + 1
  802. ' End If
  803. ' Next
  804. ' xlSheet.Cells(y * 13 + 1, 5).select
  805. ' xlSheet.Cells(y * 13 + 1, 5) = "序号:" & DataGridView1.Rows(x).Cells("项次").Value
  806. ' xlSheet.Cells(y * 13 + 1, 4).font.bold = True
  807. ' xlSheet.Cells(y * 13 + 1, 1) = "卡号:" & my_card
  808. ' xlSheet.Cells(y * 13 + 1, 1).font.bold = True
  809. ' xlSheet.Cells(y * 13 + 1, 1).font.bold = True
  810. ' xlSheet.Cells(y * 13 + 4, 5) = "鼓号"
  811. ' xlSheet.Cells(y * 13 + 5, 5) = d_no
  812. ' xlSheet.Cells(y * 13 + 4, 5).font.bold = True
  813. ' xlSheet.Cells(y * 13 + 5, 5).font.bold = True
  814. ' xlSheet.Cells(y * 13 + 6, 5) = "下鼓重"
  815. ' xlSheet.Cells(y * 13 + 7, 5) = my_weight
  816. ' xlSheet.Cells(y * 13 + 6, 5).font.bold = True
  817. ' xlSheet.Cells(y * 13 + 7, 5).font.bold = True
  818. ' xlSheet.Cells(y * 13 + 6, 4) = "百分比"
  819. ' xlSheet.Cells(y * 13 + 7, 4) = DataGridView1.Rows(x).Cells("百分比").Value
  820. ' xlSheet.Cells(y * 13 + 6, 4).font.bold = True
  821. ' xlSheet.Cells(y * 13 + 7, 4).font.bold = True
  822. ' ' xlSheet.Cells(y * 13 + 3, 3) = "客户: " & cust
  823. ' 'xlSheet.Cells(y * 13 + 4, 3) = "颜色: " & color1
  824. ' 'xlSheet.Cells(y * 13 + 5, 3) = "皮源: " & source
  825. ' 'xlSheet.Cells(y * 13 + 6, 3) = "皮重: " & wb_weight & "斤"
  826. ' ' xlSheet.Cells(y * 12 + 6, 3) = "备注: " & comment
  827. ' xlSheet.Cells(y * 13 + 2, 1) = "名称: " & DataGridView1.Rows(x).Cells("化料名称").Value
  828. ' xlSheet.Cells(y * 13 + 2, 1).Font.bold = True
  829. ' xlSheet.Cells(y * 13 + 2, 1).Font.SIZE = 18
  830. ' xlSheet.Cells(y * 13 + 3, 1) = "重量: " & Math.Round(DataGridView1.Rows(x).Cells("百分比").Value * my_weight / 100, 2) & " 公斤"
  831. ' xlSheet.Cells(y * 13 + 3, 1).font.bold = True
  832. ' xlSheet.Cells(y * 13 + 3, 1).font.SIZE = 18
  833. ' xlSheet.Cells(y * 13 + 3, 4) = DataGridView1.Rows(x).Cells("化工分类").Value.ToString
  834. ' xlSheet.Cells(y * 13 + 3, 4).font.bold = True
  835. ' xlSheet.Cells(y * 13 + 3, 4).font.SIZE = 18
  836. ' With xlSheet.Range(xlApp.Cells(y * 13 + 2, 1), xlApp.Cells(y * 13 + 3, 5)).Borders(xlEdgeLeft)
  837. ' .LineStyle = xlContinuous
  838. ' '.ColorIndex = 0
  839. ' '.TintAndShade = 0
  840. ' .Weight = xlMedium
  841. ' End With
  842. ' With xlSheet.Range(xlApp.Cells(y * 13 + 2, 1), xlApp.Cells(y * 13 + 3, 5)).Borders(xlEdgeRight)
  843. ' .LineStyle = xlContinuous
  844. ' '.ColorIndex = 0
  845. ' '.TintAndShade = 0
  846. ' .Weight = xlMedium
  847. ' End With
  848. ' With xlSheet.Range(xlApp.Cells(y * 13 + 2, 1), xlApp.Cells(y * 13 + 3, 5)).Borders(xlEdgeTop)
  849. ' .LineStyle = xlContinuous
  850. ' '.ColorIndex = 0
  851. ' '.TintAndShade = 0
  852. ' .Weight = xlMedium
  853. ' End With
  854. ' With xlSheet.Range(xlApp.Cells(y * 13 + 2, 1), xlApp.Cells(y * 13 + 3, 5)).Borders(xlEdgeBottom)
  855. ' .LineStyle = xlContinuous
  856. ' '.ColorIndex = 0
  857. ' '.TintAndShade = 0
  858. ' .Weight = xlMedium
  859. ' End With
  860. ' xlApp.Range(xlSheet.Cells(y * 13 + 2, 1), xlSheet.Cells(y * 13 + 2, 5)).Select()
  861. ' ' xlApp.Range("E2").Activate()
  862. ' xlApp.Selection.Merge
  863. ' 'xlApp.Range(xlSheet.Cells(y * 13 + 13, 2), xlSheet.Cells(y * 13 + 13, 3)).Select()
  864. ' '' xlApp.Range("E2").Activate()
  865. ' 'xlApp.Selection.Merge
  866. ' 'With xlApp.Selection
  867. ' ' .HorizontalAlignment = xlLeft
  868. ' ' .VerticalAlignment = xlCenter
  869. ' ' .WrapText = False
  870. ' ' .Orientation = 0
  871. ' ' .AddIndent = False
  872. ' ' .IndentLevel = 0
  873. ' ' .ShrinkToFit = True
  874. ' ' .ReadingOrder = xlContext
  875. ' ' .MergeCells = True
  876. ' 'End With
  877. ' 'With xlApp.Selection
  878. ' ' .HorizontalAlignment = xlLeft
  879. ' ' .VerticalAlignment = xlCenter
  880. ' ' .WrapText = False
  881. ' ' .Orientation = 0
  882. ' ' .AddIndent = False
  883. ' ' .IndentLevel = 0
  884. ' ' .ShrinkToFit = False
  885. ' ' .ReadingOrder = xlContext
  886. ' ' .MergeCells = True
  887. ' 'End With
  888. ' 'With xlApp.Selection
  889. ' ' .HorizontalAlignment = xlLeft
  890. ' ' .VerticalAlignment = xlCenter
  891. ' ' .WrapText = False
  892. ' ' .Orientation = 0
  893. ' ' .AddIndent = False
  894. ' ' .IndentLevel = 0
  895. ' ' .ShrinkToFit = True
  896. ' ' .ReadingOrder = xlContext
  897. ' ' .MergeCells = True
  898. ' 'End With
  899. ' 'xlSheet.Range(xlApp.Cells(y * 13 + 10, 1), xlApp.Cells(y * 13 + 10, 4)).Borders(xlInsideVertical).LineStyle = xlNone
  900. ' 'xlSheet.Range(xlApp.Cells(y * 13 + 10, 1), xlApp.Cells(y * 13 + 10, 4)).Borders(xlInsideHorizontal).LineStyle = xlNone
  901. ' xlSheet.Cells(y * 13 + 11, 2) = DGV1.Rows(DGV1.CurrentCell.RowIndex).Cells("品名").Value
  902. ' xlSheet.Cells(y * 13 + 13, 2) = "打印时间: " & DateTime.Now
  903. ' xlSheet.Cells(y * 13 + 12, 2) = "打印人员: " & "小甘"
  904. ' 'Dim range As Excel.Range = xlSheet.Range(xlApp.Cells(y * 13 + 2, 1), xlApp.Cells(y * 13 + 2, 1)) '粘贴图片的位置
  905. ' 'xlSheet.Paste(range, PictureBox1.Image)
  906. ' 'Dim pic As String
  907. ' 'pic = "picture " & y + 1
  908. ' 'xlApp.ActiveSheet.Shapes.Range(pic).Select
  909. ' 'xlApp.Selection.ShapeRange.ScaleWidth(0.5, Microsoft.Office.Core.MsoTriState.msoFalse, Microsoft.Office.Core.MsoScaleFrom.msoScaleFromTopLeft)
  910. ' 'xlApp.Selection.ShapeRange.IncrementTop(2.2553543307)
  911. ' y = y + 1
  912. ' Else
  913. 'ok11:
  914. ' End If
  915. ' Next
  916. ' 'xlApp.ActiveSheet.PageSetup.PrintArea = "$A$1:$E$660"
  917. ' xlApp.ActiveSheet.PageSetup.PrintArea = "$a$1:$E$" & y * 13
  918. ' ' xlSheet.Columns("C:C").ColumnWidth = 10.75
  919. ' Dim yy As Integer = 0
  920. ' xlApp.ActiveWindow.View = Microsoft.Office.Interop.Excel.XlWindowView.xlPageBreakPreview
  921. ' For x As Integer = 0 To DataGridView1.Rows.Count - 2
  922. ' If DataGridView1.Rows(x).Cells("化料名称").Value <> "水" And DataGridView1.Rows(x).Cells("化料名称").Value <> "甲酸  1200kg/桶" And DataGridView1.Rows(x).Cells("化料名称").Value <> "Eusapon OC liq 1000kg/桶" Then
  923. ' If yy <> 0 Then
  924. ' Dim r As String
  925. ' r = "A" & yy * 13 + 1
  926. ' xlApp.ActiveSheet.HPageBreaks.Add(xlApp.Range(r))
  927. ' 'xlApp.ActiveSheet.HPageBreaks(yy).Location = xlSheet.Range(r)
  928. ' 'xlApp.ActiveSheet.HPageBreaks.Add.Range(r)
  929. ' End If
  930. ' yy = yy + 1
  931. ' End If
  932. ' Next x
  933. ' 'For Each shp In xlApp.ActiveSheet.shapes
  934. ' ' shp.select
  935. ' ' xlApp.Selection.ShapeRange.ScaleWidth(0.1, Microsoft.Office.Core.MsoTriState.msoFalse, Microsoft.Office.Core.MsoScaleFrom.msoScaleFromTopLeft)
  936. ' 'Next
  937. ' With xlApp.ActiveSheet.PageSetup
  938. ' '.LeftHeader = ""
  939. ' '.CenterHeader = ""
  940. ' '.RightHeader = ""
  941. ' '.LeftFooter = ""
  942. ' '.CenterFooter = ""
  943. ' '.RightFooter = ""
  944. ' .LeftMargin = xlApp.Application.InchesToPoints(0.4)
  945. ' .RightMargin = xlApp.Application.InchesToPoints(0.4)
  946. ' .TopMargin = xlApp.Application.InchesToPoints(0.5)
  947. ' .BottomMargin = xlApp.Application.InchesToPoints(0.5)
  948. ' .HeaderMargin = xlApp.Application.InchesToPoints(0)
  949. ' .FooterMargin = xlApp.Application.InchesToPoints(0)
  950. ' .PrintHeadings = False
  951. ' .PrintGridlines = False
  952. ' .PrintComments = xlPrintNoComments
  953. ' .CenterHorizontally = False
  954. ' .CenterVertically = False
  955. ' .Orientation = xlLandscape
  956. ' .Draft = False
  957. ' ' .PaperSize = xlPaperA4
  958. ' .FirstPageNumber = xlAutomatic
  959. ' .Order = xlDownThenOver
  960. ' .BlackAndWhite = False
  961. ' .Zoom = 85
  962. ' .PrintErrors = xlPrintErrorsDisplayed
  963. ' .OddAndEvenPagesHeaderFooter = False
  964. ' .DifferentFirstPageHeaderFooter = False
  965. ' .ScaleWithDocHeaderFooter = True
  966. ' .AlignMarginsHeaderFooter = True
  967. ' End With
  968. ' DataGridView1.Sort(DataGridView1.Columns("项次"), ListSortDirection.Ascending)
  969. ' ' DT2.DefaultView.Sort = "项次 "
  970. ' MsgBox("输出完成")
  971. ' End Sub
  972. ' Private Sub editFormat(ByVal myExcel As Microsoft.Office.Interop.Excel.Application, ByVal xlSheet As Microsoft.Office.Interop.Excel.Worksheet)
  973. ' xlSheet.Columns("A:A").ColumnWidth = 1
  974. ' xlSheet.Columns("B:B").ColumnWidth = 1
  975. ' xlSheet.Columns("C:C").ColumnWidth = 8
  976. ' xlSheet.Columns("D:D").ColumnWidth = 1.5
  977. ' xlSheet.Columns("e:e").ColumnWidth = 9.63
  978. ' xlSheet.Columns("f:f").ColumnWidth = 14.25
  979. ' xlSheet.Columns("g:g").ColumnWidth = 3
  980. ' xlSheet.Columns("h:h").ColumnWidth = 3
  981. ' xlSheet.Columns("i:i").ColumnWidth = 3
  982. ' xlSheet.Columns("j:j").ColumnWidth = 10
  983. ' xlSheet.Columns("k:k").ColumnWidth = 10
  984. ' xlSheet.Columns("l:l").ColumnWidth = 4.5
  985. ' xlSheet.Columns("m:m").ColumnWidth = 4.5
  986. ' xlSheet.Columns("n:n").ColumnWidth = 8.25
  987. ' xlSheet.Columns("o:o").ColumnWidth = 6
  988. ' xlSheet.Range("A1:C1").Merge() '----流程卡号
  989. ' xlSheet.Range("A1:C1").Borders(xlDiagonalDown).LineStyle = xlNone
  990. ' xlSheet.Range("A1:C1").Borders(xlDiagonalUp).LineStyle = xlNone
  991. ' With xlSheet.Range("A1:C1").Borders(xlEdgeLeft)
  992. ' .LineStyle = xlContinuous
  993. ' .Weight = xlMedium
  994. ' .ColorIndex = xlAutomatic
  995. ' End With
  996. ' With xlSheet.Range("A1:C1").Borders(xlEdgeTop)
  997. ' .LineStyle = xlContinuous
  998. ' .Weight = xlMedium
  999. ' .ColorIndex = xlAutomatic
  1000. ' End With
  1001. ' With xlSheet.Range("A1:C1").Borders(xlEdgeBottom)
  1002. ' .LineStyle = xlContinuous
  1003. ' .Weight = xlMedium
  1004. ' .ColorIndex = xlAutomatic
  1005. ' End With
  1006. ' With xlSheet.Range("A1:C1").Borders(xlEdgeRight)
  1007. ' .LineStyle = xlContinuous
  1008. ' .Weight = xlMedium
  1009. ' .ColorIndex = xlAutomatic
  1010. ' End With
  1011. ' xlSheet.Range("A2:C2").Select() '-------打印日期
  1012. ' myExcel.Selection.Merge()
  1013. ' myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone
  1014. ' myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
  1015. ' With myExcel.Selection.Borders(xlEdgeLeft)
  1016. ' .LineStyle = xlContinuous
  1017. ' .Weight = xlMedium
  1018. ' .ColorIndex = xlAutomatic
  1019. ' End With
  1020. ' With myExcel.Selection.Borders(xlEdgeTop)
  1021. ' .LineStyle = xlContinuous
  1022. ' .Weight = xlMedium
  1023. ' .ColorIndex = xlAutomatic
  1024. ' End With
  1025. ' With myExcel.Selection.Borders(xlEdgeBottom)
  1026. ' .LineStyle = xlContinuous
  1027. ' .Weight = xlMedium
  1028. ' .ColorIndex = xlAutomatic
  1029. ' End With
  1030. ' With myExcel.Selection.Borders(xlEdgeRight)
  1031. ' .LineStyle = xlContinuous
  1032. ' .Weight = xlMedium
  1033. ' .ColorIndex = xlAutomatic
  1034. ' End With
  1035. ' xlSheet.Range("A3:C3").Select() '-----皮源
  1036. ' myExcel.Selection.Merge()
  1037. ' myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone
  1038. ' myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
  1039. ' With myExcel.Selection.Borders(xlEdgeLeft)
  1040. ' .LineStyle = xlContinuous
  1041. ' .Weight = xlMedium
  1042. ' .ColorIndex = xlAutomatic
  1043. ' End With
  1044. ' With myExcel.Selection.Borders(xlEdgeTop)
  1045. ' .LineStyle = xlContinuous
  1046. ' .Weight = xlMedium
  1047. ' .ColorIndex = xlAutomatic
  1048. ' End With
  1049. ' With myExcel.Selection.Borders(xlEdgeBottom)
  1050. ' .LineStyle = xlContinuous
  1051. ' .Weight = xlMedium
  1052. ' .ColorIndex = xlAutomatic
  1053. ' End With
  1054. ' With myExcel.Selection.Borders(xlEdgeRight)
  1055. ' .LineStyle = xlContinuous
  1056. ' .Weight = xlMedium
  1057. ' .ColorIndex = xlAutomatic
  1058. ' End With
  1059. ' xlSheet.Range("d1:f1").Select() '-------流程卡号1
  1060. ' myExcel.Selection.Merge()
  1061. ' myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone
  1062. ' myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
  1063. ' With myExcel.Selection.Borders(xlEdgeLeft)
  1064. ' .LineStyle = xlContinuous
  1065. ' .Weight = xlMedium
  1066. ' .ColorIndex = xlAutomatic
  1067. ' End With
  1068. ' With myExcel.Selection.Borders(xlEdgeTop)
  1069. ' .LineStyle = xlContinuous
  1070. ' .Weight = xlMedium
  1071. ' .ColorIndex = xlAutomatic
  1072. ' End With
  1073. ' With myExcel.Selection.Borders(xlEdgeBottom)
  1074. ' .LineStyle = xlContinuous
  1075. ' .Weight = xlMedium
  1076. ' .ColorIndex = xlAutomatic
  1077. ' End With
  1078. ' With myExcel.Selection.Borders(xlEdgeRight)
  1079. ' .LineStyle = xlContinuous
  1080. ' .Weight = xlMedium
  1081. ' .ColorIndex = xlAutomatic
  1082. ' End With
  1083. ' xlSheet.Range("d2:e2").Select() '--------打印日期1
  1084. ' myExcel.Selection.Merge()
  1085. ' myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone
  1086. ' myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
  1087. ' With myExcel.Selection.Borders(xlEdgeLeft)
  1088. ' .LineStyle = xlContinuous
  1089. ' .Weight = xlMedium
  1090. ' .ColorIndex = xlAutomatic
  1091. ' End With
  1092. ' With myExcel.Selection.Borders(xlEdgeTop)
  1093. ' .LineStyle = xlContinuous
  1094. ' .Weight = xlMedium
  1095. ' .ColorIndex = xlAutomatic
  1096. ' End With
  1097. ' With myExcel.Selection.Borders(xlEdgeBottom)
  1098. ' .LineStyle = xlContinuous
  1099. ' .Weight = xlMedium
  1100. ' .ColorIndex = xlAutomatic
  1101. ' End With
  1102. ' With myExcel.Selection.Borders(xlEdgeRight)
  1103. ' .LineStyle = xlContinuous
  1104. ' .Weight = xlMedium
  1105. ' .ColorIndex = xlAutomatic
  1106. ' End With
  1107. ' xlSheet.Range("f2:f2").Select() '--------规格1
  1108. ' myExcel.Selection.Merge()
  1109. ' myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone
  1110. ' myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
  1111. ' With myExcel.Selection.Borders(xlEdgeLeft)
  1112. ' .LineStyle = xlContinuous
  1113. ' .Weight = xlMedium
  1114. ' .ColorIndex = xlAutomatic
  1115. ' End With
  1116. ' With myExcel.Selection.Borders(xlEdgeTop)
  1117. ' .LineStyle = xlContinuous
  1118. ' .Weight = xlMedium
  1119. ' .ColorIndex = xlAutomatic
  1120. ' End With
  1121. ' With myExcel.Selection.Borders(xlEdgeBottom)
  1122. ' .LineStyle = xlContinuous
  1123. ' .Weight = xlMedium
  1124. ' .ColorIndex = xlAutomatic
  1125. ' End With
  1126. ' With myExcel.Selection.Borders(xlEdgeRight)
  1127. ' .LineStyle = xlContinuous
  1128. ' .Weight = xlMedium
  1129. ' .ColorIndex = xlAutomatic
  1130. ' End With
  1131. ' xlSheet.Range("j2:j2").Select() '--------鼓号1
  1132. ' myExcel.Selection.Merge()
  1133. ' myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone
  1134. ' myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
  1135. ' With myExcel.Selection.Borders(xlEdgeLeft)
  1136. ' .LineStyle = xlContinuous
  1137. ' .Weight = xlMedium
  1138. ' .ColorIndex = xlAutomatic
  1139. ' End With
  1140. ' With myExcel.Selection.Borders(xlEdgeTop)
  1141. ' .LineStyle = xlContinuous
  1142. ' .Weight = xlMedium
  1143. ' .ColorIndex = xlAutomatic
  1144. ' End With
  1145. ' With myExcel.Selection.Borders(xlEdgeBottom)
  1146. ' .LineStyle = xlContinuous
  1147. ' .Weight = xlMedium
  1148. ' .ColorIndex = xlAutomatic
  1149. ' End With
  1150. ' With myExcel.Selection.Borders(xlEdgeRight)
  1151. ' .LineStyle = xlContinuous
  1152. ' .Weight = xlMedium
  1153. ' .ColorIndex = xlAutomatic
  1154. ' End With
  1155. ' xlSheet.Range("d3:f3").Select() '-------皮源
  1156. ' myExcel.Selection.Merge()
  1157. ' myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone
  1158. ' myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
  1159. ' With myExcel.Selection.Borders(xlEdgeLeft)
  1160. ' .LineStyle = xlContinuous
  1161. ' .Weight = xlMedium
  1162. ' .ColorIndex = xlAutomatic
  1163. ' End With
  1164. ' With myExcel.Selection.Borders(xlEdgeTop)
  1165. ' .LineStyle = xlContinuous
  1166. ' .Weight = xlMedium
  1167. ' .ColorIndex = xlAutomatic
  1168. ' End With
  1169. ' With myExcel.Selection.Borders(xlEdgeBottom)
  1170. ' .LineStyle = xlContinuous
  1171. ' .Weight = xlMedium
  1172. ' .ColorIndex = xlAutomatic
  1173. ' End With
  1174. ' With myExcel.Selection.Borders(xlEdgeRight)
  1175. ' .LineStyle = xlContinuous
  1176. ' .Weight = xlMedium
  1177. ' .ColorIndex = xlAutomatic
  1178. ' End With
  1179. ' xlSheet.Range("g3:i3").Select() '-------备注
  1180. ' myExcel.Selection.Merge()
  1181. ' myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone
  1182. ' myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
  1183. ' With myExcel.Selection.Borders(xlEdgeLeft)
  1184. ' .LineStyle = xlContinuous
  1185. ' .Weight = xlMedium
  1186. ' .ColorIndex = xlAutomatic
  1187. ' End With
  1188. ' With myExcel.Selection.Borders(xlEdgeTop)
  1189. ' .LineStyle = xlContinuous
  1190. ' .Weight = xlMedium
  1191. ' .ColorIndex = xlAutomatic
  1192. ' End With
  1193. ' With myExcel.Selection.Borders(xlEdgeBottom)
  1194. ' .LineStyle = xlContinuous
  1195. ' .Weight = xlMedium
  1196. ' .ColorIndex = xlAutomatic
  1197. ' End With
  1198. ' With myExcel.Selection.Borders(xlEdgeRight)
  1199. ' .LineStyle = xlContinuous
  1200. ' .Weight = xlMedium
  1201. ' .ColorIndex = xlAutomatic
  1202. ' End With
  1203. ' xlSheet.Range("j3:o3").Select() '-------备注
  1204. ' myExcel.Selection.Merge()
  1205. ' myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone
  1206. ' myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
  1207. ' With myExcel.Selection.Borders(xlEdgeLeft)
  1208. ' .LineStyle = xlContinuous
  1209. ' .Weight = xlMedium
  1210. ' .ColorIndex = xlAutomatic
  1211. ' End With
  1212. ' With myExcel.Selection.Borders(xlEdgeTop)
  1213. ' .LineStyle = xlContinuous
  1214. ' .Weight = xlMedium
  1215. ' .ColorIndex = xlAutomatic
  1216. ' End With
  1217. ' With myExcel.Selection.Borders(xlEdgeBottom)
  1218. ' .LineStyle = xlContinuous
  1219. ' .Weight = xlMedium
  1220. ' .ColorIndex = xlAutomatic
  1221. ' End With
  1222. ' With myExcel.Selection.Borders(xlEdgeRight)
  1223. ' .LineStyle = xlContinuous
  1224. ' .Weight = xlMedium
  1225. ' .ColorIndex = xlAutomatic
  1226. ' End With
  1227. ' xlSheet.Range("g1:i1").Select() '--------工艺名称
  1228. ' myExcel.Selection.Merge()
  1229. ' myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone
  1230. ' myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
  1231. ' With myExcel.Selection.Borders(xlEdgeLeft)
  1232. ' .LineStyle = xlContinuous
  1233. ' .Weight = xlMedium
  1234. ' .ColorIndex = xlAutomatic
  1235. ' End With
  1236. ' With myExcel.Selection.Borders(xlEdgeTop)
  1237. ' .LineStyle = xlContinuous
  1238. ' .Weight = xlMedium
  1239. ' .ColorIndex = xlAutomatic
  1240. ' End With
  1241. ' With myExcel.Selection.Borders(xlEdgeBottom)
  1242. ' .LineStyle = xlContinuous
  1243. ' .Weight = xlMedium
  1244. ' .ColorIndex = xlAutomatic
  1245. ' End With
  1246. ' With myExcel.Selection.Borders(xlEdgeRight)
  1247. ' .LineStyle = xlContinuous
  1248. ' .Weight = xlMedium
  1249. ' .ColorIndex = xlAutomatic
  1250. ' End With
  1251. ' xlSheet.Range("g2:i2").Select() '-------规格1
  1252. ' myExcel.Selection.Merge()
  1253. ' myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone
  1254. ' myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
  1255. ' With myExcel.Selection.Borders(xlEdgeLeft)
  1256. ' .LineStyle = xlContinuous
  1257. ' .Weight = xlMedium
  1258. ' .ColorIndex = xlAutomatic
  1259. ' End With
  1260. ' With myExcel.Selection.Borders(xlEdgeTop)
  1261. ' .LineStyle = xlContinuous
  1262. ' .Weight = xlMedium
  1263. ' .ColorIndex = xlAutomatic
  1264. ' End With
  1265. ' With myExcel.Selection.Borders(xlEdgeBottom)
  1266. ' .LineStyle = xlContinuous
  1267. ' .Weight = xlMedium
  1268. ' .ColorIndex = xlAutomatic
  1269. ' End With
  1270. ' With myExcel.Selection.Borders(xlEdgeRight)
  1271. ' .LineStyle = xlContinuous
  1272. ' .Weight = xlMedium
  1273. ' .ColorIndex = xlAutomatic
  1274. ' End With
  1275. ' xlSheet.Range("j1:o1").Select() '------工艺名称1
  1276. ' myExcel.Selection.Merge()
  1277. ' myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone
  1278. ' myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
  1279. ' With myExcel.Selection.Borders(xlEdgeLeft)
  1280. ' .LineStyle = xlContinuous
  1281. ' .Weight = xlMedium
  1282. ' .ColorIndex = xlAutomatic
  1283. ' End With
  1284. ' With myExcel.Selection.Borders(xlEdgeTop)
  1285. ' .LineStyle = xlContinuous
  1286. ' .Weight = xlMedium
  1287. ' .ColorIndex = xlAutomatic
  1288. ' End With
  1289. ' With myExcel.Selection.Borders(xlEdgeBottom)
  1290. ' .LineStyle = xlContinuous
  1291. ' .Weight = xlMedium
  1292. ' .ColorIndex = xlAutomatic
  1293. ' End With
  1294. ' With myExcel.Selection.Borders(xlEdgeRight)
  1295. ' .LineStyle = xlContinuous
  1296. ' .Weight = xlMedium
  1297. ' .ColorIndex = xlAutomatic
  1298. ' End With
  1299. ' xlSheet.Range("J2:j2").Select() '------
  1300. ' myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone
  1301. ' myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
  1302. ' With myExcel.Selection.Borders(xlEdgeLeft)
  1303. ' .LineStyle = xlContinuous
  1304. ' .Weight = xlMedium
  1305. ' .ColorIndex = xlAutomatic
  1306. ' End With
  1307. ' With myExcel.Selection.Borders(xlEdgeTop)
  1308. ' .LineStyle = xlContinuous
  1309. ' .Weight = xlMedium
  1310. ' .ColorIndex = xlAutomatic
  1311. ' End With
  1312. ' With myExcel.Selection.Borders(xlEdgeBottom)
  1313. ' .LineStyle = xlContinuous
  1314. ' .Weight = xlMedium
  1315. ' .ColorIndex = xlAutomatic
  1316. ' End With
  1317. ' With myExcel.Selection.Borders(xlEdgeRight)
  1318. ' .LineStyle = xlContinuous
  1319. ' .Weight = xlMedium
  1320. ' .ColorIndex = xlAutomatic
  1321. ' End With
  1322. ' With myExcel.Selection.Borders(xlInsideVertical)
  1323. ' .LineStyle = xlContinuous
  1324. ' .Weight = xlMedium
  1325. ' .ColorIndex = xlAutomatic
  1326. ' End With
  1327. ' xlSheet.Range("k2:K2").Select() '------
  1328. ' myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone
  1329. ' myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
  1330. ' With myExcel.Selection.Borders(xlEdgeLeft)
  1331. ' .LineStyle = xlContinuous
  1332. ' .Weight = xlMedium
  1333. ' .ColorIndex = xlAutomatic
  1334. ' End With
  1335. ' With myExcel.Selection.Borders(xlEdgeTop)
  1336. ' .LineStyle = xlContinuous
  1337. ' .Weight = xlMedium
  1338. ' .ColorIndex = xlAutomatic
  1339. ' End With
  1340. ' With myExcel.Selection.Borders(xlEdgeBottom)
  1341. ' .LineStyle = xlContinuous
  1342. ' .Weight = xlMedium
  1343. ' .ColorIndex = xlAutomatic
  1344. ' End With
  1345. ' With myExcel.Selection.Borders(xlEdgeRight)
  1346. ' .LineStyle = xlContinuous
  1347. ' .Weight = xlMedium
  1348. ' .ColorIndex = xlAutomatic
  1349. ' End With
  1350. ' With myExcel.Selection.Borders(xlInsideVertical)
  1351. ' .LineStyle = xlContinuous
  1352. ' .Weight = xlMedium
  1353. ' .ColorIndex = xlAutomatic
  1354. ' End With
  1355. ' xlSheet.Range("l2:m2").Select() '----------重量
  1356. ' myExcel.Selection.Merge()
  1357. ' myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone
  1358. ' myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
  1359. ' With myExcel.Selection.Borders(xlEdgeLeft)
  1360. ' .LineStyle = xlContinuous
  1361. ' .Weight = xlMedium
  1362. ' .ColorIndex = xlAutomatic
  1363. ' End With
  1364. ' With myExcel.Selection.Borders(xlEdgeTop)
  1365. ' .LineStyle = xlContinuous
  1366. ' .Weight = xlMedium
  1367. ' .ColorIndex = xlAutomatic
  1368. ' End With
  1369. ' With myExcel.Selection.Borders(xlEdgeBottom)
  1370. ' .LineStyle = xlContinuous
  1371. ' .Weight = xlMedium
  1372. ' .ColorIndex = xlAutomatic
  1373. ' End With
  1374. ' With myExcel.Selection.Borders(xlEdgeRight)
  1375. ' .LineStyle = xlContinuous
  1376. ' .Weight = xlMedium
  1377. ' .ColorIndex = xlAutomatic
  1378. ' End With
  1379. ' xlSheet.Range("n1:o1").Select() '--------
  1380. ' myExcel.Selection.Merge()
  1381. ' myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone
  1382. ' myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
  1383. ' With myExcel.Selection.Borders(xlEdgeLeft)
  1384. ' .LineStyle = xlContinuous
  1385. ' .Weight = xlMedium
  1386. ' .ColorIndex = xlAutomatic
  1387. ' End With
  1388. ' With myExcel.Selection.Borders(xlEdgeTop)
  1389. ' .LineStyle = xlContinuous
  1390. ' .Weight = xlMedium
  1391. ' .ColorIndex = xlAutomatic
  1392. ' End With
  1393. ' With myExcel.Selection.Borders(xlEdgeBottom)
  1394. ' .LineStyle = xlContinuous
  1395. ' .Weight = xlMedium
  1396. ' .ColorIndex = xlAutomatic
  1397. ' End With
  1398. ' With myExcel.Selection.Borders(xlEdgeRight)
  1399. ' .LineStyle = xlContinuous
  1400. ' .Weight = xlMedium
  1401. ' .ColorIndex = xlAutomatic
  1402. ' End With
  1403. ' xlSheet.Range("n2:o2").Select() '-------重量
  1404. ' myExcel.Selection.Merge()
  1405. ' myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone
  1406. ' myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
  1407. ' With myExcel.Selection.Borders(xlEdgeLeft)
  1408. ' .LineStyle = xlContinuous
  1409. ' .Weight = xlMedium
  1410. ' .ColorIndex = xlAutomatic
  1411. ' End With
  1412. ' With myExcel.Selection.Borders(xlEdgeTop)
  1413. ' .LineStyle = xlContinuous
  1414. ' .Weight = xlMedium
  1415. ' .ColorIndex = xlAutomatic
  1416. ' End With
  1417. ' With myExcel.Selection.Borders(xlEdgeBottom)
  1418. ' .LineStyle = xlContinuous
  1419. ' .Weight = xlMedium
  1420. ' .ColorIndex = xlAutomatic
  1421. ' End With
  1422. ' With myExcel.Selection.Borders(xlEdgeRight)
  1423. ' .LineStyle = xlContinuous
  1424. ' .Weight = xlMedium
  1425. ' .ColorIndex = xlAutomatic
  1426. ' End With
  1427. ' End Sub
  1428. ' Private Sub cmdCancelEdit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdCancelEdit.Click
  1429. ' 'For x As Integer = 0 To dgv2.Rows.Count - 1
  1430. ' ' dgv2.Rows(x).DefaultCellStyle.Font = New Font(dgv2.DefaultCellStyle.Font, FontStyle.Regular)
  1431. ' ' dgv2.Rows(x).Cells("百分比").Style.BackColor = Color.White
  1432. ' ' dgv2.Rows(x).Cells("化料編號").Style.BackColor = Color.White
  1433. ' ' dgv2.Rows(x).Cells("化料名称").Style.BackColor = Color.White
  1434. ' ' dgv2.Rows(x).Cells("时间").Style.BackColor = Color.White
  1435. ' ' dgv2.Rows(x).Cells("備註").Style.BackColor = Color.White
  1436. ' 'Next
  1437. ' cmdSaveEdit.Visible = False
  1438. ' cmdCancelEdit.Visible = False
  1439. ' Timer1.Enabled = False
  1440. ' Label1.Visible = False
  1441. ' End Sub
  1442. ' Private Sub cmdSaveEdit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdSaveEdit.Click
  1443. ' ' dgv2.Rows(dgv2.SelectedRows(0).Index).Selected = False
  1444. ' Dim edited As Boolean = False
  1445. ' Dim cmd1 As New SqlCommand
  1446. ' cmd1.Connection = con
  1447. ' If con.State = ConnectionState.Closed Then
  1448. ' con.Open()
  1449. ' End If
  1450. ' '----------判斷是否修改
  1451. ' For x As Integer = 0 To dgv2.Rows.Count - 1
  1452. ' If DataGridView1.Rows(x).Cells("项次").Style.BackColor.Name <> "0" Or Not (DataGridView1.Rows(x).DefaultCellStyle.Font Is Nothing) Then
  1453. ' edited = True
  1454. ' Exit For
  1455. ' End If
  1456. ' If DataGridView1.Rows(x).Cells("百分比").Style.BackColor.Name <> "0" Or Not (DataGridView1.Rows(x).DefaultCellStyle.Font Is Nothing) Then
  1457. ' edited = True
  1458. ' Exit For
  1459. ' End If
  1460. ' If DataGridView1.Rows(x).Cells("化料名称").Style.BackColor.Name <> "0" Or Not (DataGridView1.Rows(x).DefaultCellStyle.Font Is Nothing) Then
  1461. ' edited = True
  1462. ' Exit For
  1463. ' End If
  1464. ' If DataGridView1.Rows(x).Cells("时间").Style.BackColor.Name <> "0" Or Not (DataGridView1.Rows(x).DefaultCellStyle.Font Is Nothing) Then
  1465. ' edited = True
  1466. ' Exit For
  1467. ' End If
  1468. ' If DataGridView1.Rows(x).Cells("备注").Style.BackColor.Name <> "0" Or Not (DataGridView1.Rows(x).DefaultCellStyle.Font Is Nothing) Then
  1469. ' edited = True
  1470. ' Exit For
  1471. ' End If
  1472. ' Next
  1473. ' '-------------------------------------------------
  1474. ' If edited = True Then
  1475. ' '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 & "'"
  1476. ' 'cmd.CommandText = sql_rcp
  1477. ' 'cmd.Connection = conn
  1478. ' 'If conn.State = ConnectionState.Closed Then
  1479. ' ' conn.Open()
  1480. ' 'End If
  1481. ' 'cmd.ExecuteNonQuery()
  1482. ' '''sql_rcp = "delete from ht_retanrcp where rcp_no=N'" & DGV1.Rows(DGV1.CurrentRow.Index).Cells(5).Value & "'"
  1483. ' '''cmd.CommandText = sql_rcp
  1484. ' '''cmd.Connection = conn
  1485. ' '''If conn.State = ConnectionState.Closed Then
  1486. ' ''' conn.Open()
  1487. ' '''End If
  1488. ' '''dr = cmd.ExecuteReader
  1489. ' ''-----------舊記錄存檔
  1490. ' 'While dr.Read()
  1491. ' ' 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") & "')"
  1492. ' ' cmd1.CommandText = sql_rcp
  1493. ' ' cmd1.ExecuteNonQuery()
  1494. ' 'End While
  1495. ' 'Dim gUserName As String = "matchy"
  1496. ' 'sql_rcp = "update " & rcp & " set last_edited ='" & Now.ToString & "',editor='" & gUserName & "' where rcp_no='" & DGV1.Rows(DGV1.CurrentRow.Index).Cells(0).Value & "'"
  1497. ' 'cmd1.CommandText = sql_rcp
  1498. ' 'cmd1.ExecuteNonQuery()
  1499. ' End If
  1500. ' '-----------將現有處方明細先刪除
  1501. ' 'sql_rcp = "delete from rcp_content where rcp_no='" & DGV1.Rows(DGV1.CurrentRow.Index).Cells(0).Value & "'"
  1502. ' 'cmd1.CommandText = sql_rcp
  1503. ' 'cmd1.ExecuteNonQuery()
  1504. ' '-----------加入新修改之處方明細
  1505. ' Dim y As Integer = 1
  1506. ' For x As Integer = 0 To DataGridView1.Rows.Count - 1
  1507. ' If (DataGridView1.Rows(x).DefaultCellStyle.Font Is Nothing) Then
  1508. ' 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 & "')"
  1509. ' cmd1.CommandText = sql_rcp
  1510. ' cmd1.ExecuteNonQuery()
  1511. ' y = y + 1
  1512. ' End If
  1513. ' Next
  1514. ' MsgBox("修改完成")
  1515. ' cmdSaveEdit.Visible = False
  1516. ' cmdCancelEdit.Visible = False
  1517. ' Timer1.Enabled = False
  1518. ' Label1.Visible = False
  1519. ' conn.Close()
  1520. ' con.Close()
  1521. ' End Sub
  1522. ' Private Sub cmdcanceladd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdcanceladd.Click
  1523. ' End Sub
  1524. ' Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
  1525. ' If dgv_record.Visible = False Then
  1526. ' dgv_record.BringToFront()
  1527. ' dgv_record.Visible = True
  1528. ' Else
  1529. ' dgv_record.Visible = False
  1530. ' End If
  1531. ' End Sub
  1532. ' Private Sub dgv_record_RowPostPaint(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewRowPostPaintEventArgs) Handles dgv_record.RowPostPaint
  1533. ' Dim linePen As New Pen(Color.SkyBlue, 2)
  1534. ' If e.RowIndex = dgv_record.Rows.Count - 1 Then
  1535. ' dgv_record.Rows(e.RowIndex).Cells("百分比").Style.ForeColor = Color.White
  1536. ' Dim startX As Integer = IIf(dgv_record.RowHeadersVisible, dgv_record.RowHeadersWidth, 0)
  1537. ' Dim startY As Integer = e.RowBounds.Top + e.RowBounds.Height - 1
  1538. ' Dim endX As Integer = startX + dgv2.Columns.GetColumnsWidth(DataGridViewElementStates.Visible) - dgv_record.HorizontalScrollingOffset
  1539. ' e.Graphics.DrawLine(linePen, startX, startY, endX, startY)
  1540. ' Exit Sub
  1541. ' End If
  1542. ' 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
  1543. ' ElseIf dgv_record.Rows(e.RowIndex).Cells("時间").Value.ToString <> "" Then
  1544. ' Dim startX As Integer = IIf(dgv2.RowHeadersVisible, dgv_record.RowHeadersWidth, 0)
  1545. ' Dim startY As Integer = e.RowBounds.Top + e.RowBounds.Height - 1
  1546. ' Dim endX As Integer = startX + dgv_record.Columns.GetColumnsWidth(DataGridViewElementStates.Visible) - dgv_record.HorizontalScrollingOffset
  1547. ' e.Graphics.DrawLine(linePen, startX, startY, endX, startY)
  1548. ' End If
  1549. ' 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
  1550. ' dgv_record.Rows(e.RowIndex).Cells("百分比").Style.ForeColor = Color.White
  1551. ' Dim startX As Integer = IIf(dgv_record.RowHeadersVisible, dgv_record.RowHeadersWidth, 0)
  1552. ' Dim startY As Integer = e.RowBounds.Top + e.RowBounds.Height - 1
  1553. ' Dim endX As Integer = startX + dgv_record.Columns.GetColumnsWidth(DataGridViewElementStates.Visible) - dgv_record.HorizontalScrollingOffset
  1554. ' e.Graphics.DrawLine(linePen, startX, startY, endX, startY)
  1555. ' End If
  1556. ' End Sub
  1557. ' Private Sub GroupBox2_Enter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles GroupBox2.Enter
  1558. ' End Sub
  1559. ' Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
  1560. ' txt_bxs.Text = ""
  1561. ' txt_frj.Text = ""
  1562. ' txt_jc.Text = ""
  1563. ' txtjc.Text = ""
  1564. ' TextBox10.Text = ""
  1565. ' TextBox5.Text = ""
  1566. ' If conn.State = ConnectionState.Closed Then
  1567. ' conn.ConnectionString = connstring
  1568. ' conn.Open()
  1569. ' End If
  1570. ' cmd.Connection = conn
  1571. ' Dim sql As String
  1572. ' sql = "select * from retan_cost where pid='" & TXT_PID.Text & "'"
  1573. ' cmd.CommandText = sql
  1574. ' dr = cmd.ExecuteReader()
  1575. ' If dr.Read Then
  1576. ' Dim my_msg As MsgBoxResult
  1577. ' my_msg = MsgBox("資料已存在,是否繼續?", MsgBoxStyle.YesNo)
  1578. ' If my_msg = MsgBoxResult.No Then
  1579. ' dr.Close()
  1580. ' Exit Sub
  1581. ' End If
  1582. ' Else
  1583. ' End If
  1584. ' dr.Close()
  1585. ' Dim io_no As String = ""
  1586. ' Dim io_count As Integer = 0
  1587. ' Dim my_weight As Integer = 0
  1588. ' Dim my_piece As Integer = 0
  1589. ' Dim matl_id As String
  1590. ' sql = "select weight,piece from production where production_id='" & TXT_PID.Text & "'"
  1591. ' cmd.CommandText = sql
  1592. ' dr = cmd.ExecuteReader
  1593. ' dr.Read()
  1594. ' my_piece = dr("piece")
  1595. ' dr.Close()
  1596. ' 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) & "'"
  1597. ' cmd.CommandText = sql
  1598. ' io_count = cmd.ExecuteScalar
  1599. ' io_no = "W" & String.Format("{0:yyMMdd}", DateTimePicker1.Value) & Chr(io_count + 65)
  1600. ' 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 & "','染色')"
  1601. ' cmd.CommandText = sql
  1602. ' cmd.ExecuteNonQuery()
  1603. ' For x As Integer = 0 To dgv2.RowCount - 1
  1604. ' sql = "select matl_id from tblmaterial where matl_no='" & dgv2.Rows(x).Cells(2).Value & "'"
  1605. ' cmd.CommandText = sql
  1606. ' dr = cmd.ExecuteReader
  1607. ' dr.Read()
  1608. ' matl_id = dr("matl_id").ToString
  1609. ' dr.Close()
  1610. ' If (dgv2.Rows(x).DefaultCellStyle.Font Is Nothing) Then
  1611. ' 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 & "')"
  1612. ' cmd.CommandText = sql
  1613. ' cmd.ExecuteNonQuery()
  1614. ' If matl_id <> "" Then
  1615. ' Dim id As Integer = 0
  1616. ' sql = "select top (1) id from retan_cost order by id desc "
  1617. ' cmd.CommandText = sql
  1618. ' id = cmd.ExecuteScalar
  1619. ' 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 & "')"
  1620. ' cmd.CommandText = sql
  1621. ' cmd.ExecuteNonQuery()
  1622. ' chem_balance(dgv2.Rows(x).Cells(2).Value, Double.Parse(txtwb_weight.Text) * my_piece * dgv2.Rows(x).Cells(1).Value / 100, x, id)
  1623. ' End If
  1624. ' Else
  1625. ' If dgv2.Rows(x).DefaultCellStyle.Font.Style <> FontStyle.Strikeout Then
  1626. ' 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 & "')"
  1627. ' cmd.CommandText = sql
  1628. ' cmd.ExecuteNonQuery()
  1629. ' If matl_id <> "" Then
  1630. ' Dim id As Integer = 0
  1631. ' sql = "select top (1) id from retan_cost "
  1632. ' cmd.CommandText = sql
  1633. ' id = cmd.ExecuteScalar
  1634. ' 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 & "')"
  1635. ' cmd.CommandText = sql
  1636. ' cmd.ExecuteNonQuery()
  1637. ' chem_balance(dgv2.Rows(x).Cells(2).Value, Double.Parse(txtwb_weight.Text) * my_piece * dgv2.Rows(x).Cells(1).Value / 100, x, id)
  1638. ' End If
  1639. ' End If
  1640. ' End If
  1641. ' Next
  1642. ' conn.Close()
  1643. ' save_cost()
  1644. ' MsgBox("作業完成")
  1645. ' End Sub
  1646. ' Private Function chem_balance(ByVal matl_no As String, ByVal quantity As Double, ByVal x As Integer, ByVal id As Integer)
  1647. ' Dim conn5 As New SqlConnection
  1648. ' Dim dt1 As New DataTable
  1649. ' Dim sql As String = ""
  1650. ' sql = "select top (1) lot_no,coin,price,quantity, w from tblchem_lot where matl_no='" & matl_no & "' and quantity-w<>0"
  1651. ' cmd.CommandText = sql
  1652. ' da.Fill(dt1)
  1653. ' If dt1.Rows.Count = 0 Then
  1654. ' Dim dt2 As New DataTable
  1655. ' sql = "select top (1) lot_no,coin,price,quantity, w from tblchem_lot where matl_no='" & matl_no & "'"
  1656. ' cmd.CommandText = sql
  1657. ' da.Fill(dt2)
  1658. ' If dt2.Rows.Count = 0 Then
  1659. ' sql = "insert into tblchem_lot (matl_no,lot_no,quantity,coin,price) values ('" & matl_no & "','120229','" & 0 & "','" & "NTD" & "','" & 0 & "')"
  1660. ' cmd.CommandText = sql
  1661. ' cmd.ExecuteScalar()
  1662. ' 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 & "')"
  1663. ' cmd.CommandText = sql
  1664. ' dr = cmd.ExecuteScalar
  1665. ' 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 & "'"
  1666. ' cmd.CommandText = sql
  1667. ' dr = cmd.ExecuteScalar
  1668. ' Else
  1669. ' 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 & "')"
  1670. ' cmd.CommandText = sql
  1671. ' dr = cmd.ExecuteScalar
  1672. ' 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 & "'"
  1673. ' cmd.CommandText = sql
  1674. ' dr = cmd.ExecuteScalar
  1675. ' End If
  1676. ' '
  1677. ' End If
  1678. ' If dt1.Rows(0).Item("quantity") - dt1.Rows(0).Item("w") - quantity > 0 Then
  1679. ' 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 & "')"
  1680. ' cmd.CommandText = sql
  1681. ' dr = cmd.ExecuteScalar
  1682. ' 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 & "'"
  1683. ' cmd.CommandText = sql
  1684. ' dr = cmd.ExecuteScalar
  1685. ' Else
  1686. ' If dt1.Rows(0).Item("quantity") - dt1.Rows(0).Item("w") > 0 Then
  1687. ' 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 & "')"
  1688. ' cmd.CommandText = sql
  1689. ' dr = cmd.ExecuteScalar
  1690. ' 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") & "'"
  1691. ' cmd.CommandText = sql
  1692. ' dr = cmd.ExecuteScalar
  1693. ' chem_balance(matl_no, quantity - (dt1.Rows(0).Item("quantity") - dt1.Rows(0).Item("w")), x + 1, id)
  1694. ' Else
  1695. ' 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 & "')"
  1696. ' cmd.CommandText = sql
  1697. ' dr = cmd.ExecuteScalar
  1698. ' 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") & "'"
  1699. ' cmd.CommandText = sql
  1700. ' dr = cmd.ExecuteScalar
  1701. ' End If
  1702. ' End If
  1703. ' End Function
  1704. ' Private Sub save_cost()
  1705. ' If conn.State = ConnectionState.Closed Then
  1706. ' conn.ConnectionString = connstring
  1707. ' conn.Open()
  1708. ' End If
  1709. ' cmd.Connection = conn
  1710. ' Dim sql As String
  1711. ' 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"
  1712. ' cmd.CommandText = sql
  1713. ' dr = cmd.ExecuteReader
  1714. ' Dim t As Double = 0
  1715. ' Dim x As Double = 0
  1716. ' Dim f As Double = 0
  1717. ' Dim d As Double = 0
  1718. ' Dim xx As Double = 0
  1719. ' While dr.Read()
  1720. ' Select Case dr("matl_id")
  1721. ' Case "T"
  1722. ' t = dr("cost")
  1723. ' Case "X"
  1724. ' x = dr("cost")
  1725. ' Case "D"
  1726. ' d = dr("cost")
  1727. ' Case "F"
  1728. ' f = dr("cost")
  1729. ' Case Else
  1730. ' xx = dr("cost")
  1731. ' End Select
  1732. ' End While
  1733. ' dr.Close()
  1734. ' Dim total As Double = t + x + f + d + xx
  1735. ' txt_bxs.Text = t
  1736. ' txt_frj.Text = f
  1737. ' txt_jc.Text = d
  1738. ' txtjc.Text = x
  1739. ' TextBox10.Text = xx
  1740. ' TextBox5.Text = total
  1741. ' End Sub
  1742. ' Private Sub TXT_PID_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TXT_PID.KeyUp
  1743. ' Dim sql As String = ""
  1744. ' Dim dr2 As SqlDataReader
  1745. ' sql = "select article from leather_io where production_id='" & TXT_PID.Text & "'"
  1746. ' cmd.CommandText = sql
  1747. ' cmd.Connection = conn
  1748. ' If conn.State = ConnectionState.Closed Then
  1749. ' conn.Open()
  1750. ' End If
  1751. ' dr2 = cmd.ExecuteReader
  1752. ' If dr2.Read Then
  1753. ' txtsum.Text = dr2("article")
  1754. ' End If
  1755. ' dr2.Close()
  1756. ' conn.Close()
  1757. ' sql = "select weight/piece as my_avg from production where production_id='" & TXT_PID.Text & "'"
  1758. ' cmd.CommandText = sql
  1759. ' cmd.Connection = conn
  1760. ' If conn.State = ConnectionState.Closed Then
  1761. ' conn.Open()
  1762. ' End If
  1763. ' dr2 = cmd.ExecuteReader
  1764. ' If dr2.Read Then
  1765. ' txtwb_weight.Text = dr2("my_avg")
  1766. ' End If
  1767. ' dr2.Close()
  1768. ' conn.Close()
  1769. ' End Sub
  1770. ' Private Sub Button10_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button10.Click
  1771. ' Dim sql As String = ""
  1772. ' cmd.Connection = conn
  1773. ' If conn.State = ConnectionState.Closed Then
  1774. ' conn.Open()
  1775. ' End If
  1776. ' ListBox2.Visible = True
  1777. ' ListBox3.Visible = True
  1778. ' ListBox4.Visible = True
  1779. ' TextBox2.Visible = True
  1780. ' TextBox3.Visible = True
  1781. ' TextBox4.Visible = True
  1782. ' 'Button11.Visible = True
  1783. ' 'Button12.Visible = True
  1784. ' 'Button13.Visible = True
  1785. ' 'Button14.Visible = True
  1786. ' Button15.Visible = True
  1787. ' sql = "select cust_name from customer order by cust_name"
  1788. ' cmd.CommandText = sql
  1789. ' dr = cmd.ExecuteReader
  1790. ' While dr.Read
  1791. ' ListBox2.Items.Add(dr("cust_name"))
  1792. ' End While
  1793. ' dr.Close()
  1794. ' sql = "select prod_name from tblproduct order by prod_name"
  1795. ' cmd.CommandText = sql
  1796. ' dr = cmd.ExecuteReader
  1797. ' While dr.Read
  1798. ' ListBox3.Items.Add(dr("prod_name"))
  1799. ' End While
  1800. ' dr.Close()
  1801. ' sql = "select color_name from color order by color_name"
  1802. ' cmd.CommandText = sql
  1803. ' dr = cmd.ExecuteReader
  1804. ' While dr.Read
  1805. ' ListBox4.Items.Add(dr("color_name"))
  1806. ' End While
  1807. ' dr.Close()
  1808. ' Button17.Visible = True
  1809. ' conn.Close()
  1810. ' End Sub
  1811. ' Private Sub Button17_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button17.Click
  1812. ' Dim sql As String = ""
  1813. ' Dim cust_no As String = ""
  1814. ' Dim prod_id As String = ""
  1815. ' Dim color_no As String = ""
  1816. ' If cmd.Connection.State = ConnectionState.Closed Then
  1817. ' conn.Open()
  1818. ' End If
  1819. ' sql = "select id from customer where cust_name='" & ListBox2.SelectedItem & "'"
  1820. ' cmd.CommandText = sql
  1821. ' cust_no = cmd.ExecuteScalar
  1822. ' sql = "select prod_id from tblproduct where prod_name='" & ListBox3.SelectedItem & "'"
  1823. ' cmd.CommandText = sql
  1824. ' prod_id = cmd.ExecuteScalar
  1825. ' sql = "select color_no from color where color_name='" & ListBox4.SelectedItem & "'"
  1826. ' cmd.CommandText = sql
  1827. ' color_no = cmd.ExecuteScalar
  1828. ' 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 & "'"
  1829. ' cmd.CommandText = sql
  1830. ' Dim c As Integer = cmd.ExecuteScalar
  1831. ' If c = 0 Then
  1832. ' rr = prod_id & String.Format("{0:D2}", c) & String.Format("{0:D3}", cust_no) & color_no
  1833. ' Else
  1834. ' rr = prod_id & String.Format("{0:D2}", c + 1) & String.Format("{0:D3}", cust_no) & color_no
  1835. ' End If
  1836. ' sql = "select count(*) from " & rcp & " where rcp_no='" & rr & "'"
  1837. ' cmd.CommandText = sql
  1838. ' c = cmd.ExecuteScalar
  1839. ' If c <> 0 Then
  1840. ' MsgBox("重覆")
  1841. ' Exit Sub
  1842. ' End If
  1843. ' rcp_name = ListBox2.SelectedItem & ListBox4.SelectedItem & ListBox3.SelectedItem
  1844. ' rcp_name = InputBox("處方名稱", "詢問", rcp_name)
  1845. ' sql = "insert into " & rcp & " (rcp_no,rcp_name,creat_d) values ( '" & rr & "',N'" & rcp_name & "','" & String.Format("{0:d}", DateTime.Now) & "')"
  1846. ' cmd.CommandText = sql
  1847. ' cmd.ExecuteNonQuery()
  1848. ' For x As Integer = 0 To dgv2.RowCount - 1
  1849. ' If (dgv2.Rows(x).DefaultCellStyle.Font Is Nothing) Then
  1850. ' Dim item As String = ""
  1851. ' If x <= 8 Then
  1852. ' item = "0" & x + 1
  1853. ' Else
  1854. ' item = x + 1
  1855. ' End If
  1856. ' 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 & "')"
  1857. ' cmd.CommandText = sql
  1858. ' cmd.ExecuteNonQuery()
  1859. ' Else
  1860. ' If dgv2.Rows(x).DefaultCellStyle.Font.Style <> FontStyle.Strikeout Then
  1861. ' Dim item As String = ""
  1862. ' If Microsoft.VisualBasic.Len(x) = 1 Then
  1863. ' item = "0" & x + 1
  1864. ' Else
  1865. ' item = x + 1
  1866. ' End If
  1867. ' 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 & "')"
  1868. ' cmd.CommandText = sql
  1869. ' cmd.ExecuteNonQuery()
  1870. ' End If
  1871. ' End If
  1872. ' Next
  1873. ' MsgBox("處方" & rr & rcp_name & "新增完成")
  1874. ' conn.Close()
  1875. ' Button17.Visible = False
  1876. ' ListBox2.Visible = False
  1877. ' ListBox3.Visible = False
  1878. ' ListBox4.Visible = False
  1879. ' TextBox2.Visible = False
  1880. ' TextBox3.Visible = False
  1881. ' TextBox4.Visible = False
  1882. ' End Sub
  1883. ' Private Sub Button18_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button18.Click
  1884. ' Dim rcp_name As String = ""
  1885. ' Dim sql As String = ""
  1886. ' If conn.State = ConnectionState.Closed Then
  1887. ' conn.Open()
  1888. ' End If
  1889. ' rcp_name = InputBox("輸入新的處方名", DGV1.Rows(DGV1.CurrentRow.Index).Cells(1).Value)
  1890. ' sql = "update " & rcp & " set rcp_name=N'" & rcp_name & "' where rcp_no='" & DGV1.Rows(DGV1.CurrentRow.Index).Cells(0).Value & "'"
  1891. ' cmd.Connection = conn
  1892. ' cmd.CommandText = sql
  1893. ' cmd.ExecuteScalar()
  1894. ' conn.Close()
  1895. ' End Sub
  1896. ' Private Sub RadioButton2_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton2.CheckedChanged
  1897. ' 'If RadioButton2.Checked = True Then
  1898. ' ' rcp = "rcp_main"
  1899. ' ' rcp1 = "rcp_content"
  1900. ' 'Else
  1901. ' ' rcp = "prescription_main"
  1902. ' ' rcp1 = "prescription_content"
  1903. ' 'End If
  1904. ' End Sub
  1905. ' Private Sub Button19_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button19.Click
  1906. ' txt_bxs.Text = ""
  1907. ' txt_frj.Text = ""
  1908. ' txt_jc.Text = ""
  1909. ' txtjc.Text = ""
  1910. ' TextBox10.Text = ""
  1911. ' TextBox5.Text = ""
  1912. ' save_cost()
  1913. ' ' ''Dim conn5 As New SqlConnection
  1914. ' ' ''Dim dt1 As New DataTable
  1915. ' ' ''If matl_no = "G300" Then
  1916. ' ' '' Dim aa As String = ""
  1917. ' ' '' aa = "asdfasf"
  1918. ' ' ''End If
  1919. ' ' ''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"
  1920. ' ' ''cmd.CommandText = Sql
  1921. ' ' ''da.Fill(dt1)
  1922. ' ' ''If dt1.Rows.Count = 0 Then
  1923. ' ' '' ListBox1.Items.Add(matl_no)
  1924. ' ' '' Dim dt2 As New DataTable
  1925. ' ' '' Sql = "select top (1) lot_no,coin,price,quantity, w from tblchem_lot where matl_no='" & matl_no & "' order by lot_no desc"
  1926. ' ' '' cmd.CommandText = Sql
  1927. ' ' '' da.Fill(dt2)
  1928. ' ' '' If dt2.Rows.Count = 0 Then
  1929. ' ' '' Sql = "insert into tblchem_lot (matl_no,lot_no,quantity,coin,price) values ('" & matl_no & "','120229','" & "0" & "','" & "NTD" & "','" & 0 & "')"
  1930. ' ' '' cmd.CommandText = Sql
  1931. ' ' '' cmd.ExecuteScalar()
  1932. ' ' '' Sql = "insert into tblchem_lot_io (lot_no,matl_no,quantity,io_type,coin,price,id) values ('120229'" & ",'" & matl_no & "','" & quantity & "','" & "領料" & "','ntd','0','" & id & "')"
  1933. ' ' '' cmd.CommandText = Sql
  1934. ' ' '' dr = cmd.ExecuteScalar
  1935. ' ' '' Sql = "update tblchem_lot set w=w+'" & quantity & "' where lot_no='120229' and matl_no='" & matl_no & "'"
  1936. ' ' '' cmd.CommandText = Sql
  1937. ' ' '' dr = cmd.ExecuteScalar
  1938. ' ' '' Else
  1939. ' ' '' 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 & "')"
  1940. ' ' '' cmd.CommandText = Sql
  1941. ' ' '' dr = cmd.ExecuteScalar
  1942. ' ' '' 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 & "'"
  1943. ' ' '' cmd.CommandText = Sql
  1944. ' ' '' dr = cmd.ExecuteScalar
  1945. ' ' '' End If
  1946. ' ' '' Exit Sub
  1947. ' ' ''End If
  1948. ' ' ''If dt1.Rows(0).Item("quantity") - dt1.Rows(0).Item("w") - quantity > 0 Then
  1949. ' ' '' 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 & "')"
  1950. ' ' '' cmd.CommandText = Sql
  1951. ' ' '' dr = cmd.ExecuteScalar
  1952. ' ' '' 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 & "'"
  1953. ' ' '' cmd.CommandText = Sql
  1954. ' ' '' dr = cmd.ExecuteScalar
  1955. ' ' ''Else
  1956. ' ' '' If dt1.Rows(0).Item("quantity") - dt1.Rows(0).Item("w") > 0 Then
  1957. ' ' '' 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 & "')"
  1958. ' ' '' cmd.CommandText = Sql
  1959. ' ' '' dr = cmd.ExecuteScalar
  1960. ' ' '' 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") & "'"
  1961. ' ' '' cmd.CommandText = Sql
  1962. ' ' '' dr = cmd.ExecuteScalar
  1963. ' ' '' chem_balance(matl_no, quantity - (dt1.Rows(0).Item("quantity") - dt1.Rows(0).Item("w")), x + 1, id)
  1964. ' ' '' Else
  1965. ' ' '' 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 & "')"
  1966. ' ' '' cmd.CommandText = Sql
  1967. ' ' '' dr = cmd.ExecuteScalar
  1968. ' ' '' 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") & "'"
  1969. ' ' '' cmd.CommandText = Sql
  1970. ' ' '' dr = cmd.ExecuteScalar
  1971. ' ' '' End If
  1972. ' ' ''End If
  1973. ' End Sub
  1974. ' Private Sub Button20_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button20.Click
  1975. ' Dim rcp_name As String = ""
  1976. ' Dim sql As String = ""
  1977. ' If conn.State = ConnectionState.Closed Then
  1978. ' conn.Open()
  1979. ' End If
  1980. ' sql = "delete from " & rcp & " where rcp_no='" & DGV1.Rows(DGV1.CurrentRow.Index).Cells(0).Value & "'"
  1981. ' cmd.Connection = conn
  1982. ' cmd.CommandText = sql
  1983. ' cmd.ExecuteScalar()
  1984. ' 'sql = "delete from " & rcp1 & " where rcp_no='" & DGV1.Rows(DGV1.CurrentRow.Index).Cells(0).Value & "'"
  1985. ' 'cmd.Connection = conn
  1986. ' 'cmd.CommandText = sql
  1987. ' 'cmd.ExecuteScalar()
  1988. ' conn.Close()
  1989. ' End Sub
  1990. ' Private Sub Button14_Click_1(sender As Object, e As EventArgs) Handles Button14.Click
  1991. ' If ListBox2.SelectedIndex = -1 Or ListBox2.SelectedIndex = -1 Or ListBox2.SelectedIndex = -1 Then
  1992. ' MsgBox("請先選擇客戶產品顏色", , "錯誤")
  1993. ' Exit Sub
  1994. ' End If
  1995. ' Dim sql As String = ""
  1996. ' Dim con As New SqlConnection
  1997. ' Dim rcp_no As String = ""
  1998. ' Dim cust_no As String = ""
  1999. ' Dim prod_id As String = ""
  2000. ' Dim color_no As String = ""
  2001. ' con.ConnectionString = connstring
  2002. ' con.Open()
  2003. ' cmd.Connection = con
  2004. ' sql = "select id from customer where cust_name='" & ListBox2.SelectedItem & "'"
  2005. ' cmd.CommandText = sql
  2006. ' cust_no = cmd.ExecuteScalar
  2007. ' sql = "select prod_id from tblproduct where prod_name='" & ListBox3.SelectedItem & "'"
  2008. ' cmd.CommandText = sql
  2009. ' prod_id = cmd.ExecuteScalar
  2010. ' sql = "select color_no from color where color_name='" & ListBox4.SelectedItem & "'"
  2011. ' cmd.CommandText = sql
  2012. ' color_no = cmd.ExecuteScalar
  2013. ' 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 & "'"
  2014. ' cmd.CommandText = sql
  2015. ' Dim c As Integer = cmd.ExecuteScalar
  2016. ' If c = 0 Then
  2017. ' rr = prod_id & String.Format("{0:D2}", c) & String.Format("{0:D3}", cust_no) & color_no
  2018. ' Else
  2019. ' rr = prod_id & String.Format("{0:D2}", c + 1) & String.Format("{0:D3}", cust_no) & color_no
  2020. ' End If
  2021. ' sql = "select count(*) from prescription_main where rcp_no='" & rr & "'"
  2022. ' cmd.CommandText = sql
  2023. ' c = cmd.ExecuteScalar
  2024. ' rcp_name = ListBox2.SelectedItem & ListBox4.SelectedItem & ListBox3.SelectedItem
  2025. ' rcp_name = InputBox("處方名稱", "詢問", rcp_name)
  2026. ' sql = "select count(*) from prescription_main where rcp_no='" & rr & "'"
  2027. ' cmd.CommandText = sql
  2028. ' Dim a As Integer = cmd.ExecuteScalar
  2029. ' If a = 0 Then
  2030. ' 'sql = "insert into prescription_main (rcp_no,rcp_name,creat_d) values ( '" & rcp_no & "','" & rcp_name & "','" & Now & "')"
  2031. ' 'cmd.CommandText = sql
  2032. ' 'Dim b As Integer = cmd.ExecuteScalar()
  2033. ' 'If b <> 0 Then
  2034. ' ' MsgBox("新增處方完成")
  2035. ' ' Exit Sub
  2036. ' 'End If
  2037. ' Else
  2038. ' MsgBox("處方編號重覆")
  2039. ' gAddfromOther = False
  2040. ' Exit Sub
  2041. ' End If
  2042. ' Dim msg As MsgBoxResult
  2043. ' msg = MsgBox("是否要由其他處方修改?", vbYesNoCancel, "詢問")
  2044. ' gAddfromOther = True
  2045. ' Dim my_rcp As String = ""
  2046. ' my_rcp = InputBox("請輸入處方編號")
  2047. ' If my_rcp = "" Then Exit Sub
  2048. ' 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 & "%'"
  2049. ' cmd.CommandText = sql_rcp
  2050. ' da.SelectCommand = cmd
  2051. ' Dim ds As New DataSet
  2052. ' da.Fill(ds)
  2053. ' DGV1.DataSource = ds.Tables(0)
  2054. ' Timer1.Enabled = True
  2055. ' con.Close()
  2056. ' End Sub
  2057. ' Private Sub dgv_cost_CellEnter(sender As Object, e As DataGridViewCellEventArgs) Handles dgv_cost.CellEnter
  2058. ' Dim ds1 As New DataSet
  2059. ' Dim ds2 As New DataSet
  2060. ' Dim cn As New SqlConnection
  2061. ' cn.ConnectionString = connstring
  2062. ' cn.Open()
  2063. ' cmd.Connection = cn
  2064. ' sql_rcp = "select rcp_content.ITEM AS 項目,rcp_content.MATL_NO AS 編號,tblMaterial.MATL_NAME AS 品名,rcp_content.percents AS 比例 " &
  2065. ' " FROM " & rcp & " INNER JOIN rcp_content ON " & rcp & ".RCP_NO = rcp_content.RCP_NO INNER JOIN " &
  2066. ' " 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"
  2067. ' cmd.CommandText = sql_rcp
  2068. ' da.SelectCommand = cmd
  2069. ' da.Fill(ds2)
  2070. ' dgv_chem_detail.DataSource = ds2.Tables(0)
  2071. ' dgv_chem_detail.Columns(0).Width = 38
  2072. ' dgv_chem_detail.Columns(1).Width = 50
  2073. ' dgv_chem_detail.Columns(2).Width = 80
  2074. ' dgv_chem_detail.Columns(3).Width = 50
  2075. ' End Sub
  2076. ' Private Sub set_grid()
  2077. ' DGV1.Columns(0).Width = 280
  2078. ' DGV1.Columns(1).Width = 140
  2079. ' 'DGV1.Columns(2).Visible = False
  2080. ' 'DGV1.Columns(3).Visible = False
  2081. ' 'DGV1.Columns(4).Visible = False
  2082. ' 'DGV1.RowHeadersVisible = False
  2083. ' 'If gUserName <> "matchy" Then
  2084. ' ' dgv2.Columns(6).Visible = False
  2085. ' ' dgv2.Columns(7).Visible = False
  2086. ' 'End If
  2087. ' End Sub
  2088. ' Private Sub set_grid1()
  2089. ' 'dgv2.Columns(0).Width = 70
  2090. ' 'dgv2.Columns(1).Width = 350
  2091. ' 'dgv2.Columns(2).Width = 80
  2092. ' 'dgv2.Columns(3).Width = 80
  2093. ' 'dgv2.Columns(4).Width = 300
  2094. ' ' dgv2.Columns(5).Visible = False
  2095. ' 'dgv2.Columns(5).Width = 150
  2096. ' 'dgv2.Columns(6).Width = 59
  2097. ' 'dgv2.Columns(7).Width = 60
  2098. ' 'dgv2.Columns(8).Width = 50
  2099. ' 'dgv2.Columns(9).Width = 200
  2100. ' 'If gUserName <> "matchy" Then
  2101. ' ' dgv2.Columns(5).Width = 207
  2102. ' ' dgv2.Columns(6).Visible = False
  2103. ' ' dgv2.Columns(7).Visible = False
  2104. ' 'End If
  2105. ' DataGridView1.Columns(0).Width = 100
  2106. ' DataGridView1.Columns(1).Width = 180
  2107. ' DataGridView1.Columns(2).Width = 150
  2108. ' DataGridView1.Columns(3).Width = 120
  2109. ' DataGridView1.Columns(4).Width = 120
  2110. ' DataGridView1.Columns(5).Width = 100
  2111. ' DataGridView1.Columns(6).Width = 280
  2112. ' DataGridView1.Columns("系统品名").Width = 300
  2113. ' DataGridView1.Columns("系统代码").Width = 250
  2114. ' For x As Integer = 7 To 16
  2115. ' DataGridView1.Columns(x).Visible = False
  2116. ' Next
  2117. ' End Sub
  2118. ' Private Sub set_grid2()
  2119. ' dgv_record.Columns(0).Width = 38
  2120. ' dgv_record.Columns(1).Width = 58
  2121. ' dgv_record.Columns(2).Width = 150
  2122. ' dgv_record.Columns(3).Width = 50
  2123. ' dgv_record.Columns(4).Width = 44
  2124. ' dgv_record.Columns(5).Width = 87
  2125. ' dgv_record.Columns(6).Width = 59
  2126. ' dgv_record.Columns(7).Width = 60
  2127. ' 'If gUserName <> "matchy" Then
  2128. ' ' dgv_record.Columns(6).Visible = False
  2129. ' ' dgv_record.Columns(7).Visible = False
  2130. ' 'End If
  2131. ' End Sub
  2132. ' Private Sub set_grid3()
  2133. ' dgv_cost.Columns(0).Width = 60
  2134. ' dgv_cost.Columns(1).Width = 60
  2135. ' 'dgv_cost.Columns(2).Width = 60
  2136. ' 'dgv_cost.Columns(3).Width = 60
  2137. ' End Sub
  2138. ' Private Sub DGV1_CellMouseUp(sender As Object, e As DataGridViewCellMouseEventArgs) Handles DGV1.CellMouseUp
  2139. ' Dim ds1 As New DataSet
  2140. ' Dim ds2 As New DataSet
  2141. ' Dim cn As New SqlConnection
  2142. ' DT2.Clear()
  2143. ' cn.ConnectionString = connstring
  2144. ' cn.Open()
  2145. ' cmd.Connection = cn
  2146. ' txttan.Text = ""
  2147. ' txtKJ.Text = ""
  2148. ' txtoil.Text = ""
  2149. ' txtdye.Text = ""
  2150. ' txtaux.Text = ""
  2151. ' txtbxs.Text = ""
  2152. ' txtfrj.Text = ""
  2153. ' 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, 项次"
  2154. ' 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
  2155. ' 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,
  2156. ' 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 系统品名,
  2157. ' HT_K3_Material.code as 系统代码
  2158. 'FROM HT_K3_Material RIGHT OUTER JOIN
  2159. ' HT_Rcp_ChemName_table ON HT_K3_Material.name = HT_Rcp_ChemName_table.sys_chem_name LEFT OUTER JOIN
  2160. ' HT_Chem_Main LEFT OUTER JOIN
  2161. ' (SELECT filename, SUBSTRING(filename, 1, CHARINDEX('_', filename) - 1) AS no
  2162. ' 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
  2163. ' HT_RetanRcp ON HT_Rcp_ChemName_table.rcp_chem_name = HT_RetanRcp.chem
  2164. '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
  2165. ' HT_K3_Material.code IS NULL)
  2166. 'ORDER BY HT_RetanRcp.rcp_no DESC, 项次"
  2167. ' sql_rcp = "SELECT
  2168. ' HT_RetanRcp.item AS 项次,
  2169. ' HT_RetanRcp.chem AS 化料名称,
  2170. ' CASE
  2171. ' WHEN type1 IS NULL THEN ''
  2172. ' ELSE HT_Chem_Main.type1
  2173. ' END AS 化工分类,
  2174. ' CASE
  2175. ' WHEN type2 IS NULL THEN N'不列印'
  2176. ' ELSE HT_Chem_Main.type2
  2177. ' END AS 类别,
  2178. ' HT_RetanRcp.percents AS 百分比,
  2179. ' HT_RetanRcp.time AS 时间,
  2180. ' HT_RetanRcp.comment AS 备注,
  2181. ' HT_Chem_Main.d1, HT_Chem_Main.d2, HT_Chem_Main.d3, HT_Chem_Main.d4, HT_Chem_Main.d5,
  2182. ' HT_Chem_Main.d6, HT_Chem_Main.d7, HT_Chem_Main.d8, HT_Chem_Main.d9,
  2183. ' HT_MSDS_File_1.filename,
  2184. ' CASE
  2185. ' WHEN HT_K3_Material.name IS NULL THEN HT_RetanRcp.chem
  2186. ' ELSE HT_K3_Material.name
  2187. ' END AS 系统品名,
  2188. ' HT_K3_Material.code AS 系统代码,
  2189. ' -- 添加进货单价
  2190. ' HT_Chem_In.price AS 进货单价
  2191. 'FROM
  2192. ' HT_K3_Material
  2193. 'RIGHT OUTER JOIN
  2194. ' HT_Rcp_ChemName_table ON HT_K3_Material.name = HT_Rcp_ChemName_table.sys_chem_name
  2195. 'LEFT OUTER JOIN
  2196. ' HT_Chem_Main
  2197. 'LEFT OUTER JOIN
  2198. ' (SELECT
  2199. ' filename,
  2200. ' SUBSTRING(filename, 1, CHARINDEX('_', filename) - 1) AS no
  2201. ' FROM
  2202. ' HT_MSDS_File
  2203. ' ) AS HT_MSDS_File_1
  2204. ' ON HT_Chem_Main.no = HT_MSDS_File_1.no
  2205. 'ON HT_Rcp_ChemName_table.sys_chem_name = HT_Chem_Main.sys_name
  2206. 'RIGHT OUTER JOIN
  2207. ' HT_RetanRcp ON HT_Rcp_ChemName_table.rcp_chem_name = HT_RetanRcp.chem
  2208. '-- 加入进货单价的子查询,连接条件改为系统代码与 HT_Chem_In.no
  2209. 'LEFT OUTER JOIN (
  2210. ' SELECT
  2211. ' code,
  2212. ' price,
  2213. ' no,
  2214. ' ROW_NUMBER() OVER (PARTITION BY code ORDER BY date DESC) AS rn
  2215. ' FROM HT_Chem_In
  2216. ' WHERE date <= DATEADD(DAY, 7, GETDATE()) -- 替换 GETDATE() 为 HT_RetanRcp.date 来动态获取日期
  2217. ') AS HT_Chem_In
  2218. ' ON HT_K3_Material.code = HT_Chem_In.code
  2219. ' AND HT_Chem_In.no = HT_Chem_In.no -- 使用 no 进行匹配
  2220. ' AND HT_Chem_In.rn = 1
  2221. 'WHERE
  2222. ' HT_RetanRcp.name = N'" & DGV1.Rows(DGV1.CurrentRow.Index).Cells("品名").Value & "'
  2223. ' AND HT_RetanRcp.date = N'" & DGV1.Rows(DGV1.CurrentRow.Index).Cells("日期").Value & "'
  2224. ' AND HT_RetanRcp.selection = N'" & DGV1.Rows(DGV1.CurrentRow.Index).Cells("选级").Value & "'
  2225. ' AND HT_RetanRcp.no = N'" & DGV1.Rows(DGV1.CurrentRow.Index).Cells("流程卡号").Value & "'
  2226. ' AND (HT_RetanRcp.chem <> '')
  2227. ' AND (HT_K3_Material.code NOT LIKE 'ck00006%' OR HT_K3_Material.code IS NULL)
  2228. 'ORDER BY
  2229. ' HT_RetanRcp.rcp_no DESC, 项次;
  2230. '"
  2231. ' Label20.Text = DGV1.Rows(DGV1.CurrentRow.Index).Cells("品名").Value.ToString
  2232. ' Label21.Text = "开削" & DGV1.Rows(DGV1.CurrentRow.Index).Cells("开削").Value.ToString
  2233. ' cmd.CommandText = sql_rcp
  2234. ' da.SelectCommand = cmd
  2235. ' da.Fill(DT2)
  2236. ' DataGridView1.DataSource = DT2
  2237. ' DataGridView1.RowTemplate.Height = 30
  2238. ' set_grid1()
  2239. ' cal_cost1()
  2240. ' End Sub
  2241. ' Private Sub cal_cost()
  2242. ' ' 使用 LINQ 进行 Group By 操作,并取每个分组中的进货单价
  2243. ' Dim groupedData = From row In DT2.AsEnumerable()
  2244. ' Group row By category = row.Field(Of String)("化工分类") Into Group
  2245. ' Select category,
  2246. ' TotalAmount = Group.Sum(Function(r) If(IsNumeric(r.Field(Of Object)("百分比")), Convert.ToDouble(r.Field(Of Object)("百分比")), 0)),
  2247. ' PurchasePrice = If(Group.Any(Function(r) IsNumeric(r.Field(Of Object)("进货单价"))),
  2248. ' Convert.ToDouble(Group.Select(Function(r) r.Field(Of Object)("进货单价")).FirstOrDefault()),
  2249. ' 0)
  2250. ' ' 创建新的 DataTable 来存储分组后的数据
  2251. ' Dim newDataTable As New DataTable()
  2252. ' newDataTable.Columns.Add("Category", GetType(String))
  2253. ' newDataTable.Columns.Add("TotalAmount", GetType(Double))
  2254. ' newDataTable.Columns.Add("PurchasePrice", GetType(Double))
  2255. ' ' 将 groupedData 中的数据插入到新的 DataTable 中
  2256. ' For Each item In groupedData
  2257. ' Dim newRow As DataRow = newDataTable.NewRow()
  2258. ' newRow("Category") = item.category
  2259. ' newRow("TotalAmount") = item.TotalAmount
  2260. ' newRow("PurchasePrice") = item.PurchasePrice
  2261. ' newDataTable.Rows.Add(newRow)
  2262. ' Next
  2263. ' DataGridView2.DataSource = newDataTable
  2264. ' DataGridView2.ReadOnly = True
  2265. ' DataGridView2.RowHeadersWidth = 20
  2266. ' End Sub
  2267. ' Private Sub cal_cost1()
  2268. ' ' 获取 DataGridView1 中当前选中行的索引
  2269. ' Dim selectedRowIndex As Integer = DGV1.CurrentCell.RowIndex
  2270. ' ' 获取 DataGridView1 中选中行的 "重量"
  2271. ' Dim weight As Double = Convert.ToDouble(DGV1.Rows(selectedRowIndex).Cells("重量").Value)
  2272. ' ' 在 DataGridView2 的 DataTable 中添加一列用于存储“金额小计”
  2273. ' If Not DataGridView1.DataSource Is Nothing Then
  2274. ' Dim dt2 As DataTable = CType(DataGridView1.DataSource, DataTable)
  2275. ' ' 检查是否已添加过金额小计列
  2276. ' If Not dt2.Columns.Contains("Amount") Then
  2277. ' dt2.Columns.Add("Amount", GetType(Double))
  2278. ' End If
  2279. ' ' 遍历 DataGridView2 中的每一行,计算金额小计
  2280. ' For Each row As DataRow In dt2.Rows
  2281. ' ' 获取 DataGridView2 中的百分比和进货单价
  2282. ' Dim percentage As Double = Convert.ToDouble(row("百分比"))
  2283. ' ' 检查进货单价是否为 DBNull
  2284. ' Dim purchasePrice As Double = 0
  2285. ' If Not IsDBNull(row("进货单价")) Then
  2286. ' purchasePrice = Convert.ToDouble(row("进货单价"))
  2287. ' End If
  2288. ' ' 如果进货单价有效,计算金额小计
  2289. ' If purchasePrice > 0 Then
  2290. ' Dim amount As Double = weight * purchasePrice * percentage / 100
  2291. ' row("Amount") = amount ' 将金额小计添加到该行
  2292. ' Else
  2293. ' row("Amount") = 0 ' 如果进货单价无效,则设置金额小计为 0
  2294. ' End If
  2295. ' Next
  2296. ' End If
  2297. ' ' 使用 LINQ 进行 Group By 操作,并按化工分类汇总百分比和金额小计
  2298. ' Dim groupedData = From row In DataGridView1.Rows.Cast(Of DataGridViewRow)()
  2299. ' Where row.Cells("化工分类").Value.ToString() <> "水" ' 排除 "水" 分类
  2300. ' Group row By category = row.Cells("化工分类").Value.ToString() Into Group
  2301. ' Select category,
  2302. ' TotalPercentag1 = Group.Sum(Function(r) Convert.ToDouble(r.Cells("百分比").Value)),
  2303. ' TotalAmount1 = Group.Sum(Function(r) Convert.ToDouble(r.Cells("Amount").Value))
  2304. ' ' 创建一个新的 DataTable 来存储汇总结果
  2305. ' Dim newDataTable As New DataTable()
  2306. ' newDataTable.Columns.Add("Category", GetType(String)) ' 分类
  2307. ' newDataTable.Columns.Add("TotalPercentage", GetType(Double)) ' 汇总的百分比
  2308. ' newDataTable.Columns.Add("TotalAmount", GetType(Double)) ' 汇总的金额小计
  2309. ' ' 将汇总数据添加到 DataTable
  2310. ' For Each item In groupedData
  2311. ' Dim newRow As DataRow = newDataTable.NewRow()
  2312. ' newRow("Category") = item.category
  2313. ' newRow("TotalPercentage") = Math.Round(item.TotalPercentag1, 1) ' 保留1位小数
  2314. ' newRow("TotalAmount") = Math.Floor(item.TotalAmount1) ' 保留整数
  2315. ' newDataTable.Rows.Add(newRow)
  2316. ' Next
  2317. ' ' 计算总百分比和总金额
  2318. ' Dim totalPercentage As Double = groupedData.Where(Function(g) g.category <> "").Sum(Function(g) g.TotalPercentag1)
  2319. ' Dim totalAmount As Double = groupedData.Where(Function(g) g.category <> "").Sum(Function(g) g.TotalAmount1)
  2320. ' ' 添加总汇总行
  2321. ' Dim totalRow As DataRow = newDataTable.NewRow()
  2322. ' totalRow("Category") = "Total"
  2323. ' totalRow("TotalPercentage") = Math.Round(totalPercentage, 1) ' 保留1位小数
  2324. ' totalRow("TotalAmount") = Math.Floor(totalAmount) ' 保留整数
  2325. ' newDataTable.Rows.Add(totalRow)
  2326. ' ' 将结果绑定到 DataGridView3
  2327. ' DataGridView2.DataSource = newDataTable
  2328. ' DataGridView2.ReadOnly = True
  2329. ' DataGridView2.RowHeadersWidth = 20
  2330. ' ' 设置最后一行的字体颜色为红色
  2331. ' Dim lastRowIndex As Integer = DataGridView2.Rows.Count - 2
  2332. ' DataGridView2.Rows(lastRowIndex).DefaultCellStyle.ForeColor = Color.Red
  2333. ' DataGridView2.AllowUserToAddRows = False
  2334. ' ' 设置 TotalAmount 列为右对齐并加上千分位格式
  2335. ' DataGridView2.Columns("TotalAmount").DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight
  2336. ' DataGridView2.Columns("TotalAmount").DefaultCellStyle.Format = "N0"
  2337. ' End Sub
  2338. ' Private Sub dgv2_RowPostPaint(sender As Object, e As DataGridViewRowPostPaintEventArgs) Handles dgv2.RowPostPaint
  2339. ' Dim linePen As New Pen(Color.Aquamarine, 2)
  2340. ' If e.RowIndex = dgv2.Rows.Count - 1 Then
  2341. ' dgv2.Rows(e.RowIndex).Cells("百分比").Style.ForeColor = Color.White
  2342. ' Dim startX As Integer = IIf(dgv2.RowHeadersVisible, dgv2.RowHeadersWidth, 0)
  2343. ' Dim startY As Integer = e.RowBounds.Top + e.RowBounds.Height - 1
  2344. ' Dim endX As Integer = startX + dgv2.Columns.GetColumnsWidth(DataGridViewElementStates.Visible) - dgv2.HorizontalScrollingOffset - 100
  2345. ' e.Graphics.DrawLine(linePen, startX, startY, endX, startY)
  2346. ' Exit Sub
  2347. ' End If
  2348. ' 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
  2349. ' ElseIf dgv2.Rows(e.RowIndex).Cells("时间").Value.ToString <> "" Then
  2350. ' Dim startX As Integer = IIf(dgv2.RowHeadersVisible, dgv2.RowHeadersWidth, 0)
  2351. ' Dim startY As Integer = e.RowBounds.Top + e.RowBounds.Height - 1
  2352. ' Dim endX As Integer = startX + dgv2.Columns.GetColumnsWidth(DataGridViewElementStates.Visible) - dgv2.HorizontalScrollingOffset - 100
  2353. ' e.Graphics.DrawLine(linePen, startX, startY, endX, startY)
  2354. ' End If
  2355. ' If (dgv2.Rows(e.RowIndex).Cells("化料名称").Value.ToString = "流水洗" Or dgv2.Rows(e.RowIndex).Cells("化料名称").Value.ToString = "洗水" Or dgv2.Rows(e.RowIndex).Cells("化料名称").Value = "排水") Then
  2356. ' dgv2.Rows(e.RowIndex).Cells("百分比").Style.ForeColor = Color.White
  2357. ' Dim startX As Integer = IIf(dgv2.RowHeadersVisible, dgv2.RowHeadersWidth, 0)
  2358. ' Dim startY As Integer = e.RowBounds.Top + e.RowBounds.Height - 1
  2359. ' Dim endX As Integer = startX + dgv2.Columns.GetColumnsWidth(DataGridViewElementStates.Visible) - dgv2.HorizontalScrollingOffset - 100
  2360. ' e.Graphics.DrawLine(linePen, startX, startY, endX, startY)
  2361. ' End If
  2362. ' End Sub
  2363. ' Private Sub DataGridView1_RowPostPaint(sender As Object, e As DataGridViewRowPostPaintEventArgs) Handles DataGridView1.RowPostPaint
  2364. ' If e.RowIndex + 1 > DataGridView1.Rows.Count - 1 Then Exit Sub
  2365. ' If DataGridView1.Rows(e.RowIndex + 1).Cells("化料名称").Value Is Nothing Then Exit Sub
  2366. ' Dim linePen As New Pen(Color.Red, 2)
  2367. ' If e.RowIndex = DataGridView1.Rows.Count - 1 Then
  2368. ' DataGridView1.Rows(e.RowIndex).Cells("百分比").Style.ForeColor = Color.White
  2369. ' Dim startX As Integer = IIf(DataGridView1.RowHeadersVisible, DataGridView1.RowHeadersWidth, 0)
  2370. ' Dim startY As Integer = e.RowBounds.Top + e.RowBounds.Height - 1
  2371. ' Dim endX As Integer = startX + DataGridView1.Columns.GetColumnsWidth(DataGridViewElementStates.Visible) - DataGridView1.HorizontalScrollingOffset - 10
  2372. ' e.Graphics.DrawLine(linePen, startX, startY, endX, startY)
  2373. ' Exit Sub
  2374. ' End If
  2375. ' If DataGridView1.Rows(e.RowIndex).Cells("时间").Value.ToString <> "" Then
  2376. ' Dim startX As Integer = IIf(DataGridView1.RowHeadersVisible, DataGridView1.RowHeadersWidth, 0)
  2377. ' Dim startY As Integer = e.RowBounds.Top + e.RowBounds.Height - 1
  2378. ' Dim endX As Integer = startX + DataGridView1.Columns.GetColumnsWidth(DataGridViewElementStates.Visible) - DataGridView1.HorizontalScrollingOffset - 10
  2379. ' e.Graphics.DrawLine(linePen, startX, startY, endX, startY)
  2380. ' End If
  2381. ' 'If (DataGridView1.Rows(e.RowIndex).Cells("化料名称").Value.ToString = "流水洗" Or DataGridView1.Rows(e.RowIndex).Cells("化料名称").Value.ToString = "洗水" Or DataGridView1.Rows(e.RowIndex).Cells("化料名称").Value = "排水") Then
  2382. ' ' DataGridView1.Rows(e.RowIndex).Cells("百分比").Style.ForeColor = Color.White
  2383. ' ' Dim startX As Integer = IIf(DataGridView1.RowHeadersVisible, DataGridView1.RowHeadersWidth, 0)
  2384. ' ' Dim startY As Integer = e.RowBounds.Top + e.RowBounds.Height - 1
  2385. ' ' Dim endX As Integer = startX + DataGridView1.Columns.GetColumnsWidth(DataGridViewElementStates.Visible) - DataGridView1.HorizontalScrollingOffset - 10
  2386. ' ' e.Graphics.DrawLine(linePen, startX, startY, endX, startY)
  2387. ' 'End If
  2388. ' End Sub
  2389. ' Private Sub Button24_Click(sender As Object, e As EventArgs) Handles Button24.Click 'msds
  2390. ' cmd.Connection = conn
  2391. ' If conn.State = ConnectionState.Closed Then
  2392. ' conn.Open()
  2393. ' End If
  2394. ' Dim sql As String
  2395. ' Dim folderPath As String = "\\DS920plus\华峰业务\AA化料文件资料\2024年整理MSDS和ZDHC\MSDS\MSDS总表"
  2396. ' ' 检查文件夹是否存在
  2397. ' If Directory.Exists(folderPath) Then
  2398. ' ' 获取文件夹内所有文件的路径
  2399. ' Dim files As String() = Directory.GetFiles(folderPath)
  2400. ' ' 遍历文件数组并输出文件名
  2401. ' For Each file As String In files
  2402. ' ' 输出文件名
  2403. ' Console.WriteLine(Path.GetFileName(file))
  2404. ' sql = "insert into ht_msds_file (filename) values (N'" & Path.GetFileName(file) & "')"
  2405. ' cmd.CommandText = sql
  2406. ' cmd.ExecuteScalar()
  2407. ' Next
  2408. ' Else
  2409. ' Console.WriteLine("目录不存在!")
  2410. ' End If
  2411. ' MsgBox("")
  2412. ' End Sub
  2413. ' Sub InsertImageWithNPOI(start_row As Integer, start_column As Integer)
  2414. ' ' 创建 NPOI 工作簿和工作表
  2415. ' Dim workbook As New XSSFWorkbook()
  2416. ' Dim sheet As XSSFSheet = workbook.CreateSheet("Sheet1")
  2417. ' ' 图片数据
  2418. ' Dim pictureData As Byte() = Nothing
  2419. ' Using ms As New MemoryStream()
  2420. ' ' 从 PictureBox1 中获取图片
  2421. ' PictureBox1.Image.Save(ms, Imaging.ImageFormat.Png)
  2422. ' pictureData = ms.ToArray()
  2423. ' End Using
  2424. ' ' 将图片添加到工作簿中
  2425. ' Dim pictureIndex As Integer = workbook.AddPicture(pictureData, PictureType.PNG)
  2426. ' ' 创建绘图对象
  2427. ' Dim drawing As XSSFDrawing = sheet.CreateDrawingPatriarch()
  2428. ' ' 创建图片锚点
  2429. ' Dim anchor As IClientAnchor = workbook.GetCreationHelper().CreateClientAnchor()
  2430. ' anchor.Col1 = start_column ' 起始列(从 0 开始计数)
  2431. ' anchor.Row1 = start_row ' 起始行(从 0 开始计数)
  2432. ' anchor.Col2 = start_column ' 结束列
  2433. ' anchor.Row2 = start_row ' 结束行
  2434. ' ' 插入图片
  2435. ' Dim picture As IPicture = drawing.CreatePicture(anchor, pictureIndex)
  2436. ' ' 调整图片大小
  2437. ' picture.Resize(0.29) ' 设置缩放比例,例如 0.29 表示缩放为原大小的 29%
  2438. ' ' 保存文件
  2439. ' Dim saveFilePath As String = "c:\GHS\output.xlsx"
  2440. ' Using fs As New FileStream(saveFilePath, FileMode.Create, FileAccess.Write)
  2441. ' workbook.Write(fs)
  2442. ' End Using
  2443. ' ' MsgBox("图片插入完成!")
  2444. ' End Sub
  2445. ' Private Sub Button25_Click(sender As Object, e As EventArgs)
  2446. ' End Sub
  2447. ' Function ImageToByteArray(image As Image) As Byte()
  2448. ' Using ms As New MemoryStream()
  2449. ' image.Save(ms, ImageFormat.Png)
  2450. ' Return ms.ToArray()
  2451. ' End Using
  2452. ' End Function
  2453. ' Private Sub Button26_Click(sender As Object, e As EventArgs) Handles Button26.Click
  2454. ' Dim my_card As String
  2455. ' Dim my_weight As Double
  2456. ' Dim d_no As String
  2457. ' Do
  2458. ' my_card = InputBox("请输入卡号:", "查询", DGV1.Rows(DGV1.CurrentCell.RowIndex).Cells(4).Value)
  2459. ' If my_card = "" Then
  2460. ' MsgBox("操作已取消。", vbInformation, "退出")
  2461. ' Exit Sub ' 立即退出子程序
  2462. ' ElseIf my_card = "" Then
  2463. ' MsgBox("请重新输入!", vbExclamation, "错误")
  2464. ' Else
  2465. ' Exit Do
  2466. ' End If
  2467. ' Loop
  2468. ' ' 验证重量输入
  2469. ' Do
  2470. ' Dim weightInput As String
  2471. ' weightInput = InputBox("请输入重量:", "查询", DGV1.Rows(DGV1.CurrentCell.RowIndex).Cells(3).Value)
  2472. ' If weightInput = "" Then
  2473. ' MsgBox("操作已取消。", vbInformation, "退出")
  2474. ' Exit Sub
  2475. ' ElseIf Not IsNumeric(weightInput) Then
  2476. ' MsgBox("重量必须是数字,请重新输入!", vbExclamation, "错误")
  2477. ' ElseIf CDbl(weightInput) <= 0 Then
  2478. ' MsgBox("重量必须大于0,请重新输入!", vbExclamation, "错误")
  2479. ' Else
  2480. ' my_weight = CDbl(weightInput)
  2481. ' Exit Do
  2482. ' End If
  2483. ' Loop
  2484. ' ' 验证编号输入
  2485. ' Do
  2486. ' d_no = InputBox("请输入编号:", "查询", 10)
  2487. ' If d_no = "" Then
  2488. ' MsgBox("操作已取消。", vbInformation, "退出")
  2489. ' Exit Sub
  2490. ' ElseIf d_no Like "*-*" Then
  2491. ' ' MsgBox("编号格式不正确,请输入类似 'P241129-4' 的编号!", vbExclamation, "错误")
  2492. ' Else
  2493. ' Exit Do
  2494. ' End If
  2495. ' Loop
  2496. ' ' 图片路径(假设图片名为 1.jpg 到 9.jpg)
  2497. ' Dim imagePaths As String() = {
  2498. ' "C:\GHS\1.jpg", "C:\GHS\2.jpg", "C:\GHS\3.jpg",
  2499. ' "C:\GHS\4.jpg", "C:\GHS\5.jpg", "C:\GHS\6.jpg",
  2500. ' "C:\GHS\7.jpg", "C:\GHS\8.jpg", "C:\GHS\9.jpg"
  2501. ' }
  2502. ' Dim dataTable As New DataTable()
  2503. ' dataTable = DataGridView1.DataSource
  2504. ' ' 创建 Excel 工作簿
  2505. ' Dim workbook As IWorkbook = New XSSFWorkbook()
  2506. ' Dim sheet As ISheet = workbook.CreateSheet("Chemicals")
  2507. ' ' 创建隐藏的图片库工作表
  2508. ' Dim imageSheet As ISheet = workbook.CreateSheet("ImageLibrary")
  2509. ' '' workbook.SetSheetHidden(workbook.GetSheetIndex("ImageLibrary"), SheetState.Hidden)
  2510. ' ' 加载图片到图片库
  2511. ' Dim drawing As IDrawing = imageSheet.CreateDrawingPatriarch()
  2512. ' For i As Integer = 0 To imagePaths.Length - 1
  2513. ' Dim imagePath As String = imagePaths(i)
  2514. ' If File.Exists(imagePath) Then
  2515. ' Dim bytes As Byte() = File.ReadAllBytes(imagePath)
  2516. ' Dim pictureIdx As Integer = workbook.AddPicture(bytes, PictureType.JPEG)
  2517. ' ' 插入图片到隐藏工作表
  2518. ' Dim anchor As IClientAnchor = workbook.GetCreationHelper().CreateClientAnchor()
  2519. ' anchor.Col1 = i + 2 ' 每张图片占一列
  2520. ' anchor.Row1 = 0
  2521. ' anchor.AnchorType = AnchorType.DontMoveAndResize
  2522. ' Dim picture As IPicture = drawing.CreatePicture(anchor, pictureIdx)
  2523. ' picture.Resize(1)
  2524. ' End If
  2525. ' Next
  2526. ' For col As Integer = 0 To 5
  2527. ' sheet.SetColumnWidth(col, 10 * 256) ' 图片列宽度
  2528. ' Next
  2529. ' ' 初始行位置
  2530. ' Dim currentRow As Integer = 0
  2531. ' Dim my_item As Integer
  2532. ' dataTable.DefaultView.Sort = "类别 ASC, 项次 ASC"
  2533. ' Dim sortedTable As DataTable = dataTable.DefaultView.ToTable()
  2534. ' ProgressBar1.Visible = True
  2535. ' ProgressBar1.Minimum = 0
  2536. ' ProgressBar1.Maximum = sortedTable.Rows.Count ' 假设 dt 是一个 DataTable
  2537. ' ProgressBar1.Value = 0 ' 初始进度为 0
  2538. ' ' 遍历 DataTable 的每一行
  2539. ' For Each row As DataRow In sortedTable.Rows
  2540. ' ProgressBar1.Value += 1
  2541. ' Application.DoEvents()
  2542. ' If row("类别") <> "不列印" Then
  2543. ' '生成二维码图片
  2544. ' Dim qrCodeImage As Image = MakeQrCode("http://192.168.110.164:8888/" & row("filename"))
  2545. ' Dim imageBytes As Byte() = ImageToByteArray(qrCodeImage)
  2546. ' ' 插入二维码图片到第4列
  2547. ' Dim drawingQrCode As IDrawing = sheet.CreateDrawingPatriarch()
  2548. ' Dim anchorQrCode As IClientAnchor = workbook.GetCreationHelper().CreateClientAnchor()
  2549. ' anchorQrCode.Col1 = 4 ' 第4列
  2550. ' anchorQrCode.Row1 = currentRow + 7 ' 当前行
  2551. ' anchorQrCode.Col2 = 5 ' 跨1列
  2552. ' anchorQrCode.Row2 = currentRow + 11 ' 占用4行
  2553. ' Dim qrPictureIdx As Integer = workbook.AddPicture(imageBytes, PictureType.PNG)
  2554. ' Dim qrPicture As IPicture = drawingQrCode.CreatePicture(anchorQrCode, qrPictureIdx)
  2555. ' qrPicture.Resize(1) ' 缩放二维码
  2556. ' ' 写入化工信息
  2557. ' 'sheet.CreateRow(currentRow).CreateCell(3).SetCellValue($"卡号:{my_card}")
  2558. ' 'sheet.CreateRow(currentRow).CreateCell(7).SetCellValue($"项次:{row("项次")}")
  2559. ' ' 创建行并插入数据
  2560. ' Dim rowToInsert = sheet.CreateRow(currentRow) ' 只创建一行
  2561. ' ' 在第 4 列插入卡号
  2562. ' rowToInsert.CreateCell(0).SetCellValue($"卡号:{my_card}")
  2563. ' ' 在第 8 列插入项次
  2564. ' rowToInsert.CreateCell(4).SetCellValue($"项次:{row("项次")}")
  2565. ' Dim cellStyle As ICellStyle = workbook.CreateCellStyle()
  2566. ' Dim font As IFont = workbook.CreateFont()
  2567. ' font.FontHeightInPoints = 18 ' 设置字体大小为 18
  2568. ' cellStyle.SetFont(font) ' 将字体应用到样式
  2569. ' 'sheet.CreateRow(currentRow + 1).CreateCell(0).SetCellValue($"化料名称:{row("化料名称")}")
  2570. ' Dim row1 = sheet.CreateRow(currentRow + 1)
  2571. ' row1.CreateCell(0).SetCellValue($"化料名称:{row("化料名称")}")
  2572. ' row1.Cells(0).CellStyle = cellStyle ' 应用样式
  2573. ' sheet.AddMergedRegion(New NPOI.SS.Util.CellRangeAddress(currentRow + 1, currentRow + 1, 0, 4))
  2574. ' Dim row2 = sheet.CreateRow(currentRow + 2)
  2575. ' row2.CreateCell(0).SetCellValue($"重量:{row("百分比") * my_weight / 100}")
  2576. ' row2.CreateCell(3).SetCellValue($"{row("化工分类")}")
  2577. ' row2.Cells(0).CellStyle = cellStyle ' 应用样式
  2578. ' row2.Cells(1).CellStyle = cellStyle ' 应用样式
  2579. ' Dim row3 = sheet.CreateRow(currentRow + 3)
  2580. ' row3.CreateCell(4).SetCellValue($"鼓号")
  2581. ' Dim row4 = sheet.CreateRow(currentRow + 4)
  2582. ' row4.CreateCell(4).SetCellValue($"{d_no}")
  2583. ' Dim row5 = sheet.CreateRow(currentRow + 5)
  2584. ' row5.CreateCell(3).SetCellValue("百分比")
  2585. ' row5.CreateCell(4).SetCellValue("下鼓重")
  2586. ' Dim row6 = sheet.CreateRow(currentRow + 6)
  2587. ' row6.CreateCell(3).SetCellValue($"{row("百分比")}")
  2588. ' row6.CreateCell(4).SetCellValue($"{my_weight}")
  2589. ' Dim row7 = sheet.CreateRow(currentRow + 10)
  2590. ' row7.CreateCell(1).SetCellValue($"{DGV1.Rows(DGV1.CurrentCell.RowIndex).Cells(1).Value}")
  2591. ' 'Dim row8 = sheet.CreateRow(currentRow + 11)
  2592. ' 'row8.CreateCell(3).SetCellValue($"{row("百分比")}")
  2593. ' Dim row9 = sheet.CreateRow(currentRow + 12)
  2594. ' row9.CreateCell(1).SetCellValue($"打印时间:{DateTime.Now}")
  2595. ' sheet.AddMergedRegion(New NPOI.SS.Util.CellRangeAddress(currentRow + 2, currentRow + 2, 0, 2))
  2596. ' sheet.AddMergedRegion(New NPOI.SS.Util.CellRangeAddress(currentRow + 2, currentRow + 2, 3, 4))
  2597. ' ' 创建一个字体和边框样式
  2598. ' Dim cellStyle1 As ICellStyle = workbook.CreateCellStyle()
  2599. ' ' 设置外边框为粗线
  2600. ' cellStyle.BorderTop = BorderStyle.Double
  2601. ' cellStyle.BorderRight = BorderStyle.Double
  2602. ' cellStyle.BorderBottom = BorderStyle.Double
  2603. ' cellStyle.BorderLeft = BorderStyle.Double
  2604. ' ' 为 A2:E3 区域设置边框
  2605. ' ' 设置粗外框
  2606. ' For rowX As Integer = currentRow + 1 To currentRow + 2 ' 行索引从 1 开始
  2607. ' For col As Integer = 0 To 4 ' 列索引从 0 到 4 (A 到 E)
  2608. ' Dim cell As ICell = sheet.GetRow(rowX).GetCell(col)
  2609. ' If cell Is Nothing Then
  2610. ' cell = sheet.GetRow(rowX).CreateCell(col)
  2611. ' End If
  2612. ' cell.CellStyle = cellStyle ' 应用样式
  2613. ' Next
  2614. ' Next
  2615. ' ' 插入 d1-d9 对应的图片
  2616. ' Dim rowStart As Integer = currentRow ' 图片从当前行开始
  2617. ' Dim colStart1 As Integer = 0
  2618. ' Dim colStart As Integer = 0 ' d1-d9 的起始列
  2619. ' Dim imgPerRow As Integer = 3 ' 每行放3张图片
  2620. ' Dim row_start As Integer = 0
  2621. ' For i As Integer = 1 To 9
  2622. ' Dim colName As String = "d" & i
  2623. ' If row(colName).ToString() = "√" Then
  2624. ' row_start += 1
  2625. ' Dim imagePath As String = $"C:\GHS\{i}.jpg" ' 假设图片路径为 C:\GHS\1.jpg 到 C:\GHS\9.jpg
  2626. ' If File.Exists(imagePath) Then
  2627. ' Dim bytes As Byte() = File.ReadAllBytes(imagePath)
  2628. ' Dim pictureIdx As Integer = workbook.AddPicture(bytes, PictureType.JPEG)
  2629. ' Dim drawingMain As IDrawing = sheet.CreateDrawingPatriarch()
  2630. ' Dim anchor As IClientAnchor = workbook.GetCreationHelper().CreateClientAnchor()
  2631. ' anchor.Col1 = colStart
  2632. ' anchor.Row1 = rowStart + 3 ' 图片放在二维码下方,开始于第5行
  2633. ' anchor.Col2 = colStart + 1 ' 图片跨2列
  2634. ' anchor.Row2 = rowStart + 8 ' 图片占用5行
  2635. ' ' 设置偏移量(像素)
  2636. ' anchor.Dx1 = 200 ' 左上角水平偏移(单位:EMU)
  2637. ' anchor.Dy1 = 0 ' 左上角垂直偏移
  2638. ' anchor.Dx2 = 500 ' 右下角水平偏移
  2639. ' anchor.Dy2 = 0 ' 右下角垂直偏移
  2640. ' ' 设置锚点类型,图片不随单元格变化
  2641. ' anchor.AnchorType = AnchorType.DontMoveAndResize
  2642. ' Dim picture As IPicture = drawingMain.CreatePicture(anchor, pictureIdx)
  2643. ' picture.Resize(1) ' 缩放比例
  2644. ' ' 更新列位置
  2645. ' colStart += 1
  2646. ' If colStart >= imgPerRow Then
  2647. ' colStart1 = 1
  2648. ' colStart = 0 ' 回到第一列
  2649. ' rowStart += 5 ' 换行后行数增加5
  2650. ' End If
  2651. ' End If
  2652. ' End If
  2653. ' Next
  2654. ' If colStart1 = 1 Then rowStart -= 5
  2655. ' ' 更新当前行位置,确保下一个化工占用新行
  2656. ' currentRow = rowStart + 13 ' 增加行数以容纳二维码和图片
  2657. ' ' 插入换页符
  2658. ' sheet.SetRowBreak(currentRow - 1)
  2659. ' End If
  2660. ' Next
  2661. ' ' 保存文件
  2662. ' ' Dim filePath As String = $"卡号标签_{DateTime.Now.ToString("yyyyMMdd_HHmmss")}.xlsx"
  2663. ' Dim filePath As String = $"卡号标签_{my_card}.xlsx"
  2664. ' Using fs As New FileStream(filePath, FileMode.Create, FileAccess.Write)
  2665. ' workbook.Write(fs)
  2666. ' End Using
  2667. ' ' 打开文件
  2668. ' If File.Exists(filePath) Then
  2669. ' Process.Start(New ProcessStartInfo With {
  2670. ' .FileName = filePath,
  2671. ' .UseShellExecute = True
  2672. ' })
  2673. ' End If
  2674. ' ProgressBar1.Visible = False
  2675. ' End Sub
  2676. ' Private Sub DGV1_CellContentClick(sender As Object, e As DataGridViewCellEventArgs) Handles DGV1.CellContentClick
  2677. ' End Sub
  2678. ' Private Sub Button5_Click(sender As Object, e As EventArgs) Handles btnSaveAs.Click
  2679. ' ' 获取用户输入的日期、流程卡号、片数、批号、重量
  2680. ' Dim inputDate As Date = Date.Now
  2681. ' Dim processCardNo As String = InputBox("请输入流程卡号:")
  2682. ' Dim inputQuantity As String = InputBox("请输入片数:")
  2683. ' Dim quantity As Integer
  2684. ' ' 尝试将用户输入的值转换为整数
  2685. ' If Integer.TryParse(inputQuantity, quantity) Then
  2686. ' ' 转换成功,quantity 已被赋值
  2687. ' Else
  2688. ' ' 如果转换失败,设置默认值或者根据需要进行处理
  2689. ' quantity = 0 ' 设置为默认值
  2690. ' End If
  2691. ' Dim spec As String = InputBox("请输入厚度:")
  2692. ' Dim batchNo As String = InputBox("请输入蓝皮批号:")
  2693. ' 'Dim weight As Double = CDbl(InputBox("请输入重量:"))
  2694. ' Dim inputweight As String
  2695. ' Dim weight As Double
  2696. ' ' 尝试将用户输入的值转换为整数
  2697. ' If Integer.TryParse(inputweight, weight) Then
  2698. ' ' 转换成功,weight 已被赋值
  2699. ' Else
  2700. ' ' 如果转换失败,设置默认值或者根据需要进行处理
  2701. ' weight = 0 ' 设置为默认值
  2702. ' End If
  2703. ' Dim name As String = InputBox("请输入工艺名:",, DGV1.Rows(DGV1.CurrentRow.Index).Cells("品名").Value)
  2704. ' ' 生成 rcp_no:根据日期和流水号生成唯一的 rcp_no
  2705. ' Dim rcp_no As String = inputDate & "_" & GetNextSerialNumber()
  2706. ' ' 准备插入数据库的命令
  2707. ' Dim cmd As New SqlCommand()
  2708. ' cmd.Connection = conn ' 假设 conn 是你的 SqlConnection 对象
  2709. ' ' 遍历 DataGridView1 中的数据并插入数据库
  2710. ' For Each row As DataGridViewRow In DataGridView1.Rows
  2711. ' ' 获取每一行的数据
  2712. ' Dim no As String = row.Cells("项次").Value.ToString()
  2713. ' Dim chem As String = row.Cells("化料名称").Value.ToString()
  2714. ' Dim percents As String = row.Cells("百分比").Value.ToString()
  2715. ' Dim time As String = If(IsDBNull(row.Cells("时间").Value), "", row.Cells("时间").Value.ToString())
  2716. ' Dim comment As String = row.Cells("备注").Value.ToString()
  2717. ' ' 插入数据到数据库(使用参数化查询)
  2718. ' Dim sql As String = "INSERT INTO ht_retanrcp (item, rcp_no, no, name, date, spec, weight, selection, chem, percents, time, comment)
  2719. ' VALUES (@item, @rcp_no, @no, @name, @retan_date, @spec, @weight, @selection, @chem, @percents, @time, @comment)"
  2720. ' cmd.CommandText = sql
  2721. ' cmd.Parameters.Clear()
  2722. ' cmd.Parameters.AddWithValue("@item", row.Index + 1) ' 使用行号作为 item
  2723. ' cmd.Parameters.AddWithValue("@rcp_no", rcp_no)
  2724. ' cmd.Parameters.AddWithValue("@no", processCardNo)
  2725. ' cmd.Parameters.AddWithValue("@name", name)
  2726. ' cmd.Parameters.AddWithValue("@retan_date", inputDate)
  2727. ' cmd.Parameters.AddWithValue("@spec", spec)
  2728. ' cmd.Parameters.AddWithValue("@weight", weight)
  2729. ' cmd.Parameters.AddWithValue("@selection", batchNo & " " & quantity & "P")
  2730. ' cmd.Parameters.AddWithValue("@chem", chem)
  2731. ' cmd.Parameters.AddWithValue("@percents", percents)
  2732. ' cmd.Parameters.AddWithValue("@time", If(time = "", DBNull.Value, time)) ' 如果 time 为空,插入 DBNull
  2733. ' cmd.Parameters.AddWithValue("@comment", comment)
  2734. ' cmd.Parameters.AddWithValue("@process_card_no", processCardNo)
  2735. ' cmd.ExecuteNonQuery() ' 执行插入操作
  2736. ' Next
  2737. ' MessageBox.Show("数据已成功保存!", "成功", MessageBoxButtons.OK, MessageBoxIcon.Information)
  2738. ' RefreshDgv1()
  2739. ' End Sub
  2740. ' Private Function GetNextSerialNumber() As Integer
  2741. ' ' 确保连接是开启的
  2742. ' If conn.State = ConnectionState.Closed Then
  2743. ' conn.Open()
  2744. ' End If
  2745. ' ' 创建查询命令
  2746. ' 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)
  2747. ' cmd.Parameters.AddWithValue("@rcp_no_prefix", DateTime.Now.ToString("yyyyMMdd") & "_")
  2748. ' ' 执行查询并返回结果
  2749. ' Dim result As Object = cmd.ExecuteScalar()
  2750. ' ' 如果没有找到结果,则返回 1
  2751. ' If result Is DBNull.Value OrElse result Is Nothing Then
  2752. ' Return 1
  2753. ' Else
  2754. ' Return CInt(result)
  2755. ' End If
  2756. ' End Function
  2757. ' Private Sub Button5_Click_1(sender As Object, e As EventArgs) Handles Button5.Click '删除’
  2758. ' If conn.State = ConnectionState.Closed Then
  2759. ' conn.Open()
  2760. ' End If
  2761. ' cmd.Connection = conn
  2762. ' Dim msg As MsgBoxResult = MsgBox("确定要删除工艺 '" & DGV1.Rows(DGV1.CurrentCell.RowIndex).Cells("品名").Value & "' ? ", MsgBoxStyle.YesNoCancel)
  2763. ' If msg = MsgBoxResult.Yes Then
  2764. ' 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 & "'"
  2765. ' cmd.CommandText = sql_rcp
  2766. ' cmd.ExecuteNonQuery()
  2767. ' MsgBox("工艺已删除")
  2768. ' Else
  2769. ' End If
  2770. ' RefreshDgv1()
  2771. ' conn.Close()
  2772. ' End Sub
  2773. ' Private Sub Button9_Click_1(sender As Object, e As EventArgs) Handles Button9.Click '修改’
  2774. ' ' 准备插入数据库的命令
  2775. ' Dim cmd As New SqlCommand()
  2776. ' cmd.Connection = conn ' 假设 conn 是你的 SqlConnection 对象
  2777. ' If conn.State = ConnectionState.Closed Then
  2778. ' conn.Open()
  2779. ' End If
  2780. ' Dim inputDate As Date = InputBox("请输入日期:",, DGV1.Rows(DGV1.CurrentRow.Index).Cells("日期").Value)
  2781. ' Dim processCardNo As String = InputBox("请输入流程卡号及片数:",, DGV1.Rows(DGV1.CurrentRow.Index).Cells("流程卡号").Value)
  2782. ' Dim spec As String = InputBox("请输入开削厚度:",, DGV1.Rows(DGV1.CurrentRow.Index).Cells("开削").Value)
  2783. ' Dim batchNo As String = InputBox("请输入蓝皮批号:",, DGV1.Rows(DGV1.CurrentRow.Index).Cells("选级").Value)
  2784. ' Dim weight As Double = CDbl(InputBox("请输入重量:",, DGV1.Rows(DGV1.CurrentRow.Index).Cells("重量").Value))
  2785. ' Dim name As String = InputBox("请输入工艺名:",, DGV1.Rows(DGV1.CurrentRow.Index).Cells("品名").Value)
  2786. ' ' 生成 rcp_no:根据日期和流水号生成唯一的 rcp_no
  2787. ' 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 & "'"
  2788. ' cmd.CommandText = sql_rcp
  2789. ' cmd.ExecuteNonQuery()
  2790. ' MsgBox("更新完成")
  2791. ' RefreshDgv1()
  2792. ' End Sub
  2793. ' ' 刷新 dgv1 数据
  2794. ' Private Sub RefreshDgv1()
  2795. ' Dim connectionString As String = connstring
  2796. ' Dim query As String = "SELECT TOP 200 date AS 日期, name AS 品名, selection AS 选级, AVG(weight) AS 重量, no AS 流程卡号, rcp_no AS 表格编号,spec as 开削 " &
  2797. ' "FROM ht_retanrcp " &
  2798. ' "GROUP BY name, date, selection, rcp_no, no,spec " &
  2799. ' "ORDER BY date DESC, rcp_no DESC"
  2800. ' ' 保存当前选中的行和列
  2801. ' Dim selectedRowIndex As Integer = DGV1.CurrentRow?.Index
  2802. ' Dim selectedColumnIndex As Integer = DGV1.CurrentCell?.ColumnIndex
  2803. ' Try
  2804. ' Using conn As New SqlConnection(connectionString)
  2805. ' conn.Open()
  2806. ' ' 使用 DataAdapter 将数据库数据填充到 DataTable
  2807. ' Using da As New SqlDataAdapter(query, conn)
  2808. ' Dim dt As New DataTable()
  2809. ' da.Fill(dt)
  2810. ' ' 将填充的数据绑定到 dgv1
  2811. ' DGV1.DataSource = dt
  2812. ' DGV1.Columns(6).Visible = False
  2813. ' End Using
  2814. ' End Using
  2815. ' ' 如果之前有选中行,刷新后重新选中
  2816. ' If selectedRowIndex >= 0 AndAlso selectedRowIndex < DGV1.Rows.Count Then
  2817. ' DGV1.CurrentCell = DGV1.Rows(selectedRowIndex).Cells(selectedColumnIndex)
  2818. ' Else
  2819. ' DGV1.CurrentCell = DGV1.Rows(0).Cells(0)
  2820. ' End If
  2821. ' Catch ex As Exception
  2822. ' MessageBox.Show("数据加载失败: " & ex.Message, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error)
  2823. ' End Try
  2824. ' Dim c As Integer = 1
  2825. ' Dim p(250) As Integer
  2826. ' Dim x As Integer
  2827. ' p(1) = 0
  2828. ' For x = 1 To DGV1.Rows.Count - 2
  2829. ' If DGV1.Rows(x).Cells(0).Value.ToString <> DGV1.Rows(x - 1).Cells(0).Value.ToString Then
  2830. ' p(c + 1) = x
  2831. ' c = c + 1
  2832. ' End If
  2833. ' Next
  2834. ' p(c + 1) = x
  2835. ' ReDim Preserve p(x)
  2836. ' If c = 1 Then
  2837. ' For z As Integer = 0 To x - 1
  2838. ' DGV1.Rows(z).DefaultCellStyle.BackColor = colorArray(1)
  2839. ' Next
  2840. ' Else
  2841. ' For cc As Integer = 1 To c
  2842. ' For z As Integer = p(cc) To p(cc + 1) - 1
  2843. ' DGV1.Rows(z).DefaultCellStyle.BackColor = colorArray(cc Mod 5)
  2844. ' Next
  2845. ' Next
  2846. ' End If
  2847. ' End Sub
  2848. ' Private Sub Button23_Click(sender As Object, e As EventArgs) Handles Button23.Click
  2849. ' If DataGridView1.DataSource Is Nothing Then
  2850. ' MsgBox("数据为空")
  2851. ' Exit Sub
  2852. ' End If
  2853. ' If isMaximized Then
  2854. ' ' 恢复原始位置和大小
  2855. ' DataGridView1.Location = originalLocation
  2856. ' DataGridView1.Size = originalSize
  2857. ' ' 更新状态标记为恢复
  2858. ' isMaximized = False
  2859. ' Button23.Text = "放大"
  2860. ' Button3.Enabled = True
  2861. ' Button9.Enabled = True
  2862. ' Button5.Enabled = True
  2863. ' btnSaveAs.Enabled = True
  2864. ' Else
  2865. ' ' 放大到指定位置和大小
  2866. ' DataGridView1.Location = New Point(17, 68) ' 移动到左上角
  2867. ' DataGridView1.Size = New Size(1800, 650) ' 设置为放大后的大小
  2868. ' ' 更新状态标记为放大
  2869. ' isMaximized = True
  2870. ' Button23.Text = "恢复"
  2871. ' Button3.Enabled = False
  2872. ' Button9.Enabled = False
  2873. ' Button5.Enabled = False
  2874. ' btnSaveAs.Enabled = False
  2875. ' End If
  2876. ' ' 将 DataGridView1 移至最上层
  2877. ' DataGridView1.BringToFront()
  2878. ' End Sub
  2879. ' Private Sub Button16_Click(sender As Object, e As EventArgs) Handles Button16.Click '领料
  2880. ' Dim my_chem As String = ""
  2881. ' For Each row As DataGridViewRow In DataGridView1.Rows
  2882. ' If row.Cells("类别").Value = "不列印" Then
  2883. ' Continue For
  2884. ' End If
  2885. ' Dim cellFont As Font = row.DefaultCellStyle.Font
  2886. ' If cellFont IsNot Nothing Then
  2887. ' Dim aa As String
  2888. ' aa = ""
  2889. ' Dim fontStyle As FontStyle = cellFont.Style
  2890. ' If FontStyle = FontStyle.Strikeout Then
  2891. ' aa = ""
  2892. ' Else
  2893. ' End If
  2894. ' 'fontStyle = cellFont.Style
  2895. ' Else
  2896. ' If row.Cells("类别").Value = "不列印" And Not (row.Cells("化料名称").Value Like "水*") Then
  2897. ' my_chem += "项次" & row.Cells("项次").Value & " " & row.Cells("化料名称").Value & vbNewLine
  2898. ' End If
  2899. ' End If
  2900. ' Next
  2901. ' If Microsoft.VisualBasic.Len(my_chem) > 0 Then
  2902. ' MsgBox("以下化工品名有误:" & vbNewLine & vbNewLine & my_chem)
  2903. ' Exit Sub
  2904. ' End If
  2905. ' Dim inputDateString As String = InputBox("请输入日期:", "", DGV1.Rows(DGV1.CurrentRow.Index).Cells("日期").Value.ToString())
  2906. ' Dim inputDate As Date
  2907. ' If Not Date.TryParse(inputDateString, inputDate) Then
  2908. ' MessageBox.Show("输入的日期格式无效,请重新输入。", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error)
  2909. ' Exit Sub ' 退出子程序,避免后续报错
  2910. ' End If
  2911. ' Dim processCardNo As String = InputBox("请输入流程卡号及片数:",, DGV1.Rows(DGV1.CurrentRow.Index).Cells("流程卡号").Value)
  2912. ' ' Dim weight As Double = CDbl(InputBox("请输入重量:",, DGV1.Rows(DGV1.CurrentRow.Index).Cells("重量").Value))
  2913. ' Dim weightString As String = InputBox("请输入重量:", "", DGV1.Rows(DGV1.CurrentRow.Index).Cells("重量").Value.ToString())
  2914. ' Dim weight As Double
  2915. ' If Not Double.TryParse(weightString, weight) Then
  2916. ' MessageBox.Show("输入的重量格式无效,请重新输入。", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error)
  2917. ' Exit Sub ' 退出子程序,防止后续代码执行
  2918. ' End If
  2919. ' ' 准备插入数据库的命令
  2920. ' Dim cmd As New SqlCommand()
  2921. ' cmd.Connection = conn ' 假设 conn 是你的 SqlConnection 对象
  2922. ' If conn.State = ConnectionState.Closed Then
  2923. ' conn.Open()
  2924. ' End If
  2925. ' ' 遍历 DataGridView1 中的数据并插入数据库
  2926. ' For Each row As DataGridViewRow In DataGridView1.Rows
  2927. ' ' 获取每一行的数据
  2928. ' Dim no As String = row.Cells("项次").Value.ToString()
  2929. ' Dim chem As String = row.Cells("系统品名").Value.ToString()
  2930. ' Dim percents As String = row.Cells("百分比").Value.ToString()
  2931. ' Dim time As String = If(IsDBNull(row.Cells("时间").Value), "", row.Cells("时间").Value.ToString())
  2932. ' Dim comment As String = row.Cells("备注").Value.ToString()
  2933. ' Dim cellFont As Font = row.DefaultCellStyle.Font
  2934. ' ' 获取字体样式
  2935. ' If cellFont IsNot Nothing Then
  2936. ' Else
  2937. ' ' 插入数据到数据库(使用参数化查询)
  2938. ' 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)
  2939. ' VALUES (@item, @rcp_name, @chem_name,@chem_code,@chem_weight, @out_date, @weight, @percents, @time, @comment,@card)"
  2940. ' cmd.CommandText = sql
  2941. ' cmd.Parameters.Clear()
  2942. ' cmd.Parameters.AddWithValue("@item", no) ' 使用行号作为 item
  2943. ' cmd.Parameters.AddWithValue("@rcp_name", DGV1.Rows(DGV1.CurrentCell.RowIndex).Cells("品名").Value)
  2944. ' cmd.Parameters.AddWithValue("@chem_name", chem)
  2945. ' cmd.Parameters.AddWithValue("@chem_code", row.Cells("系统代码").Value)
  2946. ' cmd.Parameters.AddWithValue("@chem_weight", weight * row.Cells("百分比").Value / 100)
  2947. ' cmd.Parameters.AddWithValue("@out_date", inputDate)
  2948. ' cmd.Parameters.AddWithValue("@weight", weight)
  2949. ' cmd.Parameters.AddWithValue("@percents", percents)
  2950. ' cmd.Parameters.AddWithValue("@time", If(time = "", DBNull.Value, time)) ' 如果 time 为空,插入 DBNull
  2951. ' cmd.Parameters.AddWithValue("@comment", comment)
  2952. ' cmd.Parameters.AddWithValue("@card", processCardNo)
  2953. ' cmd.ExecuteNonQuery() ' 执行插入操作
  2954. ' End If
  2955. ' Next
  2956. ' MessageBox.Show("数据已成功保存!", "成功", MessageBoxButtons.OK, MessageBoxIcon.Information)
  2957. ' conn.Close()
  2958. ' End Sub
  2959. End Class