Geen omschrijving
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 35KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488
  1. Option Strict Off
  2. Imports System.Data.SqlClient
  3. Imports System.IO
  4. Imports System.Net
  5. Imports Microsoft.Office.Interop.Excel.XlUnderlineStyle
  6. Imports Microsoft.Office.Interop.Excel.Constants
  7. Imports Microsoft.Office.Interop.Excel.XlBordersIndex
  8. Imports Microsoft.Office.Interop.Excel.XlLineStyle
  9. Imports Microsoft.Office.Interop.Excel.XlBorderWeight
  10. Imports Microsoft.Office.Interop.Excel.XlThemeFont
  11. Imports Microsoft.Office.Interop.Excel.XlThemeColor
  12. Imports Microsoft.Office.Interop.Excel.XlWindowState
  13. Imports Microsoft.Office.Interop.Excel
  14. Public Class 模具開發控制表
  15. Public Property Credentials As ICredentials
  16. ReadOnly conn As New SqlConnection
  17. ReadOnly da As New SqlDataAdapter
  18. ReadOnly cmd As New SqlCommand
  19. ReadOnly ds As New DataSet : ReadOnly ds1 As New DataSet : ReadOnly ds2 As New DataSet : ReadOnly ds3 As New DataSet
  20. Dim dr As SqlDataReader
  21. Dim DTP As String
  22. Dim xlApp As Microsoft.Office.Interop.Excel.Application
  23. Dim xlBook As Microsoft.Office.Interop.Excel.Workbook
  24. Dim xlSheet As Microsoft.Office.Interop.Excel.Worksheet
  25. Private Sub Set_DGV1載入前設定()
  26. DataGridView1.DataSource = Nothing : ds.Clear()
  27. DataGridView1.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
  28. DataGridView1.ColumnHeadersHeight = 25
  29. DataGridView1.AllowUserToAddRows = False
  30. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  31. End Sub
  32. Private Sub Set_DGV1載入後設定()
  33. cmd.Connection = conn : cmd.CommandText = SQL1 : da.SelectCommand = cmd : da.Fill(ds) : DataGridView1.DataSource = ds.Tables(0) : conn.Close()
  34. End Sub
  35. Private Sub Set_楦頭規格表清單()
  36. Set_DGV1載入前設定()
  37. If PA = "" Then
  38. SQL1 = "SELECT 模具開發單號, 結構, 材質, 楦頭編號, 模具編號, 參考原樣鞋編號, 品牌, 大底廠, 尺寸, 季節, 備註1 AS 備註, 制表, 制表日期, 模具廠
  39. FROM 模具開發控制表"
  40. Else
  41. SQL1 = "SELECT 模具開發單號, 結構, 材質, 楦頭編號, 模具編號, 參考原樣鞋編號, 品牌, 大底廠, 尺寸, 季節, 備註1 AS 備註, 制表, 制表日期, 模具廠
  42. FROM 模具開發控制表 WHERE 模具開發單號 LIKE N'%" & PA & "%' OR 結構 LIKE N'%" & PA & "%' OR 材質 LIKE N'%" & PA & "%' OR 楦頭編號 LIKE N'%" & PA & "%' OR 模具編號 LIKE N'%" & PA & "%' OR
  43. 參考原樣鞋編號 LIKE N'%" & PA & "%' OR 品牌 LIKE N'%" & PA & "%' OR 大底廠 LIKE N'%" & PA & "%' OR 尺寸 LIKE N'%" & PA & "%' OR 季節 LIKE N'%" & PA & "%'"
  44. End If
  45. Set_DGV1載入後設定() : Set_grid()
  46. End Sub
  47. Private Sub Set_grid()
  48. DataGridView1.Columns(0).Width = 142 : DataGridView1.Columns(1).Visible = False : DataGridView1.Columns(2).Visible = False : DataGridView1.Columns(3).Visible = False
  49. DataGridView1.Columns(4).Width = 142 : DataGridView1.Columns(5).Visible = False : DataGridView1.Columns(6).Visible = False : DataGridView1.Columns(7).Visible = False
  50. DataGridView1.Columns(8).Visible = False : DataGridView1.Columns(9).Visible = False : DataGridView1.Columns(10).Visible = False : DataGridView1.Columns(11).Visible = False
  51. DataGridView1.Columns(12).Visible = False : DataGridView1.Columns(13).Visible = False
  52. End Sub
  53. Private Sub ComboBox1下拉表單資料載入()
  54. conn.Close()
  55. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  56. SQL1 = "SELECT 廠商 FROM 供應商清單 WHERE (公司傳真3 LIKE '模具廠')"
  57. cmd.CommandText = SQL1 : cmd.Connection = conn : dr = cmd.ExecuteReader
  58. ComboBox1.Items.Clear() : While (dr.Read()) : ComboBox1.Items.Add(dr("廠商")) : End While : conn.Close()
  59. End Sub
  60. Private Sub ComboBox2下拉表單資料載入()
  61. conn.Close()
  62. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  63. SQL1 = "SELECT 結構 FROM 模具開發用結構清單"
  64. cmd.CommandText = SQL1 : cmd.Connection = conn : dr = cmd.ExecuteReader
  65. ComboBox2.Items.Clear() : While (dr.Read()) : ComboBox2.Items.Add(dr("結構")) : End While : conn.Close()
  66. End Sub
  67. Private Sub ComboBox3下拉表單資料載入()
  68. conn.Close()
  69. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  70. SQL1 = "SELECT 材質 FROM 模具開發用材質清單"
  71. cmd.CommandText = SQL1 : cmd.Connection = conn : dr = cmd.ExecuteReader
  72. ComboBox3.Items.Clear() : While (dr.Read()) : ComboBox3.Items.Add(dr("材質")) : End While : conn.Close()
  73. End Sub
  74. Private Sub ComboBox4下拉表單資料載入()
  75. conn.Close()
  76. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  77. SQL1 = "SELECT 楦頭編號 FROM 楦頭規格控制表 ORDER BY 楦頭編號 DESC"
  78. cmd.CommandText = SQL1 : cmd.Connection = conn : dr = cmd.ExecuteReader
  79. ComboBox4.Items.Clear() : While (dr.Read()) : ComboBox4.Items.Add(dr("楦頭編號")) : End While : conn.Close()
  80. End Sub
  81. Private Sub ComboBox5下拉表單資料載入()
  82. conn.Close()
  83. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  84. SQL1 = "SELECT CUST FROM MTTOOCUST清單 ORDER BY CUST"
  85. cmd.CommandText = SQL1 : cmd.Connection = conn : dr = cmd.ExecuteReader
  86. ComboBox5.Items.Clear() : While (dr.Read()) : ComboBox5.Items.Add(dr("CUST")) : End While : conn.Close()
  87. End Sub
  88. Private Sub ComboBox6下拉表單資料載入()
  89. conn.Close()
  90. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  91. SQL1 = "SELECT 廠商 FROM 供應商清單 WHERE (公司傳真3 LIKE '大底廠')"
  92. cmd.CommandText = SQL1 : cmd.Connection = conn : dr = cmd.ExecuteReader
  93. ComboBox6.Items.Clear() : While (dr.Read()) : ComboBox6.Items.Add(dr("廠商")) : End While : conn.Close()
  94. End Sub
  95. Private Sub ComboBox7下拉表單資料載入()
  96. conn.Close()
  97. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  98. SQL1 = "SELECT SEASON FROM 季節清單 ORDER BY SEASON"
  99. cmd.CommandText = SQL1 : cmd.Connection = conn : dr = cmd.ExecuteReader
  100. ComboBox7.Items.Clear() : While (dr.Read()) : ComboBox7.Items.Add(dr("SEASON")) : End While : conn.Close()
  101. End Sub
  102. Private Sub 模具開發控制表_Load(sender As Object, e As EventArgs) Handles MyBase.Load
  103. Me.MdiParent = WINPROFIT_ERP_SYS : Me.WindowState = 2 : Me.AutoScroll = True
  104. ComboBox1下拉表單資料載入() : ComboBox2下拉表單資料載入() : ComboBox3下拉表單資料載入() : ComboBox4下拉表單資料載入() : ComboBox5下拉表單資料載入() : ComboBox6下拉表單資料載入()
  105. ComboBox7下拉表單資料載入() : Set_楦頭規格表清單()
  106. TextBox4.Enabled = False : TextBox7.Visible = False : TextBox8.Visible = False : TextBox9.Visible = False
  107. ComboBox1.Enabled = False : ComboBox2.Enabled = False : ComboBox3.Enabled = False : ComboBox4.Enabled = False : ComboBox5.Enabled = False : ComboBox6.Enabled = False : ComboBox7.Enabled = False
  108. TextBox6.Enabled = False : TextBox1.Enabled = False : TextBox2.Enabled = False : TextBox3.Enabled = False : Button3.Enabled = False : Button6.Enabled = False
  109. Button2.Enabled = True : Button5.Enabled = True
  110. Target1 = Target & AA(13) & "/"
  111. WebBrowser1.Url = New Uri(Target1)
  112. If FolderBrowserDialog1.ShowDialog = DialogResult.OK Then
  113. WebBrowser2.Navigate(FolderBrowserDialog1.SelectedPath)
  114. End If
  115. End Sub
  116. Private Sub 圖片導入()
  117. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  118. SQL1 = "SELECT 圖片 FROM 模具開發控制表 WHERE 模具開發單號 LIKE N'" & TextBox4.Text & "'"
  119. cmd.Connection = conn : cmd.CommandText = SQL1 : dr = cmd.ExecuteReader
  120. PictureBox1.Image = Nothing
  121. While dr.Read() = True
  122. Dim unused As Byte() = New Byte(-1) {}
  123. Dim bytes As Byte() = DirectCast(dr.Item("圖片"), Byte())
  124. Dim oStream As New MemoryStream(bytes)
  125. PictureBox1.Image = Bitmap.FromStream(oStream)
  126. End While
  127. conn.Close()
  128. PictureBox1.SizeMode = 4
  129. End Sub
  130. Private Sub DataGridView1_CellClick(ByVal sender As System.Object, ByVal e As DataGridViewCellEventArgs) Handles DataGridView1.CellClick
  131. If Button2.Enabled = True Or Button5.Enabled = True Then
  132. If e.RowIndex = -1 Then : Else
  133. TextBox4.Text = DataGridView1.Rows(e.RowIndex).Cells("模具開發單號").Value : ComboBox1.Text = DataGridView1.Rows(e.RowIndex).Cells("模具廠").Value
  134. ComboBox2.Text = DataGridView1.Rows(e.RowIndex).Cells("結構").Value : ComboBox3.Text = DataGridView1.Rows(e.RowIndex).Cells("材質").Value
  135. ComboBox4.Text = DataGridView1.Rows(e.RowIndex).Cells("楦頭編號").Value : TextBox6.Text = DataGridView1.Rows(e.RowIndex).Cells("模具編號").Value
  136. TextBox1.Text = DataGridView1.Rows(e.RowIndex).Cells("參考原樣鞋編號").Value : ComboBox5.Text = DataGridView1.Rows(e.RowIndex).Cells("品牌").Value
  137. ComboBox6.Text = DataGridView1.Rows(e.RowIndex).Cells("大底廠").Value : TextBox2.Text = DataGridView1.Rows(e.RowIndex).Cells("尺寸").Value
  138. ComboBox7.Text = DataGridView1.Rows(e.RowIndex).Cells("季節").Value : TextBox3.Text = DataGridView1.Rows(e.RowIndex).Cells("備註").Value
  139. TextBox8.Text = DataGridView1.Rows(e.RowIndex).Cells("制表").Value : TextBox9.Text = DataGridView1.Rows(e.RowIndex).Cells("制表日期").Value
  140. 圖片導入()
  141. End If
  142. End If
  143. End Sub
  144. Private Sub Button7_Click(sender As Object, e As EventArgs) Handles Button7.Click
  145. PA = InputBox("請輸入要查詢的關鍵字") : Set_楦頭規格表清單() : PA = ""
  146. End Sub
  147. Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
  148. ComboBox1.Enabled = True : ComboBox2.Enabled = True : ComboBox3.Enabled = True : ComboBox4.Enabled = True : ComboBox5.Enabled = True : ComboBox6.Enabled = True : ComboBox7.Enabled = True
  149. TextBox6.Enabled = True : TextBox1.Enabled = True : TextBox2.Enabled = True : TextBox3.Enabled = True : Button3.Enabled = True : Button6.Enabled = False
  150. Button2.Enabled = False : Button5.Enabled = False
  151. ComboBox1下拉表單資料載入() : ComboBox2下拉表單資料載入() : ComboBox3下拉表單資料載入() : ComboBox4下拉表單資料載入() : ComboBox5下拉表單資料載入() : ComboBox6下拉表單資料載入()
  152. ComboBox7下拉表單資料載入()
  153. TextBox6.Text = "" : TextBox6.Text = "" : TextBox1.Text = "" : TextBox2.Text = "" : TextBox3.Text = "" : PictureBox1.Image = Nothing
  154. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  155. SQL1 = "SELECT TOP (1) 模具開發單號 FROM 模具開發控制表 ORDER BY 模具開發單號 DESC"
  156. cmd.Connection = conn : cmd.CommandText = SQL1 : dr = cmd.ExecuteReader
  157. If dr.Read() Then : TextBox4.Text = dr("模具開發單號").ToString : Else : TextBox4.Text = "MD00000000" : End If
  158. conn.Close()
  159. Dim NUM1 As Integer
  160. NUM1 = Double.Parse(Strings.Right(TextBox4.Text, 8)) + 1
  161. If NUM1 < 10 Then : TextBox4.Text = "MD" & "0000000" & NUM1
  162. ElseIf NUM1 > 9 And NUM1 < 100 Then : TextBox4.Text = "MD" & "000000" & NUM1
  163. ElseIf NUM1 > 99 And NUM1 < 1000 Then : TextBox4.Text = "MD" & "00000" & NUM1
  164. ElseIf NUM1 > 999 And NUM1 < 10000 Then : TextBox4.Text = "MD" & "0000" & NUM1
  165. ElseIf NUM1 > 9999 And NUM1 < 100000 Then : TextBox4.Text = "MD" & "000" & NUM1
  166. ElseIf NUM1 > 99999 And NUM1 < 100000 Then : TextBox4.Text = "MD" & "00" & NUM1
  167. ElseIf NUM1 > 999999 And NUM1 < 1000000 Then : TextBox4.Text = "MD" & "0" & NUM1
  168. ElseIf NUM1 > 9999999 Then : TextBox4.Text = "MD" & NUM1
  169. End If
  170. End Sub
  171. Private Sub Set_日期格式轉換()
  172. DTP = Strings.Format(Today(), "yyyy/MM/dd")
  173. End Sub
  174. Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
  175. If ComboBox1.Text = "" Or ComboBox2.Text = "" Or ComboBox3.Text = "" Or ComboBox4.Text = "" Or ComboBox5.Text = "" Or ComboBox6.Text = "" Or ComboBox7.Text = "" Or TextBox4.Text = "" Or
  176. TextBox6.Text = "" Or TextBox1.Text = "" Or TextBox2.Text = "" Or TextBox5.Text = "" Then
  177. MsgBox("資料不齊全,除了備註欄位其他位置不可空白,並請注意圖片是否有準備好。")
  178. Else
  179. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  180. SQL1 = "SELECT 模具開發單號 FROM 模具開發控制表 WHERE 楦頭編號 LIKE N'" & ComboBox4.Text & "' AND 模具編號 LIKE N'" & TextBox6.Text & "'"
  181. cmd.Connection = conn : cmd.CommandText = SQL1 : dr = cmd.ExecuteReader
  182. If dr.Read() Then
  183. conn.Close() : MsgBox("資料重複,不予許新建")
  184. Else
  185. conn.Close()
  186. Set_日期格式轉換()
  187. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  188. SQL1 = "SELECT TOP (1) 模具開發單號 FROM 模具開發控制表 WHERE 模具開發單號 LIKE N'" & TextBox4.Text & "'"
  189. cmd.Connection = conn : cmd.CommandText = SQL1 : dr = cmd.ExecuteReader
  190. If dr.Read() Then
  191. conn.Close()
  192. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  193. SQL1 = "SELECT TOP (1) 模具開發單號 FROM 模具開發控制表 ORDER BY 模具開發單號 DESC"
  194. cmd.Connection = conn : cmd.CommandText = SQL1 : dr = cmd.ExecuteReader
  195. If dr.Read() Then : TextBox4.Text = dr("模具開發單號").ToString : Else : TextBox4.Text = "MD00000000" : End If
  196. conn.Close()
  197. Dim NUM1 As Integer
  198. NUM1 = Double.Parse(Strings.Right(TextBox4.Text, 8)) + 1
  199. If NUM1 < 10 Then : TextBox4.Text = "MD" & "0000000" & NUM1
  200. ElseIf NUM1 > 9 And NUM1 < 100 Then : TextBox4.Text = "MD" & "000000" & NUM1
  201. ElseIf NUM1 > 99 And NUM1 < 1000 Then : TextBox4.Text = "MD" & "00000" & NUM1
  202. ElseIf NUM1 > 999 And NUM1 < 10000 Then : TextBox4.Text = "MD" & "0000" & NUM1
  203. ElseIf NUM1 > 9999 And NUM1 < 100000 Then : TextBox4.Text = "MD" & "000" & NUM1
  204. ElseIf NUM1 > 99999 And NUM1 < 100000 Then : TextBox4.Text = "MD" & "00" & NUM1
  205. ElseIf NUM1 > 999999 And NUM1 < 1000000 Then : TextBox4.Text = "MD" & "0" & NUM1
  206. ElseIf NUM1 > 9999999 Then : TextBox4.Text = "MD" & NUM1
  207. End If
  208. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  209. SQL1 = "INSERT INTO 模具開發控制表 (模具開發單號, 模具廠, 結構, 材質, 楦頭編號, 模具編號, 參考原樣鞋編號, 品牌, 大底廠, 尺寸, 季節, 備註1, 制表, 制表日期, 圖片) SELECT N'" & TextBox4.Text &
  210. "',N'" & ComboBox1.Text & "',N'" & ComboBox2.Text & "',N'" & ComboBox3.Text & "',N'" & ComboBox4.Text & "',N'" & TextBox6.Text & "',N'" & TextBox1.Text & "',N'" & ComboBox5.Text &
  211. "',N'" & ComboBox6.Text & "',N'" & TextBox2.Text & "',N'" & ComboBox7.Text & "',N'" & TextBox3.Text & "',N'" & gUserName & "',N'" & DTP & "', " &
  212. "BULKCOLUMN FROM OPENROWSET ( BULK '" & FTP實體位置 & AA(13) & "\" & TextBox5.Text & "', SINGLE_BLOB) AS EMPLOYEEPICTURE"
  213. cmd.Connection = conn : cmd.CommandText = SQL1 : cmd.ExecuteNonQuery() : conn.Close()
  214. Else
  215. conn.Close()
  216. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  217. SQL1 = "INSERT INTO 模具開發控制表 (模具開發單號, 模具廠, 結構, 材質, 楦頭編號, 模具編號, 參考原樣鞋編號, 品牌, 大底廠, 尺寸, 季節, 備註1, 制表, 制表日期, 圖片) SELECT N'" & TextBox4.Text &
  218. "',N'" & ComboBox1.Text & "',N'" & ComboBox2.Text & "',N'" & ComboBox3.Text & "',N'" & ComboBox4.Text & "',N'" & TextBox6.Text & "',N'" & TextBox1.Text & "',N'" & ComboBox5.Text &
  219. "',N'" & ComboBox6.Text & "',N'" & TextBox2.Text & "',N'" & ComboBox7.Text & "',N'" & TextBox3.Text & "',N'" & gUserName & "',N'" & DTP & "', " &
  220. "BULKCOLUMN FROM OPENROWSET ( BULK '" & FTP實體位置 & AA(13) & "\" & TextBox5.Text & "', SINGLE_BLOB) AS EMPLOYEEPICTURE"
  221. cmd.Connection = conn : cmd.CommandText = SQL1 : cmd.ExecuteNonQuery() : conn.Close()
  222. End If
  223. conn.Close()
  224. '---FTP方式刪除檔案----------------------------------------------------------------------------------------------------------------------------------------------------------------------
  225. Dim frq As FtpWebRequest, frp As FtpWebResponse, fcr As NetworkCredential
  226. frq = CType(WebRequest.Create(New Uri(Target1 & TextBox5.Text)), FtpWebRequest)
  227. fcr = New NetworkCredential(FTP帳號, FTP密碼)
  228. frq.Credentials = fcr
  229. frq.Method = WebRequestMethods.Ftp.DeleteFile
  230. frq.UseBinary = True
  231. frp = CType(frq.GetResponse, FtpWebResponse)
  232. frp.Close()
  233. WebBrowser1.Refresh()
  234. '----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  235. 圖片導入() : Set_楦頭規格表清單() : MsgBox("新增完成")
  236. ComboBox1.Enabled = False : ComboBox2.Enabled = False : ComboBox3.Enabled = False : ComboBox4.Enabled = False : ComboBox5.Enabled = False : ComboBox6.Enabled = False : ComboBox7.Enabled = False
  237. TextBox6.Enabled = False : TextBox1.Enabled = False : TextBox2.Enabled = False : TextBox3.Enabled = False : Button3.Enabled = False : Button6.Enabled = False
  238. Button2.Enabled = True : Button5.Enabled = True : TextBox5.Text = ""
  239. End If
  240. End If
  241. End Sub
  242. Private Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click
  243. ComboBox1.Enabled = True : ComboBox2.Enabled = True : ComboBox3.Enabled = True : ComboBox4.Enabled = True : ComboBox5.Enabled = True : ComboBox6.Enabled = True : ComboBox7.Enabled = True
  244. TextBox6.Enabled = True : TextBox1.Enabled = True : TextBox2.Enabled = True : TextBox3.Enabled = True : Button3.Enabled = False : Button6.Enabled = True
  245. Button2.Enabled = False : Button5.Enabled = False
  246. End Sub
  247. Private Sub Button6_Click(sender As Object, e As EventArgs) Handles Button6.Click
  248. Set_日期格式轉換()
  249. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  250. SQL1 = "UPDATE 模具開發控制表 SET 模具廠 = N'" & ComboBox1.Text & "', 結構 = N'" & ComboBox2.Text & "', 材質 = N'" & ComboBox3.Text & "', 楦頭編號 = N'" & ComboBox4.Text &
  251. "', 模具編號 = N'" & TextBox6.Text & "', 參考原樣鞋編號 = N'" & TextBox1.Text & "', 品牌 = N'" & ComboBox5.Text & "', 大底廠 = N'" & ComboBox6.Text & "', 尺寸 = N'" & TextBox2.Text &
  252. "', 季節 = N'" & ComboBox7.Text & "', 備註1 = N'" & TextBox3.Text & "', 制表 = N'" & gUserName & "', 制表日期 = N'" & DTP & "'
  253. WHERE 模具開發單號 LIKE N'" & TextBox4.Text & "'"
  254. cmd.Connection = conn : cmd.CommandText = SQL1 : cmd.ExecuteNonQuery() : conn.Close()
  255. Set_楦頭規格表清單()
  256. MsgBox("修改完成")
  257. ComboBox1.Enabled = False : ComboBox2.Enabled = False : ComboBox3.Enabled = False : ComboBox4.Enabled = False : ComboBox5.Enabled = False : ComboBox6.Enabled = False : ComboBox7.Enabled = False
  258. TextBox6.Enabled = False : TextBox1.Enabled = False : TextBox2.Enabled = False : TextBox3.Enabled = False : Button3.Enabled = False : Button6.Enabled = False
  259. Button2.Enabled = True : Button5.Enabled = True
  260. End Sub
  261. Private Sub TextBox5_DragEnter(sender As Object, e As DragEventArgs) Handles TextBox5.DragEnter
  262. If e.Data.GetDataPresent(DataFormats.FileDrop) Then
  263. Dim files As String()
  264. Try
  265. files = CType(e.Data.GetData(DataFormats.FileDrop), String())
  266. TextBox5.Text = files(files.Length - 1)
  267. Catch ex As Exception
  268. MessageBox.Show(ex.Message)
  269. Return
  270. End Try
  271. End If
  272. Dim STR2 As Integer = 0
  273. TextBox7.Text = TextBox5.Text
  274. If TextBox5.Text = "" Then
  275. Else
  276. For i As Integer = 0 To 9999
  277. Dim STR1 As Integer = Strings.Len(TextBox7.Text)
  278. If Strings.Right((TextBox7.Text), 1) <> "\" Then
  279. STR1 -= 1 : STR2 += 1
  280. If STR1 = 0 Then
  281. TextBox7.Text = ""
  282. TextBox5.Text = ""
  283. i = 9999
  284. Else
  285. TextBox7.Text = Strings.Left((TextBox7.Text), STR1)
  286. End If
  287. Else
  288. TextBox7.Text = Strings.Right((TextBox5.Text), STR2)
  289. TextBox5.Text = TextBox7.Text
  290. i = 9999
  291. End If
  292. Next
  293. End If
  294. End Sub
  295. Private Sub TextBox5_DragDrop(ByVal sender As Object, ByVal e As DragEventArgs) Handles TextBox5.DragDrop
  296. Dim files As Array = e.Data.GetData(DataFormats.FileDrop)
  297. For Each file As String In files
  298. TextBox5.AppendText(file + Environment.NewLine)
  299. Next
  300. End Sub
  301. Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
  302. If FolderBrowserDialog1.ShowDialog = DialogResult.OK Then
  303. WebBrowser2.Navigate(FolderBrowserDialog1.SelectedPath)
  304. End If
  305. End Sub
  306. Private Sub Button24_Click(sender As Object, e As EventArgs) Handles Button24.Click
  307. If TextBox4.Text = "" Or TextBox5.Text = "" Then
  308. MsgBox("請確定需要修改圖片的模具資料已選擇與圖片資料已準備完畢。")
  309. Else
  310. conn.Close() : Set_日期格式轉換()
  311. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  312. SQL1 = "UPDATE 模具開發控制表 SET 制表 = N'" & gUserName & "', 制表日期 = N'" & DTP & "', 圖片 = BULKCOLUMN FROM OPENROWSET ( BULK '" & FTP實體位置 & AA(13) & "\" & TextBox5.Text & "', SINGLE_BLOB) AS
  313. EMPLOYEEPICTURE WHERE (模具開發單號 = '" & TextBox4.Text & "')"
  314. cmd.CommandText = SQL1 : cmd.ExecuteNonQuery() : conn.Close()
  315. '---FTP方式刪除檔案----------------------------------------------------------------------------------------------------------------------------------------------------------------------
  316. Dim frq As FtpWebRequest, frp As FtpWebResponse, fcr As NetworkCredential
  317. frq = CType(WebRequest.Create(New Uri(Target1 & TextBox5.Text)), FtpWebRequest)
  318. fcr = New NetworkCredential(FTP帳號, FTP密碼)
  319. frq.Credentials = fcr
  320. frq.Method = WebRequestMethods.Ftp.DeleteFile
  321. frq.UseBinary = True
  322. frp = CType(frq.GetResponse, FtpWebResponse)
  323. frp.Close()
  324. WebBrowser1.Refresh()
  325. '----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  326. TextBox5.Text = ""
  327. 圖片導入()
  328. MsgBox("修改完成")
  329. End If
  330. End Sub
  331. Private Sub Button8_Click(sender As Object, e As EventArgs) Handles Button8.Click
  332. xlApp = CType(CreateObject("Excel.Application"), Microsoft.Office.Interop.Excel.Application)
  333. xlBook = xlApp.Workbooks.Add
  334. xlApp.DisplayAlerts = True
  335. xlBook.Activate()
  336. xlSheet = NewMethod(xlBook)
  337. xlSheet.Activate()
  338. xlApp.Visible = True
  339. xlApp.Application.WindowState = xlMaximized
  340. xlSheet.Cells(1, 1) = "巨益模具開發計畫表" : xlSheet.Cells(2, 1) = "模具廠 : " : xlSheet.Cells(3, 1) = "結構 : " : xlSheet.Cells(4, 1) = "材質 : " : xlSheet.Cells(5, 1) = "楦頭編號 : "
  341. xlSheet.Cells(6, 1) = "模具編號 : " : xlSheet.Cells(2, 2) = ComboBox1.Text : xlSheet.Cells(3, 2) = ComboBox2.Text : xlSheet.Cells(4, 2) = ComboBox3.Text : xlSheet.Cells(5, 2) = ComboBox4.Text
  342. xlSheet.Cells(6, 2) = TextBox6.Text : xlSheet.Cells(2, 3) = "參考漾鞋編號 : " : xlSheet.Cells(3, 3) = "品牌 : " : xlSheet.Cells(4, 3) = "大底廠 : " : xlSheet.Cells(5, 3) = "尺寸 : "
  343. xlSheet.Cells(6, 3) = "季節 : " : xlSheet.Cells(2, 4) = TextBox6.Text : xlSheet.Cells(3, 4) = ComboBox5.Text : xlSheet.Cells(4, 4) = ComboBox6.Text : xlSheet.Cells(5, 4) = TextBox2.Text
  344. xlSheet.Cells(6, 4) = ComboBox7.Text : xlSheet.Cells(7, 4) = "備註 : " : xlSheet.Cells(8, 4) = TextBox3.Text : xlSheet.Cells(52, 1) = "製表人 : " : xlSheet.Cells(52, 2) = TextBox8.Text
  345. xlSheet.Cells(52, 3) = "製表人 : " : xlSheet.Cells(52, 4) = TextBox9.Text
  346. CC(xlApp, xlSheet) : BB(xlApp, xlSheet)
  347. xlSheet.PageSetup.PrintArea = ""
  348. xlApp.Cells.Select()
  349. xlSheet.Range("B1").Select()
  350. xlApp.Application.WindowState = xlMinimized
  351. 'xlApp.ActiveSheet.Protect(DrawingObjects:=True, Contents:=True, Scenarios:=True, Password:="0911274990")
  352. 'xlApp.ActiveSheet.EnableSelection = 1
  353. MsgBox("列印完成")
  354. End Sub
  355. Private Shared Function NewMethod(xlBook As Microsoft.Office.Interop.Excel.Workbook) As Microsoft.Office.Interop.Excel.Worksheet
  356. Return CType(xlBook.Worksheets.Add, Microsoft.Office.Interop.Excel.Worksheet)
  357. End Function
  358. Private Sub CC(ByVal myExcel As Application, ByVal xlSheet As Worksheet)
  359. xlSheet.Cells.Select()
  360. With myExcel.Selection.Font : .Name = "微軟正黑體" : .Size = 12 : .Strikethrough = False : .Superscript = False : .Subscript = False : .OutlineFont = False
  361. .Shadow = False : .Underline = xlUnderlineStyleNone : .ThemeColor = xlThemeColorLight1 : .TintAndShade = 0 : .ThemeFont = xlThemeFontNone : End With
  362. xlSheet.Columns("A:A").Select : myExcel.Selection.ColumnWidth = 15 : xlSheet.Columns("B:B").Select : myExcel.Selection.ColumnWidth = 50
  363. xlSheet.Columns("C:C").Select : myExcel.Selection.ColumnWidth = 15 : xlSheet.Columns("D:D").Select : myExcel.Selection.ColumnWidth = 40
  364. xlSheet.Rows("2:6").Select : myExcel.Selection.RowHeight = 30 : xlSheet.Rows("1:1").Select : myExcel.Selection.RowHeight = 35
  365. xlSheet.Range("D8:D51").Select() : myExcel.Selection.Merge
  366. With myExcel.Selection : .HorizontalAlignment = xlLeft : .VerticalAlignment = xlTop : .WrapText = True : .Orientation = 0 : .AddIndent = False
  367. .IndentLevel = 0 : .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = True : End With
  368. xlSheet.Range("A2:D6").Select()
  369. myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone : myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
  370. With myExcel.Selection.Borders(xlEdgeLeft) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  371. With myExcel.Selection.Borders(xlEdgeTop) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  372. With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  373. With myExcel.Selection.Borders(xlEdgeRight) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  374. With myExcel.Selection.Borders(xlInsideVertical) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  375. With myExcel.Selection.Borders(xlInsideHorizontal) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  376. xlSheet.Range("A7:C51").Select()
  377. myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone : myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
  378. With myExcel.Selection.Borders(xlEdgeLeft) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  379. With myExcel.Selection.Borders(xlEdgeTop) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  380. With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  381. With myExcel.Selection.Borders(xlEdgeRight) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  382. myExcel.Selection.Borders(xlInsideVertical).LineStyle = xlNone : myExcel.Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
  383. xlSheet.Range("D7:D51").Select()
  384. myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone : myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
  385. With myExcel.Selection.Borders(xlEdgeLeft) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  386. With myExcel.Selection.Borders(xlEdgeTop) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  387. With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  388. With myExcel.Selection.Borders(xlEdgeRight) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  389. myExcel.Selection.Borders(xlInsideVertical).LineStyle = xlNone : myExcel.Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
  390. xlSheet.Rows("8:8").Select : myExcel.Selection.RowHeight = 15.75
  391. xlSheet.Range("A1:D1").Select() : myExcel.Selection.Merge
  392. With myExcel.Selection.Font : .Name = "微軟正黑體" : .Size = 26 : .Strikethrough = False : .Superscript = False : .Subscript = False : .OutlineFont = False
  393. .Shadow = False : .Underline = xlUnderlineStyleNone : .ThemeColor = xlThemeColorLight1 : .TintAndShade = 0 : .ThemeFont = xlThemeFontNone : End With
  394. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False
  395. .IndentLevel = 0 : .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = True : End With
  396. myExcel.ActiveWindow.DisplayGridlines = False
  397. myExcel.Application.PrintCommunication = False
  398. With myExcel.ActiveSheet.PageSetup
  399. .PrintTitleRows = ""
  400. .PrintTitleColumns = ""
  401. End With
  402. myExcel.Application.PrintCommunication = True
  403. myExcel.ActiveSheet.PageSetup.PrintArea = ""
  404. myExcel.Application.PrintCommunication = False
  405. With myExcel.ActiveSheet.PageSetup
  406. .LeftHeader = ""
  407. .CenterHeader = ""
  408. .RightHeader = ""
  409. .LeftFooter = ""
  410. .CenterFooter = ""
  411. .RightFooter = ""
  412. .LeftMargin = myExcel.Application.InchesToPoints(0.236220472440945)
  413. .RightMargin = myExcel.Application.InchesToPoints(0.236220472440945)
  414. .TopMargin = myExcel.Application.InchesToPoints(0.748031496062992)
  415. .BottomMargin = myExcel.Application.InchesToPoints(0.748031496062992)
  416. .HeaderMargin = myExcel.Application.InchesToPoints(0.31496062992126)
  417. .FooterMargin = myExcel.Application.InchesToPoints(0.31496062992126)
  418. .PrintHeadings = False
  419. .PrintGridlines = False
  420. .PrintQuality = 600
  421. .CenterHorizontally = True
  422. .CenterVertically = True
  423. .Draft = False
  424. .FirstPageNumber = xlAutomatic
  425. .BlackAndWhite = False
  426. .Zoom = False
  427. .FitToPagesWide = 1
  428. .FitToPagesTall = 1
  429. .OddAndEvenPagesHeaderFooter = False
  430. .DifferentFirstPageHeaderFooter = False
  431. .ScaleWithDocHeaderFooter = True
  432. .AlignMarginsHeaderFooter = True
  433. .EvenPage.LeftHeader.Text = ""
  434. .EvenPage.CenterHeader.Text = ""
  435. .EvenPage.RightHeader.Text = ""
  436. .EvenPage.LeftFooter.Text = ""
  437. .EvenPage.CenterFooter.Text = ""
  438. .EvenPage.RightFooter.Text = ""
  439. .FirstPage.LeftHeader.Text = ""
  440. .FirstPage.CenterHeader.Text = ""
  441. .FirstPage.RightHeader.Text = ""
  442. .FirstPage.LeftFooter.Text = ""
  443. .FirstPage.CenterFooter.Text = ""
  444. .FirstPage.RightFooter.Text = ""
  445. End With
  446. myExcel.Application.PrintCommunication = False
  447. End Sub
  448. Private Sub BB(ByVal myExcel As Application, ByVal xlSheet As Worksheet)
  449. Clipboard.SetDataObject(PictureBox1.Image)
  450. xlSheet.Range("A7").Select()
  451. myExcel.ActiveSheet.Pictures.Paste.Select
  452. myExcel.Selection.ShapeRange.Width = 485
  453. myExcel.Selection.ShapeRange.IncrementLeft(3)
  454. myExcel.Selection.ShapeRange.IncrementTop(3)
  455. End Sub
  456. Private Sub Button11_Click(sender As Object, e As EventArgs) Handles Button11.Click
  457. PA = "" : 供應商管理_製鞋樣品.Show() : 供應商管理_製鞋樣品.BringToFront()
  458. End Sub
  459. Private Sub Button13_Click(sender As Object, e As EventArgs) Handles Button13.Click
  460. PA = "" : 供應商管理_製鞋樣品.Show() : 供應商管理_製鞋樣品.BringToFront()
  461. End Sub
  462. Private Sub Button12_Click(sender As Object, e As EventArgs) Handles Button12.Click
  463. PA = "" : 楦頭規格表.Show() : 楦頭規格表.BringToFront()
  464. End Sub
  465. Private Sub Button10_Click(sender As Object, e As EventArgs) Handles Button10.Click
  466. 清單修改.Close() : 季節清單修改 = True : 清單修改.ShowDialog() : ComboBox7下拉表單資料載入() : 季節清單修改 = False
  467. End Sub
  468. Private Sub Button18_Click(sender As Object, e As EventArgs) Handles Button18.Click
  469. 清單修改.Close() : 模具用結構 = True : 清單修改.ShowDialog() : ComboBox2下拉表單資料載入() : 模具用結構 = False
  470. End Sub
  471. Private Sub Button9_Click(sender As Object, e As EventArgs) Handles Button9.Click
  472. 清單修改.Close() : 模具用材質 = True : 清單修改.ShowDialog() : ComboBox3下拉表單資料載入() : 模具用材質 = False
  473. End Sub
  474. End Class