No Description
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 24KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322
  1. Option Strict Off
  2. Imports System.Data.SqlClient
  3. Imports System.IO
  4. Public Class 樣品報價控制表
  5. Dim conn As New SqlConnection
  6. Dim da As New SqlDataAdapter
  7. Dim cmd As New SqlCommand
  8. Dim ds As New DataSet : Dim ds1 As New DataSet : Dim ds2 As New DataSet : Dim ds4 As New DataSet : Dim ds5 As New DataSet : Dim ds6 As New DataSet
  9. Dim dr As SqlDataReader
  10. Dim 條件變更 As String
  11. Private Sub Set_DGV1載入前設定()
  12. DataGridView1.DataSource = Nothing : ds.Clear()
  13. DataGridView1.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
  14. DataGridView1.ColumnHeadersHeight = 25
  15. DataGridView1.AllowUserToAddRows = False
  16. DataGridView1.RowTemplate.Height = 24
  17. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  18. End Sub
  19. Private Sub Set_DGV1載入後設定()
  20. cmd.Connection = conn : cmd.CommandText = SQL1 : da.SelectCommand = cmd : da.Fill(ds) : DataGridView1.DataSource = ds.Tables(0) : conn.Close() : Set_grid()
  21. End Sub
  22. Private Sub Set_清單()
  23. Set_DGV1載入前設定()
  24. SQL1 = "SELECT 樣品訂單控制表.季節, 樣品訂單控制表.客戶, 樣品訂單控制表.工廠, 樣品訂單清單.SO, 樣品訂單清單.版次,
  25. 樣品訂單清單.項次, 樣品訂單控制表.型體號碼, 樣品訂單控制表.型體名稱, 樣品訂單清單.顏色, 樣品訂單清單.數量,
  26. 樣品訂單清單.已報價 AS 已建立報價, 樣品訂單清單.流水號
  27. FROM 樣品訂單清單 LEFT OUTER JOIN
  28. 樣品訂單控制表 ON 樣品訂單清單.SO = 樣品訂單控制表.SO AND 樣品訂單清單.版次 = 樣品訂單控制表.版次
  29. " & 條件變更 & "
  30. ORDER BY 樣品訂單清單.SO, 樣品訂單清單.版次, 樣品訂單清單.項次"
  31. Set_DGV1載入後設定()
  32. End Sub
  33. Private Sub Set_grid()
  34. DataGridView1.Columns(0).Width = 55 : DataGridView1.Columns(1).Width = 170 : DataGridView1.Columns(2).Width = 70 : DataGridView1.Columns(3).Width = 55 : DataGridView1.Columns(4).Width = 40
  35. DataGridView1.Columns(5).Width = 40 : DataGridView1.Columns(6).Width = 90 : DataGridView1.Columns(7).Width = 100 : DataGridView1.Columns(8).Width = 120 : DataGridView1.Columns(9).Width = 70
  36. DataGridView1.Columns(10).Width = 60 : DataGridView1.Columns(11).Visible = False
  37. End Sub
  38. Private Sub Set_DGV2載入前設定()
  39. DataGridView2.DataSource = Nothing : ds1.Clear()
  40. DataGridView2.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
  41. DataGridView2.ColumnHeadersHeight = 25
  42. DataGridView2.AllowUserToAddRows = False
  43. DataGridView2.RowTemplate.Height = 50
  44. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  45. End Sub
  46. Private Sub Set_DGV2載入後設定()
  47. cmd.Connection = conn : cmd.CommandText = SQL1 : da.SelectCommand = cmd : da.Fill(ds1) : DataGridView2.DataSource = ds1.Tables(0) : conn.Close() : Set_grid1()
  48. End Sub
  49. Private Sub Set_清單1()
  50. Set_DGV2載入前設定()
  51. If PA = "" Then
  52. SQL1 = "SELECT SEASON, CUST, FCTY, STYLE, STYLENAME, COLOR, SO, 版次, 項次, MATERIALS, MATERIAL_CLASS,
  53. OUTSOLE, INSOLE, FC, REMARK
  54. FROM 樣品單價控制表 ORDER BY SO DESC, 版次, 項次"
  55. Else
  56. SQL1 = "SELECT SEASON, CUST, FCTY, STYLE, STYLENAME, COLOR, SO, 版次, 項次, MATERIALS, MATERIAL_CLASS,
  57. OUTSOLE, INSOLE, FC, REMARK
  58. FROM 樣品單價控制表
  59. WHERE SEASON LIKE N'%" & PA & "%' OR CUST LIKE N'%" & PA & "%' OR FCTY LIKE N'%" & PA & "%' OR STYLE LIKE N'%" & PA & "%' OR STYLENAME LIKE N'%" & PA & "%' OR
  60. COLOR LIKE N'%" & PA & "%' OR SO LIKE N'%" & PA & "%' OR 版次 LIKE N'%" & PA & "%' OR 項次 LIKE N'%" & PA & "%' OR MATERIALS LIKE N'%" & PA & "%' OR
  61. MATERIAL_CLASS LIKE N'%" & PA & "%' OR OUTSOLE LIKE N'%" & PA & "%' OR INSOLE LIKE N'%" & PA & "%' OR REMARK LIKE N'%" & PA & "%' ORDER BY SO DESC, 版次, 項次"
  62. End If
  63. 列印用SQL = SQL1
  64. Set_DGV2載入後設定()
  65. End Sub
  66. Private Sub Set_grid1()
  67. DataGridView2.Columns(0).Width = 60 : DataGridView2.Columns(1).Width = 150 : DataGridView2.Columns(2).Width = 70 : DataGridView2.Columns(3).Width = 90 : DataGridView2.Columns(4).Width = 100
  68. DataGridView2.Columns(5).Width = 120 : DataGridView2.Columns(6).Width = 60 : DataGridView2.Columns(7).Width = 40 : DataGridView2.Columns(8).Width = 40 : DataGridView2.Columns(9).Width = 343
  69. DataGridView2.Columns(10).Width = 150 : DataGridView2.Columns(11).Width = 342 : DataGridView2.Columns(12).Width = 100 : DataGridView2.Columns(13).Width = 50 : DataGridView2.Columns(14).Width = 150
  70. DataGridView2.Columns(13).DefaultCellStyle.Format = "#,##0.00"
  71. DataGridView2.Columns(13).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight
  72. DataGridView2.Columns(13).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleRight
  73. DataGridView2.Columns(9).DefaultCellStyle.BackColor = Color.MistyRose : DataGridView2.Columns(10).DefaultCellStyle.BackColor = Color.MistyRose
  74. DataGridView2.Columns(11).DefaultCellStyle.BackColor = Color.MistyRose : DataGridView2.Columns(12).DefaultCellStyle.BackColor = Color.MistyRose
  75. DataGridView2.Columns(13).DefaultCellStyle.BackColor = Color.MistyRose : DataGridView2.Columns(14).DefaultCellStyle.BackColor = Color.MistyRose
  76. DataGridView2.EditMode = DataGridViewEditMode.EditOnEnter
  77. End Sub
  78. Private Sub Set_DGV3載入前設定()
  79. DataGridView3.DataSource = Nothing : ds2.Clear()
  80. DataGridView3.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
  81. DataGridView3.ColumnHeadersHeight = 25
  82. DataGridView3.AllowUserToAddRows = False
  83. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  84. End Sub
  85. Private Sub Set_DGV3載入後設定()
  86. cmd.Connection = conn : cmd.CommandText = SQL1 : da.SelectCommand = cmd : da.Fill(ds2) : DataGridView3.DataSource = ds2.Tables(0) : conn.Close() : Set_grid2()
  87. End Sub
  88. Private Sub Set_清單2()
  89. Set_DGV3載入前設定()
  90. SQL1 = "SELECT METOO選擇按鈕.選擇, 樣品訂單清單.項次, 樣品訂單部件表.部件, 樣品訂單部件表.材料名稱,
  91. 樣品訂單部件表.材料說明 AS 顏色, 樣品訂單部件表.廠商, 樣品訂單部件表.備註, 樣品訂單部件表.版次,
  92. 樣品訂單部件表.流水號, 樣品訂單部件表.項次 AS 排列
  93. FROM 樣品訂單部件表 INNER JOIN
  94. 樣品訂單清單 ON 樣品訂單部件表.流水號 = 樣品訂單清單.流水號 LEFT OUTER JOIN
  95. METOO選擇按鈕 ON 樣品訂單部件表.SO = METOO選擇按鈕.對應 " &
  96. "WHERE (樣品訂單部件表.SO LIKE N'" & TextBox1.Text & "') AND (樣品訂單部件表.版次 LIKE N'" & TextBox3.Text & "') AND (樣品訂單清單.項次 LIKE N'" & TextBox4.Text & "') " &
  97. "AND (LEFT(樣品訂單部件表.部件,1) LIKE N'A' OR LEFT(樣品訂單部件表.部件,1) LIKE N'E') " &
  98. "ORDER BY 樣品訂單部件表.流水號, 樣品訂單部件表.項次, 樣品訂單部件表.部件"
  99. Set_DGV3載入後設定()
  100. End Sub
  101. Private Sub Set_grid2()
  102. DataGridView3.Columns(0).Width = 40 : DataGridView3.Columns(1).Width = 40 : DataGridView3.Columns(2).Width = 200 : DataGridView3.Columns(3).Width = 260 : DataGridView3.Columns(4).Width = 171
  103. DataGridView3.Columns(5).Visible = False : DataGridView3.Columns(6).Visible = False : DataGridView3.Columns(7).Visible = False : DataGridView3.Columns(8).Visible = False
  104. DataGridView3.Columns(9).Visible = False
  105. End Sub
  106. Private Sub 樣品報價控制表_Load(sender As Object, e As EventArgs) Handles MyBase.Load
  107. Me.MdiParent = WINPROFIT_ERP_SYS : Me.WindowState = 2 : Me.AutoScroll = True
  108. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  109. SQL1 = "UPDATE 樣品訂單清單 SET 已報價 = N'0' WHERE (已報價 IS NULL)"
  110. cmd.Connection = conn : cmd.CommandText = SQL1 : da.SelectCommand = cmd : cmd.ExecuteNonQuery() : conn.Close()
  111. CheckBox1.Checked = True : CheckBox2.Checked = False : TextBox9.Visible = False
  112. DataGridView3.Visible = False
  113. 條件變更 = " WHERE (樣品訂單清單.已報價 LIKE N'0')"
  114. Set_清單() : Set_清單1()
  115. End Sub
  116. Private Sub DataGridView1_RowPostPaint(ByVal sender As Object, ByVal e As DataGridViewRowPostPaintEventArgs) Handles DataGridView1.RowPostPaint
  117. Dim linePen As New Pen(Color.Blue, 2)
  118. If e.RowIndex = DataGridView1.Rows.Count - 1 Then
  119. Exit Sub
  120. Else
  121. If DataGridView1(3, e.RowIndex).Value.ToString <> DataGridView1(3, e.RowIndex + 1).Value.ToString Then
  122. Dim startX As Integer = IIf(DataGridView1.RowHeadersVisible, DataGridView1.RowHeadersWidth, 0)
  123. Dim startY As Integer = e.RowBounds.Top + e.RowBounds.Height - 1
  124. Dim endX As Integer = startX + DataGridView1.Columns.GetColumnsWidth(DataGridViewElementStates.Visible) - DataGridView1.HorizontalScrollingOffset
  125. e.Graphics.DrawLine(linePen, startX, startY, endX, startY)
  126. Exit Sub
  127. End If
  128. End If
  129. End Sub
  130. Private Sub DataGridView2_RowPostPaint(ByVal sender As Object, ByVal e As DataGridViewRowPostPaintEventArgs) Handles DataGridView2.RowPostPaint
  131. Dim linePen As New Pen(Color.Blue, 2)
  132. If e.RowIndex = DataGridView2.Rows.Count - 1 Then
  133. Exit Sub
  134. Else
  135. If DataGridView2(6, e.RowIndex).Value.ToString <> DataGridView2(6, e.RowIndex + 1).Value.ToString Then
  136. Dim startX As Integer = IIf(DataGridView2.RowHeadersVisible, DataGridView2.RowHeadersWidth, 0)
  137. Dim startY As Integer = e.RowBounds.Top + e.RowBounds.Height - 1
  138. Dim endX As Integer = startX + DataGridView2.Columns.GetColumnsWidth(DataGridViewElementStates.Visible) - DataGridView2.HorizontalScrollingOffset
  139. e.Graphics.DrawLine(linePen, startX, startY, endX, startY)
  140. Exit Sub
  141. End If
  142. End If
  143. End Sub
  144. Private Sub DataGridView1_CellClick(ByVal sender As System.Object, ByVal e As DataGridViewCellEventArgs) Handles DataGridView1.CellClick
  145. If e.RowIndex = -1 Then : Else
  146. TextBox1.Text = DataGridView1.Rows(e.RowIndex).Cells("SO").Value : TextBox3.Text = DataGridView1.Rows(e.RowIndex).Cells("版次").Value
  147. TextBox4.Text = DataGridView1.Rows(e.RowIndex).Cells("項次").Value : TextBox2.Text = DataGridView1.Rows(e.RowIndex).Cells("季節").Value
  148. TextBox5.Text = DataGridView1.Rows(e.RowIndex).Cells("工廠").Value : TextBox6.Text = DataGridView1.Rows(e.RowIndex).Cells("型體號碼").Value
  149. TextBox7.Text = DataGridView1.Rows(e.RowIndex).Cells("型體名稱").Value : TextBox8.Text = DataGridView1.Rows(e.RowIndex).Cells("顏色").Value
  150. TextBox9.Text = DataGridView1.Rows(e.RowIndex).Cells("數量").Value : TextBox16.Text = DataGridView1.Rows(e.RowIndex).Cells("客戶").Value
  151. PictureBox1.Image = Nothing : conn.Close()
  152. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  153. SQL1 = "SELECT TOP(1) 圖片 FROM 鞋型圖片資料庫 " &
  154. "WHERE 客戶 LIKE N'" & DataGridView1.Rows(e.RowIndex).Cells("客戶").Value & "' AND 形體號 LIKE N'" & DataGridView1.Rows(e.RowIndex).Cells("型體號碼").Value &
  155. "' AND 形體名 LIKE N'" & DataGridView1.Rows(e.RowIndex).Cells("型體名稱").Value & "' AND 類別 LIKE N'設計圖'"
  156. cmd.Connection = conn : cmd.CommandText = SQL1 : dr = cmd.ExecuteReader
  157. If dr.Read() Then
  158. PictureBox1.Image = Nothing : conn.Close()
  159. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  160. SQL1 = "SELECT TOP(1) 圖片 FROM 鞋型圖片資料庫 " &
  161. "WHERE 客戶 LIKE N'" & DataGridView1.Rows(e.RowIndex).Cells("客戶").Value & "' AND 形體號 LIKE N'" & DataGridView1.Rows(e.RowIndex).Cells("型體號碼").Value &
  162. "' AND 形體名 LIKE N'" & DataGridView1.Rows(e.RowIndex).Cells("型體名稱").Value & "' AND 類別 LIKE N'設計圖'"
  163. cmd.Connection = conn : cmd.CommandText = SQL1 : dr = cmd.ExecuteReader
  164. While dr.Read() = True
  165. Dim bytes As Byte() = New Byte(-1) {} : bytes = DirectCast(dr.Item("圖片"), Byte()) : Dim oStream As New MemoryStream(bytes) : PictureBox1.Image = Bitmap.FromStream(oStream)
  166. End While
  167. conn.Close()
  168. Else
  169. conn.Close()
  170. End If : PictureBox1.SizeMode = 4
  171. Set_清單2()
  172. Dim II As Integer = 0
  173. TextBox10.Text = ""
  174. For i As Integer = 0 To DataGridView3.Rows.Count - 1
  175. If Strings.Left(DataGridView3.Rows(i).Cells("部件").Value, 1) = "A" Then
  176. TextBox10.Text = TextBox10.Text & II + 1 & ". " & DataGridView3.Rows(i).Cells("材料名稱").Value & " " : II += 1
  177. End If
  178. Next
  179. II = 0
  180. TextBox12.Text = ""
  181. For i As Integer = 0 To DataGridView3.Rows.Count - 1
  182. If Strings.Left(DataGridView3.Rows(i).Cells("部件").Value, 1) = "E" Then
  183. TextBox12.Text = TextBox12.Text & II + 1 & ". " & DataGridView3.Rows(i).Cells("材料名稱").Value & " " : II += 1
  184. End If
  185. Next
  186. End If
  187. End Sub
  188. Private Sub DataGridView2_CellClick(ByVal sender As System.Object, ByVal e As DataGridViewCellEventArgs) Handles DataGridView2.CellClick
  189. If e.RowIndex = -1 Then : Else
  190. TextBox1.Text = DataGridView2.Rows(e.RowIndex).Cells("SO").Value : TextBox3.Text = DataGridView2.Rows(e.RowIndex).Cells("版次").Value
  191. TextBox4.Text = DataGridView2.Rows(e.RowIndex).Cells("項次").Value : TextBox2.Text = DataGridView2.Rows(e.RowIndex).Cells("SEASON").Value
  192. TextBox5.Text = DataGridView2.Rows(e.RowIndex).Cells("FCTY").Value : TextBox6.Text = DataGridView2.Rows(e.RowIndex).Cells("STYLE").Value
  193. TextBox7.Text = DataGridView2.Rows(e.RowIndex).Cells("STYLENAME").Value : TextBox8.Text = DataGridView2.Rows(e.RowIndex).Cells("COLOR").Value
  194. TextBox16.Text = DataGridView2.Rows(e.RowIndex).Cells("CUST").Value : TextBox10.Text = DataGridView2.Rows(e.RowIndex).Cells("MATERIALS").Value
  195. TextBox11.Text = DataGridView2.Rows(e.RowIndex).Cells("MATERIAL_CLASS").Value : TextBox12.Text = DataGridView2.Rows(e.RowIndex).Cells("OUTSOLE").Value
  196. TextBox13.Text = DataGridView2.Rows(e.RowIndex).Cells("INSOLE").Value : TextBox14.Text = DataGridView2.Rows(e.RowIndex).Cells("FC").Value
  197. TextBox15.Text = DataGridView2.Rows(e.RowIndex).Cells("REMARK").Value
  198. PictureBox1.Image = Nothing : conn.Close()
  199. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  200. SQL1 = "SELECT TOP(1) 圖片 FROM 鞋型圖片資料庫 " &
  201. "WHERE 客戶 LIKE N'" & DataGridView2.Rows(e.RowIndex).Cells("CUST").Value & "' AND 形體號 LIKE N'" & DataGridView2.Rows(e.RowIndex).Cells("STYLE").Value &
  202. "' AND 形體名 LIKE N'" & DataGridView2.Rows(e.RowIndex).Cells("STYLENAME").Value & "' AND 類別 LIKE N'設計圖'"
  203. cmd.Connection = conn : cmd.CommandText = SQL1 : dr = cmd.ExecuteReader
  204. If dr.Read() Then
  205. PictureBox1.Image = Nothing : conn.Close()
  206. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  207. SQL1 = "SELECT TOP(1) 圖片 FROM 鞋型圖片資料庫 " &
  208. "WHERE 客戶 LIKE N'" & DataGridView2.Rows(e.RowIndex).Cells("CUST").Value & "' AND 形體號 LIKE N'" & DataGridView2.Rows(e.RowIndex).Cells("STYLE").Value &
  209. "' AND 形體名 LIKE N'" & DataGridView2.Rows(e.RowIndex).Cells("STYLENAME").Value & "' AND 類別 LIKE N'設計圖'"
  210. cmd.Connection = conn : cmd.CommandText = SQL1 : dr = cmd.ExecuteReader
  211. While dr.Read() = True
  212. Dim bytes As Byte() = New Byte(-1) {} : bytes = DirectCast(dr.Item("圖片"), Byte()) : Dim oStream As New MemoryStream(bytes) : PictureBox1.Image = Bitmap.FromStream(oStream)
  213. End While
  214. conn.Close()
  215. Else
  216. conn.Close()
  217. End If : PictureBox1.SizeMode = 4
  218. TextBox14.Text = Format(Val(TextBox14.Text), "#,##0.00")
  219. End If
  220. End Sub
  221. Private Sub CheckBox1_CheckedChanged(sender As Object, e As EventArgs) Handles CheckBox1.Click
  222. CheckBox1.Checked = True : CheckBox2.Checked = False
  223. 條件變更 = " WHERE (樣品訂單清單.已報價 LIKE N'0')"
  224. DataGridView3.DataSource = Nothing : ds2.Clear()
  225. Button9.Enabled = True
  226. Set_清單()
  227. End Sub
  228. Private Sub CheckBox2_CheckedChanged(sender As Object, e As EventArgs) Handles CheckBox2.Click
  229. CheckBox1.Checked = False : CheckBox2.Checked = True
  230. 條件變更 = " WHERE (樣品訂單清單.已報價 LIKE N'1')"
  231. DataGridView3.DataSource = Nothing : ds2.Clear()
  232. Button9.Enabled = False
  233. Set_清單()
  234. End Sub
  235. Private Sub Button9_Click(sender As Object, e As EventArgs) Handles Button9.Click
  236. For i As Integer = 0 To DataGridView1.Rows.Count - 1
  237. 資料數 = DataGridView1.Rows.Count : MyModule1.進度條()
  238. If DataGridView1.Rows(i).Cells("型體名稱").Value = "" Then
  239. Else
  240. TextBox1.Text = DataGridView1.Rows(i).Cells("SO").Value : TextBox3.Text = DataGridView1.Rows(i).Cells("版次").Value
  241. TextBox4.Text = DataGridView1.Rows(i).Cells("項次").Value : TextBox2.Text = DataGridView1.Rows(i).Cells("季節").Value
  242. TextBox5.Text = DataGridView1.Rows(i).Cells("工廠").Value : TextBox6.Text = DataGridView1.Rows(i).Cells("型體號碼").Value
  243. TextBox7.Text = DataGridView1.Rows(i).Cells("型體名稱").Value : TextBox8.Text = DataGridView1.Rows(i).Cells("顏色").Value
  244. TextBox9.Text = DataGridView1.Rows(i).Cells("數量").Value : TextBox16.Text = DataGridView1.Rows(i).Cells("客戶").Value
  245. Set_清單2()
  246. Dim II As Integer = 0
  247. TextBox10.Text = ""
  248. For iii As Integer = 0 To DataGridView3.Rows.Count - 1
  249. If Strings.Left(DataGridView3.Rows(iii).Cells("部件").Value, 1) = "A" Then
  250. TextBox10.Text = TextBox10.Text & II + 1 & ". " & DataGridView3.Rows(iii).Cells("材料名稱").Value & " " : II += 1
  251. End If
  252. Next
  253. II = 0
  254. TextBox12.Text = ""
  255. For iii As Integer = 0 To DataGridView3.Rows.Count - 1
  256. If Strings.Left(DataGridView3.Rows(iii).Cells("部件").Value, 1) = "E" Then
  257. TextBox12.Text = TextBox12.Text & II + 1 & ". " & DataGridView3.Rows(iii).Cells("材料名稱").Value & " " : II += 1
  258. End If
  259. Next
  260. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  261. SQL1 = "INSERT INTO 樣品單價控制表 (SEASON, CUST, FCTY, STYLE, STYLENAME, COLOR, SO, 版次, 項次, MATERIALS, MATERIAL_CLASS, OUTSOLE, INSOLE, FC, REMARK) " &
  262. "VALUES (N'" & TextBox2.Text & "', N'" & TextBox16.Text & "', N'" & TextBox5.Text & "', N'" & TextBox6.Text & "', N'" & TextBox7.Text & "', N'" & TextBox8.Text & "', N'" & TextBox1.Text &
  263. "', N'" & TextBox3.Text & "', N'" & TextBox4.Text & "', N'" & TextBox10.Text & "', N'', N'" & TextBox12.Text & "', N'', N'0.0', N'')"
  264. cmd.Connection = conn : cmd.CommandText = SQL1 : cmd.ExecuteNonQuery() : conn.Close()
  265. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  266. SQL1 = "UPDATE 樣品訂單清單 SET 已報價 = N'1' WHERE (流水號 LIKE N'" & DataGridView1.Rows(i).Cells("流水號").Value & "')"
  267. cmd.Connection = conn : cmd.CommandText = SQL1 : da.SelectCommand = cmd : cmd.ExecuteNonQuery() : conn.Close()
  268. End If
  269. Next : WINPROFIT_ERP_SYS.ToolStripProgressBar1.Value = 0 : 最終數 = 0
  270. Set_清單() : Set_清單1() : MsgBox("資料新增完成")
  271. End Sub
  272. Private Sub Button11_Click(sender As Object, e As EventArgs) Handles Button11.Click
  273. For i As Integer = 0 To DataGridView2.Rows.Count - 1
  274. 資料數 = DataGridView2.Rows.Count : MyModule1.進度條()
  275. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  276. SQL1 = "UPDATE 樣品單價控制表 SET MATERIAL_CLASS = N'" & DataGridView2.Rows(i).Cells("MATERIAL_CLASS").Value & "', INSOLE = N'" & DataGridView2.Rows(i).Cells("INSOLE").Value &
  277. "', FC = N'" & DataGridView2.Rows(i).Cells("FC").Value & "', REMARK = N'" & DataGridView2.Rows(i).Cells("REMARK").Value & "', MATERIALS = N'" & DataGridView2.Rows(i).Cells("MATERIALS").Value &
  278. "', OUTSOLE = N'" & DataGridView2.Rows(i).Cells("OUTSOLE").Value & "' " &
  279. "WHERE (SO LIKE N'" & DataGridView2.Rows(i).Cells("SO").Value & "' AND 版次 LIKE N'" & DataGridView2.Rows(i).Cells("版次").Value & "' " &
  280. "AND 項次 LIKE N'" & DataGridView2.Rows(i).Cells("項次").Value & "')"
  281. cmd.Connection = conn : cmd.CommandText = SQL1 : da.SelectCommand = cmd : cmd.ExecuteNonQuery() : conn.Close()
  282. Next : WINPROFIT_ERP_SYS.ToolStripProgressBar1.Value = 0 : 最終數 = 0
  283. Set_清單1() : MsgBox("資料存檔完成")
  284. End Sub
  285. Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
  286. If TextBox1.Text = "" And TextBox3.Text = "" And TextBox4.Text = "" Then
  287. MsgBox("沒有選取要刪除的資料")
  288. Else
  289. Dim aa As MsgBoxResult
  290. aa = MsgBox("確定要刪除該筆資料?", MsgBoxStyle.OkCancel)
  291. If aa = MsgBoxResult.Ok Then
  292. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  293. SQL1 = "DELETE FROM 樣品單價控制表 WHERE (SO LIKE N'" & TextBox1.Text & "' AND 版次 LIKE N'" & TextBox3.Text & "' " &
  294. "AND 項次 LIKE N'" & TextBox4.Text & "')"
  295. cmd.CommandText = SQL1 : cmd.Connection = conn : cmd.ExecuteNonQuery() : conn.Close()
  296. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  297. SQL1 = "UPDATE 樣品訂單清單 SET 已報價 = N'0' WHERE (SO LIKE N'" & TextBox1.Text & "' AND 版次 LIKE N'" & TextBox3.Text & "' " &
  298. "AND 項次 LIKE N'" & TextBox4.Text & "')"
  299. cmd.Connection = conn : cmd.CommandText = SQL1 : da.SelectCommand = cmd : cmd.ExecuteNonQuery() : conn.Close()
  300. MsgBox("刪除完成") : Set_清單() : Set_清單1()
  301. End If
  302. End If
  303. End Sub
  304. Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
  305. PA = InputBox("請輸入要查詢的關鍵字") : Set_清單1() : PA = ""
  306. End Sub
  307. Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
  308. If 列印用SQL = "" Then
  309. MsgBox("沒有列印資料,請重新搜尋後列印")
  310. Else
  311. 列印_樣品報價單.ShowDialog() : 列印用SQL = ""
  312. End If
  313. End Sub
  314. End Class