Option Strict Off Imports System.Data.SqlClient Public Class 私有財務 Dim conn As New SqlConnection Dim da As New SqlDataAdapter Dim cmd As New SqlCommand Dim dr As SqlDataReader Dim conn1 As New SqlConnection Dim cmd1 As New SqlCommand Dim dr1 As SqlDataReader Dim ds As New DataSet Private Sub Set_匯總() If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If If conn1.State = ConnectionState.Closed Then : conn1.ConnectionString = ConString : conn1.Open() : End If SQL1 = "SELECT 匯率 FROM 匯率表 WHERE (對應 = '人民幣兌台幣')" SQL = "SELECT ROUND(SUM(CONVERT(FLOAT, 收入)) - SUM(CONVERT(FLOAT, 支出)), 2) AS 剩餘 From 流水帳 Where (類別 Like '互沖帳') AND " & "(明細 LIKE '%跟公司借款%' OR 明細 Like '%與公司還款%')" cmd.Connection = conn : cmd.CommandText = SQL : dr = cmd.ExecuteReader cmd1.Connection = conn1 : cmd1.CommandText = SQL1 : dr1 = cmd1.ExecuteReader If dr.Read() Then : TextBox60.Text = Format(Val(dr("剩餘").ToString), "#,##0.00") : End If If dr1.Read() Then : Label2.Text = dr1("匯率").ToString : End If ER = Double.Parse(dr1("匯率").ToString) conn.Close() : dr.Close() : conn1.Close() : dr1.Close() If conn1.State = ConnectionState.Closed Then : conn1.ConnectionString = ConString : conn1.Open() : End If SQL1 = "SELECT ROUND(SUM(CONVERT(FLOAT, 收入)) - SUM(CONVERT(FLOAT, 支出)), 2) AS 中國工商銀行總資產 FROM 流水帳 WHERE (銀行 LIKE '%中國工商銀行%')" cmd1.Connection = conn1 : cmd1.CommandText = SQL1 : dr1 = cmd1.ExecuteReader If dr1.Read() Then : R1 = Double.Parse(dr1("中國工商銀行總資產").ToString) : N1 = CDbl(CStr(Math.Round(ER * R1, 2))) Label99.Text = "¥" & Format(Val(dr1("中國工商銀行總資產").ToString), "#,##0.00") : Label134.Text = "$" & Format(Val(N1), "#,##0.00") : End If If Label99.Text = "¥" Or Label99.Text = "¥0.00" Then : Label99.Text = "¥0.00" : Label134.Text = "$ 0.00" : End If conn1.Close() : dr1.Close() If conn1.State = ConnectionState.Closed Then : conn1.ConnectionString = ConString : conn1.Open() : End If SQL1 = "SELECT ROUND(SUM(CONVERT(FLOAT, 收入)) - SUM(CONVERT(FLOAT, 支出)), 2) AS 農業銀行協叡總資產 FROM 流水帳 WHERE (銀行 LIKE '%農業銀行(協叡)%')" cmd1.Connection = conn1 : cmd1.CommandText = SQL1 : dr1 = cmd1.ExecuteReader If dr1.Read() Then : R2 = Double.Parse(dr1("農業銀行協叡總資產").ToString) : N2 = CDbl(CStr(Math.Round(ER * R2, 2))) Label100.Text = "¥" & Format(Val(dr1("農業銀行協叡總資產").ToString), "#,##0.00") : Label133.Text = "$" & Format(Val(N2), "#,##0.00") : End If If Label100.Text = "¥" Or Label100.Text = "¥0.00" Then : Label100.Text = "¥0.00" : Label133.Text = "$ 0.00" : End If conn1.Close() : dr1.Close() If conn1.State = ConnectionState.Closed Then : conn1.ConnectionString = ConString : conn1.Open() : End If SQL1 = "SELECT ROUND(SUM(CONVERT(FLOAT, 收入)) - SUM(CONVERT(FLOAT, 支出)), 2) AS 農業銀行福建叡 FROM 流水帳 WHERE (銀行 LIKE '%農業銀行福建叡%')" cmd1.Connection = conn1 : cmd1.CommandText = SQL1 : dr1 = cmd1.ExecuteReader If dr1.Read() Then : R3 = Double.Parse(dr1("農業銀行福建叡").ToString) : N3 = CDbl(CStr(Math.Round(ER * R3, 2))) Label101.Text = "¥" & Format(Val(dr1("農業銀行福建叡").ToString), "#,##0.00") : Label132.Text = "$" & Format(Val(N3), "#,##0.00") : End If If Label101.Text = "¥" Or Label101.Text = "¥0.00" Then : Label101.Text = "¥0.00" : Label132.Text = "$ 0.00" : End If conn1.Close() : dr1.Close() If conn1.State = ConnectionState.Closed Then : conn1.ConnectionString = ConString : conn1.Open() : End If SQL1 = "SELECT ROUND(SUM(CONVERT(FLOAT, 收入)) - SUM(CONVERT(FLOAT, 支出)), 2) AS 農業銀行肇慶叡 FROM 流水帳 WHERE (銀行 LIKE '%農業銀行肇慶叡%')" cmd1.Connection = conn1 : cmd1.CommandText = SQL1 : dr1 = cmd1.ExecuteReader If dr1.Read() Then : R4 = Double.Parse(dr1("農業銀行肇慶叡").ToString) : N4 = CDbl(CStr(Math.Round(ER * R4, 2))) Label102.Text = "¥" & Format(Val(dr1("農業銀行肇慶叡").ToString), "#,##0.00") : Label131.Text = "$" & Format(Val(N4), "#,##0.00") : End If If Label102.Text = "¥" Or Label102.Text = "¥0.00" Then : Label102.Text = "¥0.00" : Label131.Text = "$ 0.00" : End If conn1.Close() : dr1.Close() If conn1.State = ConnectionState.Closed Then : conn1.ConnectionString = ConString : conn1.Open() : End If SQL1 = "SELECT ROUND(SUM(CONVERT(FLOAT, 收入)) - SUM(CONVERT(FLOAT, 支出)), 2) AS 中國銀行總資產 FROM 流水帳 WHERE (銀行 LIKE '%中國銀行%')" cmd1.Connection = conn1 : cmd1.CommandText = SQL1 : dr1 = cmd1.ExecuteReader If dr1.Read() Then : R5 = Double.Parse(dr1("中國銀行總資產").ToString) : N5 = CDbl(CStr(Math.Round(ER * R5, 2))) Label103.Text = "¥" & Format(Val(dr1("中國銀行總資產").ToString), "#,##0.00") : Label130.Text = "$" & Format(Val(N5), "#,##0.00") : End If If Label103.Text = "¥" Or Label103.Text = "¥0.00" Then : Label103.Text = "¥0.00" : Label130.Text = "$ 0.00" : End If conn1.Close() : dr1.Close() If conn1.State = ConnectionState.Closed Then : conn1.ConnectionString = ConString : conn1.Open() : End If SQL1 = "SELECT ROUND(SUM(CONVERT(FLOAT, 收入)) - SUM(CONVERT(FLOAT, 支出)), 2) AS 農業銀行秀虹總資產 FROM 流水帳 WHERE (銀行 LIKE '%農業銀行(秀虹)%')" cmd1.Connection = conn1 : cmd1.CommandText = SQL1 : dr1 = cmd1.ExecuteReader If dr1.Read() Then : R6 = Double.Parse(dr1("農業銀行秀虹總資產").ToString) : N6 = CDbl(CStr(Math.Round(ER * R6, 2))) Label104.Text = "¥" & Format(Val(dr1("農業銀行秀虹總資產").ToString), "#,##0.00") : Label129.Text = "$" & Format(Val(N6), "#,##0.00") : End If If Label104.Text = "¥" Or Label104.Text = "¥0.00" Then : Label104.Text = "¥0.00" : Label129.Text = "$ 0.00" : End If conn1.Close() : dr1.Close() If conn1.State = ConnectionState.Closed Then : conn1.ConnectionString = ConString : conn1.Open() : End If SQL1 = "SELECT ROUND(SUM(CONVERT(FLOAT, 收入)) - SUM(CONVERT(FLOAT, 支出)), 2) AS 工行定存總資產 FROM 流水帳 WHERE (銀行 LIKE '%工行定存%')" cmd1.Connection = conn1 : cmd1.CommandText = SQL1 : dr1 = cmd1.ExecuteReader If dr1.Read() Then : R8 = Double.Parse(dr1("工行定存總資產").ToString) : N8 = CDbl(CStr(Math.Round(ER * R8, 2))) Label106.Text = "¥" & Format(Val(dr1("工行定存總資產").ToString), "#,##0.00") : Label127.Text = "$" & Format(Val(N8), "#,##0.00") : End If If Label106.Text = "¥" Or Label106.Text = "¥0.00" Then : Label106.Text = "¥0.00" : Label127.Text = "$ 0.00" : End If conn1.Close() : dr1.Close() If conn1.State = ConnectionState.Closed Then : conn1.ConnectionString = ConString : conn1.Open() : End If SQL1 = "SELECT ROUND(SUM(CONVERT(FLOAT, 收入)) - SUM(CONVERT(FLOAT, 支出)), 2) AS 農行協叡定存總資產 FROM 流水帳 WHERE (銀行 LIKE '%農行定存協叡%')" cmd1.Connection = conn1 : cmd1.CommandText = SQL1 : dr1 = cmd1.ExecuteReader If dr1.Read() Then : R9 = Double.Parse(dr1("農行協叡定存總資產").ToString) : N9 = CDbl(CStr(Math.Round(ER * R9, 2))) Label107.Text = "¥" & Format(Val(dr1("農行協叡定存總資產").ToString), "#,##0.00") : Label126.Text = "$" & Format(Val(N9), "#,##0.00") : End If If Label107.Text = "¥" Or Label107.Text = "¥0.00" Then : Label107.Text = "¥0.00" : Label126.Text = "$ 0.00" : End If conn1.Close() : dr1.Close() If conn1.State = ConnectionState.Closed Then : conn1.ConnectionString = ConString : conn1.Open() : End If SQL1 = "SELECT ROUND(SUM(CONVERT(FLOAT, 收入)) - SUM(CONVERT(FLOAT, 支出)), 2) AS 農行定存福建叡 FROM 流水帳 WHERE (銀行 LIKE '%農行定存福建叡%')" cmd1.Connection = conn1 : cmd1.CommandText = SQL1 : dr1 = cmd1.ExecuteReader If dr1.Read() Then : R10 = Double.Parse(dr1("農行定存福建叡").ToString) : N10 = CDbl(CStr(Math.Round(ER * R10, 2))) Label108.Text = "¥" & Format(Val(dr1("農行定存福建叡").ToString), "#,##0.00") : Label125.Text = "$" & Format(Val(N10), "#,##0.00") : End If If Label108.Text = "¥" Or Label108.Text = "¥0.00" Then : Label108.Text = "¥0.00" : Label125.Text = "$ 0.00" : End If conn1.Close() : dr1.Close() If conn1.State = ConnectionState.Closed Then : conn1.ConnectionString = ConString : conn1.Open() : End If SQL1 = "SELECT ROUND(SUM(CONVERT(FLOAT, 收入)) - SUM(CONVERT(FLOAT, 支出)), 2) AS 農行定存肇慶叡 FROM 流水帳 WHERE (銀行 LIKE '%農行定存肇慶叡%')" cmd1.Connection = conn1 : cmd1.CommandText = SQL1 : dr1 = cmd1.ExecuteReader If dr1.Read() Then : R11 = Double.Parse(dr1("農行定存肇慶叡").ToString) : N11 = CDbl(CStr(Math.Round(ER * R11, 2))) Label109.Text = "¥" & Format(Val(dr1("農行定存肇慶叡").ToString), "#,##0.00") : Label124.Text = "$" & Format(Val(N11), "#,##0.00") : End If If Label109.Text = "¥" Or Label109.Text = "¥0.00" Then : Label109.Text = "¥0.00" : Label124.Text = "$ 0.00" : End If conn1.Close() : dr1.Close() If conn1.State = ConnectionState.Closed Then : conn1.ConnectionString = ConString : conn1.Open() : End If SQL1 = "SELECT ROUND(SUM(CONVERT(FLOAT, 收入)) - SUM(CONVERT(FLOAT, 支出)), 2) AS 中行定存總資產 FROM 流水帳 WHERE (銀行 LIKE '%中行定存%')" cmd1.Connection = conn1 : cmd1.CommandText = SQL1 : dr1 = cmd1.ExecuteReader If dr1.Read() Then : R12 = Double.Parse(dr1("中行定存總資產").ToString) : N12 = CDbl(CStr(Math.Round(ER * R12, 2))) Label110.Text = "¥" & Format(Val(dr1("中行定存總資產").ToString), "#,##0.00") : Label123.Text = "$" & Format(Val(N12), "#,##0.00") : End If If Label110.Text = "¥" Or Label110.Text = "¥0.00" Then : Label110.Text = "¥0.00" : Label123.Text = "$ 0.00" : End If conn1.Close() : dr1.Close() If conn1.State = ConnectionState.Closed Then : conn1.ConnectionString = ConString : conn1.Open() : End If SQL1 = "SELECT ROUND(SUM(CONVERT(FLOAT, 收入)) - SUM(CONVERT(FLOAT, 支出)), 2) AS 農行秀虹定存總資產 FROM 流水帳 WHERE (銀行 LIKE '%農行定存秀虹%')" cmd1.Connection = conn1 : cmd1.CommandText = SQL1 : dr1 = cmd1.ExecuteReader If dr1.Read() Then : R13 = Double.Parse(dr1("農行秀虹定存總資產").ToString) : N13 = CDbl(CStr(Math.Round(ER * R13, 2))) Label111.Text = "¥" & Format(Val(dr1("農行秀虹定存總資產").ToString), "#,##0.00") : Label122.Text = "$" & Format(Val(N13), "#,##0.00") : End If If Label111.Text = "¥" Or Label111.Text = "¥0.00" Then : Label111.Text = "¥0.00" : Label122.Text = "$ 0.00" : End If conn1.Close() : dr1.Close() If conn1.State = ConnectionState.Closed Then : conn1.ConnectionString = ConString : conn1.Open() : End If SQL1 = "SELECT ROUND(SUM(CONVERT(FLOAT, 收入)) - SUM(CONVERT(FLOAT, 支出)), 2) AS 郵局協叡總資產 FROM 流水帳 WHERE (銀行 LIKE '%郵局(協叡)%')" cmd1.Connection = conn1 : cmd1.CommandText = SQL1 : dr1 = cmd1.ExecuteReader If dr1.Read() Then : N15 = Double.Parse(dr1("郵局協叡總資產").ToString) : R15 = CDbl(CStr(Math.Round(N15 / ER, 2))) Label113.Text = "$" & Format(Val(dr1("郵局協叡總資產").ToString), "#,##0.00") : Label142.Text = "¥" & Format(Val(R15), "#,##0.00") : End If If Label113.Text = "$" Or Label113.Text = "$0.00" Then : Label113.Text = "$0.00" : Label142.Text = "¥ 0.00" : End If conn1.Close() : dr1.Close() If conn1.State = ConnectionState.Closed Then : conn1.ConnectionString = ConString : conn1.Open() : End If SQL1 = "SELECT ROUND(SUM(CONVERT(FLOAT, 收入)) - SUM(CONVERT(FLOAT, 支出)), 2) AS 新光銀行協叡總資產 FROM 流水帳 WHERE (銀行 LIKE '%新光銀行(協叡)%')" cmd1.Connection = conn1 : cmd1.CommandText = SQL1 : dr1 = cmd1.ExecuteReader If dr1.Read() Then : N16 = Double.Parse(dr1("新光銀行協叡總資產").ToString) : R16 = CDbl(CStr(Math.Round(N16 / ER, 2))) Label114.Text = "$" & Format(Val(dr1("新光銀行協叡總資產").ToString), "#,##0.00") : Label141.Text = "¥" & Format(Val(R16), "#,##0.00") : End If If Label114.Text = "$" Or Label114.Text = "$0.00" Then : Label114.Text = "$0.00" : Label141.Text = "¥ 0.00" : End If conn1.Close() : dr1.Close() If conn1.State = ConnectionState.Closed Then : conn1.ConnectionString = ConString : conn1.Open() : End If SQL1 = "SELECT ROUND(SUM(CONVERT(FLOAT, 收入)) - SUM(CONVERT(FLOAT, 支出)), 2) AS 中國信託協叡總資產 FROM 流水帳 WHERE (銀行 LIKE '%中國信託(協叡)%')" cmd1.Connection = conn1 : cmd1.CommandText = SQL1 : dr1 = cmd1.ExecuteReader If dr1.Read() Then : N17 = Double.Parse(dr1("中國信託協叡總資產").ToString) : R17 = CDbl(CStr(Math.Round(N17 / ER, 2))) Label115.Text = "$" & Format(Val(dr1("中國信託協叡總資產").ToString), "#,##0.00") : Label140.Text = "¥" & Format(Val(R17), "#,##0.00") : End If If Label115.Text = "$" Or Label115.Text = "$0.00" Then : Label115.Text = "$0.00" : Label140.Text = "¥ 0.00" : End If conn1.Close() : dr1.Close() If conn1.State = ConnectionState.Closed Then : conn1.ConnectionString = ConString : conn1.Open() : End If SQL1 = "SELECT ROUND(SUM(CONVERT(FLOAT, 收入)) - SUM(CONVERT(FLOAT, 支出)), 2) AS 郵局秀虹總資產 FROM 流水帳 WHERE (銀行 LIKE '%郵局(秀虹)%')" cmd1.Connection = conn1 : cmd1.CommandText = SQL1 : dr1 = cmd1.ExecuteReader If dr1.Read() Then : N18 = Double.Parse(dr1("郵局秀虹總資產").ToString) : R18 = CDbl(CStr(Math.Round(N18 / ER, 2))) Label116.Text = "$" & Format(Val(dr1("郵局秀虹總資產").ToString), "#,##0.00") : Label139.Text = "¥" & Format(Val(R18), "#,##0.00") : End If If Label116.Text = "$" Or Label116.Text = "$0.00" Then : Label116.Text = "$0.00" : Label139.Text = "¥ 0.00" : End If conn1.Close() : dr1.Close() If conn1.State = ConnectionState.Closed Then : conn1.ConnectionString = ConString : conn1.Open() : End If SQL1 = "SELECT ROUND(SUM(CONVERT(FLOAT, 收入)) - SUM(CONVERT(FLOAT, 支出)), 2) AS 新光銀行秀虹總資產 FROM 流水帳 WHERE (銀行 LIKE '%新光銀行(秀虹)%')" cmd1.Connection = conn1 : cmd1.CommandText = SQL1 : dr1 = cmd1.ExecuteReader If dr1.Read() Then : N19 = Double.Parse(dr1("新光銀行秀虹總資產").ToString) : R19 = CDbl(CStr(Math.Round(N19 / ER, 2))) Label117.Text = "$" & Format(Val(dr1("新光銀行秀虹總資產").ToString), "#,##0.00") : Label138.Text = "¥" & Format(Val(R19), "#,##0.00") : End If If Label117.Text = "$" Or Label117.Text = "$0.00" Then : Label117.Text = "$0.00" : Label138.Text = "¥ 0.00" : End If conn1.Close() : dr1.Close() If conn1.State = ConnectionState.Closed Then : conn1.ConnectionString = ConString : conn1.Open() : End If SQL1 = "SELECT ROUND(SUM(CONVERT(FLOAT, 收入)) - SUM(CONVERT(FLOAT, 支出)), 2) AS 中國信託秀虹總資產 FROM 流水帳 WHERE (銀行 LIKE '%中國信託(秀虹)%')" cmd1.Connection = conn1 : cmd1.CommandText = SQL1 : dr1 = cmd1.ExecuteReader If dr1.Read() Then : N20 = Double.Parse(dr1("中國信託秀虹總資產").ToString) : R20 = CDbl(CStr(Math.Round(N20 / ER, 2))) Label118.Text = "$" & Format(Val(dr1("中國信託秀虹總資產").ToString), "#,##0.00") : Label137.Text = "¥" & Format(Val(R20), "#,##0.00") : End If If Label118.Text = "$" Or Label118.Text = "$0.00" Then : Label118.Text = "$0.00" : Label137.Text = "¥ 0.00" : End If conn1.Close() : dr1.Close() If conn1.State = ConnectionState.Closed Then : conn1.ConnectionString = ConString : conn1.Open() : End If SQL1 = "SELECT ROUND(SUM(CONVERT(FLOAT, 收入)) - SUM(CONVERT(FLOAT, 支出)), 2) AS 元大銀行 FROM 流水帳 WHERE (銀行 LIKE '%元大銀行%')" cmd1.Connection = conn1 : cmd1.CommandText = SQL1 : dr1 = cmd1.ExecuteReader If dr1.Read() Then : N21 = Double.Parse(dr1("元大銀行").ToString) : R21 = CDbl(CStr(Math.Round(N21 / ER, 2))) Label119.Text = "$" & Format(Val(dr1("元大銀行").ToString), "#,##0.00") : Label136.Text = "¥" & Format(Val(R21), "#,##0.00") : End If If Label119.Text = "$" Or Label119.Text = "$0.00" Then : Label119.Text = "$0.00" : Label136.Text = "¥ 0.00" : End If conn1.Close() : dr1.Close() If conn1.State = ConnectionState.Closed Then : conn1.ConnectionString = ConString : conn1.Open() : End If SQL1 = "SELECT ROUND(SUM(CONVERT(FLOAT, 收入)) - SUM(CONVERT(FLOAT, 支出)), 2) AS 元大證卷 FROM 流水帳 WHERE (銀行 LIKE '%元大證卷%')" cmd1.Connection = conn1 : cmd1.CommandText = SQL1 : dr1 = cmd1.ExecuteReader If dr1.Read() Then : N22 = Double.Parse(dr1("元大證卷").ToString) : R22 = CDbl(CStr(Math.Round(N22 / ER, 2))) Label120.Text = "$" & Format(Val(dr1("元大證卷").ToString), "#,##0.00") : Label135.Text = "¥" & Format(Val(R22), "#,##0.00") : End If If Label120.Text = "$" Or Label120.Text = "$0.00" Then : Label120.Text = "$0.00" : Label135.Text = "¥ 0.00" : End If conn1.Close() : dr1.Close() If conn1.State = ConnectionState.Closed Then : conn1.ConnectionString = ConString : conn1.Open() : End If SQL1 = "SELECT ROUND(SUM(CONVERT(FLOAT, 收入)) - SUM(CONVERT(FLOAT, 支出)), 2) AS 台幣現金總資產 FROM 流水帳 WHERE (銀行 LIKE '%台幣現金%')" cmd1.Connection = conn1 : cmd1.CommandText = SQL1 : dr1 = cmd1.ExecuteReader If dr1.Read() Then : N23 = Double.Parse(dr1("台幣現金總資產").ToString) : R23 = CDbl(CStr(Math.Round(N23 / ER, 2))) Label150.Text = "$" & Format(Val(dr1("台幣現金總資產").ToString), "#,##0.00") : Label148.Text = "¥" & Format(Val(R23), "#,##0.00") : End If If Label150.Text = "$" Or Label150.Text = "$0.00" Then : Label150.Text = "$0.00" : Label148.Text = "¥ 0.00" : End If conn1.Close() : dr1.Close() If conn1.State = ConnectionState.Closed Then : conn1.ConnectionString = ConString : conn1.Open() : End If SQL1 = "SELECT ROUND(SUM(CONVERT(FLOAT, 收入)) - SUM(CONVERT(FLOAT, 支出)), 2) AS 人民幣現金總資產 FROM 流水帳 WHERE (銀行 LIKE '%人民幣現金%')" cmd1.Connection = conn1 : cmd1.CommandText = SQL1 : dr1 = cmd1.ExecuteReader If dr1.Read() Then : R24 = Double.Parse(dr1("人民幣現金總資產").ToString) : N24 = CDbl(CStr(Math.Round(ER * R24, 2))) Label147.Text = "¥" & Format(Val(dr1("人民幣現金總資產").ToString), "#,##0.00") : Label149.Text = "$" & Format(Val(N24), "#,##0.00") : End If If Label147.Text = "¥" Or Label147.Text = "¥0.00" Then : Label147.Text = "¥0.00" : Label149.Text = "$ 0.00" : End If conn1.Close() : dr1.Close() Label161.Text = "$" & Format(Val(N1 + N2 + N3 + N4 + N5 + N6 + N8 + N9 + N10 + N11 + N12 + N13 + N15 + N16 + N17 + N18 + N19 + N20 + N21 + N22 + N23 + N24), "#,##0.00") SUM1 = N1 + N2 + N3 + N4 + N5 + N6 + N8 + N9 + N10 + N11 + N12 + N13 + N15 + N16 + N17 + N18 + N19 + N20 + N21 + N22 + N23 + N24 Label180.Text = CStr(Math.Round((N1 / SUM1) * 100, 2)) & "%" : Label179.Text = CStr(Math.Round((N2 / SUM1) * 100, 2)) & "%" Label178.Text = CStr(Math.Round((N3 / SUM1) * 100, 2)) & "%" : Label177.Text = CStr(Math.Round((N4 / SUM1) * 100, 2)) & "%" Label176.Text = CStr(Math.Round((N5 / SUM1) * 100, 2)) & "%" : Label175.Text = CStr(Math.Round((N6 / SUM1) * 100, 2)) & "%" Label173.Text = CStr(Math.Round((N8 / SUM1) * 100, 2)) & "%" : Label172.Text = CStr(Math.Round((N9 / SUM1) * 100, 2)) & "%" Label171.Text = CStr(Math.Round((N10 / SUM1) * 100, 2)) & "%" : Label170.Text = CStr(Math.Round((N11 / SUM1) * 100, 2)) & "%" Label169.Text = CStr(Math.Round((N12 / SUM1) * 100, 2)) & "%" : Label168.Text = CStr(Math.Round((N13 / SUM1) * 100, 2)) & "%" Label188.Text = CStr(Math.Round((N15 / SUM1) * 100, 2)) & "%" : Label187.Text = CStr(Math.Round((N16 / SUM1) * 100, 2)) & "%" Label186.Text = CStr(Math.Round((N17 / SUM1) * 100, 2)) & "%" : Label185.Text = CStr(Math.Round((N18 / SUM1) * 100, 2)) & "%" Label184.Text = CStr(Math.Round((N19 / SUM1) * 100, 2)) & "%" : Label183.Text = CStr(Math.Round((N20 / SUM1) * 100, 2)) & "%" Label182.Text = CStr(Math.Round((N21 / SUM1) * 100, 2)) & "%" : Label181.Text = CStr(Math.Round((N22 / SUM1) * 100, 2)) & "%" Label192.Text = CStr(Math.Round((N23 / SUM1) * 100, 2)) & "%" : Label191.Text = CStr(Math.Round((N24 / SUM1) * 100, 2)) & "%" Label160.Text = "¥" & Format(Val(R1 + R2 + R3 + R4 + R5 + R6 + R8 + R9 + R10 + R11 + R12 + R13 + R15 + R16 + R17 + R18 + R19 + R20 + R21 + R22 + R23 + R24), "#,##0.00") Label162.Text = "$" & Format(Val(N1 + N2 + N3 + N4 + N5 + N6 + N8 + N9 + N10 + N11 + N12 + N13), "#,##0.00") Label163.Text = "¥" & Format(Val(R1 + R2 + R3 + R4 + R5 + R6 + R8 + R9 + R10 + R11 + R12 + R13), "#,##0.00") SUM2 = R1 + R2 + R3 + R4 + R5 + R6 + R8 + R9 + R10 + R11 + R12 + R13 Label206.Text = CStr(Math.Round((R1 / SUM2) * 100, 2)) & "%" : Label205.Text = CStr(Math.Round((R2 / SUM2) * 100, 2)) & "%" Label204.Text = CStr(Math.Round((R3 / SUM2) * 100, 2)) & "%" : Label203.Text = CStr(Math.Round((R4 / SUM2) * 100, 2)) & "%" Label202.Text = CStr(Math.Round((R5 / SUM2) * 100, 2)) & "%" : Label201.Text = CStr(Math.Round((R6 / SUM2) * 100, 2)) & "%" Label199.Text = CStr(Math.Round((R8 / SUM2) * 100, 2)) & "%" : Label198.Text = CStr(Math.Round((R9 / SUM2) * 100, 2)) & "%" Label197.Text = CStr(Math.Round((R10 / SUM2) * 100, 2)) & "%" : Label196.Text = CStr(Math.Round((R11 / SUM2) * 100, 2)) & "%" Label195.Text = CStr(Math.Round((R12 / SUM2) * 100, 2)) & "%" : Label194.Text = CStr(Math.Round((R13 / SUM2) * 100, 2)) & "%" Label165.Text = "$" & N15 + N16 + N17 + N18 + N19 + N20 + N21 + N22 + N23 + N24 SUM3 = N15 + N16 + N17 + N18 + N19 + N20 + N21 + N22 Label214.Text = CStr(Math.Round((N15 / SUM3) * 100, 2)) & "%" : Label213.Text = CStr(Math.Round((N16 / SUM3) * 100, 2)) & "%" Label212.Text = CStr(Math.Round((N17 / SUM3) * 100, 2)) & "%" : Label211.Text = CStr(Math.Round((N18 / SUM3) * 100, 2)) & "%" Label210.Text = CStr(Math.Round((N19 / SUM3) * 100, 2)) & "%" : Label209.Text = CStr(Math.Round((N20 / SUM3) * 100, 2)) & "%" Label208.Text = CStr(Math.Round((N21 / SUM3) * 100, 2)) & "%" : Label207.Text = CStr(Math.Round((N22 / SUM3) * 100, 2)) & "%" Label164.Text = "¥" & Format(Val(R15 + R16 + R17 + R18 + R19 + R20 + R21 + R22 + R23 + R24), "#,##0.00") End Sub Private Sub Set_明細() Dim 薪資收入 As Double : Dim 其他收入 As Double : Dim 利息 As Double : Dim 加總1 As Double : Dim 加總2 As Double Dim 交通費 As Double : Dim 住宿費 As Double : Dim 伙食費 As Double : Dim 娛樂費 As Double : Dim 家用費 As Double : Dim 醫療費 As Double : Dim 務公費 As Double Dim 交際費 As Double : Dim 其他支出 As Double : Dim 手續費 As Double DataGridView1.DataSource = Nothing : ds.Clear() DataGridView1.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing DataGridView1.ColumnHeadersHeight = 25 DataGridView1.AllowUserToAddRows = False If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If If TextBox2.Text = "" Then SQL = "SELECT 流水號, 銀行, 日期, 類別, 明細, 收入, 支出 FROM 流水帳 WHERE (銀行 LIKE '%人民幣現金%') ORDER BY CONVERT(date, 日期) DESC" ElseIf TextBox2.Text <> "" Then SQL = "SELECT 流水號, 銀行, 日期, 類別, 明細, 收入, 支出 FROM 流水帳 WHERE (銀行 LIKE '" & TextBox2.Text & "') ORDER BY CONVERT(date, 日期) DESC" End If cmd.Connection = conn : cmd.CommandText = SQL : da.SelectCommand = cmd : da.Fill(ds) : DataGridView1.DataSource = ds.Tables(0) : conn.Close() If conn1.State = ConnectionState.Closed Then : conn1.ConnectionString = ConString : conn1.Open() : End If If TextBox2.Text = "" Then SQL1 = "SELECT SUM(CONVERT(FLOAT, 收入)) AS 薪資收入 FROM 流水帳 WHERE (銀行 LIKE '%人民幣現金%') AND (類別 LIKE '%薪資收入%')" ElseIf TextBox2.Text <> "" Then SQL1 = "SELECT SUM(CONVERT(FLOAT, 收入)) AS 薪資收入 FROM 流水帳 WHERE (銀行 LIKE '" & TextBox2.Text & "') AND (類別 LIKE '%薪資收入%')" End If cmd1.Connection = conn1 : cmd1.CommandText = SQL1 : dr1 = cmd1.ExecuteReader If dr1.Read() Then : 薪資收入 = Format(Val(dr1("薪資收入").ToString), "#,##0.00") : End If TextBox26.Text = Format(Val(薪資收入), "#,##0.00") conn1.Close() : dr1.Close() If conn1.State = ConnectionState.Closed Then : conn1.ConnectionString = ConString : conn1.Open() : End If If TextBox2.Text = "" Then SQL1 = "SELECT SUM(CONVERT(FLOAT, 收入)) AS 其他收入 FROM 流水帳 WHERE (銀行 LIKE '%人民幣現金%') AND (類別 LIKE '%其他收入%')" ElseIf TextBox2.Text <> "" Then SQL1 = "SELECT SUM(CONVERT(FLOAT, 收入)) AS 其他收入 FROM 流水帳 WHERE (銀行 LIKE '" & TextBox2.Text & "') AND (類別 LIKE '%其他收入%')" End If cmd1.Connection = conn1 : cmd1.CommandText = SQL1 : dr1 = cmd1.ExecuteReader If dr1.Read() Then : 其他收入 = Format(Val(dr1("其他收入").ToString), "#,##0.00") : End If TextBox27.Text = Format(Val(其他收入), "#,##0.00") conn1.Close() : dr1.Close() If conn1.State = ConnectionState.Closed Then : conn1.ConnectionString = ConString : conn1.Open() : End If If TextBox2.Text = "" Then SQL1 = "SELECT SUM(CONVERT(FLOAT, 收入)) AS 利息 FROM 流水帳 WHERE (銀行 LIKE '%人民幣現金%') AND (類別 LIKE '%利息%')" ElseIf TextBox2.Text <> "" Then SQL1 = "SELECT SUM(CONVERT(FLOAT, 收入)) AS 利息 FROM 流水帳 WHERE (銀行 LIKE '" & TextBox2.Text & "') AND (類別 LIKE '%利息%')" End If cmd1.Connection = conn1 : cmd1.CommandText = SQL1 : dr1 = cmd1.ExecuteReader If dr1.Read() Then : 利息 = Format(Val(dr1("利息").ToString), "#,##0.00") : End If TextBox28.Text = Format(Val(利息), "#,##0.00") conn1.Close() : dr1.Close() 加總1 = CStr(Math.Round(Double.Parse(薪資收入) + Double.Parse(其他收入) + Double.Parse(利息), 2)) : TextBox40.Text = Format(Val(加總1), "#,##0.00") TextBox42.Text = CStr(Math.Round((Double.Parse(薪資收入) / Double.Parse(加總1)) * 100, 2)) TextBox43.Text = CStr(Math.Round((Double.Parse(其他收入) / Double.Parse(加總1)) * 100, 2)) TextBox44.Text = CStr(Math.Round((Double.Parse(利息) / Double.Parse(加總1)) * 100, 2)) If conn1.State = ConnectionState.Closed Then : conn1.ConnectionString = ConString : conn1.Open() : End If If TextBox2.Text = "" Then SQL1 = "SELECT SUM(CONVERT(FLOAT, 支出)) AS 交通費 FROM 流水帳 WHERE (銀行 LIKE '%人民幣現金%') AND (類別 LIKE '%交通費%')" ElseIf TextBox2.Text <> "" Then SQL1 = "SELECT SUM(CONVERT(FLOAT, 支出)) AS 交通費 FROM 流水帳 WHERE (銀行 LIKE '" & TextBox2.Text & "') AND (類別 LIKE '%交通費%')" End If cmd1.Connection = conn1 : cmd1.CommandText = SQL1 : dr1 = cmd1.ExecuteReader If dr1.Read() Then : 交通費 = Format(Val(dr1("交通費").ToString), "#,##0.00") : End If TextBox29.Text = Format(Val(交通費), "#,##0.00") conn1.Close() : dr1.Close() If conn1.State = ConnectionState.Closed Then : conn1.ConnectionString = ConString : conn1.Open() : End If If TextBox2.Text = "" Then SQL1 = "SELECT SUM(CONVERT(FLOAT, 支出)) AS 住宿費 FROM 流水帳 WHERE (銀行 LIKE '%人民幣現金%') AND (類別 LIKE '%住宿費%')" ElseIf TextBox2.Text <> "" Then SQL1 = "SELECT SUM(CONVERT(FLOAT, 支出)) AS 住宿費 FROM 流水帳 WHERE (銀行 LIKE '" & TextBox2.Text & "') AND (類別 LIKE '%住宿費%')" End If cmd1.Connection = conn1 : cmd1.CommandText = SQL1 : dr1 = cmd1.ExecuteReader If dr1.Read() Then : 住宿費 = Format(Val(dr1("住宿費").ToString), "#,##0.00") : End If TextBox30.Text = Format(Val(住宿費), "#,##0.00") conn1.Close() : dr1.Close() If conn1.State = ConnectionState.Closed Then : conn1.ConnectionString = ConString : conn1.Open() : End If If TextBox2.Text = "" Then SQL1 = "SELECT SUM(CONVERT(FLOAT, 支出)) AS 伙食費 FROM 流水帳 WHERE (銀行 LIKE '%人民幣現金%') AND (類別 LIKE '%伙食費%')" ElseIf TextBox2.Text <> "" Then SQL1 = "SELECT SUM(CONVERT(FLOAT, 支出)) AS 伙食費 FROM 流水帳 WHERE (銀行 LIKE '" & TextBox2.Text & "') AND (類別 LIKE '%伙食費%')" End If cmd1.Connection = conn1 : cmd1.CommandText = SQL1 : dr1 = cmd1.ExecuteReader If dr1.Read() Then : 伙食費 = Format(Val(dr1("伙食費").ToString), "#,##0.00") : End If TextBox31.Text = Format(Val(伙食費), "#,##0.00") conn1.Close() : dr1.Close() If conn1.State = ConnectionState.Closed Then : conn1.ConnectionString = ConString : conn1.Open() : End If If TextBox2.Text = "" Then SQL1 = "SELECT SUM(CONVERT(FLOAT, 支出)) AS 娛樂費 FROM 流水帳 WHERE (銀行 LIKE '%人民幣現金%') AND (類別 LIKE '%娛樂費%')" ElseIf TextBox2.Text <> "" Then SQL1 = "SELECT SUM(CONVERT(FLOAT, 支出)) AS 娛樂費 FROM 流水帳 WHERE (銀行 LIKE '" & TextBox2.Text & "') AND (類別 LIKE '%娛樂費%')" End If cmd1.Connection = conn1 : cmd1.CommandText = SQL1 : dr1 = cmd1.ExecuteReader If dr1.Read() Then : 娛樂費 = Format(Val(dr1("娛樂費").ToString), "#,##0.00") : End If TextBox32.Text = Format(Val(娛樂費), "#,##0.00") conn1.Close() : dr1.Close() If conn1.State = ConnectionState.Closed Then : conn1.ConnectionString = ConString : conn1.Open() : End If If TextBox2.Text = "" Then SQL1 = "SELECT SUM(CONVERT(FLOAT, 支出)) AS 家用費 FROM 流水帳 WHERE (銀行 LIKE '%人民幣現金%') AND (類別 LIKE '%家用費%')" ElseIf TextBox2.Text <> "" Then SQL1 = "SELECT SUM(CONVERT(FLOAT, 支出)) AS 家用費 FROM 流水帳 WHERE (銀行 LIKE '" & TextBox2.Text & "') AND (類別 LIKE '%家用費%')" End If cmd1.Connection = conn1 : cmd1.CommandText = SQL1 : dr1 = cmd1.ExecuteReader If dr1.Read() Then : 家用費 = Format(Val(dr1("家用費").ToString), "#,##0.00") : End If TextBox33.Text = Format(Val(家用費), "#,##0.00") conn1.Close() : dr1.Close() If conn1.State = ConnectionState.Closed Then : conn1.ConnectionString = ConString : conn1.Open() : End If If TextBox2.Text = "" Then SQL1 = "SELECT SUM(CONVERT(FLOAT, 支出)) AS 醫療費 FROM 流水帳 WHERE (銀行 LIKE '%人民幣現金%') AND (類別 LIKE '%醫療費%')" ElseIf TextBox2.Text <> "" Then SQL1 = "SELECT SUM(CONVERT(FLOAT, 支出)) AS 醫療費 FROM 流水帳 WHERE (銀行 LIKE '" & TextBox2.Text & "') AND (類別 LIKE '%醫療費%')" End If cmd1.Connection = conn1 : cmd1.CommandText = SQL1 : dr1 = cmd1.ExecuteReader If dr1.Read() Then : 醫療費 = Format(Val(dr1("醫療費").ToString), "#,##0.00") : End If TextBox34.Text = Format(Val(醫療費), "#,##0.00") conn1.Close() : dr1.Close() If conn1.State = ConnectionState.Closed Then : conn1.ConnectionString = ConString : conn1.Open() : End If If TextBox2.Text = "" Then SQL1 = "SELECT SUM(CONVERT(FLOAT, 支出)) AS 務公費 FROM 流水帳 WHERE (銀行 LIKE '%人民幣現金%') AND (類別 LIKE '%務公費%')" ElseIf TextBox2.Text <> "" Then SQL1 = "SELECT SUM(CONVERT(FLOAT, 支出)) AS 務公費 FROM 流水帳 WHERE (銀行 LIKE '" & TextBox2.Text & "') AND (類別 LIKE '%務公費%')" End If cmd1.Connection = conn1 : cmd1.CommandText = SQL1 : dr1 = cmd1.ExecuteReader If dr1.Read() Then : 務公費 = Format(Val(dr1("務公費").ToString), "#,##0.00") : End If TextBox35.Text = Format(Val(務公費), "#,##0.00") conn1.Close() : dr1.Close() If conn1.State = ConnectionState.Closed Then : conn1.ConnectionString = ConString : conn1.Open() : End If If TextBox2.Text = "" Then SQL1 = "SELECT SUM(CONVERT(FLOAT, 支出)) AS 交際費 FROM 流水帳 WHERE (銀行 LIKE '%人民幣現金%') AND (類別 LIKE '%交際費%')" ElseIf TextBox2.Text <> "" Then SQL1 = "SELECT SUM(CONVERT(FLOAT, 支出)) AS 交際費 FROM 流水帳 WHERE (銀行 LIKE '" & TextBox2.Text & "') AND (類別 LIKE '%交際費%')" End If cmd1.Connection = conn1 : cmd1.CommandText = SQL1 : dr1 = cmd1.ExecuteReader If dr1.Read() Then : 交際費 = Format(Val(dr1("交際費").ToString), "#,##0.00") : End If TextBox36.Text = Format(Val(交際費), "#,##0.00") conn1.Close() : dr1.Close() If conn1.State = ConnectionState.Closed Then : conn1.ConnectionString = ConString : conn1.Open() : End If If TextBox2.Text = "" Then SQL1 = "SELECT SUM(CONVERT(FLOAT, 支出)) AS 其他支出 FROM 流水帳 WHERE (銀行 LIKE '%人民幣現金%') AND (類別 LIKE '%其他支出%')" ElseIf TextBox2.Text <> "" Then SQL1 = "SELECT SUM(CONVERT(FLOAT, 支出)) AS 其他支出 FROM 流水帳 WHERE (銀行 LIKE '" & TextBox2.Text & "') AND (類別 LIKE '%其他支出%')" End If cmd1.Connection = conn1 : cmd1.CommandText = SQL1 : dr1 = cmd1.ExecuteReader If dr1.Read() Then : 其他支出 = Format(Val(dr1("其他支出").ToString), "#,##0.00") : End If TextBox37.Text = Format(Val(其他支出), "#,##0.00") conn1.Close() : dr1.Close() If conn1.State = ConnectionState.Closed Then : conn1.ConnectionString = ConString : conn1.Open() : End If If TextBox2.Text = "" Then SQL1 = "SELECT SUM(CONVERT(FLOAT, 支出)) AS 手續費 FROM 流水帳 WHERE (銀行 LIKE '%人民幣現金%') AND (類別 LIKE '%手續費%')" ElseIf TextBox2.Text <> "" Then SQL1 = "SELECT SUM(CONVERT(FLOAT, 支出)) AS 手續費 FROM 流水帳 WHERE (銀行 LIKE '" & TextBox2.Text & "') AND (類別 LIKE '%手續費%')" End If cmd1.Connection = conn1 : cmd1.CommandText = SQL1 : dr1 = cmd1.ExecuteReader If dr1.Read() Then : 手續費 = Format(Val(dr1("手續費").ToString), "#,##0.00") : End If TextBox39.Text = Format(Val(手續費), "#,##0.00") conn1.Close() : dr1.Close() 加總2 = CStr(Math.Round(Double.Parse(交通費) + Double.Parse(住宿費) + Double.Parse(伙食費) + Double.Parse(娛樂費) + Double.Parse(家用費) + Double.Parse(醫療費) + Double.Parse(務公費) + Double.Parse(交際費) + Double.Parse(其他支出) + Double.Parse(手續費), 2)) TextBox41.Text = Format(Val(加總2), "#,##0.00") TextBox45.Text = CStr(Math.Round((Double.Parse(交通費) / Double.Parse(加總2)) * 100, 2)) TextBox46.Text = CStr(Math.Round((Double.Parse(住宿費) / Double.Parse(加總2)) * 100, 2)) TextBox47.Text = CStr(Math.Round((Double.Parse(伙食費) / Double.Parse(加總2)) * 100, 2)) TextBox48.Text = CStr(Math.Round((Double.Parse(娛樂費) / Double.Parse(加總2)) * 100, 2)) TextBox49.Text = CStr(Math.Round((Double.Parse(家用費) / Double.Parse(加總2)) * 100, 2)) TextBox50.Text = CStr(Math.Round((Double.Parse(醫療費) / Double.Parse(加總2)) * 100, 2)) TextBox51.Text = CStr(Math.Round((Double.Parse(務公費) / Double.Parse(加總2)) * 100, 2)) TextBox52.Text = CStr(Math.Round((Double.Parse(交際費) / Double.Parse(加總2)) * 100, 2)) TextBox53.Text = CStr(Math.Round((Double.Parse(其他支出) / Double.Parse(加總2)) * 100, 2)) TextBox54.Text = CStr(Math.Round((Double.Parse(手續費) / Double.Parse(加總2)) * 100, 2)) If conn1.State = ConnectionState.Closed Then : conn1.ConnectionString = ConString : conn1.Open() : End If If TextBox2.Text = "" Then SQL1 = "SELECT SUM(CONVERT(FLOAT, 收入)) AS 互沖帳 FROM 流水帳 WHERE (銀行 LIKE '%人民幣現金%') AND (類別 LIKE '%互沖帳%')" ElseIf TextBox2.Text <> "" Then SQL1 = "SELECT SUM(CONVERT(FLOAT, 收入)) AS 互沖帳 FROM 流水帳 WHERE (銀行 LIKE '" & TextBox2.Text & "') AND (類別 LIKE '%互沖帳%')" End If cmd1.Connection = conn1 : cmd1.CommandText = SQL1 : dr1 = cmd1.ExecuteReader If dr1.Read() Then : TextBox55.Text = dr1("互沖帳").ToString : End If If TextBox55.Text = "" Then : TextBox55.Text = "0.00" : End If conn1.Close() : dr1.Close() If conn1.State = ConnectionState.Closed Then : conn1.ConnectionString = ConString : conn1.Open() : End If If TextBox2.Text = "" Then SQL1 = "SELECT SUM(CONVERT(FLOAT, 支出)) AS 互沖帳 FROM 流水帳 WHERE (銀行 LIKE '%人民幣現金%') AND (類別 LIKE '%互沖帳%')" ElseIf TextBox2.Text <> "" Then SQL1 = "SELECT SUM(CONVERT(FLOAT, 支出)) AS 互沖帳 FROM 流水帳 WHERE (銀行 LIKE '" & TextBox2.Text & "') AND (類別 LIKE '%互沖帳%')" End If cmd1.Connection = conn1 : cmd1.CommandText = SQL1 : dr1 = cmd1.ExecuteReader If dr1.Read() Then : TextBox56.Text = dr1("互沖帳").ToString : End If If TextBox56.Text = "" Then : TextBox56.Text = "0.00" : End If conn1.Close() : dr1.Close() If conn1.State = ConnectionState.Closed Then : conn1.ConnectionString = ConString : conn1.Open() : End If If TextBox2.Text = "" Then SQL1 = "SELECT SUM(CONVERT(FLOAT, 收入)) AS 定存 FROM 流水帳 WHERE (銀行 LIKE '%人民幣現金%') AND (類別 LIKE '%定存%')" ElseIf TextBox2.Text <> "" Then SQL1 = "SELECT SUM(CONVERT(FLOAT, 收入)) AS 定存 FROM 流水帳 WHERE (銀行 LIKE '" & TextBox2.Text & "') AND (類別 LIKE '%定存%')" End If cmd1.Connection = conn1 : cmd1.CommandText = SQL1 : dr1 = cmd1.ExecuteReader If dr1.Read() Then : TextBox58.Text = dr1("定存").ToString : End If If TextBox58.Text = "" Then : TextBox58.Text = "0.00" : End If conn1.Close() : dr1.Close() If conn1.State = ConnectionState.Closed Then : conn1.ConnectionString = ConString : conn1.Open() : End If If TextBox2.Text = "" Then SQL1 = "SELECT SUM(CONVERT(FLOAT, 支出)) AS 定存 FROM 流水帳 WHERE (銀行 LIKE '%人民幣現金%') AND (類別 LIKE '%定存%')" ElseIf TextBox2.Text <> "" Then SQL1 = "SELECT SUM(CONVERT(FLOAT, 支出)) AS 定存 FROM 流水帳 WHERE (銀行 LIKE '" & TextBox2.Text & "') AND (類別 LIKE '%定存%')" End If cmd1.Connection = conn1 : cmd1.CommandText = SQL1 : dr1 = cmd1.ExecuteReader If dr1.Read() Then : TextBox59.Text = dr1("定存").ToString : End If If TextBox59.Text = "" Then : TextBox59.Text = "0.00" : End If conn1.Close() : dr1.Close() TextBox38.Text = Format(Val(CStr(Math.Round((Double.Parse(加總1) + Double.Parse(TextBox55.Text) + Double.Parse(TextBox58.Text)) - (Double.Parse(加總2) + Double.Parse(TextBox56.Text) + Double.Parse(TextBox59.Text)), 2))), "#,##0.00") If ComboBox2.Text = "" Then : GroupBox5.Text = "人民幣現金-帳本清單" : Else : GroupBox5.Text = ComboBox2.Text + "-帳本清單" : End If End Sub Private Sub 設定格式() CheckBox1.Enabled = False : CheckBox2.Enabled = False CheckBox1.Checked = False : CheckBox2.Checked = False ComboBox3.Location = New Point(343, 22) : ComboBox4.Location = New Point(343, 22) ComboBox3.Text = "" : ComboBox4.Text = "" ComboBox3.Enabled = False : ComboBox4.Enabled = False Label260.Enabled = False : Label261.Enabled = False End Sub Private Sub Set_grid() DataGridView1.Columns(0).Width = 75 : DataGridView1.Columns(1).Visible = False : DataGridView1.Columns(2).Width = 75 : DataGridView1.Columns(3).Width = 60 DataGridView1.Columns(4).Width = 180 : DataGridView1.Columns(5).Width = 60 : DataGridView1.Columns(6).Width = 60 End Sub Private Sub 流水號產生() Dim NUM1 As Integer = 0 For NUM1 = 0 To 99 Dim d As String : Dim f As String : Dim g As Integer = 1 If Month(Now) < 10 Then d = "0" & CStr(Month(Now)) Else d = CStr(Month(Now)) End If If Now.Day() < 10 Then f = "0" & CStr(Now.Day()) Else f = CStr(Now.Day()) End If If NUM1 < 10 Then TextBox6.Text = "A" & Microsoft.VisualBasic.Right(CStr(Year(Now)), 2) & d & f & "0" & NUM1 Else TextBox6.Text = "A" & Microsoft.VisualBasic.Right(CStr(Year(Now)), 2) & d & f & NUM1 End If TextBox16.Text = "" If conn1.State = ConnectionState.Closed Then : conn1.ConnectionString = ConString : conn1.Open() : End If SQL1 = "SELECT 流水號 FROM 流水帳 WHERE (流水號 ='" & TextBox6.Text & "')" cmd1.Connection = conn1 : cmd1.CommandText = SQL1 : dr1 = cmd1.ExecuteReader If dr1.Read() Then TextBox16.Text = dr1("流水號").ToString End If conn1.Close() If TextBox16.Text = "" Then TextBox16.Text = "可用" TextBox1.Text = TextBox6.Text NUM1 = 99 End If Next End Sub Private Sub 公帳流水號產生() Dim NUM2 As Integer = 0 For NUM2 = 0 To 99 Dim d As String : Dim f As String : Dim g As Integer = 1 If Month(Now) < 10 Then d = "0" & CStr(Month(Now)) Else d = CStr(Month(Now)) End If If Now.Day() < 10 Then f = "0" & CStr(Now.Day()) Else f = CStr(Now.Day()) End If If NUM2 < 10 Then TextBox8.Text = "B" & Microsoft.VisualBasic.Right(CStr(Year(Now)), 2) & d & f & "0" & NUM2 Else TextBox8.Text = "B" & Microsoft.VisualBasic.Right(CStr(Year(Now)), 2) & d & f & NUM2 End If TextBox17.Text = "" If conn1.State = ConnectionState.Closed Then : conn1.ConnectionString = ConString : conn1.Open() : End If SQL1 = "SELECT 流水號 FROM 公帳流水帳 WHERE (流水號 ='" & TextBox8.Text & "')" cmd1.Connection = conn1 : cmd1.CommandText = SQL1 : dr1 = cmd1.ExecuteReader If dr1.Read() Then TextBox17.Text = dr1("流水號").ToString End If conn1.Close() If TextBox17.Text = "" Then TextBox17.Text = "可用" NUM2 = 99 End If Next End Sub Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load Me.MdiParent = GCM_ERP_SYS 設定格式() : Set_匯總() : Set_明細() : Set_grid() End Sub Private Sub 登入閒置控制_MouseMove(sender As Object, e As EventArgs) Handles MyBase.MouseMove timeNow = 0 GCM_ERP_SYS.Timer1.Enabled = False GCM_ERP_SYS.Timer1.Enabled = True End Sub Private Sub 登入閒置控制_KeyPress(sender As Object, e As EventArgs) Handles MyBase.KeyPress timeNow = 0 GCM_ERP_SYS.Timer1.Enabled = False GCM_ERP_SYS.Timer1.Enabled = True End Sub Private Sub DataGridView1_CellClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellClick If e.RowIndex = -1 Then : Else TextBox1.Text = DataGridView1(0, e.RowIndex).Value.ToString : TextBox2.Text = DataGridView1(1, e.RowIndex).Value.ToString DateTimePicker1.Text = DataGridView1(2, e.RowIndex).Value.ToString : ComboBox1.Text = DataGridView1(3, e.RowIndex).Value.ToString TextBox3.Text = DataGridView1(4, e.RowIndex).Value.ToString : TextBox4.Text = DataGridView1(5, e.RowIndex).Value.ToString TextBox5.Text = DataGridView1(6, e.RowIndex).Value.ToString End If End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click DateTimePicker1.Enabled = True : ComboBox1.Enabled = True : Button7.Enabled = True : Button5.Enabled = True End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click Button4.Enabled = True : Button5.Enabled = True End Sub Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click Button5.Enabled = True : Button8.Enabled = True End Sub Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click If ComboBox1.Text = "" Or TextBox2.Text = "" Then MsgBox("請選擇銀行或帳目類別") Else 流水號產生() If TextBox16.Text = "可用" Then If ComboBox1.Text = "互沖帳" And CheckBox4.Checked = False Then If ComboBox3.Text = "" And ComboBox4.Text = "" Then MsgBox("請選擇轉出銀行") ElseIf ComboBox3.Text <> "" And ComboBox4.Text <> "" Then ComboBox3.Text = "" : ComboBox4.Text = "" MsgBox("請選擇轉出銀行") Else If CheckBox1.Checked = True Then Dim a As String = InputBox("請輸入轉出帳務明細") : Dim a1 As String = InputBox("請輸入轉入帳務明細") : Dim b As String = InputBox("請輸入沖帳金額") TextBox3.Text = a : TextBox4.Text = "" : TextBox5.Text = b If conn.State = ConnectionState.Closed Then : conn.Open() : End If SQL = "INSERT INTO 流水帳 (流水號, 銀行, 日期, 類別, 明細, 收入, 支出) VALUES ('" & TextBox1.Text & "','" & TextBox2.Text & "','" & Format(DateTimePicker1.Value, "yyyy/MM/dd") & "','" & ComboBox1.Text & "','" & TextBox3.Text & "','" & TextBox4.Text & "','" & TextBox5.Text & "')" cmd.CommandText = SQL : cmd.ExecuteNonQuery() 流水號產生() TextBox3.Text = a1 : TextBox4.Text = b : TextBox5.Text = "" If conn.State = ConnectionState.Closed Then : conn.Open() : End If SQL = "INSERT INTO 流水帳 (流水號, 銀行, 日期, 類別, 明細, 收入, 支出) VALUES ('" & TextBox1.Text & "','" & TextBox7.Text & "','" & Format(DateTimePicker1.Value, "yyyy/MM/dd") & "','" & ComboBox1.Text & "','" & TextBox3.Text & "','" & TextBox4.Text & "','" & TextBox5.Text & "')" cmd.CommandText = SQL : cmd.ExecuteNonQuery() TextBox57.Text = ComboBox3.Text ElseIf CheckBox2.Checked = True Then Dim b As String = InputBox("請輸入沖帳金額") If conn.State = ConnectionState.Closed Then : conn.Open() : End If TextBox3.Text = "轉工巧明投資" : TextBox4.Text = "" : TextBox5.Text = b SQL = "INSERT INTO 流水帳 (流水號, 銀行, 日期, 類別, 明細, 收入, 支出) VALUES ('" & TextBox1.Text & "','" & TextBox2.Text & "','" & Format(DateTimePicker1.Value, "yyyy/MM/dd") & "','" & ComboBox1.Text & "','" & TextBox3.Text & "','" & TextBox4.Text & "','" & TextBox5.Text & "')" cmd.CommandText = SQL : cmd.ExecuteNonQuery() 公帳流水號產生() TextBox3.Text = "轉入款-李協叡" : TextBox4.Text = b : TextBox5.Text = "" If conn.State = ConnectionState.Closed Then : conn.Open() : End If SQL = "INSERT INTO 公帳流水帳 (流水號, 銀行, 日期, 類別, 明細, 收入, 支出, 人員) VALUES ('" & TextBox8.Text & "','" & TextBox7.Text & "','" & Format(DateTimePicker1.Value, "yyyy/MM/dd") & "','" & ComboBox1.Text & "','" & TextBox3.Text & "','" & TextBox4.Text & "','" & TextBox5.Text & "','" & TextBox18.Text & "')" cmd.CommandText = SQL : cmd.ExecuteNonQuery() TextBox3.Text = "轉工巧明投資" : TextBox4.Text = "" : TextBox5.Text = b : TextBox57.Text = ComboBox2.Text End If MsgBox("新增完成") End If ElseIf ComboBox1.Text <> "互沖帳" Or CheckBox4.Checked = True Then Dim a As String = InputBox("請輸入帳務明細") : Dim b As String = InputBox("請輸入收入金額") : Dim c As String = InputBox("請輸入支出金額") TextBox3.Text = a : TextBox4.Text = b : TextBox5.Text = c If conn.State = ConnectionState.Closed Then : conn.Open() : End If SQL = "INSERT INTO 流水帳 (流水號, 銀行, 日期, 類別, 明細, 收入, 支出) VALUES ('" & TextBox1.Text & "','" & TextBox2.Text & "','" & Format(DateTimePicker1.Value, "yyyy/MM/dd") & "','" & ComboBox1.Text & "','" & TextBox3.Text & "','" & TextBox4.Text & "','" & TextBox5.Text & "')" cmd.CommandText = SQL : cmd.ExecuteNonQuery() MsgBox("新增完成") End If Else MsgBox("程式有誤請找程序管理員") End If conn.Close() End If Button7.Enabled = False : Button5.Enabled = False 設定格式() : Set_匯總() : Set_明細() : Set_grid() End Sub Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click If conn.State = ConnectionState.Closed Then : conn.Open() : End If SQL = "UPDATE 流水帳 SET 銀行 = '" & TextBox2.Text & "', 日期 = '" & Format(DateTimePicker1.Value, "yyyy/MM/dd") & "', 類別 = '" & ComboBox1.Text & "', 明細 = '" & TextBox3.Text & "', 收入 = '" & TextBox4.Text & "', 支出 = '" & TextBox5.Text & "' WHERE (流水號 = '" & TextBox1.Text & "')" cmd.CommandText = SQL : cmd.ExecuteNonQuery() MsgBox("修改完成") conn.Close() Button4.Enabled = False : Button5.Enabled = False Set_匯總() : Set_明細() : Set_grid() End Sub Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click SQL = "DELETE FROM 流水帳 WHERE (流水號 = '" & TextBox1.Text & "')" cmd.CommandText = SQL : cmd.Connection = conn If conn.State = ConnectionState.Closed Then : conn.Open() : End If Dim aa As MsgBoxResult aa = MsgBox("確定要刪除該筆資料?", MsgBoxStyle.OkCancel) If aa = MsgBoxResult.Ok Then : cmd.ExecuteNonQuery() : MsgBox("刪除完成") : End If conn.Close() Button5.Enabled = False : Button8.Enabled = False Set_匯總() : Set_明細() : Set_grid() End Sub Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click Button4.Enabled = False : Button5.Enabled = False : Button7.Enabled = False : Button8.Enabled = False End Sub Private Sub Button6_Click(sender As Object, e As EventArgs) Handles Button6.Click Set_匯總() : Set_明細() : Set_grid() End Sub Private Sub ComboBox2_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox2.SelectedIndexChanged If ComboBox2.Text = "" Then : TextBox2.Text = "" : TextBox57.Text = "" : End If If ComboBox2.Text = "工商銀行-江門-活存-叡" Then : TextBox2.Text = "中國工商銀行" : TextBox57.Text = "工商銀行-江門-活存-叡" : End If If ComboBox2.Text = "農業銀行-珠海-活存-叡" Then : TextBox2.Text = "農業銀行(協叡)" : TextBox57.Text = "農業銀行-珠海-活存-叡" : End If If ComboBox2.Text = "農業銀行-福建-活存-叡" Then : TextBox2.Text = "農業銀行福建叡" : TextBox57.Text = "農業銀行-福建-活存-叡" : End If If ComboBox2.Text = "農業銀行-肇慶-活存-叡" Then : TextBox2.Text = "農業銀行肇慶叡" : TextBox57.Text = "農業銀行-肇慶-活存-叡" : End If If ComboBox2.Text = "中國銀行-江門-活存-虹" Then : TextBox2.Text = "中國銀行" : TextBox57.Text = "中國銀行-江門-活存-虹" : End If If ComboBox2.Text = "農業銀行-珠海-活存-虹" Then : TextBox2.Text = "農業銀行(秀虹)" : TextBox57.Text = "農業銀行-珠海-活存-虹" : End If If ComboBox2.Text = "農業銀行-福建-活存-虹" Then : TextBox2.Text = "農業銀行福建虹" : TextBox57.Text = "農業銀行-福建-活存-虹" : End If If ComboBox2.Text = "工商銀行-江門-定存-叡" Then : TextBox2.Text = "工行定存" : TextBox57.Text = "工商銀行-江門-定存-叡" : End If If ComboBox2.Text = "農業銀行-珠海-定存-叡" Then : TextBox2.Text = "農行定存協叡" : TextBox57.Text = "農業銀行-珠海-定存-叡" : End If If ComboBox2.Text = "農業銀行-福建-定存-叡" Then : TextBox2.Text = "農行定存福建叡" : TextBox57.Text = "農業銀行-福建-定存-叡" : End If If ComboBox2.Text = "農業銀行-肇慶-定存-叡" Then : TextBox2.Text = "農行定存肇慶叡" : TextBox57.Text = "農業銀行-肇慶-定存-叡" : End If If ComboBox2.Text = "中國銀行-江門-定存-虹" Then : TextBox2.Text = "中行定存" : TextBox57.Text = "中國銀行-江門-定存-虹" : End If If ComboBox2.Text = "農業銀行-珠海-定存-虹" Then : TextBox2.Text = "農行定存秀虹" : TextBox57.Text = "農業銀行-珠海-定存-虹" : End If If ComboBox2.Text = "農業銀行-福建-定存-虹" Then : TextBox2.Text = "農行定存福建虹" : TextBox57.Text = "農業銀行-福建-定存-虹" : End If If ComboBox2.Text = "中華郵政-台灣-活存-叡" Then : TextBox2.Text = "郵局(協叡)" : TextBox57.Text = "中華郵政-台灣-活存-叡" : End If If ComboBox2.Text = "新光銀行-台灣-活存-叡" Then : TextBox2.Text = "新光銀行(協叡)" : TextBox57.Text = "新光銀行-台灣-活存-叡" : End If If ComboBox2.Text = "中國信託-台灣-活存-叡" Then : TextBox2.Text = "中國信託(協叡)" : TextBox57.Text = "中國信託-台灣-活存-叡" : End If If ComboBox2.Text = "中華郵政-台灣-活存-虹" Then : TextBox2.Text = "郵局(秀虹)" : TextBox57.Text = "中華郵政-台灣-活存-虹" : End If If ComboBox2.Text = "新光銀行-台灣-活存-虹" Then : TextBox2.Text = "新光銀行(秀虹)" : TextBox57.Text = "新光銀行-台灣-活存-虹" : End If If ComboBox2.Text = "中國信託-台灣-活存-虹" Then : TextBox2.Text = "中國信託(秀虹)" : TextBox57.Text = "中國信託-台灣-活存-虹" : End If If ComboBox2.Text = "元大銀行-台灣-活存-虹" Then : TextBox2.Text = "元大銀行" : TextBox57.Text = "元大銀行-台灣-活存-虹" : End If If ComboBox2.Text = "元大證卷-台灣-股票-虹" Then : TextBox2.Text = "元大證卷" : TextBox57.Text = "元大證卷-台灣-股票-虹" : End If If ComboBox2.Text = "台幣現金" Then : TextBox2.Text = "台幣現金" : TextBox57.Text = "台幣現金" : End If If ComboBox2.Text = "人民幣現金" Then : TextBox2.Text = "人民幣現金" : TextBox57.Text = "人民幣現金" : End If Set_明細() : Set_grid() End Sub Private Sub ComboBox3_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox3.SelectedIndexChanged If ComboBox3.Text = "" Then : TextBox7.Text = "" : End If If ComboBox3.Text = "工商銀行-江門-活存-叡" Then : TextBox7.Text = "中國工商銀行" : End If If ComboBox3.Text = "農業銀行-珠海-活存-叡" Then : TextBox7.Text = "農業銀行(協叡)" : End If If ComboBox3.Text = "農業銀行-福建-活存-叡" Then : TextBox7.Text = "農業銀行福建叡" : End If If ComboBox3.Text = "農業銀行-肇慶-活存-叡" Then : TextBox7.Text = "農業銀行肇慶叡" : End If If ComboBox3.Text = "中國銀行-江門-活存-虹" Then : TextBox7.Text = "中國銀行" : End If If ComboBox3.Text = "農業銀行-珠海-活存-虹" Then : TextBox7.Text = "農業銀行(秀虹)" : End If If ComboBox3.Text = "農業銀行-福建-活存-虹" Then : TextBox7.Text = "農業銀行福建虹" : End If If ComboBox3.Text = "工商銀行-江門-定存-叡" Then : TextBox7.Text = "工行定存" : End If If ComboBox3.Text = "農業銀行-珠海-定存-叡" Then : TextBox7.Text = "農行定存協叡" : End If If ComboBox3.Text = "農業銀行-福建-定存-叡" Then : TextBox7.Text = "農行定存福建叡" : End If If ComboBox3.Text = "農業銀行-肇慶-定存-叡" Then : TextBox7.Text = "農行定存肇慶叡" : End If If ComboBox3.Text = "中國銀行-江門-定存-虹" Then : TextBox7.Text = "中行定存" : End If If ComboBox3.Text = "農業銀行-珠海-定存-虹" Then : TextBox7.Text = "農行定存秀虹" : End If If ComboBox3.Text = "農業銀行-福建-定存-虹" Then : TextBox7.Text = "農行定存福建虹" : End If If ComboBox3.Text = "中華郵政-台灣-活存-叡" Then : TextBox7.Text = "郵局(協叡)" : End If If ComboBox3.Text = "新光銀行-台灣-活存-叡" Then : TextBox7.Text = "新光銀行(協叡)" : End If If ComboBox3.Text = "中國信託-台灣-活存-叡" Then : TextBox7.Text = "中國信託(協叡)" : End If If ComboBox3.Text = "中華郵政-台灣-活存-虹" Then : TextBox7.Text = "郵局(秀虹)" : End If If ComboBox3.Text = "新光銀行-台灣-活存-虹" Then : TextBox7.Text = "新光銀行(秀虹)" : End If If ComboBox3.Text = "中國信託-台灣-活存-虹" Then : TextBox7.Text = "中國信託(秀虹)" : End If If ComboBox3.Text = "元大銀行-台灣-活存-虹" Then : TextBox7.Text = "元大銀行" : End If If ComboBox3.Text = "元大證卷-台灣-股票-虹" Then : TextBox7.Text = "元大證卷" : End If If ComboBox3.Text = "台幣現金" Then : TextBox7.Text = "台幣現金" : End If If ComboBox3.Text = "人民幣現金" Then : TextBox7.Text = "人民幣現金" : End If End Sub Private Sub ComboBox4_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox4.SelectedIndexChanged If ComboBox4.Text = "" Then : TextBox7.Text = "" : End If If ComboBox4.Text = "台幣現金" Then : TextBox7.Text = "台幣現金" : End If If ComboBox4.Text = "人民幣現金" Then : TextBox7.Text = "人民幣現金" : End If End Sub Private Sub Button9_Click(sender As Object, e As EventArgs) Handles Button9.Click 月份查詢.Show() End Sub Private Sub Button10_Click(sender As Object, e As EventArgs) Handles Button10.Click 分類查詢.Show() End Sub Private Sub CheckBox1_CheckedChanged(sender As Object, e As EventArgs) Handles CheckBox1.Click CheckBox1.Checked = True : CheckBox2.Checked = False : ComboBox3.Visible = True : ComboBox4.Visible = False : ComboBox3.Enabled = True End Sub Private Sub CheckBox2_CheckedChanged(sender As Object, e As EventArgs) Handles CheckBox2.Click CheckBox1.Checked = False : CheckBox2.Checked = True : ComboBox3.Visible = False : ComboBox4.Visible = True : ComboBox4.Enabled = True End Sub Private Sub CheckBox3_CheckedChanged(sender As Object, e As EventArgs) Handles CheckBox3.CheckedChanged If CheckBox3.Checked = True Then : DateTimePicker1.Value = Today() : End If End Sub Private Sub ComboBox1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox1.SelectedIndexChanged If ComboBox1.Text <> "互沖帳" Then CheckBox1.Enabled = False : CheckBox2.Enabled = False : CheckBox1.Checked = False : CheckBox2.Checked = True : 設定格式() ElseIf ComboBox1.Text = "互沖帳" Then CheckBox1.Enabled = True : CheckBox2.Enabled = True : Label260.Enabled = True : Label261.Enabled = True If CheckBox1.Checked = True Then ComboBox3.Visible = True : ComboBox4.Visible = False : ComboBox3.Enabled = True ElseIf CheckBox2.Checked = True Then ComboBox3.Visible = False : ComboBox4.Visible = True : ComboBox4.Enabled = True End If End If End Sub Private Sub DateTimePicker1_ValueChanged(sender As Object, e As EventArgs) Handles DateTimePicker1.ValueChanged If DateTimePicker1.Value <> Today() Then : CheckBox3.Checked = False : End If End Sub End Class