123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330 |
- Option Strict Off
- Imports System.Data.SqlClient
- Public Class 訂單管理控制表
- ReadOnly ds As New DataSet : ReadOnly ds1 As New DataSet : ReadOnly ds2 As New DataSet
- Dim EDR As Integer = 0 : Dim ESTR As String
- Dim 狀態 As String : Dim GGHH As String : Dim HHJJ As String : Dim 申請數量 As Integer
- Private Sub Set_清單()
- DataGridView1.DataSource = Nothing : ds.Clear() : DataGridView1.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing : DataGridView1.ColumnHeadersHeight = 50
- DataGridView1.AllowUserToAddRows = False : DataGridView1.ClipboardCopyMode = DataGridViewClipboardCopyMode.EnableWithoutHeaderText : DataGridView1.MultiSelect = True
- SQL_訂單管理控制表庫存()
- da.Fill(ds) : DataGridView1.DataSource = ds.Tables(0) : conn.Close()
-
- DataGridView1.Columns(0).FillWeight = 115 : DataGridView1.Columns(1).Visible = False : DataGridView1.Columns(2).Visible = False : DataGridView1.Columns(3).FillWeight = 330
- DataGridView1.Columns(4).Visible = False : DataGridView1.Columns(5).Visible = False : DataGridView1.Columns(6).Visible = False : DataGridView1.Columns(7).FillWeight = 70
- DataGridView1.Columns(8).Visible = False : DataGridView1.Columns(9).FillWeight = 70 : DataGridView1.Columns(10).Visible = False : DataGridView1.Columns(11).FillWeight = 70
- DataGridView1.Columns(12).Visible = False : DataGridView1.Columns(13).FillWeight = 70 : DataGridView1.Columns(14).Visible = False : DataGridView1.Columns(15).Visible = False
-
- DataGridView1.Columns(6).DefaultCellStyle.Format = "#,##0" : DataGridView1.Columns(7).DefaultCellStyle.Format = "#,##0" : DataGridView1.Columns(8).DefaultCellStyle.Format = "#,##0"
- DataGridView1.Columns(9).DefaultCellStyle.Format = "#,##0" : DataGridView1.Columns(10).DefaultCellStyle.Format = "#,##0" : DataGridView1.Columns(11).DefaultCellStyle.Format = "#,##0"
- DataGridView1.Columns(12).DefaultCellStyle.Format = "#,##0" : DataGridView1.Columns(13).DefaultCellStyle.Format = "#,##0"
- DataGridView1.Columns(0).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter : DataGridView1.Columns(0).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter
- DataGridView1.Columns(6).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter : DataGridView1.Columns(6).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter
- DataGridView1.Columns(7).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter : DataGridView1.Columns(7).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter
- DataGridView1.Columns(8).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter : DataGridView1.Columns(8).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter
- DataGridView1.Columns(9).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter : DataGridView1.Columns(9).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter
- DataGridView1.Columns(10).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter : DataGridView1.Columns(10).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter
- DataGridView1.Columns(11).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter : DataGridView1.Columns(11).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter
- DataGridView1.Columns(12).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter : DataGridView1.Columns(12).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter
- DataGridView1.Columns(13).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter : DataGridView1.Columns(13).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter
-
- DataGridView1.Columns(0).ReadOnly = True : DataGridView1.Columns(3).ReadOnly = True : DataGridView1.Columns(4).ReadOnly = True : DataGridView1.Columns(5).ReadOnly = True
- DataGridView1.Columns(6).ReadOnly = True : DataGridView1.Columns(7).ReadOnly = True : DataGridView1.Columns(8).ReadOnly = True : DataGridView1.Columns(9).ReadOnly = True
- DataGridView1.Columns(10).ReadOnly = True : DataGridView1.Columns(11).ReadOnly = True : DataGridView1.Columns(12).ReadOnly = True : DataGridView1.Columns(13).ReadOnly = True
-
- DataGridView1.Columns(7).DefaultCellStyle.BackColor = Color.MistyRose : DataGridView1.Columns(8).DefaultCellStyle.BackColor = Color.MistyRose
- DataGridView1.Columns(9).DefaultCellStyle.BackColor = Color.LightYellow : DataGridView1.Columns(10).DefaultCellStyle.BackColor = Color.LightYellow
- DataGridView1.Columns(11).DefaultCellStyle.BackColor = Color.LightGreen : DataGridView1.Columns(12).DefaultCellStyle.BackColor = Color.LightGreen
- For i As Integer = 0 To DataGridView1.Rows.Count - 1
- If DataGridView1.Rows(i).Cells("庫存").Value.ToString = "" Then : DataGridView1.Rows(i).Cells("庫存").Value = 0 : End If
- If DataGridView1.Rows(i).Cells("未入庫").Value.ToString = "" Then : DataGridView1.Rows(i).Cells("未入庫").Value = 0 : End If
- If DataGridView1.Rows(i).Cells("在途成本_台幣").Value.ToString = "" Then : DataGridView1.Rows(i).Cells("在途成本_台幣").Value = 0 : End If
- If DataGridView1.Rows(i).Cells("未出庫").Value.ToString = "" Then : DataGridView1.Rows(i).Cells("未出庫").Value = 0 : End If
- If DataGridView1.Rows(i).Cells("備貨成本_台幣").Value.ToString = "" Then : DataGridView1.Rows(i).Cells("備貨成本_台幣").Value = 0 : End If
- DataGridView1.Rows(i).Cells("可領用").Value = DataGridView1.Rows(i).Cells("庫存").Value - DataGridView1.Rows(i).Cells("未出庫").Value
- Next
- End Sub
- Private Sub Set_訂單控制表()
- DataGridView3.DataSource = Nothing : ds2.Clear() : DataGridView3.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing : DataGridView3.ColumnHeadersHeight = 25
- DataGridView3.AllowUserToAddRows = False : DataGridView3.ClipboardCopyMode = DataGridViewClipboardCopyMode.EnableWithoutHeaderText : DataGridView3.MultiSelect = True
- SQL_訂單管理控制表控制表()
- da.Fill(ds2) : DataGridView3.DataSource = ds2.Tables(0) : conn.Close()
-
- DataGridView3.Columns(0).FillWeight = 80 : DataGridView3.Columns(1).FillWeight = 80 : DataGridView3.Columns(2).Visible = False : DataGridView3.Columns(3).FillWeight = 80
- DataGridView3.Columns(4).FillWeight = 80 : DataGridView3.Columns(5).FillWeight = 80 : DataGridView3.Columns(6).FillWeight = 80 : DataGridView3.Columns(7).FillWeight = 80
- DataGridView3.Columns(8).Visible = False
-
- DataGridView3.Columns(0).ReadOnly = True : DataGridView3.Columns(1).ReadOnly = True : DataGridView3.Columns(2).ReadOnly = True : DataGridView3.Columns(3).ReadOnly = True
- DataGridView3.Columns(4).ReadOnly = True : DataGridView3.Columns(5).ReadOnly = True : DataGridView3.Columns(6).ReadOnly = True : DataGridView3.Columns(7).ReadOnly = True
- DataGridView3.Columns(8).ReadOnly = True
- End Sub
- Private Sub Set_訂單明細表()
- DataGridView2.DataSource = Nothing : ds1.Clear() : DataGridView2.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing : DataGridView2.ColumnHeadersHeight = 25
- DataGridView2.AllowUserToAddRows = False : DataGridView2.ClipboardCopyMode = DataGridViewClipboardCopyMode.EnableWithoutHeaderText : DataGridView2.MultiSelect = True
- SQL_訂單管理控制表控明細()
- da.Fill(ds1) : DataGridView2.DataSource = ds1.Tables(0) : conn.Close()
-
- DataGridView2.Columns(0).Visible = False : DataGridView2.Columns(1).Visible = False : DataGridView2.Columns(2).Visible = False : DataGridView2.Columns(3).FillWeight = 100
- DataGridView2.Columns(4).Visible = False : DataGridView2.Columns(5).Visible = False : DataGridView2.Columns(6).FillWeight = 30 : DataGridView2.Columns(7).FillWeight = 65
- DataGridView2.Columns(8).FillWeight = 65 : DataGridView2.Columns(9).FillWeight = 65 : DataGridView2.Columns(10).FillWeight = 25 : DataGridView2.Columns(11).FillWeight = 60
-
- DataGridView2.Columns(6).DefaultCellStyle.Format = "#,##0"
- DataGridView2.Columns(6).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter : DataGridView2.Columns(6).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter
- DataGridView2.Columns(7).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter : DataGridView2.Columns(7).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter
- DataGridView2.Columns(8).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter : DataGridView2.Columns(8).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter
- DataGridView2.Columns(9).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter : DataGridView2.Columns(9).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter
- DataGridView2.Columns(10).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter : DataGridView2.Columns(10).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter
-
- DataGridView2.Columns(0).ReadOnly = True : DataGridView2.Columns(1).ReadOnly = True : DataGridView2.Columns(2).ReadOnly = True : DataGridView2.Columns(3).ReadOnly = True
- DataGridView2.Columns(4).ReadOnly = True : DataGridView2.Columns(5).ReadOnly = True : DataGridView2.Columns(6).ReadOnly = True : DataGridView2.Columns(7).ReadOnly = True
- DataGridView2.Columns(8).ReadOnly = True : DataGridView2.Columns(9).ReadOnly = True : DataGridView2.Columns(10).ReadOnly = True : DataGridView2.Columns(11).ReadOnly = True
- End Sub
- Private Sub ComboBox1下拉表單資料載入()
- SQL_物料頁碼清單()
- ComboBox1.Items.Clear() : While (dr.Read()) : ComboBox1.Items.Add(dr("頁碼")) : End While : conn.Close()
- End Sub
- Private Sub ComboBox2下拉表單資料載入()
- SQL_客戶資料表_下拉清單讀取()
- ComboBox2.Items.Clear() : ComboBox3.Items.Clear() : While (dr.Read()) : ComboBox2.Items.Add(dr("簡稱")) : ComboBox3.Items.Add(dr("編號")) : End While : conn.Close()
- End Sub
- Private Sub ComboBox5下拉表單資料載入()
- SQL_倉名下拉清單()
- ComboBox5.Items.Clear() : While (dr.Read()) : ComboBox5.Items.Add(dr("倉名")) : End While : conn.Close()
- End Sub
- Private Sub 訂單資料輸入_Load(sender As Object, e As EventArgs) Handles MyBase.Load
- Me.MdiParent = MAOJI_ERP_SYS : Me.WindowState = 2 : Me.AutoScroll = True
- CheckBox1.Checked = True : TextBox7.Enabled = False : TextBox13.Enabled = False : TextBox15.Enabled = False : TextBox16.Visible = False : ComboBox3.Visible = False : RadioButton1.Checked = True
- Button1.Enabled = False : DataGridView2.Visible = False : DataGridView3.Visible = True : ComboBox4.SelectedIndex = 0
- Set_訂單控制表() : ComboBox2下拉表單資料載入()
- ComboBox5.SelectedIndex = 0
- '-----------------------------------------判別訂單準備是否已經齊套-------------------------------------------------------------------------------------------------------------------------------
- For i As Integer = 0 To DataGridView3.Rows.Count - 1
- 資料數 = DataGridView3.Rows.Count : MyModule1.進度條()
- Dim 判別齊套 As Boolean = True
- If DataGridView3.Rows(i).Cells("出貨備齊").Value = True Then : Else
- TextBox9.Text = DataGridView3.Rows(i).Cells("訂單流水號").Value.ToString : DateTimePicker1.Value = DataGridView3.Rows(i).Cells("下單日").Value.ToString
- DateTimePicker2.Value = DataGridView3.Rows(i).Cells("交期").Value.ToString : ComboBox3.Text = DataGridView3.Rows(i).Cells("客戶編號").Value.ToString
- Set_訂單明細表()
- For ii As Integer = 0 To DataGridView2.Rows.Count - 1
- If DataGridView2.Rows(ii).Cells("出貨單號").Value.ToString = "" Then
- 判別齊套 = False
- Exit For
- End If
- Next
- If 判別齊套 = False Then : Else
- PA1 = TextBox9.Text : SQL_訂單控制表_出貨備齊() : conn.Close()
- End If
- End If
- Next : MAOJI_ERP_SYS.ToolStripProgressBar1.Value = 0 : 最終數 = 0
- Set_訂單控制表() : ComboBox1下拉表單資料載入() : ComboBox2下拉表單資料載入() : ComboBox5下拉表單資料載入() : TextBox9.Text = "" : ComboBox5.SelectedIndex = 0
- End Sub
- Private Sub DataGridView1_CellClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellClick
- If e.RowIndex = -1 Then : Else
- TextBox13.Text = DataGridView1.Rows(e.RowIndex).Cells("供應商編號").Value.ToString : TextBox7.Text = DataGridView1.Rows(e.RowIndex).Cells("料號").Value.ToString
- TextBox16.Text = DataGridView1.Rows(e.RowIndex).Cells("加權成本_台幣").Value.ToString : TextBox17.Text = DataGridView1.Rows(e.RowIndex).Cells("售價").Value.ToString
- TextBox15.Text = Format(DataGridView1.Rows(e.RowIndex).Cells("庫存").Value - DataGridView1.Rows(e.RowIndex).Cells("未出庫").Value, "#,##0")
- TextBox17.Text = Format(Val(TextBox17.Text), "#,##0")
- End If
- End Sub
- Private Sub DataGridView2_CellClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView2.CellClick
- If e.RowIndex = -1 Then : Else
- TextBox2.Text = DataGridView2.Rows(e.RowIndex).Cells("出貨單號").Value.ToString
- End If
- End Sub
- Private Sub DataGridView3_CellClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView3.CellClick
- If e.RowIndex = -1 Then : Else
- ComboBox2下拉表單資料載入()
- TextBox9.Text = DataGridView3.Rows(e.RowIndex).Cells("訂單流水號").Value.ToString : DateTimePicker1.Value = DataGridView3.Rows(e.RowIndex).Cells("下單日").Value.ToString
- DateTimePicker2.Value = DataGridView3.Rows(e.RowIndex).Cells("交期").Value.ToString : ComboBox3.Text = DataGridView3.Rows(e.RowIndex).Cells("客戶編號").Value.ToString
- Set_訂單明細表()
- End If
- End Sub
- Private Sub DataGridView1_RowPostPaint(ByVal sender As Object, ByVal e As DataGridViewRowPostPaintEventArgs) Handles DataGridView1.RowPostPaint
- Dim linePen As New Pen(Color.Blue, 2)
- If e.RowIndex = DataGridView1.Rows.Count - 1 Then : Exit Sub
- Else
- If CheckBox1.Checked = True Then
- If DataGridView1(0, e.RowIndex).Value.ToString <> DataGridView1(0, e.RowIndex + 1).Value.ToString Then
- Dim startX As Integer = IIf(DataGridView1.RowHeadersVisible, DataGridView1.RowHeadersWidth, 0)
- Dim startY As Integer = e.RowBounds.Top + e.RowBounds.Height - 1
- Dim endX As Integer = startX + DataGridView1.Columns.GetColumnsWidth(DataGridViewElementStates.Visible) - DataGridView1.HorizontalScrollingOffset
- e.Graphics.DrawLine(linePen, startX, startY, endX, startY) : Exit Sub
- End If
- Else
- If DataGridView1(2, e.RowIndex).Value.ToString <> DataGridView1(2, e.RowIndex + 1).Value.ToString Then
- Dim startX As Integer = IIf(DataGridView1.RowHeadersVisible, DataGridView1.RowHeadersWidth, 0)
- Dim startY As Integer = e.RowBounds.Top + e.RowBounds.Height - 1
- Dim endX As Integer = startX + DataGridView1.Columns.GetColumnsWidth(DataGridViewElementStates.Visible) - DataGridView1.HorizontalScrollingOffset
- e.Graphics.DrawLine(linePen, startX, startY, endX, startY) : Exit Sub
- End If
- End If
- End If
- For i As Integer = 0 To DataGridView1.Rows.Count - 1
- If DataGridView1.Rows(i).Cells("可領用").Value = 0 Then : DataGridView1.Rows(i).DefaultCellStyle.BackColor = Color.LightPink : End If
- Next
- End Sub
- Private Sub TextBox5_TextChanged(sender As Object, e As EventArgs) Handles TextBox5.TextChanged
- PA = TextBox5.Text
- SQL_客戶資料表關鍵字查詢()
- ComboBox2.Items.Clear() : ComboBox3.Items.Clear() : While (dr.Read()) : ComboBox2.Items.Add(dr("簡稱")) : ComboBox3.Items.Add(dr("編號")) : End While : conn.Close()
- End Sub
- Private Sub TextBox1_TextChanged(sender As Object, e As EventArgs) Handles TextBox1.Click
- Set_清單()
- End Sub
- Private Sub ComboBox1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox1.Click
- Set_清單()
- End Sub
- Private Sub CheckBox1_CheckedChanged(sender As Object, e As EventArgs) Handles CheckBox1.Click
- CheckBox1.Checked = True : CheckBox2.Checked = False : Set_清單()
- End Sub
- Private Sub CheckBox2_CheckedChanged(sender As Object, e As EventArgs) Handles CheckBox2.Click
- CheckBox1.Checked = False : CheckBox2.Checked = True : Set_清單()
- End Sub
- Private Sub ComboBox2_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox2.SelectedIndexChanged
- ComboBox3.SelectedIndex = ComboBox2.SelectedIndex
- End Sub
- Private Sub ComboBox3_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox3.SelectedIndexChanged
- ComboBox2.SelectedIndex = ComboBox3.SelectedIndex
- End Sub
- Private Sub ComboBox5_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox5.SelectedIndexChanged
- PA = ComboBox5.Text : SQL_倉名編號取得()
- If dr.Read() Then : TextBox19.Text = dr("倉名編號") : End If : conn.Close() : Set_清單()
- End Sub
- Private Sub RadioButton1_CheckedChanged(sender As Object, e As EventArgs) Handles RadioButton1.Click
- DataGridView2.Visible = False : DataGridView3.Visible = True : Button1.Enabled = False : RadioButton1.Checked = True : RadioButton2.Checked = False : TextBox2.Text = ""
- End Sub
- Private Sub RadioButton2_CheckedChanged(sender As Object, e As EventArgs) Handles RadioButton2.Click
- If TextBox9.Text = "" Then
- MsgBox("請先選擇訂單。") : RadioButton1.Checked = True : RadioButton2.Checked = False : DataGridView2.Visible = False : DataGridView3.Visible = True : Button1.Enabled = False : TextBox2.Text = ""
- Else
- RadioButton1.Checked = False : RadioButton2.Checked = True : DataGridView2.Visible = True : DataGridView3.Visible = False : Button1.Enabled = True : TextBox2.Text = ""
- If DataGridView2.Rows.Count > 0 Then
- TextBox2.Text = DataGridView2.Rows(0).Cells("出貨單號").Value.ToString
- End If
- End If
- End Sub
- Private Sub Set_日期格式轉換()
- If CheckBox1.Checked = False Then
- DTP = Format(Today(), "yyyy/MM/dd") : DTP1 = Format(Today(), "yyyyMMdd") : DTP2 = Format(DateTimePicker2.Value, "yyyy/MM/dd")
- Else
- DTP1 = Format(DateTimePicker1.Value, "yyyyMMdd") : DTP = Format(DateTimePicker1.Value, "yyyy/MM/dd") : DTP2 = Format(DateTimePicker2.Value, "yyyy/MM/dd")
- End If
- End Sub
- Private Sub Set_日期格式轉換1()
- If TextBox2.Text = "" Then
- If CheckBox3.Checked = False Then
- DTP = Format(Today(), "yyyy/MM/dd") : DTP1 = Format(Today(), "yyyyMMdd") : DTP2 = Format(DateTimePicker2.Value, "yyyy/MM/dd")
- Else
- DTP = Format(DateTimePicker1.Value, "yyyy/MM/dd") : DTP1 = Format(DateTimePicker1.Value, "yyyyMMdd") : DTP2 = Format(DateTimePicker2.Value, "yyyy/MM/dd")
- End If
- Else
- DTP = Format(DateTimePicker1.Value, "yyyy/MM/dd") : DTP1 = Format(DateTimePicker1.Value, "yyyyMMdd") : DTP2 = Format(DateTimePicker2.Value, "yyyy/MM/dd")
- End If
- End Sub
- Private Sub Set_自動生成流水號1()
- SQL_倉儲明細表流水號最後一筆()
- If dr.Read() Then : EDR = Double.Parse(Strings.Right(dr("資料流水號").ToString, 8)) : Else : EDR = 0 : End If : conn.Close() : EDR += 1
- If EDR < 10 Then : ESTR = "WD" & "0000000" & EDR
- ElseIf EDR > 9 And EDR < 100 Then : ESTR = "WD" & "000000" & EDR
- ElseIf EDR > 99 And EDR < 1000 Then : ESTR = "WD" & "00000" & EDR
- ElseIf EDR > 999 And EDR < 10000 Then : ESTR = "WD" & "0000" & EDR
- ElseIf EDR > 9999 And EDR < 100000 Then : ESTR = "WD" & "000" & EDR
- ElseIf EDR > 99999 And EDR < 100000 Then : ESTR = "WD" & "00" & EDR
- ElseIf EDR > 999999 And EDR < 1000000 Then : ESTR = "WD" & "0" & EDR
- ElseIf EDR > 9999999 Then : ESTR = "WD" & EDR : End If
- End Sub
- Private Sub Set_新增明細()
- If ComboBox4.Text = "直接出貨" Then : HHJJ = "銷售出庫" : Else : HHJJ = "組裝出庫" : End If
- PA1 = ESTR : PA2 = TextBox2.Text : PA3 = TextBox13.Text : PA4 = TextBox7.Text : NU1 = TextBox16.Text : NU2 = 1 : NU3 = 0 : NU4 = 申請數量 : PA5 = HHJJ : PA6 = DTP
- PA7 = ComboBox3.Text : NU5 = TextBox17.Text : PA8 = TextBox19.Text : PA9 = DTP2 : PA10 = TextBox9.Text
- SQL_倉儲明細表新增_含訂單編號() : conn.Close() : MsgBox("資料新增完畢 。")
- End Sub
- Private Sub Set_生成出貨單()
- If TextBox2.Text = "" Then
- '----------------------自动生成單據編號-------------------------------------------------------------------------
- Dim NUM1 As Integer : Set_日期格式轉換()
- For i As Integer = 1 To 999
- NUM1 = 0 + i
- If NUM1 < 10 Then : TextBox2.Text = "WD-" & DTP1 & "-00" & NUM1
- ElseIf NUM1 > 9 And NUM1 < 100 Then : TextBox2.Text = "WD-" & DTP1 & "-0" & NUM1
- ElseIf NUM1 > 99 Then : TextBox2.Text = "WD-" & DTP1 & "-" & NUM1 : End If
- PA1 = TextBox2.Text : SQL_倉儲明細表生成單據編號()
- If dr.Read() Then : Else : i = 999 : conn.Close() : End If : conn.Close()
- Next
- Set_自動生成流水號1() : TextBox14.Text = ESTR : conn.Close() : Set_新增明細()
- Else
- Set_日期格式轉換1() : Set_自動生成流水號1() : TextBox14.Text = ESTR : conn.Close() : Set_新增明細()
- End If : Set_清單()
- End Sub
- Private Sub Set_自動生成流水號2()
- SQL_訂單明細表流水號最後一筆()
- If dr.Read() Then : EDR = Double.Parse(Strings.Right(dr("資料流水號").ToString, 8)) : Else : EDR = 0 : End If : conn.Close() : EDR += 1
- If EDR < 10 Then : GGHH = "A" & "0000000" & EDR
- ElseIf EDR > 9 And EDR < 100 Then : GGHH = "A" & "000000" & EDR
- ElseIf EDR > 99 And EDR < 1000 Then : GGHH = "A" & "00000" & EDR
- ElseIf EDR > 999 And EDR < 10000 Then : GGHH = "A" & "0000" & EDR
- ElseIf EDR > 9999 And EDR < 100000 Then : GGHH = "A" & "000" & EDR
- ElseIf EDR > 99999 And EDR < 100000 Then : GGHH = "A" & "00" & EDR
- ElseIf EDR > 999999 And EDR < 1000000 Then : GGHH = "A" & "0" & EDR
- ElseIf EDR > 9999999 Then : GGHH = "A" & EDR : End If
- End Sub
- Private Sub Set_新增訂單明細資料()
- PA1 = GGHH : PA2 = TextBox9.Text : PA3 = TextBox7.Text : NU1 = 申請數量 : PA4 = TextBox2.Text : PA5 = 狀態 : SQL_訂單明細表新增() : conn.Close()
- End Sub
- Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
- If TextBox7.Text = "" Then : MsgBox("料號沒有選擇") : Else
- If ComboBox3.Text = "" Then : MsgBox("客戶沒有選擇") : Else
- If ComboBox4.Text = "" Then : MsgBox("請選擇--直接出貨--還是--組裝出貨--。") : Else
- If NumericUpDown1.Value = 0 Then : MsgBox("數量不可為零") : Else
- If TextBox7.Text = "" Then
- MsgBox("請先選擇物料。") : Else
- If Val(TextBox15.Text) = 0 And NumericUpDown1.Value > 0 Then
- '------------------開訂單-----出貨單----------------------------------------------------------------------------------------------------------------------------------
- 狀態 = "C"
- 申請數量 = NumericUpDown1.Value
- Set_自動生成流水號2() : Set_新增訂單明細資料()
- Set_清單() : Set_訂單明細表()
- ElseIf Val(TextBox15.Text) >= NumericUpDown1.Value And NumericUpDown1.Value > 0 Then
- '------------------開訂單-----出貨單----------------------------------------------------------------------------------------------------------------------------------
- 狀態 = "A"
- 申請數量 = NumericUpDown1.Value
- Set_生成出貨單() : Set_自動生成流水號2() : Set_新增訂單明細資料()
- Set_清單() : Set_訂單明細表()
- ElseIf Val(TextBox15.Text) < NumericUpDown1.Value And Val(TextBox15.Text) > 0 And NumericUpDown1.Value > 0 Then
- '------------------開訂單---------------------------------------------------------------------------------------------------------------------------------------------
- 狀態 = "B"
- 申請數量 = Val(TextBox15.Text)
- Set_生成出貨單() : Dim OOPP As String = TextBox2.Text
- Set_自動生成流水號2() : Set_新增訂單明細資料()
- 申請數量 = NumericUpDown1.Value - Val(TextBox15.Text) : TextBox2.Text = ""
- Set_自動生成流水號2() : Set_新增訂單明細資料()
- TextBox2.Text = OOPP
- Set_清單() : Set_訂單明細表()
- End If
- End If
- End If
- End If
- End If
- End If
- End Sub
- '-----------------------------滑鼠右鍵------------------------------------------------------------------------------------------------------------------------------------------
- Private Sub 重新整理ToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles 重新整理ToolStripMenuItem.Click
- ComboBox1下拉表單資料載入() : ComboBox2下拉表單資料載入() : ComboBox5下拉表單資料載入() : Set_訂單控制表()
- End Sub
- Private Sub 開立新的採購單ToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles 開立新的採購單ToolStripMenuItem.Click
- If ComboBox2.Text = "" Then : MsgBox("請先選擇客戶。")
- Else
- Dim NUM1 As Integer : Set_日期格式轉換()
- For i As Integer = 1 To 999
- NUM1 = 0 + i
- If NUM1 < 10 Then : TextBox9.Text = "PO-" & DTP1 & "-00" & NUM1
- ElseIf NUM1 > 9 And NUM1 < 100 Then : TextBox9.Text = "PO-" & DTP1 & "-0" & NUM1
- ElseIf NUM1 > 99 Then : TextBox9.Text = "PO-" & DTP1 & "-" & NUM1 : End If
- SQL_訂單控制表流水號最後一筆()
- If dr.Read() Then : Else : i = 999 : conn.Close() : End If : conn.Close()
- Next
- SQL_訂單控制表新增() : conn.Close() : Set_訂單控制表() : Set_訂單明細表()
- RadioButton1.Checked = False : RadioButton2.Checked = True : DataGridView2.Visible = True : DataGridView3.Visible = False : Button1.Enabled = True
- End If
- End Sub
- End Class
|