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 31KB

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