Keine Beschreibung
Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

業務專案控制表.vb 30KB

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