Ingen beskrivning
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 28KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410
  1. Option Strict Off
  2. Imports System.Net
  3. Public Class 業務專案控制表
  4. ReadOnly ds, ds1, ds2 As New DataSet
  5. Dim DTP(2) As String
  6. Private Sub DGV1讀取前設定()
  7. DataGridView1.DataSource = Nothing : ds.Clear()
  8. DataGridView1.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
  9. DataGridView1.ColumnHeadersHeight = 50
  10. DataGridView1.AllowUserToAddRows = False
  11. ConnOpen()
  12. End Sub
  13. Private Sub DGV1讀取後設定()
  14. CmdSet_For_DGV() : da.Fill(ds) : DataGridView1.DataSource = ds.Tables(0) : conn.Close() : Set_grid1()
  15. End Sub
  16. Private Sub 讀取專案主檔()
  17. DGV1讀取前設定()
  18. If PA = "" Then
  19. SQL1 = "SELECT 專案流水號, 專案內容, 專案性質, 合約性質, 備註, 專案人數 AS 執行人數, 執行天數, 地點, 報價, 報價日期, 專案成本 AS 報價金額, 立案, 立案日期, 收款金額 AS 訂金,
  20. 結案, 結案日期, 應收金額 AS 應收尾款, 幣別, 建檔, 客戶
  21. FROM 業務專案主檔 ORDER BY 專案流水號 DESC"
  22. Else
  23. SQL1 = "SELECT 專案流水號, 專案內容, 專案性質, 合約性質, 備註, 專案人數 AS 執行人數, 執行天數, 地點, 報價, 報價日期, 專案成本 AS 報價金額, 立案, 立案日期, 收款金額 AS 訂金,
  24. 結案, 結案日期, 應收金額 AS 應收尾款, 幣別, 建檔, 客戶
  25. FROM 業務專案主檔
  26. WHERE 專案流水號 LIKE '%" & PA & "%' OR 專案內容 LIKE '%" & PA & "%' OR 專案人數 LIKE '%" & PA & "%' OR 執行天數 LIKE '%" & PA & "%' OR 地點 LIKE '%" & PA & "%' OR
  27. 立案日期 LIKE '%" & PA & "%' OR 結案日期 LIKE '%" & PA & "%' OR 備註 LIKE '%" & PA & "%' OR 結案 LIKE '%" & PA & "%'
  28. ORDER BY 專案流水號 DESC"
  29. End If
  30. DGV1讀取後設定()
  31. End Sub
  32. Private Sub Set_grid1()
  33. DataGridView1.Columns(0).Width = 90 : DataGridView1.Columns(1).Width = 300 : DataGridView1.Columns(2).Width = 70 : DataGridView1.Columns(3).Width = 70
  34. DataGridView1.Columns(4).Width = 350 : DataGridView1.Columns(5).Width = 40 : DataGridView1.Columns(6).Width = 40 : DataGridView1.Columns(7).Width = 100
  35. DataGridView1.Columns(8).Width = 50 : DataGridView1.Columns(9).Width = 80 : DataGridView1.Columns(10).Width = 90 : DataGridView1.Columns(11).Width = 50
  36. DataGridView1.Columns(12).Width = 80 : DataGridView1.Columns(13).Width = 90 : DataGridView1.Columns(14).Width = 50 : DataGridView1.Columns(15).Width = 80
  37. DataGridView1.Columns(16).Width = 90 : DataGridView1.Columns(17).Width = 60 : DataGridView1.Columns(18).Visible = False : DataGridView1.Columns(19).Width = 85
  38. DataGridView1.Columns(5).DefaultCellStyle.Format = "#,##0" : DataGridView1.Columns(6).DefaultCellStyle.Format = "#,##0" : DataGridView1.Columns(10).DefaultCellStyle.Format = "#,##0"
  39. DataGridView1.Columns(13).DefaultCellStyle.Format = "#,##0" : DataGridView1.Columns(16).DefaultCellStyle.Format = "#,##0"
  40. DataGridView1.Columns(5).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight : DataGridView1.Columns(5).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleRight
  41. DataGridView1.Columns(6).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight : DataGridView1.Columns(6).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleRight
  42. DataGridView1.Columns(10).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight : DataGridView1.Columns(10).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleRight
  43. DataGridView1.Columns(13).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight : DataGridView1.Columns(13).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleRight
  44. DataGridView1.Columns(16).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight : DataGridView1.Columns(16).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleRight
  45. For i As Integer = 0 To DataGridView1.Rows.Count - 1
  46. If DataGridView1.Rows(i).Cells("報價").Value Is DBNull.Value Then : DataGridView1.Rows(i).Cells("報價").Value = False : End If
  47. If DataGridView1.Rows(i).Cells("立案").Value Is DBNull.Value Then : DataGridView1.Rows(i).Cells("立案").Value = False : End If
  48. If DataGridView1.Rows(i).Cells("結案").Value Is DBNull.Value Then : DataGridView1.Rows(i).Cells("結案").Value = False : End If
  49. If DataGridView1.Rows(i).Cells("建檔").Value Is DBNull.Value Then : DataGridView1.Rows(i).Cells("建檔").Value = False : End If
  50. If DataGridView1.Rows(i).Cells("立案").Value = False Then
  51. DataGridView1.Rows(i).Cells("執行天數").Value = 0
  52. ElseIf DataGridView1.Rows(i).Cells("立案").Value = True And (DataGridView1.Rows(i).Cells("結案日期").Value.ToString = "" Or DataGridView1.Rows(i).Cells("結案日期").Value.ToString = " ") Then
  53. DataGridView1.Rows(i).Cells("執行天數").Value = DateDiff("d", DataGridView1.Rows(i).Cells("立案日期").Value, Format(Today(), "yyyy/MM/dd")) + 1
  54. ElseIf DataGridView1.Rows(i).Cells("立案").Value = True And (DataGridView1.Rows(i).Cells("結案日期").Value.ToString <> "" Or DataGridView1.Rows(i).Cells("結案日期").Value.ToString <> " ") Then
  55. DataGridView1.Rows(i).Cells("執行天數").Value = DateDiff("d", DataGridView1.Rows(i).Cells("立案日期").Value, DataGridView1.Rows(i).Cells("結案日期").Value) + 1
  56. End If
  57. Next i
  58. End Sub
  59. Private Sub DGV3讀取前設定()
  60. DataGridView3.DataSource = Nothing : ds2.Clear()
  61. DataGridView3.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
  62. DataGridView3.ColumnHeadersHeight = 25
  63. DataGridView3.AllowUserToAddRows = False
  64. ConnOpen()
  65. End Sub
  66. Private Sub DGV3讀取後設定()
  67. CmdSet_For_DGV() : da.Fill(ds2) : DataGridView3.DataSource = ds2.Tables(0) : conn.Close() : Set_grid3()
  68. End Sub
  69. Private Sub 讀取專案人事資料()
  70. DGV3讀取前設定()
  71. SQL1 = "SELECT 人員資料.姓名, 人員資料.性別, 人員資料.薪資結構, 人員資料.月薪 / 25 AS 月薪, 人員資料.日薪, 人員資料.時薪 * 8 AS 時薪, 業務專案清單.專案流水號, 業務專案清單.對應流水號
  72. FROM 業務專案清單 INNER JOIN 人員資料 ON 業務專案清單.對應流水號 = 人員資料.人員編號
  73. WHERE (業務專案清單.專案流水號 = '" & TextBox1.Text & "')"
  74. DGV3讀取後設定()
  75. End Sub
  76. Private Sub Set_grid3()
  77. DataGridView3.Columns(0).Width = 90 : DataGridView3.Columns(1).Width = 80 : DataGridView3.Columns(2).Visible = False
  78. DataGridView3.Columns(3).Visible = False : DataGridView3.Columns(4).Visible = False : DataGridView3.Columns(5).Visible = False
  79. DataGridView3.Columns(6).Visible = False : DataGridView3.Columns(7).Visible = False
  80. End Sub
  81. Private Sub DGV2讀取前設定()
  82. DataGridView2.DataSource = Nothing : ds1.Clear() : ds1.Reset()
  83. DataGridView2.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
  84. DataGridView2.ColumnHeadersHeight = 25
  85. DataGridView2.AllowUserToAddRows = False
  86. ConnOpen()
  87. End Sub
  88. Private Sub DGV2讀取後設定()
  89. CmdSet_For_DGV() : da.Fill(ds1) : DataGridView2.DataSource = ds1.Tables(0) : conn.Close() : Set_grid2()
  90. End Sub
  91. Private Sub 員工資料()
  92. DGV2讀取前設定()
  93. If PA = "" Then
  94. SQL1 = "SELECT 人員編號, 姓名, 性別, 出生年份, 手機, 薪資結構 FROM 人員資料"
  95. Else
  96. SQL1 = "SELECT 人員編號, 姓名, 性別, 出生年份, 手機, 薪資結構 FROM 人員資料 WHERE 人員編號 LIKE '%" & PA & "%' OR 姓名 LIKE '%" & PA & "%' OR 性別 LIKE '%" & PA & "%' " &
  97. "OR 籍貫 LIKE '%" & PA & "%' OR 出生年份 LIKE '%" & PA & "%' OR 證件 LIKE '%" & PA & "%' OR 証號 LIKE '%" & PA & "%' OR 手機 LIKE '%" & PA & "%' " &
  98. "OR 薪資結構 LIKE '%" & PA & "%' OR 薪資 LIKE '%" & PA & "%' OR 備註 LIKE '%" & PA & "%'"
  99. End If
  100. DGV2讀取後設定()
  101. End Sub
  102. Private Sub Set_grid2()
  103. DataGridView2.Columns(0).Width = 80 : DataGridView2.Columns(1).Width = 70 : DataGridView2.Columns(2).Width = 50
  104. DataGridView2.Columns(3).Visible = False : DataGridView2.Columns(4).Width = 100 : DataGridView2.Columns(5).Visible = False
  105. End Sub
  106. Private Sub ComboBox2下拉表單資料載入()
  107. conn.Close()
  108. ConnOpen()
  109. SQL1 = "SELECT 客户 FROM 客戶清單 ORDER BY 客户"
  110. CmdSet_For_dr()
  111. ComboBox2.Items.Clear()
  112. While (dr.Read()) : ComboBox2.Items.Add(dr("客户")) : End While
  113. conn.Close()
  114. End Sub
  115. Private Sub 業務專案建檔_Load(sender As Object, e As EventArgs) Handles MyBase.Load
  116. Me.MdiParent = GCM_ERP_SYS : Me.WindowState = 2 : Me.AutoScroll = True
  117. TextBox5.Visible = False : TextBox6.Enabled = False : TextBox7.Enabled = False : TextBox8.Visible = False
  118. TextBox11.Text = "0.00" : TextBox12.Text = "0.00" : TextBox13.Text = "0.00" : TextBox16.Text = "0"
  119. 讀取專案主檔() : 員工資料() : ComboBox2下拉表單資料載入()
  120. Target1 = Target & AA(4) & "/"
  121. WebBrowser3.Url = New Uri(Target1)
  122. If FolderBrowserDialog1.ShowDialog = DialogResult.OK Then
  123. WebBrowser1.Navigate(FolderBrowserDialog1.SelectedPath)
  124. End If
  125. End Sub
  126. Private Sub 登入閒置控制_MouseMove(sender As Object, e As EventArgs) Handles MyBase.MouseMove
  127. timeNow = 0
  128. GCM_ERP_SYS.Timer1.Enabled = False
  129. GCM_ERP_SYS.Timer1.Enabled = True
  130. End Sub
  131. Private Sub 登入閒置控制_KeyPress(sender As Object, e As EventArgs) Handles MyBase.KeyPress
  132. timeNow = 0
  133. GCM_ERP_SYS.Timer1.Enabled = False
  134. GCM_ERP_SYS.Timer1.Enabled = True
  135. End Sub
  136. Private Sub DataGridView1_RowPostPaint(ByVal sender As Object, ByVal e As DataGridViewRowPostPaintEventArgs) Handles DataGridView1.RowPostPaint
  137. Dim linePen As New Pen(Color.Blue, 2)
  138. If e.RowIndex = DataGridView1.Rows.Count - 1 Then
  139. Exit Sub
  140. Else
  141. If DataGridView1.Rows(e.RowIndex).Cells("立案").Value = True And DataGridView1.Rows(e.RowIndex).Cells("結案").Value = False Then
  142. Dim startX As Integer = IIf(DataGridView1.RowHeadersVisible, DataGridView1.RowHeadersWidth, 0)
  143. Dim startY As Integer = e.RowBounds.Top + e.RowBounds.Height - 1
  144. Dim endX As Integer = startX + DataGridView1.Columns.GetColumnsWidth(DataGridViewElementStates.Visible) - DataGridView1.HorizontalScrollingOffset
  145. e.Graphics.DrawLine(linePen, startX, startY, endX, startY)
  146. Exit Sub
  147. End If
  148. End If
  149. For i As Integer = 0 To DataGridView1.Rows.Count - 1
  150. If DataGridView1.Rows(i).Cells("幣別").Value.ToString = "TWD" Then
  151. DataGridView1.Rows(i).DefaultCellStyle.BackColor = Color.LightPink
  152. ElseIf DataGridView1.Rows(i).Cells("幣別").Value.ToString = "USD" Then
  153. DataGridView1.Rows(i).DefaultCellStyle.BackColor = Color.LightGreen
  154. ElseIf DataGridView1.Rows(i).Cells("幣別").Value.ToString = "RMB" Then
  155. DataGridView1.Rows(i).DefaultCellStyle.BackColor = Color.LightGoldenrodYellow
  156. ElseIf DataGridView1.Rows(i).Cells("幣別").Value.ToString = "HKD" Then
  157. DataGridView1.Rows(i).DefaultCellStyle.BackColor = Color.DarkBlue
  158. End If
  159. Next
  160. End Sub
  161. Private Sub DataGridView3_CellClick(ByVal sender As System.Object, ByVal e As DataGridViewCellEventArgs) Handles DataGridView3.CellClick
  162. If e.RowIndex = -1 Then : Else
  163. TextBox8.Text = DataGridView3.Rows(e.RowIndex).Cells("專案流水號").Value
  164. TextBox7.Text = DataGridView3.Rows(e.RowIndex).Cells("對應流水號").Value
  165. End If
  166. End Sub
  167. Private Sub DataGridView2_CellClick(ByVal sender As System.Object, ByVal e As DataGridViewCellEventArgs) Handles DataGridView2.CellClick
  168. If e.RowIndex = -1 Then : Else
  169. TextBox6.Text = DataGridView2(0, e.RowIndex).Value.ToString
  170. End If
  171. End Sub
  172. Private Sub DataGridView1_CellClick(ByVal sender As System.Object, ByVal e As DataGridViewCellEventArgs) Handles DataGridView1.CellClick
  173. If e.RowIndex = -1 Then : Else
  174. ComboBox2下拉表單資料載入()
  175. TextBox1.Text = DataGridView1.Rows(e.RowIndex).Cells("專案流水號").Value : TextBox2.Text = DataGridView1.Rows(e.RowIndex).Cells("專案內容").Value
  176. TextBox3.Text = DataGridView1.Rows(e.RowIndex).Cells("地點").Value : TextBox4.Text = DataGridView1.Rows(e.RowIndex).Cells("備註").Value
  177. TextBox16.Text = DataGridView1.Rows(e.RowIndex).Cells("執行天數").Value
  178. ComboBox3.Text = DataGridView1.Rows(e.RowIndex).Cells("專案性質").Value.ToString : ComboBox4.Text = DataGridView1.Rows(e.RowIndex).Cells("合約性質").Value.ToString
  179. ComboBox5.Text = DataGridView1.Rows(e.RowIndex).Cells("幣別").Value.ToString
  180. PA2 = DataGridView1.Rows(e.RowIndex).Cells("客戶").Value.ToString : ComboBox2.Text = DataGridView1.Rows(e.RowIndex).Cells("客戶").Value.ToString
  181. CheckBox10.Checked = DataGridView1.Rows(e.RowIndex).Cells("報價").Value
  182. DTP(2) = DataGridView1.Rows(e.RowIndex).Cells("報價日期").Value.ToString
  183. If DTP(2) = "" Then : DateTimePicker3.Format = DateTimePickerFormat.Custom : DateTimePicker3.CustomFormat = " "
  184. Else : DateTimePicker3.Format = DateTimePickerFormat.Short : DateTimePicker3.Text = DTP(2) : DateTimePicker3.Text = DateTimePicker3.Text : End If
  185. TextBox12.Text = Format(Val(DataGridView1.Rows(e.RowIndex).Cells("報價金額").Value), "#,##0.00")
  186. CheckBox11.Checked = DataGridView1.Rows(e.RowIndex).Cells("立案").Value
  187. DTP(0) = DataGridView1.Rows(e.RowIndex).Cells("立案日期").Value.ToString
  188. If DTP(0) = "" Then : DateTimePicker1.Format = DateTimePickerFormat.Custom : DateTimePicker1.CustomFormat = " "
  189. Else : DateTimePicker1.Format = DateTimePickerFormat.Short : DateTimePicker1.Text = DTP(0) : DateTimePicker1.Text = DateTimePicker1.Text : End If
  190. TextBox11.Text = Format(Val(DataGridView1.Rows(e.RowIndex).Cells("訂金").Value), "#,##0.00")
  191. CheckBox1.Checked = DataGridView1.Rows(e.RowIndex).Cells("結案").Value
  192. DTP(1) = DataGridView1.Rows(e.RowIndex).Cells("結案日期").Value.ToString
  193. If DTP(1) = "" Then : DateTimePicker2.Format = DateTimePickerFormat.Custom : DateTimePicker2.CustomFormat = " "
  194. Else : DateTimePicker2.Format = DateTimePickerFormat.Short : DateTimePicker2.Text = DTP(1) : DateTimePicker2.Text = DateTimePicker2.Text : End If
  195. TextBox13.Text = Format(Val(DataGridView1.Rows(e.RowIndex).Cells("應收尾款").Value), "#,##0.00")
  196. 讀取專案人事資料()
  197. Button5.Enabled = False
  198. CheckBox12.Checked = DataGridView1.Rows(e.RowIndex).Cells("建檔").Value
  199. If DataGridView1.Rows(e.RowIndex).Cells("建檔").Value = True Then
  200. Target1 = Target & AA(4) & "/" & DataGridView1.Rows(e.RowIndex).Cells("專案流水號").Value & "/"
  201. WebBrowser3.Url = New Uri(Target1)
  202. Else
  203. Target1 = Target & AA(4) & "/"
  204. WebBrowser3.Url = New Uri(Target1)
  205. End If
  206. ComboBox1.Text = DataGridView3.Rows.Count
  207. End If
  208. End Sub
  209. Private Sub DateTimePicker1_ValueChanged(sender As Object, e As EventArgs) Handles DateTimePicker1.MouseDown
  210. DateTimePicker1.Format = DateTimePickerFormat.Short
  211. End Sub
  212. Private Sub DateTimePicker2_ValueChanged(sender As Object, e As EventArgs) Handles DateTimePicker2.MouseDown
  213. DateTimePicker2.Format = DateTimePickerFormat.Short
  214. End Sub
  215. Private Sub DateTimePicker3_ValueChanged(sender As Object, e As EventArgs) Handles DateTimePicker3.MouseDown
  216. DateTimePicker3.Format = DateTimePickerFormat.Short
  217. End Sub
  218. Private Sub Button13_Click(sender As Object, e As EventArgs) Handles Button13.Click
  219. DateTimePicker1.Format = DateTimePickerFormat.Custom : DateTimePicker1.CustomFormat = " "
  220. End Sub
  221. Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
  222. DateTimePicker2.Format = DateTimePickerFormat.Custom : DateTimePicker2.CustomFormat = " "
  223. End Sub
  224. Private Sub Button9_Click(sender As Object, e As EventArgs) Handles Button9.Click
  225. DateTimePicker3.Format = DateTimePickerFormat.Custom : DateTimePicker3.CustomFormat = " "
  226. End Sub
  227. Private Sub Button10_Click(sender As Object, e As EventArgs) Handles Button10.Click
  228. Target1 = Target & AA(4) & "/"
  229. WebBrowser3.Url = New Uri(Target1)
  230. End Sub
  231. Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
  232. PA = InputBox("請輸入要查詢的資料") : 員工資料() : PA = ""
  233. End Sub
  234. Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
  235. PA = InputBox("請輸入要查詢的資料") : 讀取專案主檔() : PA = ""
  236. End Sub
  237. Private Sub Button14_Click(sender As Object, e As EventArgs) Handles Button14.Click
  238. If FolderBrowserDialog1.ShowDialog = DialogResult.OK Then
  239. WebBrowser1.Navigate(FolderBrowserDialog1.SelectedPath)
  240. End If
  241. End Sub
  242. Private Sub Button8_Click(sender As Object, e As EventArgs) Handles Button8.Click
  243. TextBox1.Text = "" : TextBox2.Text = "" : TextBox3.Text = "" : TextBox4.Text = ""
  244. TextBox11.Text = "0.00" : TextBox12.Text = "0.00" : TextBox13.Text = "0.00" : TextBox16.Text = "0"
  245. CheckBox1.Checked = False : CheckBox10.Checked = False : CheckBox11.Checked = False
  246. DateTimePicker1.Format = DateTimePickerFormat.Custom : DateTimePicker1.CustomFormat = " "
  247. DateTimePicker2.Format = DateTimePickerFormat.Custom : DateTimePicker2.CustomFormat = " "
  248. DateTimePicker3.Format = DateTimePickerFormat.Custom : DateTimePicker3.CustomFormat = " "
  249. Button5.Enabled = True
  250. End Sub
  251. Private Sub Set_日期格式轉換()
  252. DTP(0) = DateTimePicker1.Text : DTP(1) = DateTimePicker2.Text : DTP(2) = DateTimePicker3.Text
  253. If DTP(0) = " " Then : DTP(0) = "" : Else : DTP(0) = Format(DateTimePicker1.Value, "yyyy/MM/dd") : End If
  254. If DTP(1) = " " Then : DTP(1) = "" : Else : DTP(1) = Format(DateTimePicker2.Value, "yyyy/MM/dd") : End If
  255. If DTP(2) = " " Then : DTP(2) = "" : Else : DTP(2) = Format(DateTimePicker3.Value, "yyyy/MM/dd") : End If
  256. End Sub
  257. Private Sub Button6_Click(sender As Object, e As EventArgs) Handles Button6.Click
  258. ConnOpen()
  259. Set_日期格式轉換()
  260. SQL1 = "UPDATE 業務專案主檔 SET 專案內容 = N'" & TextBox2.Text & "', 專案性質 = N'" & ComboBox3.Text & "', 合約性質 = N'" & ComboBox4.Text & "', 備註 = '" & TextBox4.Text &
  261. "', 專案人數 = '" & ComboBox1.Text & "', 執行天數 = '" & TextBox16.Text & "', 地點 = '" & TextBox3.Text & "', 報價 = '" & CheckBox10.Checked &
  262. "', 報價日期 = '" & DTP(2) & "', 專案成本 = '" & TextBox12.Text & "', 立案 = '" & CheckBox11.Checked & "', 立案日期 = '" & DTP(0) &
  263. "', 收款金額 = '" & TextBox11.Text & "', 結案 = '" & CheckBox1.Checked & "', 結案日期 = '" & DTP(1) &
  264. "', 應收金額 = '" & TextBox13.Text & "', 幣別 = '" & ComboBox5.Text & "', 建檔 = '" & CheckBox12.Checked & "', 客戶 = N'" & ComboBox2.Text & "'
  265. WHERE 專案流水號 LIKE '" & TextBox1.Text & "'"
  266. cmd.CommandText = SQL1 : cmd.ExecuteNonQuery()
  267. MsgBox("修改完成")
  268. conn.Close()
  269. 讀取專案主檔()
  270. End Sub
  271. Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
  272. Dim aa1 As MsgBoxResult
  273. aa1 = MsgBox("確定要刪除該筆資料?", MsgBoxStyle.OkCancel)
  274. If aa1 = MsgBoxResult.Ok Then
  275. ConnOpen()
  276. SQL1 = "DELETE FROM 業務專案主檔 WHERE (專案流水號 = '" & TextBox1.Text & "')"
  277. cmd.CommandText = SQL1 : cmd.Connection = conn : cmd.ExecuteNonQuery() : conn.Close()
  278. ConnOpen()
  279. SQL1 = "DELETE FROM 業務專案清單 WHERE (專案流水號 = '" & TextBox1.Text & "')"
  280. cmd.CommandText = SQL1 : cmd.Connection = conn : cmd.ExecuteNonQuery() : conn.Close()
  281. '------------------FTP刪除資料夾-----------------------------------------------------------------------------------------
  282. Dim frq As FtpWebRequest, fcr As NetworkCredential
  283. frq = CType(WebRequest.Create(New Uri(Target & AA(4) & "/" & TextBox1.Text)), FtpWebRequest)
  284. fcr = New NetworkCredential(FTP帳號, FTP密碼)
  285. Dim frp As FtpWebResponse
  286. frq.Credentials = fcr '认证信息
  287. frq.Method = WebRequestMethods.Ftp.RemoveDirectory
  288. frp = CType(frq.GetResponse, FtpWebResponse) '发送、操作、并返回
  289. frp.Close()
  290. MsgBox("刪除完成")
  291. End If
  292. 讀取專案主檔()
  293. End Sub
  294. Private Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click
  295. Dim NUM1 As Integer
  296. For NUM1 = 0 To 99999999
  297. If NUM1 < 10 Then : TextBox1.Text = "BP" & "0000000" & NUM1
  298. ElseIf NUM1 > 9 And NUM1 < 100 Then : TextBox1.Text = "BP" & "000000" & NUM1
  299. ElseIf NUM1 > 99 And NUM1 < 1000 Then : TextBox1.Text = "BP" & "00000" & NUM1
  300. ElseIf NUM1 > 999 And NUM1 < 10000 Then : TextBox1.Text = "BP" & "0000" & NUM1
  301. ElseIf NUM1 > 9999 And NUM1 < 100000 Then : TextBox1.Text = "BP" & "000" & NUM1
  302. ElseIf NUM1 > 99999 And NUM1 < 1000000 Then : TextBox1.Text = "BP" & "00" & NUM1
  303. ElseIf NUM1 > 999999 And NUM1 < 10000000 Then : TextBox1.Text = "BP" & "0" & NUM1
  304. ElseIf NUM1 > 9999999 Then : TextBox1.Text = "BP" & NUM1 : End If
  305. ConnOpen()
  306. SQL1 = "SELECT 專案流水號 FROM 業務專案主檔 WHERE (專案流水號 ='" & TextBox1.Text & "')"
  307. CmdSet_For_dr()
  308. If dr.Read() Then : TextBox1.Text = dr("專案流水號").ToString : TextBox5.Text = "NO" : Else : TextBox5.Text = "" : End If
  309. conn.Close()
  310. If TextBox5.Text = "" Then : NUM1 = 99999999 : End If
  311. Next
  312. Set_日期格式轉換()
  313. ConnOpen()
  314. SQL1 = "INSERT INTO 業務專案主檔 (專案流水號, 專案內容, 專案性質, 合約性質, 備註, 專案人數, 執行天數, 地點, 報價, 報價日期, 專案成本, 立案, 立案日期, 收款金額, 結案,
  315. 結案日期, 應收金額, 幣別, 建檔, 客戶) " &
  316. "VALUES (N'" & TextBox1.Text & "', N'" & TextBox2.Text & "', N'" & ComboBox3.Text & "', N'" & ComboBox4.Text & "', N'" & TextBox4.Text & "', N'" & ComboBox1.Text &
  317. "', N'" & TextBox16.Text & "', N'" & TextBox3.Text & "', N'" & CheckBox10.Checked & "', N'" & DTP(2) & "', N'" & TextBox12.Text & "', N'" & CheckBox11.Checked &
  318. "', N'" & DTP(0) & "', N'" & TextBox11.Text & "', N'" & CheckBox1.Checked & "', N'" & DTP(1) & "', N'" & TextBox13.Text & "', N'" & ComboBox5.Text &
  319. "', N'" & CheckBox12.Checked & "', N'" & ComboBox2.Text & "')"
  320. cmd.Connection = conn : cmd.CommandText = SQL1 : cmd.ExecuteNonQuery() : conn.Close()
  321. '------------------FTP新增資料夾-----------------------------------------------------------------------------------------
  322. Dim frq As FtpWebRequest, fcr As NetworkCredential
  323. frq = CType(WebRequest.Create(New Uri(Target & AA(4) & "/" & TextBox1.Text)), FtpWebRequest)
  324. fcr = New NetworkCredential(FTP帳號, FTP密碼)
  325. Dim frp As FtpWebResponse
  326. frq.Credentials = fcr '认证信息
  327. frq.Method = WebRequestMethods.Ftp.MakeDirectory
  328. frp = CType(frq.GetResponse, FtpWebResponse) '发送、操作、并返回
  329. frp.Close()
  330. MsgBox("新增完成")
  331. 讀取專案主檔()
  332. End Sub
  333. Private Sub Button7_Click(sender As Object, e As EventArgs) Handles Button7.Click
  334. If TextBox1.Text = "" Or TextBox6.Text = "" Then
  335. MsgBox("請正確選擇資料")
  336. Else
  337. ConnOpen()
  338. SQL1 = "SELECT 專案流水號, 對應流水號 FROM 業務專案清單 WHERE (專案流水號 ='" & TextBox1.Text & "') AND (對應流水號 ='" & TextBox6.Text & "')"
  339. CmdSet_For_dr()
  340. If dr.Read() Then
  341. MsgBox("資料已經存在")
  342. Else
  343. TextBox5.Text = "YES"
  344. End If
  345. conn.Close()
  346. If TextBox5.Text = "YES" Then
  347. ConnOpen()
  348. SQL1 = "INSERT INTO 業務專案清單 (專案流水號, 對應流水號, 設計天數) VALUES ('" & TextBox1.Text & "','" & TextBox6.Text & "','0')"
  349. cmd.Connection = conn : cmd.CommandText = SQL1 : cmd.ExecuteNonQuery()
  350. MsgBox("新增完成")
  351. conn.Close()
  352. 讀取專案人事資料()
  353. Else
  354. End If
  355. End If
  356. End Sub
  357. Private Sub Button11_Click(sender As Object, e As EventArgs) Handles Button11.Click
  358. Dim aa As MsgBoxResult
  359. aa = MsgBox("確定要刪除該筆資料?", MsgBoxStyle.OkCancel)
  360. If aa = MsgBoxResult.Ok Then
  361. ConnOpen()
  362. SQL1 = "DELETE FROM 業務專案清單 WHERE (專案流水號 = '" & TextBox8.Text & "') AND (對應流水號 = '" & TextBox7.Text & "')"
  363. cmd.CommandText = SQL1 : cmd.Connection = conn : cmd.ExecuteNonQuery() : conn.Close()
  364. MsgBox("刪除完成")
  365. End If
  366. 讀取專案人事資料()
  367. ComboBox1.Text = DataGridView3.Rows.Count
  368. ConnOpen()
  369. SQL1 = "UPDATE 業務專案主檔 SET 專案人數 = '" & ComboBox1.Text & "' WHERE 專案流水號 LIKE '" & TextBox1.Text & "'"
  370. cmd.Connection = conn : cmd.CommandText = SQL1 : cmd.ExecuteNonQuery() : conn.Close()
  371. 讀取專案主檔()
  372. End Sub
  373. Private Sub Button12_Click(sender As Object, e As EventArgs) Handles Button12.Click
  374. WebBrowser1.GoBack()
  375. End Sub
  376. Private Sub Button15_Click(sender As Object, e As EventArgs) Handles Button15.Click
  377. WebBrowser1.GoForward()
  378. End Sub
  379. Private Sub Button17_Click(sender As Object, e As EventArgs) Handles Button17.Click
  380. WebBrowser3.GoBack()
  381. End Sub
  382. Private Sub Button16_Click(sender As Object, e As EventArgs) Handles Button16.Click
  383. WebBrowser3.GoForward()
  384. End Sub
  385. Private Sub Button19_Click(sender As Object, e As EventArgs) Handles Button19.Click
  386. ComboBox2下拉表單資料載入()
  387. End Sub
  388. Private Sub Button20_Click(sender As Object, e As EventArgs) Handles Button20.Click
  389. 讀取專案主檔()
  390. End Sub
  391. Private Sub Button18_Click(sender As Object, e As EventArgs) Handles Button18.Click
  392. If ComboBox3.Text = "" Or PA2 = "" Then
  393. MsgBox("沒有選擇專案。")
  394. ElseIf ComboBox3.Text = "軟體設計" And PA2 <> "" Then
  395. 系統開發功能點檢表.Close() : 系統開發功能點檢表.Show() : 系統開發功能點檢表.BringToFront()
  396. Else
  397. MsgBox("軟體設計以外的專案還未開發。")
  398. End If
  399. End Sub
  400. End Class