123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419 |
- Imports System.Data.SqlClient
- Imports System.Net
- Imports System.Windows.Forms.VisualStyles.VisualStyleElement
-
- Public Class Frm_TM
- Dim cmd As New SqlCommand
- Dim da As New SqlDataAdapter
- Dim dt As New DataTable
- Dim sql As String
- Dim conn As New SqlConnection
- Private dateTimePicker1 As DateTimePicker
- Dim p() As String
- Dim my_cust As String = ""
- Dim colorArray(10) As Color
- Dim sql_retan As String = ""
- Dim sql_retan_re As String = ""
- Dim sql_spray As String = ""
- Dim sql_buff As String = ""
- Dim dt_retan As DataTable
- Dim dt_retan_re As DataTable
- Dim dt_spray As DataTable
- Dim dt_buff As DataTable
- Private Sub Frm_TM_Load(sender As Object, e As EventArgs) Handles MyBase.Load
-
-
-
- conn.ConnectionString = connstring
- conn.Open()
-
- cmd.Connection = conn
-
-
-
- sql = "SELECT CARD as 卡号, card2 as 卡号1, 类别, type as 类别1, AVG(下鼓重) AS 下鼓重, cast(AVG(price) as numeric(10,2)) AS 单价, code, 选级, card_shaving as 出库卡, CUST as 客户, COLOR as 颜色, source as 皮源,
- DATE as 日期, 厚度, dd as 技术员, 皮源1, 皮源代码, AVG(挑级仓出库重) AS 出库重, SUM(chem) AS 化工成本, cast(SUM(chem)
- / AVG(投鼓重) / 6 as numeric(10,2)) AS 每尺化工
- FROM (SELECT TOP (100) PERCENT p.CARD, CASE WHEN substring(p.CARD, 3, 1) = 'F' THEN substring(p.CARD, 4, 10)
- + 'F' ELSE substring(p.CARD, 4, 10) + 'P' END AS card2, CASE WHEN substring(p.card, 3, 1)
- = 'P' THEN N'贴膜' WHEN substring(p.card, 3, 1) = 'F' THEN '反毛' ELSE '其他' END AS 类别, p.type,
- AVG(p.WEIGHT) / 2 AS 下鼓重, COUNT(*) AS Expr2, CASE WHEN rt_shaving_out.price IS NULL
- THEN 30 ELSE rt_shaving_out.price END AS price, CASE WHEN rt_shaving_out.weight IS NULL
- THEN AVG(p.WEIGHT) / 2 ELSE rt_shaving_out.weight END AS weight, CASE WHEN rt_shaving_out.code IS NULL
- THEN '212F.XX.2.1' ELSE rt_shaving_out.code END AS code, CASE WHEN rt_shaving_out.name IS NULL
- THEN N'D级' ELSE rt_shaving_out.name END AS 选级, rt_shaving_out.card1,
- rt_shaving_out.card AS card_shaving, p.CUST, p.COLOR, p.source, CASE WHEN rt_wetblue_name.code IS NULL
- THEN '212F.XX' ELSE rt_wetblue_name.code END AS 编码, CASE WHEN rt_wetblue_name.name IS NULL
- THEN N'杂皮 二层' ELSE rt_wetblue_name.name END AS 皮源, p.DATE,
- CASE WHEN substring(rt_shaving_out.code, 13, 1) = '1' THEN '1.02' WHEN substring(rt_shaving_out.code, 13, 1)
- = '2' THEN '1.24' WHEN substring(rt_shaving_out.code, 13, 1)
- = '3' THEN '1.46' WHEN substring(rt_shaving_out.code, 13, 1)
- = '4' THEN '1.68' WHEN substring(rt_shaving_out.code, 13, 1) IS NULL THEN '1.24' END AS 厚度, p.dd,
- CASE WHEN rt_shaving_out.card1 IS NULL AND
- p.type = N'套染' THEN N'套染' WHEN rt_shaving_out.price IS NULL AND
- p.type = N'打底' THEN N'回鼓' ELSE N'打底' END AS 备注,
- CASE WHEN p.source LIKE N'%无铬鞣%' THEN N'无铬鞣 二层' WHEN p.source LIKE N'%阿根廷%' THEN N'阿根廷 二层'
- WHEN p.source LIKE N'%澳%' THEN N'澳大利亚 二层' WHEN (p.source LIKE N'%巴西%' OR
- p.source LIKE N'%bx%')
- THEN N'巴西 二层' WHEN p.source LIKE N'%智利%' THEN N'智利 二层' WHEN p.source LIKE N'%德国%' THEN N'德国 二层'
- WHEN p.source LIKE N'%西班牙%' THEN N'西班牙 二层' WHEN p.source LIKE N'%欧洲%' THEN N'欧洲 二层' WHEN
- p.source LIKE N'%法国%' THEN N'法国 二层' WHEN p.source LIKE N'%爱尔兰%' THEN N'爱尔兰 二层' WHEN p.source
- LIKE N'%APP%' THEN N'美国 二层' WHEN p.source LIKE N'%日本%' THEN N'日本 二层' WHEN p.source LIKE N'%美国%'
- THEN N'美国 二层' WHEN p.source LIKE N'%新西兰%' THEN N'新西兰 二层' WHEN p.source LIKE N'%小皮%' THEN
- N'小皮 二层' WHEN p.source LIKE N'%英国%' THEN N'英国 二层' WHEN p.source LIKE N'%墨西哥%' THEN N'墨西哥 二层'
- WHEN p.source LIKE N'%乌拉圭%' THEN N'乌拉圭 二层' WHEN p.source LIKE N'%南非%' THEN N'南非 二层' WHEN
- p.source LIKE N'%孟加拉%' THEN N'孟加拉 二层' WHEN p.source LIKE N'%泰国%' THEN N'泰国 二层' ELSE N'杂皮 二层'
- END AS 皮源1,
- CASE WHEN p.source LIKE N'%无铬鞣%' THEN N'CT' WHEN p.source LIKE N'%阿根廷%' THEN N'AR' WHEN p.source
- LIKE N'%澳%' THEN N'AU' WHEN (p.source LIKE N'%巴西%' OR
- p.source LIKE N'%bx%')
- THEN N'BR' WHEN p.source LIKE N'%智利%' THEN N'CL' WHEN p.source LIKE N'%德国%' THEN N'DE' WHEN p.source
- LIKE N'%西班牙%' THEN N'ES' WHEN p.source LIKE N'%欧洲%' THEN N'EU' WHEN p.source LIKE N'%法国%' THEN
- N'FR' WHEN p.source LIKE N'%爱尔兰%' THEN N'IE' WHEN p.source LIKE N'%日本%' THEN N'JP' WHEN p.source LIKE
- N'%越南APP%' THEN N'US' WHEN p.source LIKE N'%美国%' THEN N'US' WHEN p.source LIKE N'%新西兰%' THEN N'NZ'
- WHEN p.source LIKE N'%小皮%' THEN N'SS' WHEN p.source LIKE N'%英国%' THEN N'UK' WHEN p.source LIKE N'%墨西哥%'
- THEN N'MX' WHEN p.source LIKE N'%乌拉圭%' THEN N'UY' WHEN p.source LIKE N'%南非%' THEN N'ZA' WHEN p.source
- LIKE N'%孟加拉%' THEN N'BD' WHEN p.source LIKE N'%泰国%' THEN N'TH' ELSE N'XX' END AS 皮源代码,
- rt_shaving_out.weight AS 挑级仓出库重, CASE WHEN rt_shaving_out.weight IS NULL THEN AVG(p.weight)
- / 2 ELSE rt_shaving_out.weight END AS 投鼓重, RT_SYS_CHEM_OUT.CODE AS Expr1,
- RT_SYS_CHEM_OUT.NAME, rt_chem_price_li.price1 AS chemprice,
- RT_SYS_CHEM_OUT.WEIGHT AS chemweight, CASE WHEN rt_chem_price_li.price1 IS NULL
- THEN 0 ELSE rt_chem_price_li.price1 * rt_sys_chem_out.weight END AS chem
- FROM RT_SYS_CHEM_OUT INNER JOIN
- rt_chem_price_li ON RT_SYS_CHEM_OUT.CODE = rt_chem_price_li.code RIGHT OUTER JOIN
- (SELECT NO, AREA, MONTH, HEADER, HEADER2, DATE, CARD, CARD1, CUST, COLOR, W1, P1, A1, W2, P2, A2,
- W3, P3, A3, W4, P4, A4, source, TOTAL, class, type, DATE1, WEIGHT, P, COMa, COMb, COMc, dd, ee, ff,
- gg, hh, Dep
- FROM RT_RETAN_RECORD_D
- WHERE (DATE BETWEEN '2024/6/1' AND '2024/6/30') AND (COMa NOT LIKE N'%叠皮%') AND
- (WEIGHT IS NOT NULL)) AS p ON RT_SYS_CHEM_OUT.CARD = p.CARD LEFT OUTER JOIN
- rt_wetblue_name RIGHT OUTER JOIN
- rt_shaving_out ON LEFT(rt_wetblue_name.code, 7) = LEFT(rt_shaving_out.code, 7) ON
- p.CARD = rt_shaving_out.card1
- GROUP BY p.type, p.CARD, p.CARD1, rt_shaving_out.price, rt_shaving_out.weight, rt_shaving_out.code,
- rt_shaving_out.name, rt_shaving_out.card1, rt_shaving_out.card, p.CUST, p.COLOR, p.source,
- rt_wetblue_name.code, rt_wetblue_name.name, p.DATE, p.dd, RT_SYS_CHEM_OUT.CODE,
- RT_SYS_CHEM_OUT.NAME, rt_chem_price_li.price1, RT_SYS_CHEM_OUT.WEIGHT
- ORDER BY p.CARD) AS s
- GROUP BY CARD, card2, 类别, type, 下鼓重, code, 选级, card1, card_shaving, CUST, COLOR, source, 编码, 皮源, DATE, 厚度, dd,
- 备注, 皮源1, 皮源代码
- HAVING (type = N'打底') and card_shaving is not null" ''----蓝皮下鼓
-
-
-
-
- cmd.CommandText = sql
-
- dt_retan = New DataTable
- da.SelectCommand = cmd
- da.Fill(dt_retan)
-
-
-
-
-
-
-
-
-
-
-
-
- End Sub
-
- Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
-
-
- Dim aa As String
- Dim my_card As String = ""
- Dim my_date As Date
-
- aa = TextBox8.Text
-
- If aa = "" Then
- MsgBox("请输入起始单号")
- Exit Sub
- End If
-
-
-
- Dim xlApp As Microsoft.Office.Interop.Excel.Application
- Dim xlBook As Microsoft.Office.Interop.Excel.Workbook
- Dim xlSheet As Microsoft.Office.Interop.Excel.Worksheet
- Dim xlSheet2 As Microsoft.Office.Interop.Excel.Worksheet
-
-
-
-
- Dim file_name As String = ""
- Dim file_name1 As String = ""
- Dim my_weight As Double = 0
- Dim a As Integer = 0
- Dim my_count As Integer = 0
- Dim my_x As Integer = 0
-
-
-
- xlApp = CreateObject("Excel.Application")
- xlApp.Visible = True
- xlApp.DisplayAlerts = False
-
-
- xlBook = xlApp.Workbooks.Open("D:\K3\k3表格模板\下鼓染色入库.xls",, True)
-
- xlBook.Activate()
-
- Dim dt2 As New DataTable
-
-
- For i = 1 To xlApp.Worksheets.Count
-
- If xlApp.Workbooks(1).Worksheets(i).name = "Page1" Then
- xlSheet = xlApp.Workbooks(1).Worksheets(i)
- xlSheet.Activate()
- Exit For
- End If
-
-
- Next
-
-
- Dim my_no As String = "CPRK"
- Dim yy As Integer = 1
- Dim x As Integer = 0
-
- Dim dt_inprocess As New DataTable
-
-
- sql = "select * from rt_TM240630 order by no"
-
- cmd.CommandText = sql
-
- da.SelectCommand = cmd
- da.Fill(dt_inprocess)
-
-
-
-
-
-
-
- For x = 0 To dt_inprocess.Rows.Count - 1 '-----------loop
-
-
-
-
-
- xlSheet.Cells(my_x + 2, 1) = "2024/06/30"
- xlSheet.Cells(my_x + 2, 2) = "2024/06/30"
- xlSheet.Cells(my_x + 2, 3) = "'曾添梅"
- xlSheet.Cells(my_x + 2, 4) = "'" & my_no & aa
- xlSheet.Cells(my_x + 2, 5) = "'zhang"
- xlSheet.Cells(my_x + 2, 6) = "'1"
- xlSheet.Cells(my_x + 2, 7) = "'2"
- xlSheet.Cells(my_x + 2, 8) = "'165701"
-
-
- xlSheet.Cells(my_x + 2, 9) = "'620-R"
- xlSheet.Cells(my_x + 2, 10) = "'生产部-R"
-
- xlSheet.Cells(my_x + 2, 11) = "'103"
- xlSheet.Cells(my_x + 2, 12) = "'曾添梅"
- xlSheet.Cells(my_x + 2, 13) = "'103"
- xlSheet.Cells(my_x + 2, 14) = "'曾添梅"
- xlSheet.Cells(my_x + 2, 15) = "'85"
-
-
-
-
- For i = 1 To xlApp.Worksheets.Count
-
- If xlApp.Workbooks(1).Worksheets(i).name = "Page2" Then
- xlSheet2 = xlApp.Workbooks(1).Worksheets(i)
- xlSheet2.Activate()
- Exit For
- End If
-
- Next
-
-
-
-
- ' sql = "SELECT TOP (100) PERCENT p.CARD, CASE WHEN substring(p.CARD, 3, 1) = 'F' THEN substring(p.CARD, 4, 10)
- ' + 'F' ELSE substring(p.CARD, 4, 10) + 'P' END AS card2, CASE WHEN substring(p.card, 3, 1)
- ' = 'P' THEN N'贴膜' WHEN substring(p.card, 3, 1) = 'F' THEN '反毛' ELSE '其他' END AS 类别, p.type, AVG(p.WEIGHT)
- ' / 2 AS 下鼓重, COUNT(*) AS Expr2, CASE WHEN rt_shaving_out.price IS NULL
- ' THEN 30 ELSE rt_shaving_out.price END AS price, CASE WHEN rt_shaving_out.weight IS NULL THEN AVG(p.WEIGHT)
- ' / 2 ELSE rt_shaving_out.weight END AS weight, CASE WHEN rt_shaving_out.code IS NULL
- ' THEN '212F.XX.2.1' ELSE rt_shaving_out.code END AS code, CASE WHEN rt_shaving_out.name IS NULL
- ' THEN N'D级' ELSE rt_shaving_out.name END AS 选级, rt_shaving_out.card1, rt_shaving_out.card AS Expr3, p.CUST,
- ' p.COLOR, p.source, CASE WHEN rt_wetblue_name.code IS NULL
- ' THEN '212F.XX' ELSE rt_wetblue_name.code END AS 编码, CASE WHEN rt_wetblue_name.name IS NULL
- ' THEN N'杂皮 二层' ELSE rt_wetblue_name.name END AS 皮源, p.DATE, CASE WHEN substring(rt_shaving_out.code, 13, 1)
- ' = '1' THEN '1.02' WHEN substring(rt_shaving_out.code, 13, 1) = '2' THEN '1.24' WHEN substring(rt_shaving_out.code, 13, 1)
- ' = '3' THEN '1.46' WHEN substring(rt_shaving_out.code, 13, 1) = '4' THEN '1.68' WHEN substring(rt_shaving_out.code, 13, 1)
- ' IS NULL THEN '1.24' END AS 厚度, p.dd, CASE WHEN rt_shaving_out.card1 IS NULL AND
- ' p.type = N'套染' THEN N'套染' WHEN rt_shaving_out.price IS NULL AND
- ' p.type = N'打底' THEN N'回鼓' ELSE N'打底' END AS 备注,
- ' CASE WHEN p.source LIKE N'%无铬鞣%' THEN N'无铬鞣 二层' WHEN p.source LIKE N'%阿根廷%' THEN N'阿根廷 二层' WHEN
- ' p.source LIKE N'%澳%' THEN N'澳大利亚 二层' WHEN (p.source LIKE N'%巴西%' OR
- ' p.source LIKE N'%bx%')
- ' THEN N'巴西 二层' WHEN p.source LIKE N'%智利%' THEN N'智利 二层' WHEN p.source LIKE N'%德国%' THEN N'德国 二层' WHEN
- ' p.source LIKE N'%西班牙%' THEN N'西班牙 二层' WHEN p.source LIKE N'%欧洲%' THEN N'欧洲 二层' WHEN p.source LIKE N'%法国%'
- ' THEN N'法国 二层' WHEN p.source LIKE N'%爱尔兰%' THEN N'爱尔兰 二层' WHEN p.source LIKE N'%APP%' THEN N'美国 二层'
- ' WHEN p.source LIKE N'%日本%' THEN N'日本 二层' WHEN p.source LIKE N'%美国%' THEN N'美国 二层' WHEN p.source LIKE
- ' N'%新西兰%' THEN N'新西兰 二层' WHEN p.source LIKE N'%小皮%' THEN N'小皮 二层' WHEN p.source LIKE N'%英国%' THEN
- ' N'英国 二层' WHEN p.source LIKE N'%墨西哥%' THEN N'墨西哥 二层' WHEN p.source LIKE N'%乌拉圭%' THEN N'乌拉圭 二层'
- ' WHEN p.source LIKE N'%南非%' THEN N'南非 二层' WHEN p.source LIKE N'%孟加拉%' THEN N'孟加拉 二层' WHEN p.source
- ' LIKE N'%泰国%' THEN N'泰国 二层' ELSE N'杂皮 二层' END AS 皮源1,
- ' CASE WHEN p.source LIKE N'%无铬鞣%' THEN N'CT' WHEN p.source LIKE N'%阿根廷%' THEN N'AR' WHEN p.source LIKE N'%澳%'
- ' THEN N'AU' WHEN (p.source LIKE N'%巴西%' OR
- ' p.source LIKE N'%bx%')
- ' THEN N'BR' WHEN p.source LIKE N'%智利%' THEN N'CL' WHEN p.source LIKE N'%德国%' THEN N'DE' WHEN p.source LIKE N'%西班牙%'
- ' THEN N'ES' WHEN p.source LIKE N'%欧洲%' THEN N'EU' WHEN p.source LIKE N'%法国%' THEN N'FR' WHEN p.source LIKE N'%爱尔兰%'
- ' THEN N'IE' WHEN p.source LIKE N'%日本%' THEN N'JP' WHEN p.source LIKE N'%APP%' THEN N'US' WHEN p.source LIKE
- ' N'%美国%' THEN N'US' WHEN p.source LIKE N'%新西兰%' THEN N'NZ' WHEN p.source LIKE N'%小皮%' THEN N'SS' WHEN p.source
- ' LIKE N'%英国%' THEN N'UK' WHEN p.source LIKE N'%墨西哥%' THEN N'MX' WHEN p.source LIKE N'%乌拉圭%' THEN N'UY' WHEN
- ' p.source LIKE N'%南非%' THEN N'ZA' WHEN p.source LIKE N'%孟加拉%' THEN N'BD' WHEN p.source LIKE N'%泰国%' THEN
- ' N'TH' ELSE N'XX' END AS 皮源代码, rt_shaving_out.weight AS 挑级仓出库重, CASE WHEN rt_shaving_out.weight IS NULL
- ' THEN AVG(p.weight) / 2 ELSE rt_shaving_out.weight END AS 投鼓重
- 'FROM rt_wetblue_name RIGHT OUTER JOIN
- ' rt_shaving_out ON LEFT(rt_wetblue_name.code, 7) = LEFT(rt_shaving_out.code, 7) RIGHT OUTER JOIN
- ' (SELECT NO, AREA, MONTH, HEADER, HEADER2, DATE, CARD, CARD1, CUST, COLOR, W1, P1, A1, W2, P2, A2, W3, P3,
- ' A3, W4, P4, A4, source, TOTAL, class, type, DATE1, WEIGHT, P, COMa, COMb, COMc, dd, ee, ff, gg, hh, Dep
- ' FROM RT_RETAN_RECORD_D
- ' WHERE (DATE BETWEEN '2024/6/1' AND '2024/6/30') AND (COMa NOT LIKE N'%叠皮%') AND (WEIGHT IS NOT NULL) and card=N'" & dt_retan.Rows(x).Item("卡号") & "'And date=N'" & dt_retan.Rows(x).Item("日期") & "') AS p
- ' ON rt_shaving_out.card1 = p.CARD
- 'GROUP BY p.type, p.CARD, p.CARD1, rt_shaving_out.price, rt_shaving_out.weight, rt_shaving_out.code, rt_shaving_out.name,
- ' rt_shaving_out.card1, rt_shaving_out.card, p.CUST, p.COLOR, p.source, rt_wetblue_name.code, rt_wetblue_name.name,
- ' p.DATE, p.dd
- 'ORDER BY p.CARD"
-
- sql = "SELECT TOP (200) rt_TM240630.date, rt_TM240630.no, rt_TM240630.card, rt_TM240630.type, rt_TM240630.word, rt_TM240630.cust,
- rt_TM240630.color, rt_TM240630.weight_ini, rt_TM240630.tech, rt_TM240630.source, rt_TM240630.thick, rt_TM240630.word1,
- rt_TM240630.weight, rt_TM240630.commentB, rt_TM240630.commentC, rt_TM240630.commentD, rt_TM240630.commentE,
- rt_TM240630.serial, rt_TM240630.comment, rt_TM240630.source1, rt_TM240630.code, rt_shaving_price.price
- FROM rt_TM240630 LEFT OUTER JOIN
- rt_shaving_price ON rt_TM240630.code = rt_shaving_price.source where rt_TM240630.no='" & dt_inprocess.Rows(x).Item("no") & "'"
-
-
- dt2 = New DataTable
- cmd.CommandText = sql
- da.SelectCommand = cmd
- da.Fill(dt2)
-
-
-
-
-
- Dim serial As Integer = 1
-
- For y = 0 To dt2.Rows.Count - 1
-
- xlSheet2.Cells(yy + 1 + y, 2) = "'" & serial '行号
- xlSheet2.Cells(yy + 1 + y, 3) = "'" & my_no & aa
-
- If dt2.Rows(y).Item("type") = "反绒" Then
-
- xlSheet2.Cells(yy + 1 + y, 5) = "313.FM"
- xlSheet2.Cells(yy + 1 + y, 6) = "二层皮"
-
- Else
-
- xlSheet2.Cells(yy + 1 + y, 5) = "313.PU"
- xlSheet2.Cells(yy + 1 + y, 6) = "贴膜皮"
-
-
- End If
-
-
-
-
-
- xlSheet2.Cells(yy + 1 + y, 14) = dt2.Rows(y).Item("weight") / 2
-
-
- If (dt2.Rows(y).Item("color") Like "*4300*" Or dt2.Rows(y).Item("color") Like "*4800*" Or dt2.Rows(y).Item("color") Like "*白*") And dt2.Rows(y).Item("type") = "反绒" Then
-
- xlSheet2.Cells(yy + 1 + y, 15) = dt2.Rows(y).Item("price") + (1.7 + 1.4) * 6
- xlSheet2.Cells(yy + 1 + y, 16) = dt2.Rows(y).Item("weight") / 2 * (dt2.Rows(y).Item("price") + (1.7 + 1.4) * 6)
- xlSheet2.Cells(yy + 1 + y, 46) = 1.7
- xlSheet2.Cells(yy + 1 + y, 45) = 1.4
-
-
- ElseIf dt2.Rows(y).Item("type") = "反绒" And dt2.Rows(y).Item("color") Like "*黑*" Then
-
-
- xlSheet2.Cells(yy + 1 + y, 15) = dt2.Rows(y).Item("price") + (1.3 + 1.4) * 6
- xlSheet2.Cells(yy + 1 + y, 16) = dt2.Rows(y).Item("weight") / 2 * (dt2.Rows(y).Item("price") + (1.3 + 1.4) * 6)
- xlSheet2.Cells(yy + 1 + y, 46) = 1.3
- xlSheet2.Cells(yy + 1 + y, 45) = 1.4
-
- ElseIf dt2.Rows(y).Item("type") = "反绒" Then
-
-
- xlSheet2.Cells(yy + 1 + y, 15) = dt2.Rows(y).Item("price") + (1.5 + 1.4) * 6
- xlSheet2.Cells(yy + 1 + y, 16) = dt2.Rows(y).Item("weight") / 2 * (dt2.Rows(y).Item("price") + (1.5 + 1.4) * 6)
-
- xlSheet2.Cells(yy + 1 + y, 46) = 1.5
- xlSheet2.Cells(yy + 1 + y, 45) = 1.4
- ElseIf dt2.Rows(y).Item("type") = "PU" And dt2.Rows(y).Item("color") Like "*白*" Then
-
- xlSheet2.Cells(yy + 1 + y, 15) = dt2.Rows(y).Item("price") + (0.6 + 1) * 6
- xlSheet2.Cells(yy + 1 + y, 16) = dt2.Rows(y).Item("weight") / 2 * xlSheet2.Cells(yy + 1 + y, 15).value
-
- xlSheet2.Cells(yy + 1 + y, 46) = 0.6
- xlSheet2.Cells(yy + 1 + y, 45) = 1
-
- ElseIf dt2.Rows(y).Item("type") = "PU" And dt2.Rows(y).Item("color") Like "*黑*" Then
-
- xlSheet2.Cells(yy + 1 + y, 15) = dt2.Rows(y).Item("price") + (0.8 + 1) * 6
- xlSheet2.Cells(yy + 1 + y, 16) = dt2.Rows(y).Item("weight") / 2 * xlSheet2.Cells(yy + 1 + y, 15).value
-
- xlSheet2.Cells(yy + 1 + y, 46) = 0.8
- xlSheet2.Cells(yy + 1 + y, 45) = 1
-
-
- ElseIf dt2.Rows(y).Item("type") = "PU" Then
-
- xlSheet2.Cells(yy + 1 + y, 15) = dt2.Rows(y).Item("price") + (0.7 + 1) * 6
- xlSheet2.Cells(yy + 1 + y, 16) = dt2.Rows(y).Item("weight") / 2 * xlSheet2.Cells(yy + 1 + y, 15).value
-
- xlSheet2.Cells(yy + 1 + y, 46) = 0.7
- xlSheet2.Cells(yy + 1 + y, 45) = 1
- ElseIf dt2.Rows(y).Item("code") = "小皮 二层" Then
-
-
- xlSheet2.Cells(yy + 1 + y, 15) = 5.4 * 6
- xlSheet2.Cells(yy + 1 + y, 16) = dt2.Rows(y).Item("weight") / 2 * 5.4 * 6
-
- End If
-
-
-
- If dt2.Rows(y).Item("commentE") = "在制水场" And Not (dt2.Rows(y).Item("type") = "PU") Then
-
-
- xlSheet2.Cells(yy + 1 + y, 15) = xlSheet2.Cells(yy + 1 + y, 15).value - 0.6 * 6
- xlSheet2.Cells(yy + 1 + y, 16) = dt2.Rows(y).Item("weight") / 2 * xlSheet2.Cells(yy + 1 + y, 15).value
-
-
- ElseIf dt2.Rows(y).Item("commentE") = "在制涂饰" And Not (dt2.Rows(y).Item("type") = "PU") Then
-
- xlSheet2.Cells(yy + 1 + y, 15) = xlSheet2.Cells(yy + 1 + y, 15).value - 0.4 * 6
- xlSheet2.Cells(yy + 1 + y, 16) = dt2.Rows(y).Item("weight") / 2 * xlSheet2.Cells(yy + 1 + y, 15).value
-
- ElseIf Not (dt2.Rows(y).Item("type") = "PU") Then
-
- xlSheet2.Cells(yy + 1 + y, 15) = xlSheet2.Cells(yy + 1 + y, 15).value + 0.2 * 6
- xlSheet2.Cells(yy + 1 + y, 16) = dt2.Rows(y).Item("weight") / 2 * xlSheet2.Cells(yy + 1 + y, 15).value
-
-
- End If
-
-
-
-
- xlSheet2.Cells(yy + 1 + y, 17) = "313 " & dt2.Rows(y).Item("code")
- xlSheet2.Cells(yy + 1 + y, 18) = "2024/6/30盘点"
-
-
- If dt2.Rows(y).Item("commentE") = "在制水场" Then
-
- xlSheet2.Cells(yy + 1 + y, 25) = "'213A-R.01"
- xlSheet2.Cells(yy + 1 + y, 26) = "染色仓/蓝皮下鼓"
-
-
- ElseIf dt2.Rows(y).Item("commentE") = "在制涂饰" Then
-
- xlSheet2.Cells(yy + 1 + y, 25) = "'313"
- xlSheet2.Cells(yy + 1 + y, 26) = "涂饰在制品"
-
- ElseIf dt2.Rows(y).Item("commentE") = "待打包" Then
-
- xlSheet2.Cells(yy + 1 + y, 25) = "'517"
- xlSheet2.Cells(yy + 1 + y, 26) = "成品仓"
-
-
- End If
-
-
-
- xlSheet2.Cells(yy + 1 + y, 38) = "'" & dt2.Rows(y).Item("cust")
- xlSheet2.Cells(yy + 1 + y, 39) = "'" & dt2.Rows(y).Item("commentD")
- xlSheet2.Cells(yy + 1 + y, 40) = dt2.Rows(y).Item("tech")
-
- xlSheet2.Cells(yy + 1 + y, 41) = dt2.Rows(y).Item("source")
- xlSheet2.Cells(yy + 1 + y, 42) = dt2.Rows(y).Item("color")
- ' xlSheet2.Cells(yy + 1 + y, 43) = dt2.Rows(y).Item("厚度")
- xlSheet2.Cells(yy + 1 + y, 44) = dt2.Rows(y).Item("card")
- 'xlSheet2.Cells(yy + 1 + y, 45) = dt2.Rows(y).Item("选级")
-
- xlSheet2.Cells(yy + 1 + y, 47) = dt2.Rows(y).Item("weight_ini")
-
- xlSheet2.Cells(yy + 1 + y, 48) = dt2.Rows(y).Item("type")
-
-
-
- serial = serial + 1
-
- Next
-
- yy = yy + dt2.Rows.Count
-
-
- aa = aa + 1
- my_x = my_x + 1
- my_card = dt_inprocess.Rows(x).Item("card")
- my_date = dt_inprocess.Rows(x).Item("date")
-
-
- Next
-
- xlSheet2.Range("A2:A" & x + 1).FillDown()
- 'xlSheet2.Range("B2:B" & x + 1).FillDown()
- xlSheet2.Range("D2:D" & x + 1).FillDown()
- xlSheet2.Range("J2:J" & x + 1).FillDown()
- xlSheet2.Range("L2:L" & x + 1).FillDown()
- xlSheet2.Range("M2:M" & x + 1).FillDown()
- 'xlSheet2.Range("O2:O" & x + 1).FillDown()
- 'xlSheet2.Range("P2:P" & x + 1).FillDown()
-
-
-
-
-
- MsgBox("")
-
-
-
- End Sub
-
- Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click '成品仓
-
-
-
-
- Dim aa As String
- Dim my_card As String = ""
- Dim my_date As Date
-
- aa = TextBox8.Text
-
- If aa = "" Then
- MsgBox("请输入起始单号")
- Exit Sub
- End If
-
-
-
- Dim xlApp As Microsoft.Office.Interop.Excel.Application
- Dim xlBook As Microsoft.Office.Interop.Excel.Workbook
- Dim xlSheet As Microsoft.Office.Interop.Excel.Worksheet
- Dim xlSheet2 As Microsoft.Office.Interop.Excel.Worksheet
-
-
-
-
- Dim file_name As String = ""
- Dim file_name1 As String = ""
- Dim my_weight As Double = 0
- Dim a As Integer = 0
- Dim my_count As Integer = 0
- Dim my_x As Integer = 0
-
-
-
- xlApp = CreateObject("Excel.Application")
- xlApp.Visible = True
- xlApp.DisplayAlerts = False
-
-
- xlBook = xlApp.Workbooks.Open("D:\K3\k3表格模板\下鼓染色入库.xls",, True)
-
- xlBook.Activate()
-
- Dim dt2 As New DataTable
-
-
- For i = 1 To xlApp.Worksheets.Count
-
- If xlApp.Workbooks(1).Worksheets(i).name = "Page1" Then
- xlSheet = xlApp.Workbooks(1).Worksheets(i)
- xlSheet.Activate()
- Exit For
- End If
-
-
- Next
-
-
- Dim my_no As String = "CPRK"
- Dim yy As Integer = 1
- Dim x As Integer = 0
-
- Dim dt_inprocess As New DataTable
-
-
- sql = "SELECT rt_finish_stock_0630.date, rt_finish_stock_0630.cust, rt_finish_stock_0630.color, rt_finish_stock_0630.card,
- rt_finish_stock_0630.pattern, rt_finish_stock_0630.sf, rt_finish_stock_0630.comment, rt_finish_stock_0630.type,
- rt_finish_stock_0630.source, rt_finish_stock_0630.size, rt_finish_stock_0630.lot, rt_finish_stock_0630.wh,
- rt_finish_stock_0630.id, CASE WHEN rt_shaving_price.price IS NOT NULL
- THEN CAST(rt_shaving_price.price / 5.8 AS numeric(10, 2))
- WHEN lot LIKE '%12+%' THEN 4.8 WHEN lot LIKE '%8-12%' THEN 4.2 WHEN lot LIKE '%4-8%' THEN 3.6 END AS price,
- CASE WHEN type LIKE '%反毛%' AND color LIKE '%白%' THEN 1.7 + 0.2 WHEN type LIKE '%反毛%' AND
- color LIKE '%黑%' THEN 1.3 + 0.2 WHEN type LIKE '%反毛%' THEN 1.5 + 0.2 WHEN type LIKE N'%贴膜%' AND
- color LIKE '%白%' THEN 0.6 + 1.6 WHEN type LIKE N'%贴膜%' THEN 0.8 + 1.4 END AS retan_cost,
- CASE WHEN type LIKE '%反毛%' THEN 1.5 WHEN type LIKE N'%贴膜%' THEN 1.5 END AS p_cost
- FROM rt_finish_stock_0630 LEFT OUTER JOIN
- rt_shaving_price ON rt_finish_stock_0630.lot = '516 ' + rt_shaving_price.source
- ORDER BY rt_finish_stock_0630.id"
-
- cmd.CommandText = sql
-
- da.SelectCommand = cmd
- da.Fill(dt_inprocess)
-
-
-
-
-
-
-
- For x = 0 To dt_inprocess.Rows.Count - 1 '-----------loop
-
-
-
-
-
- xlSheet.Cells(my_x + 2, 1) = "2024/06/30"
- xlSheet.Cells(my_x + 2, 2) = "2024/06/30"
- xlSheet.Cells(my_x + 2, 3) = "'吴小男"
- xlSheet.Cells(my_x + 2, 4) = "'" & my_no & aa
- xlSheet.Cells(my_x + 2, 5) = "'zhang"
- xlSheet.Cells(my_x + 2, 6) = "'1"
- xlSheet.Cells(my_x + 2, 7) = "'2"
- xlSheet.Cells(my_x + 2, 8) = "'165701"
-
-
-
-
-
-
- xlSheet.Cells(my_x + 2, 9) = "'620-R"
- xlSheet.Cells(my_x + 2, 10) = "'生产部-R"
-
-
- xlSheet.Cells(my_x + 2, 11) = "'120"
- xlSheet.Cells(my_x + 2, 12) = "'吴小男"
- xlSheet.Cells(my_x + 2, 13) = "'120"
- xlSheet.Cells(my_x + 2, 14) = "'吴小男"
- xlSheet.Cells(my_x + 2, 15) = "'85"
-
-
-
-
- For i = 1 To xlApp.Worksheets.Count
-
- If xlApp.Workbooks(1).Worksheets(i).name = "Page2" Then
- xlSheet2 = xlApp.Workbooks(1).Worksheets(i)
- xlSheet2.Activate()
- Exit For
- End If
-
- Next
-
-
-
-
-
-
-
- sql = "SELECT rt_finish_stock_0630.date, rt_finish_stock_0630.cust, rt_finish_stock_0630.color, rt_finish_stock_0630.card,
- rt_finish_stock_0630.pattern, cast(rt_finish_stock_0630.sf as numeric(10,1)) as sf, rt_finish_stock_0630.comment, rt_finish_stock_0630.type,
- rt_finish_stock_0630.source, rt_finish_stock_0630.size, rt_finish_stock_0630.lot, rt_finish_stock_0630.wh,
- rt_finish_stock_0630.id, CASE WHEN rt_shaving_price.price IS NOT NULL
- THEN CAST(rt_shaving_price.price / 6 AS numeric(10, 2))
- WHEN lot LIKE '%12+%' THEN 4.8 WHEN lot LIKE '%8-12%' THEN 4.2 WHEN lot LIKE '%4-8%' THEN 3.6 END AS price,
- CASE WHEN type LIKE '%反毛%' AND color LIKE '%白%' THEN 1.7 + 0.2 WHEN type LIKE '%反毛%' AND
- color LIKE '%黑%' THEN 1.3 + 0.2 WHEN type LIKE '%反毛%' THEN 1.5 + 0.2 WHEN type LIKE N'%贴膜%' AND
- color LIKE '%白%' THEN 1.8 WHEN type LIKE N'%贴膜%' AND color LIKE '%黑%' THEN 1.5 else 1.8 END AS retan_cost,
- CASE WHEN type LIKE '%反毛%' THEN 1.4 WHEN type LIKE N'%贴膜%' THEN 0.3 END AS p_cost
- FROM rt_finish_stock_0630 LEFT OUTER JOIN
- rt_shaving_price ON rt_finish_stock_0630.lot = '516 ' + rt_shaving_price.source where rt_finish_stock_0630.id='" & dt_inprocess.Rows(x).Item("id") & "'"
-
-
- dt2 = New DataTable
- cmd.CommandText = sql
- da.SelectCommand = cmd
- da.Fill(dt2)
-
-
-
-
-
- Dim serial As Integer = 1
-
- For y = 0 To dt2.Rows.Count - 1
-
- xlSheet2.Cells(yy + 1 + y, 2) = "'" & serial '行号
- xlSheet2.Cells(yy + 1 + y, 3) = "'" & my_no & aa
-
- If dt2.Rows(y).Item("type") Like "*反毛*" Then
-
- xlSheet2.Cells(yy + 1 + y, 5) = "516.F.FM"
- xlSheet2.Cells(yy + 1 + y, 6) = "二层皮"
-
- Else
-
- xlSheet2.Cells(yy + 1 + y, 5) = "516.P.PU"
- xlSheet2.Cells(yy + 1 + y, 6) = "贴膜皮"
-
-
- End If
-
-
- If dt2.Rows(y).Item("wh") = "待发货" Then
-
-
- If dt2.Rows(y).Item("wh") = "反毛" Then
-
- xlSheet2.Cells(yy + 1 + y, 15) = dt2.Rows(y).Item("price") + dt2.Rows(y).Item("retan_cost") + dt2.Rows(y).Item("p_cost")
- xlSheet2.Cells(yy + 1 + y, 16) = dt2.Rows(y).Item("sf") * xlSheet2.Cells(yy + 1 + y, 15).value
- xlSheet2.Cells(yy + 1 + y, 45) = dt2.Rows(y).Item("retan_cost")
- xlSheet2.Cells(yy + 1 + y, 46) = dt2.Rows(y).Item("p_cost")
-
-
-
- Else
-
- xlSheet2.Cells(yy + 1 + y, 15) = dt2.Rows(y).Item("price") + dt2.Rows(y).Item("retan_cost") + dt2.Rows(y).Item("p_cost")
- xlSheet2.Cells(yy + 1 + y, 16) = dt2.Rows(y).Item("sf") * xlSheet2.Cells(yy + 1 + y, 15).value
- xlSheet2.Cells(yy + 1 + y, 45) = dt2.Rows(y).Item("retan_cost")
- xlSheet2.Cells(yy + 1 + y, 46) = dt2.Rows(y).Item("p_cost")
-
- End If
-
-
-
-
-
- Else
-
- xlSheet2.Cells(yy + 1 + y, 15) = 4
- xlSheet2.Cells(yy + 1 + y, 16) = dt2.Rows(y).Item("sf") * 4
-
-
-
- End If
-
-
- xlSheet2.Cells(yy + 1 + y, 14) = dt2.Rows(y).Item("sf")
-
- xlSheet2.Cells(yy + 1 + y, 17) = dt2.Rows(y).Item("lot")
- xlSheet2.Cells(yy + 1 + y, 18) = "2024/6/30成品盘点 " & dt2.Rows(y).Item("wh")
-
-
-
-
- xlSheet2.Cells(yy + 1 + y, 25) = "'516-R"
- xlSheet2.Cells(yy + 1 + y, 26) = "待售成品仓/赤湖"
-
-
-
-
-
-
- xlSheet2.Cells(yy + 1 + y, 38) = "'" & dt2.Rows(y).Item("cust")
- xlSheet2.Cells(yy + 1 + y, 40) = "'" & dt2.Rows(y).Item("wh")
- ' xlSheet2.Cells(yy + 1 + y, 40) = dt2.Rows(y).Item("tech")
-
- ' xlSheet2.Cells(yy + 1 + y, 41) = dt2.Rows(y).Item("")
- xlSheet2.Cells(yy + 1 + y, 42) = dt2.Rows(y).Item("color")
- xlSheet2.Cells(yy + 1 + y, 43) = dt2.Rows(y).Item("size")
- xlSheet2.Cells(yy + 1 + y, 44) = dt2.Rows(y).Item("card")
-
-
-
-
-
-
- 'xlSheet2.Cells(yy + 1 + y, 47) = dt2.Rows(y).Item("weight_ini")
-
- 'xlSheet2.Cells(yy + 1 + y, 48) = dt2.Rows(y).Item("type")
- xlSheet2.Cells(yy + 1 + y, 49) = dt2.Rows(y).Item("pattern")
-
- xlSheet2.Cells(yy + 1 + y, 50) = dt2.Rows(y).Item("type")
-
-
-
- serial = serial + 1
-
- Next
-
- yy = yy + dt2.Rows.Count
-
-
- aa = aa + 1
- my_x = my_x + 1
- my_card = dt_inprocess.Rows(x).Item("card")
- my_date = dt_inprocess.Rows(x).Item("date")
-
-
- Next
-
- xlSheet2.Range("A2:A" & x + 1).FillDown()
- 'xlSheet2.Range("B2:B" & x + 1).FillDown()
- xlSheet2.Range("D2:D" & x + 1).FillDown()
- xlSheet2.Range("J2:J" & x + 1).FillDown()
- xlSheet2.Range("L2:L" & x + 1).FillDown()
- xlSheet2.Range("M2:M" & x + 1).FillDown()
- 'xlSheet2.Range("O2:O" & x + 1).FillDown()
- 'xlSheet2.Range("P2:P" & x + 1).FillDown()
-
-
-
-
-
- MsgBox("")
-
-
-
-
- End Sub
-
- Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
-
-
- Dim dt As New DataTable
-
- Dim file_name As String = ""
-
- Dim a As Integer = 0
- Dim my_count As Integer = 0
- If OpenFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
-
- file_name = OpenFileDialog1.FileName
- Else
- Exit Sub
-
-
- End If
-
-
-
- ' Dim filepath As String = Me.Button28.Text
-
-
-
-
- Dim sourceFileName As String = file_name
-
-
- Dim address2 As String = "ftp://" & my_ip & ":7788/K3/打尺入库/" & OpenFileDialog1.SafeFileName
-
- Dim address3() As String
-
- address3 = Split(address2, "ftp://" & my_ip & ":7788/")
- Dim add4 As String
-
- add4 = "d:\k3\" & address3(1)
-
- add4 = "d:\k3\打尺入库\" & OpenFileDialog1.SafeFileName
-
-
-
-
- Dim userName As String = "matchy3c"
- Dim password As String = "Lafayette11"
- Dim showUI As Boolean = True
- Dim connectionTimeout As Integer = 500
-
-
- Dim client As WebClient = New WebClient
- client.Credentials = New NetworkCredential(userName, password)
- client.Proxy = GlobalProxySelection.GetEmptyWebProxy()
- client.UploadFile(address2, sourceFileName)
-
-
-
- sql = "delete from RT_tm_measure_in where year(date)=" & Year(dtp1.Value) & " and month(date)=" & Month(dtp1.Value) & "" '----
-
- cmd.CommandText = sql
- cmd.ExecuteNonQuery()
-
-
-
-
-
-
-
- sql = "Select * FROM OPENDATASOURCE ('Microsoft.ACE.OLEDB.12.0','Excel 12.0;HDR=Yes;IMEX=1;Database=" & add4 & "')... [产品入库序时簿$]"
-
- cmd.CommandText = sql
-
- da.SelectCommand = cmd
- da.Fill(dt)
- dgv1.DataSource = dt
-
-
-
-
- Dim my_sqlbulk As New SqlBulkCopy(conn)
-
- my_sqlbulk.DestinationTableName = "dbo.RT_tm_measure_in"
- my_sqlbulk.WriteToServer(dt)
-
- MsgBox("导入完成!")
-
-
-
- End Sub
-
- Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click '打尺入库
-
-
-
-
-
-
-
- Dim aa As String
- Dim my_card As String = ""
- Dim my_date As Date
-
- aa = TextBox8.Text
-
- If aa = "" Then
- MsgBox("请输入起始单号")
- Exit Sub
- End If
-
-
-
- Dim xlApp As Microsoft.Office.Interop.Excel.Application
- Dim xlBook As Microsoft.Office.Interop.Excel.Workbook
- Dim xlSheet As Microsoft.Office.Interop.Excel.Worksheet
- Dim xlSheet2 As Microsoft.Office.Interop.Excel.Worksheet
-
-
-
-
- Dim file_name As String = ""
- Dim file_name1 As String = ""
- Dim my_weight As Double = 0
- Dim a As Integer = 0
- Dim my_count As Integer = 0
- Dim my_x As Integer = 0
-
-
-
- xlApp = CreateObject("Excel.Application")
- xlApp.Visible = True
- xlApp.DisplayAlerts = False
-
-
- xlBook = xlApp.Workbooks.Open("D:\K3\k3表格模板\下鼓染色入库.xls",, True)
-
- xlBook.Activate()
-
- Dim dt2 As New DataTable
-
-
- For i = 1 To xlApp.Worksheets.Count
-
- If xlApp.Workbooks(1).Worksheets(i).name = "Page1" Then
- xlSheet = xlApp.Workbooks(1).Worksheets(i)
- xlSheet.Activate()
- Exit For
- End If
-
-
- Next
-
-
- Dim my_no As String = "CPRK"
- Dim yy As Integer = 1
- Dim x As Integer = 0
-
- Dim dt_inprocess As New DataTable
-
-
- sql = "SELECT date, dep, no, wh, code, codename, spec, qty, price, amount, lot, comment, card, cust, spec1, color, pattern, order_sf,measure,
- CASE WHEN codename = N'杂皮贴膜 二层' AND (cust LIKE '%086%' OR
- cust LIKE '%088%') THEN N'516 贴膜 8-12' WHEN codename = N'杂皮贴膜 二层' AND (cust LIKE '%好兄弟%')
- THEN N'516 贴膜 12+' WHEN codename = N'杂皮贴膜 二层' AND (cust LIKE '%JX%')
- THEN N'516 贴膜 4-8' WHEN codename = N'杂皮贴膜 二层' THEN N'516 贴膜 8-12' WHEN codename <> N'杂皮贴膜 二层' THEN
- '516 ' + codename END AS name, id FROM RT_TM_measure_in where date between '2024/7/27' and '2024/7/31' ORDER BY measure "
-
- cmd.CommandText = sql
-
- da.SelectCommand = cmd
- da.Fill(dt_inprocess)
-
-
-
-
-
-
-
- For x = 0 To dt_inprocess.Rows.Count - 1 '-----------loop
-
-
-
-
-
- xlSheet.Cells(my_x + 2, 1) = dt_inprocess.Rows(x).Item("date")
- xlSheet.Cells(my_x + 2, 2) = dt_inprocess.Rows(x).Item("date")
- xlSheet.Cells(my_x + 2, 3) = "'曾添梅"
- xlSheet.Cells(my_x + 2, 4) = "'" & my_no & aa
- xlSheet.Cells(my_x + 2, 5) = "'zhang"
- xlSheet.Cells(my_x + 2, 6) = "'1"
- xlSheet.Cells(my_x + 2, 7) = "'2"
- xlSheet.Cells(my_x + 2, 8) = "'165701"
-
-
-
-
-
-
- xlSheet.Cells(my_x + 2, 9) = "'655P-R"
- xlSheet.Cells(my_x + 2, 10) = "'修剪、成检、量尺、包装-R"
-
-
- xlSheet.Cells(my_x + 2, 11) = "'120"
- xlSheet.Cells(my_x + 2, 12) = "'吴小男"
- xlSheet.Cells(my_x + 2, 13) = "'120"
- xlSheet.Cells(my_x + 2, 14) = "'吴小男"
- xlSheet.Cells(my_x + 2, 15) = "'85"
-
-
-
-
- For i = 1 To xlApp.Worksheets.Count
-
- If xlApp.Workbooks(1).Worksheets(i).name = "Page2" Then
- xlSheet2 = xlApp.Workbooks(1).Worksheets(i)
- xlSheet2.Activate()
- Exit For
- End If
-
- Next
-
-
-
-
-
-
-
- sql = "SELECT date, dep, no, wh, code, codename, spec, qty, price, amount, lot, comment, card, cust, spec1, color, pattern, order_sf,
- CASE WHEN codename like N'%贴膜%' AND (cust LIKE '%086%' OR
- cust LIKE '%088%') THEN N'516 贴膜 8-12' WHEN codename like N'%贴膜%' AND (cust LIKE '%好兄弟%')
- THEN N'516 贴膜 12+' WHEN codename like N'%贴膜%' AND (cust LIKE '%JX%')
- THEN N'516 贴膜 4-8' WHEN codename like N'%贴膜%' THEN N'516 贴膜 8-12' WHEN not(codename like N'%贴膜%') THEN
- '516 ' + codename END AS name, id
- FROM RT_TM_measure_in where measure='" & dt_inprocess.Rows(x).Item("measure") & "'"
-
-
-
-
-
-
- dt2 = New DataTable
- cmd.CommandText = sql
- da.SelectCommand = cmd
- da.Fill(dt2)
-
-
-
-
-
- Dim serial As Integer = 1
-
- For y = 0 To dt2.Rows.Count - 1
-
- xlSheet2.Cells(yy + 1 + y, 2) = "'" & serial '行号
- xlSheet2.Cells(yy + 1 + y, 3) = "'" & my_no & aa
-
- If dt2.Rows(y).Item("name") Like "*贴膜*" Then
-
- xlSheet2.Cells(yy + 1 + y, 5) = "516.P.PU"
- xlSheet2.Cells(yy + 1 + y, 6) = "贴膜皮"
-
- Else
-
- xlSheet2.Cells(yy + 1 + y, 5) = "516.F.FM"
- xlSheet2.Cells(yy + 1 + y, 6) = "二层皮"
-
-
- End If
-
-
-
-
-
- xlSheet2.Cells(yy + 1 + y, 14) = dt2.Rows(y).Item("qty")
- ' xlSheet2.Cells(yy + 1 + y, 15) = dt2.Rows(y).Item("price")
- 'xlSheet2.Cells(yy + 1 + y, 16) = dt2.Rows(y).Item("sf") * dt2.Rows(y).Item("price")
- xlSheet2.Cells(yy + 1 + y, 17) = dt2.Rows(y).Item("name")
- xlSheet2.Cells(yy + 1 + y, 18) = "打尺入库 " & dt2.Rows(y).Item("wh")
-
-
-
-
- xlSheet2.Cells(yy + 1 + y, 25) = "'516-R"
- xlSheet2.Cells(yy + 1 + y, 26) = "待售成品仓/赤湖"
-
-
-
-
-
-
- xlSheet2.Cells(yy + 1 + y, 38) = "'" & dt2.Rows(y).Item("cust")
- xlSheet2.Cells(yy + 1 + y, 39) = "'" & dt2.Rows(y).Item("comment")
- ' xlSheet2.Cells(yy + 1 + y, 40) = dt2.Rows(y).Item("tech")
-
- ' xlSheet2.Cells(yy + 1 + y, 41) = dt2.Rows(y).Item("")
- xlSheet2.Cells(yy + 1 + y, 42) = dt2.Rows(y).Item("color")
- ' xlSheet2.Cells(yy + 1 + y, 43) = dt2.Rows(y).Item("size")
- xlSheet2.Cells(yy + 1 + y, 44) = dt2.Rows(y).Item("card")
-
-
-
- ' xlSheet2.Cells(yy + 1 + y, 45) = dt2.Rows(y).Item("retan_cost")
- ' xlSheet2.Cells(yy + 1 + y, 46) = dt2.Rows(y).Item("p_cost")
-
-
- 'xlSheet2.Cells(yy + 1 + y, 47) = dt2.Rows(y).Item("weight_ini")
-
- 'xlSheet2.Cells(yy + 1 + y, 48) = dt2.Rows(y).Item("type")
- 'xlSheet2.Cells(yy + 1 + y, 49) = dt2.Rows(y).Item("pattern")
-
- ' xlSheet2.Cells(yy + 1 + y, 50) = dt2.Rows(y).Item("type")
-
-
-
- serial = serial + 1
-
- Next
-
- yy = yy + dt2.Rows.Count
-
-
- aa = aa + 1
- my_x = my_x + 1
- ' my_card = dt_inprocess.Rows(x).Item("card")
- ' my_date = dt_inprocess.Rows(x).Item("date")
-
-
- Next
-
- xlSheet2.Range("A2:A" & x + 1).FillDown()
- 'xlSheet2.Range("B2:B" & x + 1).FillDown()
- xlSheet2.Range("D2:D" & x + 1).FillDown()
- xlSheet2.Range("J2:J" & x + 1).FillDown()
- xlSheet2.Range("L2:L" & x + 1).FillDown()
- xlSheet2.Range("M2:M" & x + 1).FillDown()
- 'xlSheet2.Range("O2:O" & x + 1).FillDown()
- 'xlSheet2.Range("P2:P" & x + 1).FillDown()
-
-
-
-
-
- MsgBox("")
-
-
-
-
- End Sub
-
- Private Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click
-
-
-
-
-
-
-
-
-
-
-
-
-
- End Sub
-
- Private Sub Button6_Click(sender As Object, e As EventArgs) Handles Button6.Click '516调账
-
-
-
-
-
-
-
-
-
- Dim aa As String
- Dim my_card As String = ""
- Dim my_date As Date
-
- aa = TextBox8.Text
-
- If aa = "" Then
- MsgBox("请输入起始单号")
- Exit Sub
- End If
-
-
-
- Dim xlApp As Microsoft.Office.Interop.Excel.Application
- Dim xlBook As Microsoft.Office.Interop.Excel.Workbook
- Dim xlSheet As Microsoft.Office.Interop.Excel.Worksheet
- Dim xlSheet2 As Microsoft.Office.Interop.Excel.Worksheet
-
-
-
-
- Dim file_name As String = ""
- Dim file_name1 As String = ""
- Dim my_weight As Double = 0
- Dim a As Integer = 0
- Dim my_count As Integer = 0
- Dim my_x As Integer = 0
-
-
-
- xlApp = CreateObject("Excel.Application")
- xlApp.Visible = True
- xlApp.DisplayAlerts = False
-
-
- xlBook = xlApp.Workbooks.Open("D:\K3\k3表格模板\下鼓染色入库.xls",, True)
-
- xlBook.Activate()
-
- Dim dt2 As New DataTable
-
-
- For i = 1 To xlApp.Worksheets.Count
-
- If xlApp.Workbooks(1).Worksheets(i).name = "Page1" Then
- xlSheet = xlApp.Workbooks(1).Worksheets(i)
- xlSheet.Activate()
- Exit For
- End If
-
-
- Next
-
-
- Dim my_no As String = "CPRK"
- Dim yy As Integer = 1
- Dim x As Integer = 0
-
- Dim dt_inprocess As New DataTable
-
-
- sql = "select * from rt_516_old_bal "
-
- cmd.CommandText = sql
-
- da.SelectCommand = cmd
- da.Fill(dt_inprocess)
-
-
-
-
-
-
-
- For x = 0 To dt_inprocess.Rows.Count - 1 '-----------loop
-
-
-
-
-
- xlSheet.Cells(my_x + 2, 1) = "2024/06/30"
- xlSheet.Cells(my_x + 2, 2) = "2024/06/30"
- xlSheet.Cells(my_x + 2, 3) = "'吴小男"
- xlSheet.Cells(my_x + 2, 4) = "'" & my_no & aa
- xlSheet.Cells(my_x + 2, 5) = "'zhang"
-
- If dt_inprocess.Rows(x).Item("qty") > 0 Then
-
- xlSheet.Cells(my_x + 2, 6) = "'-1"
- Else
- xlSheet.Cells(my_x + 2, 6) = "'1"
- End If
-
- xlSheet.Cells(my_x + 2, 7) = "'2"
- xlSheet.Cells(my_x + 2, 8) = "'165701"
-
-
-
-
-
-
- xlSheet.Cells(my_x + 2, 9) = "'655P-R"
- xlSheet.Cells(my_x + 2, 10) = "'修剪、成检、量尺、包装-R"
-
-
- xlSheet.Cells(my_x + 2, 11) = "'120"
- xlSheet.Cells(my_x + 2, 12) = "'吴小男"
- xlSheet.Cells(my_x + 2, 13) = "'120"
- xlSheet.Cells(my_x + 2, 14) = "'吴小男"
- xlSheet.Cells(my_x + 2, 15) = "'85"
-
-
-
-
- For i = 1 To xlApp.Worksheets.Count
-
- If xlApp.Workbooks(1).Worksheets(i).name = "Page2" Then
- xlSheet2 = xlApp.Workbooks(1).Worksheets(i)
- xlSheet2.Activate()
- Exit For
- End If
-
- Next
-
-
-
-
-
-
-
- sql = "select code,codename,lot,wh,whname,cast(qty as numeric(10,2)) as qty,qty1 from rt_516_old_bal where id='" & dt_inprocess.Rows(x).Item("id") & "'"
-
-
-
-
-
-
- dt2 = New DataTable
- cmd.CommandText = sql
- da.SelectCommand = cmd
- da.Fill(dt2)
-
-
-
-
-
- Dim serial As Integer = 1
-
- For y = 0 To dt2.Rows.Count - 1
-
- xlSheet2.Cells(yy + 1 + y, 2) = "'" & serial '行号
- xlSheet2.Cells(yy + 1 + y, 3) = "'" & my_no & aa
-
-
-
- xlSheet2.Cells(yy + 1 + y, 5) = dt2.Rows(y).Item("code")
- xlSheet2.Cells(yy + 1 + y, 6) = dt2.Rows(y).Item("codename")
-
-
-
-
-
-
-
-
- xlSheet2.Cells(yy + 1 + y, 14) = -dt2.Rows(y).Item("qty")
-
- xlSheet2.Cells(yy + 1 + y, 17) = "'" & dt2.Rows(y).Item("lot")
- xlSheet2.Cells(yy + 1 + y, 18) = "'2024/6/30 新编码调账"
-
-
-
-
- xlSheet2.Cells(yy + 1 + y, 25) = "'516-R"
- xlSheet2.Cells(yy + 1 + y, 26) = "待售成品仓/赤湖"
-
-
-
-
-
-
- 'xlSheet2.Cells(yy + 1 + y, 38) = "'" & dt2.Rows(y).Item("cust")
- 'xlSheet2.Cells(yy + 1 + y, 39) = "'" & dt2.Rows(y).Item("comment")
- ' xlSheet2.Cells(yy + 1 + y, 40) = dt2.Rows(y).Item("tech")
-
- ' xlSheet2.Cells(yy + 1 + y, 41) = dt2.Rows(y).Item("")
- 'xlSheet2.Cells(yy + 1 + y, 42) = dt2.Rows(y).Item("color")
- ' xlSheet2.Cells(yy + 1 + y, 43) = dt2.Rows(y).Item("size")
- 'xlSheet2.Cells(yy + 1 + y, 44) = dt2.Rows(y).Item("card")
-
-
-
- ' xlSheet2.Cells(yy + 1 + y, 45) = dt2.Rows(y).Item("retan_cost")
- ' xlSheet2.Cells(yy + 1 + y, 46) = dt2.Rows(y).Item("p_cost")
-
-
- 'xlSheet2.Cells(yy + 1 + y, 47) = dt2.Rows(y).Item("weight_ini")
-
- 'xlSheet2.Cells(yy + 1 + y, 48) = dt2.Rows(y).Item("type")
- 'xlSheet2.Cells(yy + 1 + y, 49) = dt2.Rows(y).Item("pattern")
-
- ' xlSheet2.Cells(yy + 1 + y, 50) = dt2.Rows(y).Item("type")
-
-
-
- serial = serial + 1
-
- Next
-
- yy = yy + dt2.Rows.Count
-
-
- aa = aa + 1
- my_x = my_x + 1
- ' my_card = dt_inprocess.Rows(x).Item("card")
- ' my_date = dt_inprocess.Rows(x).Item("date")
-
-
- Next
-
- xlSheet2.Range("A2:A" & x + 1).FillDown()
- 'xlSheet2.Range("B2:B" & x + 1).FillDown()
- xlSheet2.Range("D2:D" & x + 1).FillDown()
- xlSheet2.Range("J2:J" & x + 1).FillDown()
- xlSheet2.Range("L2:L" & x + 1).FillDown()
- xlSheet2.Range("M2:M" & x + 1).FillDown()
- 'xlSheet2.Range("O2:O" & x + 1).FillDown()
- 'xlSheet2.Range("P2:P" & x + 1).FillDown()
-
-
-
-
-
- MsgBox("")
-
-
-
-
-
-
-
-
- End Sub
-
- Private Sub Button7_Click(sender As Object, e As EventArgs) Handles Button7.Click
-
-
- dt = New DataTable
-
- sql = "SELECT t3 as 皮源,cast(sum(sf) as numeric(10,1)) as 尺数 FROM Rt_measure_daily WHERE (date BETWEEN '2024/7/1' AND '2024/7/31') group by t3"
- cmd.CommandText = sql
-
- da.Fill(dt)
-
-
- DGV1.DataSource = dt
-
-
-
-
-
- End Sub
- End Class
|