⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 存款.vb

📁 银行帐户管理系统
💻 VB
字号:
Public Class 存款
    Inherits System.Windows.Forms.Form
    Dim strconn As String = "data source=.;initial catalog=weboy;user id=sa;password=;"
    Dim objds As New Data.DataSet
    Dim objda As SqlClient.SqlDataAdapter
    Dim bingpage As BindingManagerBase
    Dim strsql As String
    Dim result As String

    Dim sql As String
    Dim cn As New SqlClient.SqlConnection
    Dim cmd As SqlClient.SqlCommand

    Dim str, str1 As String


    Dim objcommand As SqlClient.SqlCommand
    Dim objdr As SqlClient.SqlDataReader
    Dim i As Integer = 3
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        If TextBox1.Text = TextBox2.Text Then
            If TextBox3.Text <> TextBox4.Text Then
                MsgBox("请确定两次输入的存款金额相同")
                Exit Sub
            End If
        End If
        If TextBox3.Text = TextBox4.Text Then
            If TextBox1.Text <> TextBox2.Text Then
                MsgBox("请确定两次输入的帐户号码相同")
                Exit Sub
            End If
        End If
        Button2.Enabled = True
        result = MessageBox.Show("确定存款?", "系统提示", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation)
        If result = Windows.Forms.DialogResult.No Then
            Me.Close()
        Else
            If TextBox1.Text = "" Or TextBox2.Text = "" Or TextBox3.Text = "" Or TextBox4.Text = "" Then
                MsgBox("输入信息不能为空!")
            Else
                str = "select ID from CConsumers"
                objcommand = New SqlClient.SqlCommand(str, New SqlClient.SqlConnection(strconn))
                objcommand.Connection.Open()
                objdr = objcommand.ExecuteReader(CommandBehavior.CloseConnection)
                With objdr
                    Do While .Read = True
                        str = .GetString(0)
                        If Trim(TextBox1.Text) <> Trim(str) Then
                            MessageBox.Show(" 该帐户不存在,请确认帐户号码是否正确!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information)
                            TextBox1.Text = ""
                            TextBox2.Text = ""
                            TextBox3.Text = ""
                            TextBox4.Text = ""
                            TextBox1.Focus()
                            Exit Sub
                        Else
                            strsql = "select money from CConsumers where ID='" & Trim(TextBox1.Text) & "'"
                            objda = New SqlClient.SqlDataAdapter(strsql, strconn)
                            objda.Fill(objds, "CConsumers")
                            bingpage = Me.BindingContext(objds, "CConsumers")
                            TextBox5.DataBindings.Add(New Binding("text", objds, "CConsumers.money"))
                            If (Val(TextBox3.Text)) > 0 Then
                                sql = "update CConsumers set money='" & Trim(Val(TextBox5.Text) + Val(TextBox3.Text)) & "' where ID='" & Trim(TextBox1.Text) & "'"
                                cn.ConnectionString = strconn
                                cn.Open()
                                cmd = New SqlClient.SqlCommand(sql, cn)
                                cmd.ExecuteNonQuery()
                                cmd.Dispose()
                                cn.Dispose()
                                MessageBox.Show("存款成功!" & vbCrLf & "当前帐户金额为:" & Trim(Val(TextBox5.Text) + Val(TextBox3.Text)) & "元", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information)
                                Me.Close()
                                Exit Sub
                            End If
                        End If
                    Loop
                End With
            End If
        End If
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Me.Close()
    End Sub

    Private Sub Label1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label1.Click

    End Sub
End Class

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -