12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010 |
- Imports System.Data.SqlClient
- Imports System.Windows.Forms.VisualStyles.VisualStyleElement
-
- Public Class Frm_Measure_PU
- Dim cmd As New SqlCommand
- Dim da As New SqlDataAdapter
- Dim dt As New DataTable
- Dim sql As String
- Private Sub Frm_Measure_Load(sender As Object, e As EventArgs) Handles MyBase.Load
-
-
- Dim conn As New SqlConnection
-
-
-
- 'connstring = "Data Source=127.0.0.1;Persist Security Info=True;User ID=sa;Password=Lafayette11;Initial Catalog=maindb_hy2014"
- conn.ConnectionString = connstring
- conn.Open()
-
-
-
- dgv2.RowHeadersWidth = 15
- dgv2.ColumnHeadersHeight = 20
-
-
- dgv2.ClipboardCopyMode = DataGridViewClipboardCopyMode.EnableAlwaysIncludeHeaderText
- DataGridView1.ClipboardCopyMode = DataGridViewClipboardCopyMode.EnableAlwaysIncludeHeaderText
- DataGridView2.ClipboardCopyMode = DataGridViewClipboardCopyMode.EnableAlwaysIncludeHeaderText
- DataGridView3.ClipboardCopyMode = DataGridViewClipboardCopyMode.EnableAlwaysIncludeHeaderText
- DataGridView4.ClipboardCopyMode = DataGridViewClipboardCopyMode.EnableAlwaysIncludeHeaderText
- DataGridView5.ClipboardCopyMode = DataGridViewClipboardCopyMode.EnableAlwaysIncludeHeaderText
- DataGridView6.ClipboardCopyMode = DataGridViewClipboardCopyMode.EnableAlwaysIncludeHeaderText
- DataGridView7.ClipboardCopyMode = DataGridViewClipboardCopyMode.EnableAlwaysIncludeHeaderText
- DataGridView8.ClipboardCopyMode = DataGridViewClipboardCopyMode.EnableAlwaysIncludeHeaderText
-
-
- cmd.Connection = conn
- sql = "select top(1) date1 from rt_pu_measure2_temp order by date1 desc"
- cmd.CommandText = sql
-
- Label22.Text = cmd.ExecuteScalar
-
-
-
-
- End Sub
-
- Private Sub Button7_Click(sender As Object, e As EventArgs) Handles Button7.Click
-
-
- sql = "SELECT count(*) as 笔数,comment1 as 分类,cast(sum(sf) as numeric(10,1)) as sf FROM Rt_pu_measure2_TEMP WHERE (date1 BETWEEN '" & String.Format("{0:d}", dtp_begin.Value) & "' and '" & String.Format("{0:d}", dtp_end.Value) & "') group by comment1" '--全部
- dt = New DataTable
- cmd.CommandText = sql
- da.SelectCommand = cmd
-
- da.Fill(dt)
- ' dt.Columns(0).ColumnName = "贴膜打尺"
- dgv2.DataSource = dt
-
- dgv2.Columns(0).Width = 65
- dgv2.Columns(1).Width = 110
- dgv2.Columns(2).Width = 80
-
-
- sql = "SELECT cast(sum(sf) as numeric(10,1)) as sf FROM Rt_pu_measure2_TEMP WHERE (date1 BETWEEN '" & String.Format("{0:d}", dtp_begin.Value) & "' and '" & String.Format("{0:d}", dtp_end.Value) & "') "
- dt = New DataTable
- cmd.CommandText = sql
-
- Label3.Text = cmd.ExecuteScalar.ToString
-
-
-
-
- sql = "SELECT count(*) as 笔数,comment1 as 分类,cast(sum(sf) as numeric(10,1)) as 尺数 FROM Rt_pu_measure2_TEMP WHERE (date1 BETWEEN '" & String.Format("{0:d}", dtp_begin.Value) & "' and '" & String.Format("{0:d}", dtp_end.Value) & "') and not( comment1 like N'%仓存%' or comment1 like N'%仓库%' or comment1 like N'%库存%' or comment1 like N'%取%' or comment1 like N'%退返%' or comment1 like N'%冲孔%' or comment1 like N'%返车间%') group by comment1" '-----------------------------------------------正常
- dt = New DataTable
- cmd.CommandText = sql
- da.SelectCommand = cmd
-
- da.Fill(dt)
-
- DataGridView1.DataSource = dt
-
- DataGridView1.Columns(0).Width = 65
- DataGridView1.Columns(1).Width = 110
- DataGridView1.Columns(2).Width = 80
-
-
- sql = "SELECT cast(sum(sf) as numeric(10,1)) as sf FROM Rt_pu_measure2_TEMP WHERE (date1 BETWEEN '" & String.Format("{0:d}", dtp_begin.Value) & "' and '" & String.Format("{0:d}", dtp_end.Value) & "') and not( comment1 like N'%仓存%' or comment1 like N'%仓库%' or comment1 like N'%库存%' or comment1 like N'%取%' or comment1 like N'%退返%' or comment1 like N'%冲孔%' or comment1 like N'%返车间%')"
-
- dt = New DataTable
- cmd.CommandText = sql
-
- Label15.Text = cmd.ExecuteScalar.ToString
-
-
-
-
-
-
-
- sql = "SELECT count(*) as 笔数,comment1 as 分类,cast(sum(sf) as numeric(10,1)) as 尺数 FROM Rt_pu_measure2_TEMP WHERE (date1 BETWEEN '" & String.Format("{0:d}", dtp_begin.Value) & "' and '" & String.Format("{0:d}", dtp_end.Value) & "') and comment1 like N'%仓存%' group by comment1" '----仓存
- dt = New DataTable
- cmd.CommandText = sql
- da.SelectCommand = cmd
- da.Fill(dt)
- DataGridView2.DataSource = dt
- DataGridView2.Columns(0).Width = 65
- DataGridView2.Columns(1).Width = 110
- DataGridView2.Columns(2).Width = 80
-
-
- sql = "SELECT cast(sum(sf) as numeric(10,1)) as 尺数 FROM Rt_pu_measure2_TEMP WHERE (date1 BETWEEN '" & String.Format("{0:d}", dtp_begin.Value) & "' and '" & String.Format("{0:d}", dtp_end.Value) & "') and comment1 like N'%仓存%'"
- dt = New DataTable
- cmd.CommandText = sql
-
- Label5.Text = cmd.ExecuteScalar.ToString
-
-
-
- sql = "SELECT count(*) as 笔数,comment1 as 分类,cast(sum(sf) as numeric(10,1)) as 尺数 FROM Rt_pu_measure2_TEMP WHERE (date1 BETWEEN '" & String.Format("{0:d}", dtp_begin.Value) & "' and '" & String.Format("{0:d}", dtp_end.Value) & "') and comment1 like N'%仓库%' group by comment1" '-----仓库
- dt = New DataTable
- cmd.CommandText = sql
- da.SelectCommand = cmd
- da.Fill(dt)
- DataGridView3.DataSource = dt
-
- DataGridView3.Columns(0).Width = 65
- DataGridView3.Columns(1).Width = 110
- DataGridView3.Columns(2).Width = 80
-
-
- sql = "SELECT cast(sum(sf) as numeric(10,1)) as 尺数 FROM Rt_pu_measure2_TEMP WHERE (date1 BETWEEN '" & String.Format("{0:d}", dtp_begin.Value) & "' and '" & String.Format("{0:d}", dtp_end.Value) & "') and comment1 like N'%仓库%' "
- dt = New DataTable
- cmd.CommandText = sql
-
- Label7.Text = cmd.ExecuteScalar.ToString
-
-
- sql = "SELECT count(*) as 笔数,comment1 as 分类,cast(sum(sf) as numeric(10,1)) as 尺数 FROM Rt_pu_measure2_TEMP WHERE (date1 BETWEEN '" & String.Format("{0:d}", dtp_begin.Value) & "' and '" & String.Format("{0:d}", dtp_end.Value) & "') and comment1 like N'%库存%' group by comment1" '------库存
- dt = New DataTable
- cmd.CommandText = sql
- da.SelectCommand = cmd
- da.Fill(dt)
- DataGridView4.DataSource = dt
- DataGridView4.Columns(0).Width = 65
- DataGridView4.Columns(1).Width = 110
- DataGridView4.Columns(2).Width = 80
-
- sql = "SELECT cast(sum(sf) as numeric(10,1)) as 尺数 FROM Rt_pu_measure2_TEMP WHERE (date1 BETWEEN '" & String.Format("{0:d}", dtp_begin.Value) & "' and '" & String.Format("{0:d}", dtp_end.Value) & "') and comment1 like N'%库存%'"
- dt = New DataTable
- cmd.CommandText = sql
-
- Label9.Text = cmd.ExecuteScalar.ToString
-
- sql = "SELECT count(*) as 笔数,comment1,cast(sum(sf) as numeric(10,1)) as sf FROM Rt_pu_measure2_TEMP WHERE (date1 BETWEEN '" & String.Format("{0:d}", dtp_begin.Value) & "' and '" & String.Format("{0:d}", dtp_end.Value) & "') and comment1 like N'%取%' group by comment1" '----待打包
- dt = New DataTable
- cmd.CommandText = sql
- da.SelectCommand = cmd
- da.Fill(dt)
- DataGridView5.DataSource = dt
- DataGridView5.Columns(0).Width = 65
- DataGridView5.Columns(1).Width = 110
- DataGridView5.Columns(2).Width = 80
-
- sql = "SELECT cast(sum(sf) as numeric(10,1)) as sf FROM Rt_pu_measure2_TEMP WHERE (date1 BETWEEN '" & String.Format("{0:d}", dtp_begin.Value) & "' and '" & String.Format("{0:d}", dtp_end.Value) & "') and comment1 like N'%取%'"
- dt = New DataTable
- cmd.CommandText = sql
-
- Label11.Text = cmd.ExecuteScalar.ToString
-
- sql = "SELECT count(*) as 笔数,comment1,cast(sum(sf) as numeric(10,1)) as sf FROM Rt_pu_measure2_TEMP WHERE (date1 BETWEEN '" & String.Format("{0:d}", dtp_begin.Value) & "' and '" & String.Format("{0:d}", dtp_end.Value) & "') and comment1 like N'%退返%' group by comment1" '-----退返
- dt = New DataTable
- cmd.CommandText = sql
- da.SelectCommand = cmd
- da.Fill(dt)
- DataGridView6.DataSource = dt
- DataGridView6.Columns(0).Width = 65
- DataGridView6.Columns(1).Width = 110
- DataGridView6.Columns(2).Width = 80
-
-
- sql = "SELECT cast(sum(sf) as numeric(10,1)) as sf FROM Rt_pu_measure2_TEMP WHERE (date1 BETWEEN '" & String.Format("{0:d}", dtp_begin.Value) & "' and '" & String.Format("{0:d}", dtp_end.Value) & "') and comment1 like N'%退返%'"
- dt = New DataTable
- cmd.CommandText = sql
-
- Label13.Text = cmd.ExecuteScalar.ToString
-
-
-
- sql = "SELECT count(*) as 笔数, comment1 as 分类, cast(sum(sf) as numeric(10,1)) as sf FROM Rt_pu_measure2_TEMP WHERE (date1 BETWEEN '" & String.Format("{0:d}", dtp_begin.Value) & "' and '" & String.Format("{0:d}", dtp_end.Value) & "') and comment1 like N'%冲孔%' group by comment1" '-----冲孔
- dt = New DataTable
- cmd.CommandText = sql
- da.SelectCommand = cmd
- da.Fill(dt)
- DataGridView7.DataSource = dt
- DataGridView7.Columns(0).Width = 65
- DataGridView7.Columns(1).Width = 110
- DataGridView7.Columns(2).Width = 80
-
- sql = "SELECT cast(sum(sf) as numeric(10,1)) as sf FROM Rt_pu_measure2_TEMP WHERE (date1 BETWEEN '" & String.Format("{0:d}", dtp_begin.Value) & "' and '" & String.Format("{0:d}", dtp_end.Value) & "') and comment1 like N'%冲孔%'"
- dt = New DataTable
- cmd.CommandText = sql
-
- Label17.Text = cmd.ExecuteScalar.ToString
-
-
-
-
- sql = "SELECT count(*) as 笔数, comment1 as 分类, cast(sum(sf) as numeric(10,1)) as sf FROM Rt_pu_measure2_TEMP WHERE (date1 BETWEEN '" & String.Format("{0:d}", dtp_begin.Value) & "' and '" & String.Format("{0:d}", dtp_end.Value) & "') and comment1 like N'%返车间%' group by comment1" '-----返车间
- dt = New DataTable
- cmd.CommandText = sql
- da.SelectCommand = cmd
- da.Fill(dt)
- DataGridView8.DataSource = dt
- DataGridView8.Columns(0).Width = 65
- DataGridView8.Columns(1).Width = 110
- DataGridView8.Columns(2).Width = 80
-
- sql = "SELECT cast(sum(sf) as numeric(10,1)) as sf FROM Rt_pu_measure2_TEMP WHERE (date1 BETWEEN '" & String.Format("{0:d}", dtp_begin.Value) & "' and '" & String.Format("{0:d}", dtp_end.Value) & "') and comment1 like N'%返车间%'"
- dt = New DataTable
- cmd.CommandText = sql
-
- Label19.Text = cmd.ExecuteScalar.ToString
-
-
-
-
-
-
-
-
-
- With dgv2.Columns(0).DefaultCellStyle
-
- .Alignment = DataGridViewContentAlignment.MiddleCenter
-
- End With
-
-
- With dgv2.Columns(2).DefaultCellStyle
- .Format = "n1"
- .Alignment = DataGridViewContentAlignment.MiddleRight
-
- End With
-
-
- Label23.Text = Val(Label15.Text) + Val(Label5.Text) + Val(Label17.Text) + Val(Label7.Text) + Val(Label9.Text) + Val(Label19.Text) + Val(Label11.Text) + Val(Label13.Text)
-
-
-
- End Sub
-
- Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click '--516打尺入库
-
-
- Dim aa As String
- Dim bb As String
- Dim my_card As String = ""
- Dim my_date As Date
-
- aa = TextBox8.Text
- bb = 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表格模板\PU打尺入库.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 = "CPRK0"
- Dim yy As Integer = 1
- Dim x As Integer = 0
-
- Dim dt_inprocess As New DataTable
-
-
- Dim dt_out As New DataTable
-
- sql = "select date1 from rt_pu_measure2_temp where (date1 BETWEEN '" & String.Format("{0:d}", dtp_begin.Value) & "' and '" & String.Format("{0:d}", dtp_end.Value) & "') group by date1 order by date1"
- cmd.CommandText = sql
- da.SelectCommand = cmd
- da.Fill(dt_out)
-
-
-
-
- For x = 0 To dt_out.Rows.Count - 1 '-----------loop
-
-
-
-
-
- xlSheet.Cells(x + 2, 1) = dt_out.Rows(x).Item("date1")
- xlSheet.Cells(x + 2, 2) = dt_out.Rows(x).Item("date1")
- xlSheet.Cells(x + 2, 3) = "'曾添梅"
- xlSheet.Cells(x + 2, 4) = "'" & my_no & bb
- xlSheet.Cells(x + 2, 5) = "'zhang"
- xlSheet.Cells(x + 2, 6) = "'1"
- xlSheet.Cells(x + 2, 7) = "'2"
- xlSheet.Cells(x + 2, 8) = "'165701"
-
-
-
-
-
-
- xlSheet.Cells(x + 2, 9) = "'655P-R"
- xlSheet.Cells(x + 2, 10) = "'修剪、成检、量尺、包装-R"
- xlSheet.Cells(x + 2, 11) = "'120"
- xlSheet.Cells(x + 2, 12) = "'吴小男"
- xlSheet.Cells(x + 2, 13) = "'120"
- xlSheet.Cells(x + 2, 14) = "'吴小男"
- xlSheet.Cells(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
-
-
-
-
-
-
-
-
-
- Dim serial As Integer = 1
- For xx As Integer = 1 To 5
-
- Dim sql1 As String
-
- Dim my_type As String
-
-
-
-
- Select Case xx
- Case 1
- sql = "SELECT date1 ,cust,color,thick,pattern,comment1,case when comment1 like N'%4-8%' or comment1 like N'%7%' then N'516 贴膜 4-8' when (comment1 like N'%8以上%' or comment1 like N'%8%') and (comment1 not like N'%4%') then N'516 贴膜 8-12' when comment1 like N'%12%' then N'516 贴膜 12+' end as spec, cast(sf as numeric(10,1)) as 尺数 FROM Rt_pu_measure2_TEMP WHERE (date1 = '" & dt_out.Rows(x).Item("date1") & "') and not( comment1 like N'%仓存%' or comment1 like N'%仓库%' or comment1 like N'%库存%' or comment1 like N'%取%' or comment1 like N'%退返%' or comment1 like N'%冲孔%' or comment1 like N'%返车间%') order by date1 "
- my_type = "--正常--"
-
- Case 2
- sql = "SELECT date1 ,cust,color,thick,pattern,comment1,case when comment1 like N'%4-8%' or comment1 like N'%7%' then N'516 贴膜 4-8' when (comment1 like N'%8以上%' or comment1 like N'%8%') and (comment1 not like N'%4%') then N'516 贴膜 8-12' when comment1 like N'%12%' then N'516 贴膜 12+' end as spec,cast(sf as numeric(10,1)) as 尺数 FROM Rt_pu_measure2_TEMP WHERE (date1 = '" & dt_out.Rows(x).Item("date1") & "') and (comment1 not like N'%冲孔%') and (comment1 like N'%仓存%' or comment1 like N'%仓库%') order by date1" '----仓存仓库
- my_type = "--仓库--"
- Case 3
- sql = "SELECT date1, cust,color,thick,case when (comment1 like N'%4-8%' or comment1 like N'%7%') then N'516 贴膜 4-8' when (comment1 like N'%8以上%' or comment1 like N'%8%') and (comment1 not like N'%4%') then N'516 贴膜 8-12' when (comment1 like N'%12%') then N'516 贴膜 12+' end as spec, CAST((sf) AS numeric(10, 1)) AS 尺数,comment1
- FROM Rt_pu_measure2_TEMP where (date1 = '" & dt_out.Rows(x).Item("date1") & "') and (comment1 not like N'%冲孔%') and ((comment1 like N'%取%') or (comment1 like N'%库存%')) ORDER BY date1"
-
- my_type = "--待打包、库存--"
- Case 4
- sql = "SELECT date1 ,cust,color,thick,case when comment1 like N'%4-8%' or comment1 like N'%7%' then N'516 贴膜 4-8' when (comment1 like N'%8以上%' or comment1 like N'%8%') and (comment1 not like N'%4%') then N'516 贴膜 8-12' when comment1 like N'%12%' then N'516 贴膜 12+' end as spec, CAST((sf) AS numeric(10, 1)) AS 尺数,comment1
- FROM Rt_pu_measure2_TEMP where (date1 = '" & dt_out.Rows(x).Item("date1") & "') and (comment1 like N'%退返%') order by date1 " '---退返
- my_type = "--退返--"
- Case 5
- sql = "SELECT date1 , cust,color,thick,case when comment1 like N'%4-8%' or comment1 like N'%7%' then N'516 贴膜 4-8' when (comment1 like N'%8以上%' or comment1 like N'%8%') and (comment1 not like N'%4%') then N'516 贴膜 8-12' when comment1 like N'%12%' then N'516 贴膜 12+' end as spec, CAST((sf) AS numeric(10, 1)) AS 尺数,comment1
- FROM Rt_pu_measure2_TEMP where (date1 = '" & dt_out.Rows(x).Item("date1") & "') and ((comment1 like N'%冲孔%') or (comment1 like N'%返车间%')) ORDER BY date1 "
- my_type = "--冲孔、返车间--"
-
-
-
- End Select
-
-
-
-
- dt2 = New DataTable
- cmd.CommandText = sql
- da.SelectCommand = cmd
- da.Fill(dt2)
-
-
-
-
-
-
-
- For y = 0 To dt2.Rows.Count - 1
-
- xlSheet2.Cells(yy + 1 + y, 2) = "'" & serial '行号
- xlSheet2.Cells(yy + 1 + y, 3) = "'" & my_no & bb
-
- '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("尺数")
- ' 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("spec") '批号
- xlSheet2.Cells(yy + 1 + y, 18) = "打尺入库" & my_type
-
-
-
-
- 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("color")
- xlSheet2.Cells(yy + 1 + y, 40) = "'" & dt2.Rows(y).Item("date1")
- xlSheet2.Cells(yy + 1 + y, 43) = dt2.Rows(y).Item("thick")
- xlSheet2.Cells(yy + 1 + y, 47) = dt2.Rows(y).Item("comment1")
-
-
-
-
-
- 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" & xlSheet2.UsedRange.Rows.Count).FillDown()
- 'xlSheet2.Range("B2:B" & x + 1).FillDown()
- xlSheet2.Range("D2:D" & xlSheet2.UsedRange.Rows.Count).FillDown()
- xlSheet2.Range("J2:J" & xlSheet2.UsedRange.Rows.Count).FillDown()
- xlSheet2.Range("L2:L" & xlSheet2.UsedRange.Rows.Count).FillDown()
- xlSheet2.Range("M2:M" & xlSheet2.UsedRange.Rows.Count).FillDown()
- 'xlSheet2.Range("O2:O" & x + 1).FillDown()
- 'xlSheet2.Range("P2:P" & x + 1).FillDown()
-
- bb = bb + 1
-
- Next
-
-
- MsgBox("")
-
-
-
- End Sub
-
- Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click '-----313出库
-
- Dim aa As String
- Dim bb As String
- Dim my_card As String = ""
- Dim my_date As Date
-
- aa = TextBox1.Text
- bb = TextBox1.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表格模板\PU打尺出库.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 = "SCLL0"
- Dim yy As Integer = 1
- Dim x As Integer = 0
-
- Dim dt_inprocess As New DataTable
-
-
- Dim dt_out As New DataTable
-
- sql = "select date1 from rt_pu_measure2_temp where (date1 BETWEEN '" & String.Format("{0:d}", dtp_begin.Value) & "' and '" & String.Format("{0:d}", dtp_end.Value) & "') group by date1 order by date1"
- sql = "SELECT date FROM Rt_pu_measure1
- WHERE (date BETWEEN '" & String.Format("{0:d}", dtp_begin.Value) & "' and '" & String.Format("{0:d}", dtp_end.Value) & "') and card not like '%返工皮%' group by date"
- cmd.CommandText = sql
- da.SelectCommand = cmd
- da.Fill(dt_out)
-
-
-
-
- For x = 0 To dt_out.Rows.Count - 1 '-----------loop
-
-
-
-
-
- xlSheet.Cells(x + 2, 1) = dt_out.Rows(x).Item("date")
- xlSheet.Cells(x + 2, 2) = dt_out.Rows(x).Item("date")
- xlSheet.Cells(x + 2, 3) = "'曾添梅"
- xlSheet.Cells(x + 2, 4) = "'" & my_no & bb
- xlSheet.Cells(x + 2, 5) = "'zhang"
- xlSheet.Cells(x + 2, 6) = "'1"
- xlSheet.Cells(x + 2, 7) = "'24"
- xlSheet.Cells(x + 2, 8) = "'165701"
- xlSheet.Cells(x + 2, 9) = "'651P-R"
- xlSheet.Cells(x + 2, 10) = "'中检、量尺-R"
- xlSheet.Cells(x + 2, 12) = "'103"
- xlSheet.Cells(x + 2, 13) = "'曾添梅"
- xlSheet.Cells(x + 2, 14) = "'103"
- xlSheet.Cells(x + 2, 15) = "'曾添梅"
-
-
-
-
-
- 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
-
-
-
-
-
-
-
-
-
- Dim serial As Integer = 1
-
-
-
-
-
- sql = "SELECT date, card, card1, source, cust, spec, color, weight1/2 as weight, sf, cast(sf1 as numeric(10,2)) as rate, tech
- FROM Rt_pu_measure1 WHERE (date = '" & String.Format("{0:d}", dtp_begin.Value) & "') and card not like '%返工皮%' order by card1"
-
- sql = "SELECT date, card, card1, source, cust, spec, color, weight1 / 2 AS weight, sf, CAST(sf1 AS numeric(10, 2)) AS rate, tech,
- CASE WHEN source LIKE N'%无铬鞣%' THEN N'无铬鞣 二层' WHEN source LIKE N'%阿根廷%' THEN N'阿根廷 二层' WHEN source LIKE N'%澳%' THEN N'澳大利亚 二层'
- WHEN (source LIKE N'%巴西%' OR
- source LIKE N'%bx%' OR
- source LIKE N'%南美%')
- THEN N'巴西 二层' WHEN source LIKE N'%智利%' THEN N'智利 二层' WHEN source LIKE N'%德国%' THEN N'德国 二层' WHEN source LIKE N'%西班牙%' THEN N'西班牙 二层'
- WHEN source LIKE N'%欧洲%' THEN N'欧洲 二层' WHEN source LIKE N'%法国%' THEN N'法国 二层' WHEN source LIKE N'%爱尔兰%' THEN N'爱尔兰 二层' WHEN
- source LIKE N'%APP%' THEN N'美国 二层' WHEN source LIKE N'%日本%' THEN N'日本 二层' WHEN source LIKE N'%美国%' THEN N'美国 二层' WHEN source LIKE
- N'%新西兰%' THEN N'新西兰 二层' WHEN source LIKE N'%小皮%' THEN N'小皮 二层' WHEN source LIKE N'%英国%' THEN N'英国 二层' WHEN source LIKE N'%墨西哥%'
- THEN N'墨西哥 二层' WHEN source LIKE N'%乌拉圭%' THEN N'乌拉圭 二层' WHEN source LIKE N'%南非%' THEN N'南非 二层' WHEN source LIKE N'%孟加拉%' THEN
- N'孟加拉 二层' WHEN source LIKE N'%泰国%' THEN N'泰国 二层' ELSE N'杂皮 二层' END AS 皮源
- FROM Rt_pu_measure1
- WHERE (date = '" & dt_out.Rows(x).Item("date") & "') AND (card NOT LIKE '%返工皮%')"
-
-
- dt2 = New DataTable
- cmd.CommandText = sql
- da.SelectCommand = cmd
- da.Fill(dt2)
-
-
-
-
-
-
-
- For y = 0 To dt2.Rows.Count - 1
-
- xlSheet2.Cells(yy + 1 + y, 2) = "'" & serial '行号
- xlSheet2.Cells(yy + 1 + y, 3) = "'" & my_no & bb
- xlSheet2.Cells(yy + 1 + y, 4) = "'24"
- 'If dt2.Rows(y).Item("name") Like "*贴膜*" Then
-
- xlSheet2.Cells(yy + 1 + y, 6) = "516.P.PU"
- xlSheet2.Cells(yy + 1 + y, 7) = "贴膜皮"
-
-
- xlSheet2.Cells(yy + 1 + y, 24) = dt2.Rows(y).Item("weight")
- ' 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, 23) = "313 " & dt2.Rows(y).Item("皮源") '批号
- xlSheet2.Cells(yy + 1 + y, 28) = "中检仓" & "/" & dt2.Rows(y).Item("cust") & "/" & dt2.Rows(y).Item("color") '备注
-
-
-
-
-
- xlSheet2.Cells(yy + 1 + y, 35) = "'313"
- xlSheet2.Cells(yy + 1 + y, 36) = "涂饰在制品"
-
- xlSheet2.Cells(yy + 1 + y, 52) = "'" & dt2.Rows(y).Item("cust")
- xlSheet2.Cells(yy + 1 + y, 54) = "'" & dt2.Rows(y).Item("rate")
- xlSheet2.Cells(yy + 1 + y, 55) = "'" & dt2.Rows(y).Item("tech")
- xlSheet2.Cells(yy + 1 + y, 56) = "'" & dt2.Rows(y).Item("color")
- xlSheet2.Cells(yy + 1 + y, 57) = "'" & dt2.Rows(y).Item("spec")
- xlSheet2.Cells(yy + 1 + y, 58) = dt2.Rows(y).Item("card")
- ' xlSheet2.Cells(yy + 1 + y, 47) = dt2.Rows(y).Item("comment1")
-
-
-
-
-
- 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")
-
-
-
-
-
-
- bb = bb + 1
-
- Next
-
- xlSheet2.Range("A2:A" & xlSheet2.UsedRange.Rows.Count).FillDown()
- 'xlSheet2.Range("B2:B" & x + 1).FillDown()
- xlSheet2.Range("D2:D" & xlSheet2.UsedRange.Rows.Count).FillDown()
- xlSheet2.Range("J2:J" & xlSheet2.UsedRange.Rows.Count).FillDown()
- xlSheet2.Range("L2:L" & xlSheet2.UsedRange.Rows.Count).FillDown()
- xlSheet2.Range("M2:M" & xlSheet2.UsedRange.Rows.Count).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 '------517B出库
-
-
-
-
-
-
- Dim aa As String
- Dim bb As String
- Dim my_card As String = ""
- Dim my_date As Date
-
- aa = TextBox2.Text
- bb = aa
-
-
- If aa = "" Then
- MsgBox("请输入起始单号")
- Exit Sub
- End If
-
-
-
- Dim xlApp As Microsoft.Office.Interop.Excel.Application
- Dim xlApp1 As Microsoft.Office.Interop.Excel.Application
- Dim xlBook As Microsoft.Office.Interop.Excel.Workbook
- Dim xlBook1 As Microsoft.Office.Interop.Excel.Workbook
- Dim xlSheet As Microsoft.Office.Interop.Excel.Worksheet
- Dim xlSheet2 As Microsoft.Office.Interop.Excel.Worksheet
-
- Dim xlSheet_1 As Microsoft.Office.Interop.Excel.Worksheet
- Dim xlSheet2_2 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表格模板\313打尺出库.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 = "SCLL0"
- Dim yy As Integer = 1
- Dim x As Integer = 0
-
-
- Dim my_total_no As Integer = 0
-
- Dim dt As New DataTable
-
- sql = "select date1 from rt_pu_measure2_temp where (date1 BETWEEN '" & String.Format("{0:d}", dtp_begin.Value) & "' and '" & String.Format("{0:d}", dtp_end.Value) & "') group by date1 order by date1"
- cmd.CommandText = sql
- da.SelectCommand = cmd
- Dim dt_out As New DataTable
- da.Fill(dt_out)
-
-
-
- Dim final_no As Integer
-
- For x = 0 To dt_out.Rows.Count - 1 '-----------loop
-
-
-
-
-
- xlSheet.Cells(x + 2, 1) = String.Format("{0:d}", dt_out.Rows(x).Item("date1"))
- xlSheet.Cells(x + 2, 2) = String.Format("{0:d}", dt_out.Rows(x).Item("date1"))
- xlSheet.Cells(x + 2, 3) = "'曾添梅"
- xlSheet.Cells(x + 2, 4) = "'" & my_no & bb
- xlSheet.Cells(x + 2, 5) = "'zhang"
- xlSheet.Cells(x + 2, 6) = "'1"
- xlSheet.Cells(x + 2, 7) = "'24"
- xlSheet.Cells(x + 2, 8) = "'165701"
- xlSheet.Cells(x + 2, 9) = "'655P-R"
- xlSheet.Cells(x + 2, 10) = "'修剪、成检、量尺、包装-R"
- xlSheet.Cells(x + 2, 12) = "'103"
- xlSheet.Cells(x + 2, 13) = "'曾添梅"
- xlSheet.Cells(x + 2, 14) = "'103"
- xlSheet.Cells(x + 2, 15) = "'曾添梅"
- ' xlSheet.Cells(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
-
-
- Dim serial As Integer = 1
- For xx As Integer = 1 To 5
-
- Dim sql1 As String
-
- Dim my_type As String
-
- Select Case xx
- Case 1
- sql = "SELECT date1 ,cust,color,thick,pattern,comment1,case when comment1 like N'%4-8%' or comment1 like N'%7%' then N'516 贴膜 4-8' when (comment1 like N'%8以上%' or comment1 like N'%8%') and (comment1 not like N'%4%') then N'516 贴膜 8-12' when comment1 like N'%12%' then N'516 贴膜 12+' end as spec, cast(sf as numeric(10,1)) as 尺数 FROM Rt_pu_measure2_TEMP WHERE (date1 = '" & dt_out.Rows(x).Item("date1") & "') and not( comment1 like N'%仓存%' or comment1 like N'%仓库%' or comment1 like N'%库存%' or comment1 like N'%取%' or comment1 like N'%退返%' or comment1 like N'%冲孔%' or comment1 like N'%返车间%') order by date1 "
- my_type = "--正常--"
-
- Case 2
- sql = "SELECT date1 ,cust,color,thick,pattern,comment1,case when comment1 like N'%4-8%' or comment1 like N'%7%' then N'516 贴膜 4-8' when (comment1 like N'%8以上%' or comment1 like N'%8%') and (comment1 not like N'%4%') then N'516 贴膜 8-12' when comment1 like N'%12%' then N'516 贴膜 12+' end as spec,cast(sf as numeric(10,1)) as 尺数 FROM Rt_pu_measure2_TEMP WHERE (date1 = '" & dt_out.Rows(x).Item("date1") & "') and (comment1 not like N'%冲孔%') and (comment1 like N'%仓存%' or comment1 like N'%仓库%') order by date1" '----仓存仓库
- my_type = "--仓库--"
- Case 3
- sql = "SELECT date1, cust,color,thick,case when (comment1 like N'%4-8%' or comment1 like N'%7%') then N'516 贴膜 4-8' when (comment1 like N'%8以上%' or comment1 like N'%8%') and (comment1 not like N'%4%') then N'516 贴膜 8-12' when (comment1 like N'%12%') then N'516 贴膜 12+' end as spec, CAST((sf) AS numeric(10, 1)) AS 尺数,comment1
- FROM Rt_pu_measure2_TEMP where (date1 = '" & dt_out.Rows(x).Item("date1") & "') and (comment1 not like N'%冲孔%') and ((comment1 like N'%取%') or (comment1 like N'%库存%')) ORDER BY date1"
-
- my_type = "--待打包、库存--"
- Case 4
- sql = "SELECT date1 ,cust,color,thick,case when comment1 like N'%4-8%' or comment1 like N'%7%' then N'516 贴膜 4-8' when (comment1 like N'%8以上%' or comment1 like N'%8%') and (comment1 not like N'%4%') then N'516 贴膜 8-12' when comment1 like N'%12%' then N'516 贴膜 12+' end as spec, CAST((sf) AS numeric(10, 1)) AS 尺数,comment1
- FROM Rt_pu_measure2_TEMP where (date1 = '" & dt_out.Rows(x).Item("date1") & "') and (comment1 like N'%退返%') order by date1 " '---退返
- my_type = "--退返--"
- Case 5
- sql = "SELECT date1 , cust,color,thick,case when comment1 like N'%4-8%' or comment1 like N'%7%' then N'516 贴膜 4-8' when (comment1 like N'%8以上%' or comment1 like N'%8%') and (comment1 not like N'%4%') then N'516 贴膜 8-12' when comment1 like N'%12%' then N'516 贴膜 12+' end as spec, CAST((sf) AS numeric(10, 1)) AS 尺数,comment1
- FROM Rt_pu_measure2_TEMP where (date1 = '" & dt_out.Rows(x).Item("date1") & "') and ((comment1 like N'%冲孔%') or (comment1 like N'%返车间%')) ORDER BY date1 "
- my_type = "--冲孔、返车间--"
-
-
-
-
- End Select
-
-
-
-
- dt2 = New DataTable
- cmd.CommandText = sql
- da.SelectCommand = cmd
- da.Fill(dt2)
-
- For y = 0 To dt2.Rows.Count - 1
-
- xlSheet2.Cells(yy + 1 + y, 2) = "'" & serial '行号
- xlSheet2.Cells(yy + 1 + y, 3) = "'" & my_no & bb
-
-
-
- xlSheet2.Cells(yy + 1 + y, 6) = "313.P.PU"
- xlSheet2.Cells(yy + 1 + y, 7) = "二层皮"
-
-
-
-
-
- xlSheet2.Cells(yy + 1 + y, 24) = String.Format(dt2.Rows(y).Item("尺数"), "###0.0")
- ' 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, 23) = dt2.Rows(y).Item("spec") '批号
- xlSheet2.Cells(yy + 1 + y, 28) = "打尺入库" & my_type
-
-
-
-
- xlSheet2.Cells(yy + 1 + y, 35) = "'517B"
- xlSheet2.Cells(yy + 1 + y, 36) = "PU成品仓"
-
-
-
-
-
-
- xlSheet2.Cells(yy + 1 + y, 52) = "'" & dt2.Rows(y).Item("cust")
- xlSheet2.Cells(yy + 1 + y, 54) = dt2.Rows(y).Item("尺数")
- xlSheet2.Cells(yy + 1 + y, 56) = "'" & dt2.Rows(y).Item("color")
- ' xlSheet2.Cells(yy + 1 + y, 40) = "'" & dt2.Rows(y).Item("date")
- xlSheet2.Cells(yy + 1 + y, 57) = dt2.Rows(y).Item("thick")
- xlSheet2.Cells(yy + 1 + y, 58) = dt2.Rows(y).Item("comment1")
- ' xlSheet2.Cells(yy + 1 + y, 61) = dt2.Rows(y).Item("commentB")
- ' xlSheet2.Cells(yy + 1 + y, 64) = dt2.Rows(y).Item("retan_weight")
-
-
-
-
-
- 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
- bb = bb + 1
- final_no = x
- Next
-
-
-
-
-
-
-
-
-
-
- 'my_total_no = my_total_no + dt.Rows.Count
- ''For dd As Integer = 0 To dt.Rows.Count - 1
-
-
-
-
- xlSheet2.Range("A2:A" & final_no).FillDown()
- 'xlSheet2.Range("B2:B" & x + 1).FillDown()
- xlSheet2.Range("D2:D" & final_no).FillDown()
- xlSheet2.Range("I2:I" & final_no).FillDown()
- xlSheet2.Range("J2:J" & final_no).FillDown()
- xlSheet2.Range("K2:V" & final_no).FillDown()
-
- xlSheet.Range("A2:A" & final_no).FillDown()
- xlSheet.Range("R2:V" & final_no).FillDown()
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- MsgBox("")
-
- End Sub
- End Class
|