Без опису
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. Option Strict Off
  2. Imports System.Data.SqlClient
  3. Public Class 匯率修改
  4. ReadOnly ds As New DataSet
  5. Private Sub Set_grid()
  6. DataGridView4.Columns(0).FillWeight = 60 : DataGridView4.Columns(1).FillWeight = 60
  7. DataGridView4.Columns(2).FillWeight = 60 : DataGridView4.Columns(3).FillWeight = 60
  8. DataGridView4.Columns(4).FillWeight = 60 : DataGridView4.Columns(5).FillWeight = 60
  9. End Sub
  10. Private Sub Set_日期()
  11. TextBox4.Text = Format(DateTimePicker1.Value, "yyyy") : TextBox5.Text = Format(DateTimePicker1.Value, "MM")
  12. End Sub
  13. Private Sub Set_歷史匯率清單()
  14. DataGridView4.DataSource = Nothing : ds.Clear()
  15. DataGridView4.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
  16. DataGridView4.ColumnHeadersHeight = 25
  17. DataGridView4.AllowUserToAddRows = False
  18. ConnOpen()
  19. SQL1 = "SELECT 年, 月, 買進匯率, 賣出匯率, 中心匯率, 美金匯率 FROM 歷史匯率表 ORDER BY 年 DESC, 月 DESC"
  20. CmdSet_For_DGV() : da.Fill(ds) : DataGridView4.DataSource = ds.Tables(0) : conn.Close()
  21. End Sub
  22. Private Sub DataGridView4_CellClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView4.CellClick
  23. If e.RowIndex = -1 Then : Else
  24. TextBox2.Text = DataGridView4(2, e.RowIndex).Value.ToString
  25. TextBox3.Text = DataGridView4(3, e.RowIndex).Value.ToString
  26. TextBox1.Text = DataGridView4(4, e.RowIndex).Value.ToString
  27. TextBox6.Text = DataGridView4(5, e.RowIndex).Value.ToString
  28. End If
  29. End Sub
  30. Private Sub Set_日期寫入()
  31. Set_日期()
  32. ConnOpen()
  33. SQL1 = "SELECT 買進匯率, 賣出匯率, 中心匯率 FROM 歷史匯率表 WHERE (年 LIKE '" & TextBox4.Text & "%') AND (月 LIKE '" & TextBox5.Text & "%')"
  34. CmdSet_For_dr()
  35. If dr.Read() Then
  36. ConnOpen()
  37. SQL1 = "UPDATE 歷史匯率表 SET 買進匯率 = '" & TextBox2.Text & "', 賣出匯率 = '" & TextBox3.Text & "', 中心匯率 = '" & TextBox1.Text & "', 美金匯率 = '" & TextBox6.Text & "'
  38. WHERE (年 LIKE '" & TextBox4.Text & "%') AND (月 LIKE '" & TextBox5.Text & "%')"
  39. CmdSet_For_dr() : conn.Close()
  40. Else
  41. ConnOpen()
  42. SQL1 = "INSERT INTO 歷史匯率表 (年, 月, 買進匯率, 賣出匯率, 中心匯率, 美金匯率) VALUES ('" & TextBox4.Text & "','" & TextBox5.Text & "
  43. ','" & TextBox2.Text & "', '" & TextBox3.Text & "', '" & TextBox1.Text & "', '" & TextBox6.Text & "')"
  44. CmdSet_For_dr() : conn.Close()
  45. End If : conn.Close() : MsgBox("完成")
  46. End Sub
  47. Private Sub 匯率修改_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  48. DateTimePicker1.Value = Today
  49. ConnOpen()
  50. SQL1 = "SELECT 匯率 FROM 匯率表 WHERE (對應 = '人民幣兌台幣')"
  51. CmdSet_For_dr()
  52. If dr.Read() Then : TextBox1.Text = dr("匯率").ToString : End If
  53. If TextBox1.Text = "" Then : TextBox1.Text = "0.00" : End If
  54. conn.Close() : dr.Close()
  55. ConnOpen()
  56. SQL1 = "SELECT 買進匯率, 賣出匯率, 美金匯率 FROM 歷史匯率表 WHERE (年 LIKE '" & TextBox4.Text & "%') AND (月 LIKE '" & TextBox5.Text & "%')"
  57. CmdSet_For_dr()
  58. If dr.Read() Then : TextBox2.Text = dr("買進匯率").ToString : TextBox3.Text = dr("賣出匯率").ToString : TextBox3.Text = dr("美金匯率").ToString : End If
  59. If TextBox1.Text = "" Then : TextBox1.Text = "0.00" : End If
  60. conn.Close() : dr.Close()
  61. Set_歷史匯率清單() : Set_grid() : Set_日期()
  62. End Sub
  63. Private Sub 登入閒置控制_MouseMove(sender As Object, e As EventArgs) Handles MyBase.MouseMove
  64. timeNow = 0
  65. GCM_ERP_SYS.Timer1.Enabled = False
  66. GCM_ERP_SYS.Timer1.Enabled = True
  67. End Sub
  68. Private Sub 登入閒置控制_KeyPress(sender As Object, e As EventArgs) Handles MyBase.KeyPress
  69. timeNow = 0
  70. GCM_ERP_SYS.Timer1.Enabled = False
  71. GCM_ERP_SYS.Timer1.Enabled = True
  72. End Sub
  73. Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
  74. TextBox1.Enabled = True : TextBox2.Enabled = True : TextBox3.Enabled = True : TextBox6.Enabled = True : Button4.Enabled = True : Button5.Enabled = True
  75. End Sub
  76. Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
  77. TextBox1.Enabled = False : TextBox2.Enabled = False : TextBox3.Enabled = False : TextBox6.Enabled = False : Button4.Enabled = False : Button5.Enabled = False
  78. End Sub
  79. Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
  80. If TextBox1.Text = "" Or TextBox2.Text = "" Or TextBox3.Text = "" Then
  81. MsgBox("輸入資料有誤")
  82. Else
  83. If CheckBox1.Checked = False Then
  84. DateTimePicker1.Value = Today
  85. Set_日期寫入()
  86. ConnOpen()
  87. SQL1 = "UPDATE 匯率表 SET 匯率 = '" & TextBox1.Text & "' WHERE (對應 = '人民幣兌台幣')"
  88. CmdSet_For_dr() : conn.Close() : dr.Close()
  89. Else
  90. Set_日期寫入()
  91. End If
  92. End If
  93. TextBox1.Enabled = False : TextBox2.Enabled = False : TextBox3.Enabled = False : TextBox6.Enabled = False : Button4.Enabled = False : Button5.Enabled = False
  94. Set_歷史匯率清單() : Set_grid() : Set_日期()
  95. End Sub
  96. Private Sub TextBox2_TextChanged(sender As Object, e As EventArgs) Handles TextBox2.TextChanged
  97. If TextBox2.Text <> "" And TextBox3.Text <> "" Then
  98. TextBox1.Text = (Val(TextBox2.Text) + Val(TextBox3.Text)) / 2
  99. End If
  100. End Sub
  101. Private Sub TextBox3_TextChanged(sender As Object, e As EventArgs) Handles TextBox3.TextChanged
  102. If TextBox2.Text <> "" And TextBox3.Text <> "" Then
  103. TextBox1.Text = (Val(TextBox2.Text) + Val(TextBox3.Text)) / 2
  104. End If
  105. End Sub
  106. End Class