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

📄 usersendform.cs

📁 aTm机 daima认真阅读您的文件包然后写出其具体功能(至少要20个字)。尽量不要让站长把时间都花费在为您修正说明上。压缩包解压时不能有密码。
💻 CS
字号:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace Bank
{
    public partial class UserSendform : Form
    {

        public UserSendform()
        {
            InitializeComponent();
        }

        private void UserbtnEnter_Click(object sender, EventArgs e)
        {
            //判断输入是否正确
            string str = String.Empty;//string  int 对比验证
            str = UsertxtSend.Text;
            int result;


            MaintxtSendID.Text = HelperSend.LoginID;
            int moneyadd = int.Parse(UsertxtSend.Text);
            if (moneyadd<= int.Parse(HelperSend.LoginMoney))
            {
                int money = int.Parse(HelperSend.LoginMoney) - moneyadd;
                string id = MaintxtSendID.Text.Trim();
                int add = 0;
                string sql = string.Format("update users set money = {0} where id = {1}", money, id);

                Console.WriteLine(sql);
                if (int.TryParse(str, out result))
                {
                    try
                    {
                        SqlCommand command = new SqlCommand(sql, DBHelper.connection);
                        DBHelper.connection.Close();
                        DBHelper.connection.Open();

                        add = (int)command.ExecuteNonQuery();




                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("数据库出错了!\n\n" + ex, "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    }
                    finally
                    {
                        DBHelper.connection.Close();
                    }
                    MessageBox.Show("您取款的金额是:\n" + UsertxtSend.Text + "元");

                }
                else
                {
                    MessageBox.Show("对不起,请正确输入存款数!");
                }
                //对数据库进行操作
            }
            else 
            {
                MessageBox.Show("对不起,您没有那么多钱!请重新输入");
                this.UsertxtSend.Focus();
            }
        }

        private void UserbtnExit_Click(object sender, EventArgs e)
        {
                this.Close();
        }
    }
}

⌨️ 快捷键说明

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