ATM

来源:互联网 发布:nativeshare.js vue 编辑:程序博客网 时间:2024/04/28 13:56


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace ATM
{
    public partial class ATM开户 : Form
    {
        public ATM开户()
        {
            InitializeComponent();
        }

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

       
        private void button1_Click_1(object sender, EventArgs e)
        {
            a();
        }
        private void a()
        {
            if (validateInput())
            {
                MessageBox.Show("恭喜您验证通过^-^!!!");
                string loginid = txtLoginId.Text.Trim();
                string pwd = textBox2.Text.Trim();
                string name = txtName.Text.Trim();
                string stuNo = txtNum.Text.Trim();
                string address = txtAddress.Text.Trim();
                string phone = txtPhone.Text.Trim();
               
                //string UserStateId =txtStateId.Text.Trim();
                string sex = rdoSet1.Checked ? "活动" : "挂失";
              
                // string state = rdoState1.Checked ? "1" : "0";
                string state = rdoSet1.Checked ? rdoSet1.Tag.ToString() : rdoSet2.Tag.ToString();


                string sql = string.Format(@"SELECT  cardInfo.cardID, userInfo.customerName, userInfo.PID, userInfo.telephone, cardInfo.state
FROM      cardInfo INNER JOIN
                   userInfo ON cardInfo.customerID = userInfo.customerID)values('{0}',{1}',{2},'{3}','{4}','{5}','{6})"
                    , loginid, pwd, name, stuNo, address, phone, sex);
                int num = DBHelper.ExecuteNonQuery(sql);
                if (num > 0)
                {
                    MessageBox.Show("数据插入成功!", "操作提示");
                    ATM开户 stu = new ATM开户();
                    stu.Show();

                }
                else
                {
                    MessageBox.Show("数据插入失败!", "操作提示");
                }
            }
        }
        private bool validateInput()
        {if  (txtName.Text.Trim() == "")
            {
                MessageBox.Show("请输入开户名!", "输入提示");
                txtName.Focus();
                return false;
            }
            if (txtNum.Text.Trim() == "")
            {
                MessageBox.Show("请输入身份证号!", "输入提示");
                txtNum.Focus();
                return false;
            }

            if (txtNum.Text.Length!=18)
            {
                MessageBox.Show("身份证号长度必须等于15或18个字符!", "输入提示");
                txtNum.Focus();
                return false;

            } long n = 0;
            if (long.TryParse(txtNum.Text.Trim(), out n) == false)
            {
                MessageBox.Show("身份证号必须为数字字符!", "输入提示");
                txtNum.Focus();
                return false;
            }

            if (txtPhone.Text.Trim() == "")
            {
                MessageBox.Show("请输入电话!", "输入提示");
                txtPhone.Focus();
                return false;
            }
            if (txtPhone.Text.Length != 11)
            {
                MessageBox.Show("电话号码格式为xxxx-xxxxxxxx13位或手机号11位!", "输入提示");
                txtPhone.Focus();
                return false;

            }
            long phone = 0;
            if (long.TryParse(txtPhone.Text.Trim(), out phone) == false)
            {
                MessageBox.Show("电话号码必须为数字字符和-组合!", "输入提示");
                txtPhone.Focus();
                return false;
            }
           
            if (txtAddress.Text.Trim() == "")
            {
                MessageBox.Show("请输入地址!可选输入", "输入提示");
               
            }
           
            if (this.txtLoginId.Text.Trim()=="")
            {
                MessageBox.Show("请输入开户名!","输入提示");
                txtLoginId.Focus();
                return false;}
            if (textBox1.Text.Trim() == "")
            {
                MessageBox.Show("请输入金额!", "输入提示");
                textBox1.Focus();
                return false;
            }
            if (this.textBox2.Text.Trim() == "")
            {
                MessageBox.Show("请输入密码!","输入提示");
                textBox2.Focus();
                return false;
            }
            if (textBox2.Text.Length != 6)
            {
                MessageBox.Show("密码长度必须等于6个字符!", "输入提示");
                textBox2.Focus();
                return false ;
               
            }
           
           
           
  return true;
           
       

           // this.Hide();
        }

        private void ATM开户_Load(object sender, EventArgs e)
        {

        }

      
      
    }
}

0 0