Няма описание
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

供應商資料.vb 9.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. Option Strict Off
  2. Public Class 供應商資料
  3. ReadOnly ds As New DataSet
  4. Private Sub 讀取供應商料表()
  5. DataGridView1.DataSource = Nothing : ds.Clear()
  6. DataGridView1.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
  7. DataGridView1.ColumnHeadersHeight = 25
  8. DataGridView1.AllowUserToAddRows = False
  9. ConnOpen()
  10. SQL1 = "SELECT 流水碼, 供應商, 公司名, 公司地址, 公司電話1, 公司電話2, 公司電話3, 公司傳真1, 公司傳真2, 公司傳真3, 聯繫人1, 聯繫人2, 聯繫人3, " &
  11. "聯繫人1職稱, 聯繫人2職稱, 聯繫人3職稱, 聯繫人1電話, 聯繫人2電話, 聯繫人3電話 FROM 供應商資料表"
  12. CmdSet_For_DGV() : da.Fill(ds) : DataGridView1.DataSource = ds.Tables(0) : conn.Close()
  13. End Sub
  14. Private Sub Set_grid()
  15. DataGridView1.Columns(0).Width = 60 : DataGridView1.Columns(1).Width = 75 : DataGridView1.Columns(2).Width = 140
  16. DataGridView1.Columns(3).Width = 200 : DataGridView1.Columns(4).Width = 90 : DataGridView1.Columns(5).Width = 90
  17. DataGridView1.Columns(6).Width = 90 : DataGridView1.Columns(7).Width = 90 : DataGridView1.Columns(8).Width = 90
  18. DataGridView1.Columns(9).Width = 90
  19. DataGridView1.Columns(10).Width = 90 : DataGridView1.Columns(11).Width = 90 : DataGridView1.Columns(12).Width = 90
  20. DataGridView1.Columns(13).Visible = False : DataGridView1.Columns(14).Visible = False : DataGridView1.Columns(15).Visible = False
  21. DataGridView1.Columns(16).Visible = False : DataGridView1.Columns(17).Visible = False : DataGridView1.Columns(18).Visible = False
  22. End Sub
  23. Private Sub DataGridView1_CellClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellClick
  24. If e.RowIndex = -1 Then : Else
  25. TextBox1.Text = DataGridView1(0, e.RowIndex).Value.ToString : TextBox2.Text = DataGridView1(1, e.RowIndex).Value.ToString
  26. TextBox3.Text = DataGridView1(2, e.RowIndex).Value.ToString : TextBox4.Text = DataGridView1(3, e.RowIndex).Value.ToString
  27. TextBox5.Text = DataGridView1(4, e.RowIndex).Value.ToString : TextBox6.Text = DataGridView1(5, e.RowIndex).Value.ToString
  28. TextBox7.Text = DataGridView1(6, e.RowIndex).Value.ToString : TextBox8.Text = DataGridView1(7, e.RowIndex).Value.ToString
  29. TextBox9.Text = DataGridView1(8, e.RowIndex).Value.ToString : TextBox10.Text = DataGridView1(9, e.RowIndex).Value.ToString
  30. TextBox11.Text = DataGridView1(10, e.RowIndex).Value.ToString : TextBox12.Text = DataGridView1(11, e.RowIndex).Value.ToString
  31. TextBox13.Text = DataGridView1(12, e.RowIndex).Value.ToString : TextBox14.Text = DataGridView1(13, e.RowIndex).Value.ToString
  32. TextBox15.Text = DataGridView1(14, e.RowIndex).Value.ToString : TextBox16.Text = DataGridView1(15, e.RowIndex).Value.ToString
  33. TextBox17.Text = DataGridView1(16, e.RowIndex).Value.ToString : TextBox18.Text = DataGridView1(17, e.RowIndex).Value.ToString
  34. TextBox19.Text = DataGridView1(18, e.RowIndex).Value.ToString
  35. End If
  36. End Sub
  37. Private Sub 供應商資料_Load(sender As Object, e As EventArgs) Handles MyBase.Load
  38. Me.MdiParent = GCM_ERP_SYS
  39. Me.WindowState = 2
  40. 讀取供應商料表() : Set_grid()
  41. End Sub
  42. Private Sub 登入閒置控制_MouseMove(sender As Object, e As EventArgs) Handles MyBase.MouseMove
  43. timeNow = 0
  44. GCM_ERP_SYS.Timer1.Enabled = False
  45. GCM_ERP_SYS.Timer1.Enabled = True
  46. End Sub
  47. Private Sub 登入閒置控制_KeyPress(sender As Object, e As EventArgs) Handles MyBase.KeyPress
  48. timeNow = 0
  49. GCM_ERP_SYS.Timer1.Enabled = False
  50. GCM_ERP_SYS.Timer1.Enabled = True
  51. End Sub
  52. Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
  53. Dim a As String = InputBox("請輸入供應商名稱") : Dim b As String = InputBox("請輸入供應商公司名稱") : Dim c As String = InputBox("請輸入供應商地址")
  54. Dim d As String = InputBox("請輸入供應商公司電話1") : Dim f As String = InputBox("請輸入供應商公司電話2") : Dim g As String = InputBox("請輸入供應商公司電話3")
  55. Dim h As String = InputBox("請輸入供應商公司傳真1") : Dim i As String = InputBox("請輸入供應商公司傳真2") : Dim j As String = InputBox("請輸入供應商公司傳真3")
  56. Dim k As String = InputBox("請輸入供應商聯繫人1") : Dim n As String = InputBox("請輸入供應商聯繫人1職稱") : Dim q As String = InputBox("請輸入供應商聯繫人1電話")
  57. Dim l As String = InputBox("請輸入供應商聯繫人2") : Dim o As String = InputBox("請輸入供應商聯繫人2職稱") : Dim r As String = InputBox("請輸入供應商聯繫人2電話")
  58. Dim m As String = InputBox("請輸入供應商聯繫人3") : Dim p As String = InputBox("請輸入供應商聯繫人3職稱") : Dim s As String = InputBox("請輸入供應商聯繫人3電話")
  59. TextBox2.Text = a : TextBox3.Text = b : TextBox4.Text = c : TextBox5.Text = d : TextBox6.Text = f : TextBox7.Text = g : TextBox8.Text = h : TextBox9.Text = i
  60. TextBox10.Text = j : TextBox11.Text = k : TextBox12.Text = l : TextBox13.Text = m : TextBox14.Text = n : TextBox15.Text = o : TextBox16.Text = p
  61. TextBox17.Text = q : TextBox18.Text = r : TextBox19.Text = s
  62. If TextBox2.Text = "" Or TextBox3.Text = "" Or TextBox5.Text = "" Then
  63. MsgBox("請供應商、公司銘及公司電話1不可為空白")
  64. Else
  65. Dim NUM1 As Integer
  66. For NUM1 = 0 To 9999
  67. If NUM1 < 10 Then
  68. TextBox20.Text = "SU" & "00" & NUM1
  69. ElseIf NUM1 > 9 And NUM1 < 100 Then
  70. TextBox20.Text = "SU" & "0" & NUM1
  71. ElseIf NUM1 > 99 Then
  72. TextBox20.Text = "SU" & NUM1
  73. End If
  74. ConnOpen()
  75. SQL1 = "SELECT 流水碼 FROM 供應商資料表 WHERE (流水碼 ='" & TextBox20.Text & "')"
  76. CmdSet_For_dr()
  77. If dr.Read() Then : TextBox1.Text = dr("流水碼").ToString : Else : TextBox1.Text = "" : End If
  78. conn.Close()
  79. If TextBox1.Text = "" Then
  80. TextBox1.Text = TextBox20.Text : TextBox20.Text = "可用"
  81. NUM1 = 9999
  82. End If
  83. Next
  84. If TextBox20.Text = "可用" Then
  85. ConnOpen()
  86. SQL1 = "INSERT INTO 供應商資料表 (流水碼, 供應商, 公司名, 公司地址, 公司電話1, 公司電話2, 公司電話3, 公司傳真1, 公司傳真2, 公司傳真3, 聯繫人1, 聯繫人2, 聯繫人3, " &
  87. "聯繫人1職稱, 聯繫人2職稱, 聯繫人3職稱, 聯繫人1電話, 聯繫人2電話, 聯繫人3電話) VALUES ('" & TextBox1.Text & "','" & TextBox2.Text &
  88. "','" & TextBox3.Text & "','" & TextBox4.Text & "','" & TextBox5.Text & "','" & TextBox6.Text & "','" & TextBox7.Text & "','" & TextBox8.Text &
  89. "','" & TextBox9.Text & "','" & TextBox10.Text & "','" & TextBox11.Text & "','" & TextBox12.Text & "','" & TextBox13.Text & "','" & TextBox14.Text &
  90. "','" & TextBox15.Text & "','" & TextBox16.Text & "','" & TextBox17.Text & "','" & TextBox18.Text & "','" & TextBox19.Text & "')"
  91. cmd.Connection = conn : cmd.CommandText = SQL1 : cmd.ExecuteNonQuery()
  92. MsgBox("新增完成")
  93. conn.Close()
  94. End If
  95. End If
  96. TextBox20.Text = ""
  97. 讀取供應商料表() : Set_grid()
  98. End Sub
  99. Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
  100. ConnOpen()
  101. SQL1 = "UPDATE 供應商資料表 SET 供應商 = '" & TextBox2.Text & "', 公司名 = '" & TextBox3.Text & "', 公司地址 = '" & TextBox4.Text &
  102. "', 公司電話1 = '" & TextBox5.Text & "', 公司電話2 = '" & TextBox6.Text & "', 公司電話3 = '" & TextBox7.Text & "', 公司傳真1 = '" & TextBox8.Text &
  103. "', 公司傳真2 = '" & TextBox9.Text & "', 公司傳真3 = '" & TextBox10.Text & "', 聯繫人1 = '" & TextBox11.Text & "', 聯繫人2 = '" & TextBox12.Text &
  104. "', 聯繫人3 = '" & TextBox13.Text & "', 聯繫人1職稱 = '" & TextBox14.Text & "', 聯繫人2職稱 = '" & TextBox15.Text & "', 聯繫人3職稱 = '" & TextBox16.Text &
  105. "', 聯繫人1電話 = '" & TextBox17.Text & "', 聯繫人2電話 = '" & TextBox18.Text & "', 聯繫人3電話 = '" & TextBox19.Text &
  106. "' WHERE (流水碼 = '" & TextBox1.Text & "')"
  107. cmd.CommandText = SQL1 : cmd.ExecuteNonQuery()
  108. MsgBox("修改完成")
  109. conn.Close()
  110. 讀取供應商料表() : Set_grid()
  111. End Sub
  112. Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
  113. SQL1 = "DELETE FROM 供應商資料表 WHERE (流水碼 = '" & TextBox1.Text & "')"
  114. cmd.CommandText = SQL1 : cmd.Connection = conn
  115. ConnOpen()
  116. Dim aa As MsgBoxResult
  117. aa = MsgBox("確定要刪除該筆資料?", MsgBoxStyle.OkCancel)
  118. If aa = MsgBoxResult.Ok Then : cmd.ExecuteNonQuery() : MsgBox("刪除完成") : End If
  119. conn.Close()
  120. 讀取供應商料表() : Set_grid()
  121. End Sub
  122. End Class