Нема описа
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

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