説明なし
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

供應商資料管理.vb 13KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. Option Strict Off
  2. Public Class 供應商資料管理
  3. ReadOnly ds As New DataSet
  4. Dim EDR As Integer = 0 : Dim ESTR As String
  5. Private Sub Set_供應商清單()
  6. DataGridView1.DataSource = Nothing : ds.Clear() : DataGridView1.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
  7. DataGridView1.ColumnHeadersHeight = 50 : DataGridView1.AllowUserToAddRows = False : DataGridView1.ClipboardCopyMode = DataGridViewClipboardCopyMode.EnableWithoutHeaderText
  8. DataGridView1.MultiSelect = True
  9. SQL__供應商資料管理清單()
  10. cmd.Connection = conn : cmd.CommandText = SQL1 : da.SelectCommand = cmd : da.Fill(ds) : DataGridView1.DataSource = ds.Tables(0) : conn.Close()
  11. DataGridView1.Columns(0).Visible = False : DataGridView1.Columns(1).FillWeight = 8 : DataGridView1.Columns(2).FillWeight = 3.5 : DataGridView1.Columns(3).Visible = False
  12. DataGridView1.Columns(4).Visible = False : DataGridView1.Columns(5).FillWeight = 6 : DataGridView1.Columns(6).FillWeight = 6 : DataGridView1.Columns(7).FillWeight = 6
  13. DataGridView1.Columns(8).FillWeight = 6 : DataGridView1.Columns(9).FillWeight = 16 : DataGridView1.Columns(10).FillWeight = 2 : DataGridView1.Columns(11).FillWeight = 16
  14. DataGridView1.Columns(12).FillWeight = 2 : DataGridView1.Columns(13).Visible = False : DataGridView1.Columns(14).Visible = False : DataGridView1.Columns(15).Visible = False
  15. DataGridView1.Columns(16).Visible = False : DataGridView1.Columns(17).Visible = False : DataGridView1.Columns(18).Visible = False : DataGridView1.Columns(19).Visible = False
  16. DataGridView1.Columns(20).Visible = False : DataGridView1.Columns(21).Visible = False : DataGridView1.Columns(22).Visible = False : DataGridView1.Columns(23).Visible = False
  17. DataGridView1.Columns(24).Visible = False : DataGridView1.Columns(25).FillWeight = 3.5 : DataGridView1.Columns(26).FillWeight = 7.5 : DataGridView1.Columns(27).FillWeight = 1.5
  18. DataGridView1.Columns(28).FillWeight = 1.5 : DataGridView1.Columns(29).FillWeight = 1.5 : DataGridView1.Columns(30).FillWeight = 1.5 : DataGridView1.Columns(31).FillWeight = 1.5
  19. DataGridView1.Columns(32).Visible = False : DataGridView1.Columns(33).FillWeight = 1.5 : DataGridView1.Columns(34).FillWeight = 1.5
  20. DataGridView1.Columns(29).DefaultCellStyle.Format = "#,##0" : DataGridView1.Columns(30).DefaultCellStyle.Format = "#,##0"
  21. DataGridView1.Columns(29).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight : DataGridView1.Columns(29).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleRight
  22. DataGridView1.Columns(30).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight : DataGridView1.Columns(30).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleRight
  23. DataGridView1.Columns(1).ReadOnly = True : DataGridView1.Columns(2).ReadOnly = True : DataGridView1.Columns(3).ReadOnly = True : DataGridView1.Columns(4).ReadOnly = True
  24. DataGridView1.Columns(5).ReadOnly = True : DataGridView1.Columns(6).ReadOnly = True : DataGridView1.Columns(7).ReadOnly = True : DataGridView1.Columns(8).ReadOnly = True
  25. DataGridView1.Columns(9).ReadOnly = True : DataGridView1.Columns(10).ReadOnly = True : DataGridView1.Columns(11).ReadOnly = True : DataGridView1.Columns(12).ReadOnly = True
  26. DataGridView1.Columns(13).ReadOnly = True : DataGridView1.Columns(14).ReadOnly = True : DataGridView1.Columns(15).ReadOnly = True : DataGridView1.Columns(16).ReadOnly = True
  27. DataGridView1.Columns(17).ReadOnly = True : DataGridView1.Columns(18).ReadOnly = True : DataGridView1.Columns(19).ReadOnly = True : DataGridView1.Columns(20).ReadOnly = True
  28. DataGridView1.Columns(21).ReadOnly = True : DataGridView1.Columns(22).ReadOnly = True : DataGridView1.Columns(23).ReadOnly = True : DataGridView1.Columns(24).ReadOnly = True
  29. DataGridView1.Columns(25).ReadOnly = True : DataGridView1.Columns(26).ReadOnly = True : DataGridView1.Columns(27).ReadOnly = True : DataGridView1.Columns(28).ReadOnly = True
  30. DataGridView1.Columns(29).ReadOnly = True : DataGridView1.Columns(30).ReadOnly = True : DataGridView1.Columns(31).ReadOnly = True : DataGridView1.Columns(32).ReadOnly = True
  31. DataGridView1.Columns(33).ReadOnly = True : DataGridView1.Columns(34).ReadOnly = True
  32. End Sub
  33. Private Sub ComboBox1下拉表單資料載入()
  34. PA = "%%" : SQL_付款方式查詢()
  35. ComboBox1.Items.Clear() : While (dr.Read()) : ComboBox1.Items.Add(dr("付款方式")) : End While : conn.Close()
  36. End Sub
  37. Private Sub 供應商資料管理_Load(sender As Object, e As EventArgs) Handles MyBase.Load
  38. Me.MdiParent = MAOJI_ERP_SYS : Me.WindowState = 2 : Me.AutoScroll = True
  39. TextBox1.Enabled = False : TextBox27.Visible = False
  40. ComboBox1下拉表單資料載入() : Set_供應商清單()
  41. If gUserName = "李協叡" Then : 資料刪除ToolStripMenuItem.Enabled = True : Else : 資料刪除ToolStripMenuItem.Enabled = False : End If
  42. End Sub
  43. Private Sub DataGridView1_CellClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellClick
  44. If e.RowIndex = -1 Then : Else
  45. TextBox1.Text = DataGridView1.Rows(e.RowIndex).Cells("編號").Value.ToString : TextBox2.Text = DataGridView1.Rows(e.RowIndex).Cells("名稱").Value.ToString
  46. TextBox3.Text = DataGridView1.Rows(e.RowIndex).Cells("簡稱").Value.ToString : TextBox4.Text = DataGridView1.Rows(e.RowIndex).Cells("負責人").Value.ToString
  47. TextBox5.Text = DataGridView1.Rows(e.RowIndex).Cells("負責人電話").Value.ToString : TextBox6.Text = DataGridView1.Rows(e.RowIndex).Cells("公司電話1").Value.ToString
  48. TextBox7.Text = DataGridView1.Rows(e.RowIndex).Cells("公司電話2").Value.ToString : TextBox8.Text = DataGridView1.Rows(e.RowIndex).Cells("傳真1").Value.ToString
  49. TextBox9.Text = DataGridView1.Rows(e.RowIndex).Cells("傳真2").Value.ToString : TextBox10.Text = DataGridView1.Rows(e.RowIndex).Cells("地址1").Value.ToString
  50. TextBox11.Text = DataGridView1.Rows(e.RowIndex).Cells("郵遞區號1").Value.ToString : TextBox12.Text = DataGridView1.Rows(e.RowIndex).Cells("地址2").Value.ToString
  51. TextBox13.Text = DataGridView1.Rows(e.RowIndex).Cells("郵遞區號2").Value.ToString : TextBox14.Text = DataGridView1.Rows(e.RowIndex).Cells("聯絡人1").Value.ToString
  52. TextBox15.Text = DataGridView1.Rows(e.RowIndex).Cells("聯絡人電話1").Value.ToString : TextBox16.Text = DataGridView1.Rows(e.RowIndex).Cells("聯絡人1MAIL").Value.ToString
  53. TextBox17.Text = DataGridView1.Rows(e.RowIndex).Cells("聯1LINE_唯信").Value.ToString : TextBox18.Text = DataGridView1.Rows(e.RowIndex).Cells("聯絡人2").Value.ToString
  54. TextBox19.Text = DataGridView1.Rows(e.RowIndex).Cells("聯絡人電話2").Value.ToString : TextBox20.Text = DataGridView1.Rows(e.RowIndex).Cells("聯絡人2MAIL").Value.ToString
  55. TextBox21.Text = DataGridView1.Rows(e.RowIndex).Cells("聯2LINE_唯信").Value.ToString : TextBox22.Text = DataGridView1.Rows(e.RowIndex).Cells("聯絡人3").Value.ToString
  56. TextBox23.Text = DataGridView1.Rows(e.RowIndex).Cells("聯絡人手機3").Value.ToString : TextBox24.Text = DataGridView1.Rows(e.RowIndex).Cells("聯絡人3MAIL").Value.ToString
  57. TextBox25.Text = DataGridView1.Rows(e.RowIndex).Cells("聯3LINE_唯信").Value.ToString : TextBox26.Text = DataGridView1.Rows(e.RowIndex).Cells("統一編號").Value.ToString
  58. ComboBox1.Text = DataGridView1.Rows(e.RowIndex).Cells("付款方式").Value.ToString : NumericUpDown1.Value = DataGridView1.Rows(e.RowIndex).Cells("請款日").Value.ToString
  59. NumericUpDown2.Value = DataGridView1.Rows(e.RowIndex).Cells("票據日").Value.ToString : NumericUpDown3.Value = DataGridView1.Rows(e.RowIndex).Cells("折扣").Value.ToString
  60. NumericUpDown4.Value = DataGridView1.Rows(e.RowIndex).Cells("稅率").Value.ToString : ComboBox2.Text = DataGridView1.Rows(e.RowIndex).Cells("幣別").Value.ToString
  61. TextBox28.Text = DataGridView1.Rows(e.RowIndex).Cells("備註").Value.ToString : CheckBox1.Checked = DataGridView1.Rows(e.RowIndex).Cells("外貿").Value
  62. CheckBox2.Checked = DataGridView1.Rows(e.RowIndex).Cells("停用").Value
  63. End If
  64. End Sub
  65. Private Sub ComboBox1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox1.SelectedIndexChanged
  66. PA1 = ComboBox1.Text : SQL_付款方式_編號()
  67. If dr.Read() Then : TextBox27.Text = dr("編號") : End If : conn.Close()
  68. End Sub
  69. Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
  70. PA = InputBox("請輸入要查詢的關鍵字")
  71. Set_供應商清單()
  72. End Sub
  73. Private Sub Button6_Click(sender As Object, e As EventArgs) Handles Button6.Click
  74. DataGridView1.Enabled = False
  75. TextBox2.Text = "" : TextBox3.Text = "" : TextBox4.Text = "" : TextBox5.Text = "" : TextBox6.Text = "" : TextBox7.Text = "" : TextBox8.Text = "" : TextBox9.Text = ""
  76. TextBox10.Text = "" : TextBox11.Text = "" : TextBox12.Text = "" : TextBox13.Text = "" : TextBox14.Text = "" : TextBox15.Text = "" : TextBox16.Text = "" : TextBox17.Text = ""
  77. TextBox18.Text = "" : TextBox19.Text = "" : TextBox20.Text = "" : TextBox21.Text = "" : TextBox22.Text = "" : TextBox23.Text = "" : TextBox24.Text = "" : TextBox25.Text = ""
  78. TextBox26.Text = "" : NumericUpDown1.Value = 0 : NumericUpDown2.Value = 0 : NumericUpDown3.Value = 0 : NumericUpDown4.Value = 0 : ComboBox2.Text = "NTD" : TextBox28.Text = ""
  79. TextBox27.Text = "" : CheckBox1.Checked = False : CheckBox2.Checked = False : ComboBox1下拉表單資料載入()
  80. '----------------------自动生成流水号-------------------------------------------------------------------------
  81. SQL_供應商資料表流水號最後一筆()
  82. If dr.Read() Then : EDR = Double.Parse(Strings.Right(dr("編號").ToString, 8)) : Else : EDR = 0 : End If : conn.Close() : EDR += 1
  83. If EDR < 10 Then : ESTR = "FI" & "0000000" & EDR
  84. ElseIf EDR > 9 And EDR < 100 Then : ESTR = "FI" & "000000" & EDR
  85. ElseIf EDR > 99 And EDR < 1000 Then : ESTR = "FI" & "00000" & EDR
  86. ElseIf EDR > 999 And EDR < 10000 Then : ESTR = "FI" & "0000" & EDR
  87. ElseIf EDR > 9999 And EDR < 100000 Then : ESTR = "FI" & "000" & EDR
  88. ElseIf EDR > 99999 And EDR < 100000 Then : ESTR = "FI" & "00" & EDR
  89. ElseIf EDR > 999999 And EDR < 1000000 Then : ESTR = "FI" & "0" & EDR
  90. ElseIf EDR > 9999999 Then : ESTR = "FI" & EDR : End If : TextBox1.Text = ESTR
  91. End Sub
  92. Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
  93. If DataGridView1.Enabled = False Then
  94. If ComboBox1.Text = "" Then : MsgBox("沒有選擇付款方式 。")
  95. Else
  96. SQL_供應商資料表新增() : conn.Close()
  97. MsgBox("資料新增完畢 。") : Set_供應商清單() : PA = "" : DataGridView1.Enabled = True
  98. End If
  99. Else
  100. SQL_供應商資料表修改() : conn.Close()
  101. MsgBox("資料存檔完畢 。") : Set_供應商清單() : PA = "" : DataGridView1.Enabled = True
  102. End If
  103. End Sub
  104. '-----------------------------滑鼠右鍵------------------------------------------------------------------------------------------------------------------------------------------
  105. Private Sub 重新整理ToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles 重新整理ToolStripMenuItem.Click
  106. PA = "" : Set_供應商清單()
  107. End Sub
  108. Private Sub 關鍵字查詢ToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles 關鍵字查詢ToolStripMenuItem.Click
  109. Me.Button3.PerformClick()
  110. End Sub
  111. Private Sub 新增供應商資料ToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles 新增供應商資料ToolStripMenuItem.Click
  112. Me.Button6.PerformClick()
  113. End Sub
  114. Private Sub 資料存檔ToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles 資料存檔ToolStripMenuItem.Click
  115. Me.Button4.PerformClick()
  116. End Sub
  117. Private Sub 資料刪除ToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles 資料刪除ToolStripMenuItem.Click
  118. Dim aa As MsgBoxResult = MsgBox("確定要刪除該筆資料?", MsgBoxStyle.OkCancel)
  119. If aa = MsgBoxResult.Ok Then
  120. SQL_供應商資料表刪除() : conn.Close() : MsgBox("刪除完成") : Set_供應商清單() : PA = ""
  121. End If
  122. End Sub
  123. End Class