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

📄 form2.cs

📁 由于本系统为一个公司销售管理系统
💻 CS
字号:
using System;
using System.Data.SqlClient;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace WindowsApplication1
{
    public partial class Register : Form
    {
        private bool flag;
        private string limit;
        public string name;
        public bool flag1;
        public string getlimit
        {
            get
            {
                return limit;
            }
        }
        public bool setFlag
        {
            set
            {
                 flag=value;
            }
        }

        public string getname
        {
            get
            {
                return name;
            }
        }

        public Register()
        {
            limit = "1";
            InitializeComponent();
        }
        
        private void button2_Click(object sender, EventArgs e)
        {
            this.Close();
        }
        DataSet ds = new DataSet();
        private void button1_Click(object sender, EventArgs e)
        {
            if (textBox1.Text == "")
                MessageBox.Show("User-name can not null!");
            else if (textBox2.Text == "")
                MessageBox.Show("Password can not null!");
            else try
                {

                    textBox1.Enabled = true;
                    SqlConnection conn = new SqlConnection("server=;database=ll;uid=sa;pwd=;");
                    string insert = "insert into users(username,password,limit,sex,phone) values('" + textBox1.Text + "','" + textBox2.Text + "','" + limit + "','" + comboBox1.Text + "','" + textBox4.Text + "') ";
                    SqlDataAdapter q = new SqlDataAdapter(insert, conn);
                    q.Fill(ds, "users");
                }
                catch (IndexOutOfRangeException)
                {
                    MessageBox.Show("Input data error or User has existed!");
                    textBox2.Text = "";
                    textBox1.Text = "";
                    textBox4.Text = "";
                    comboBox1.Text = "";
                    return;
                }
            name = textBox1.Text;
            MessageBox.Show("Insert successful! ");
            flag1 = true;
            this.Close();
        }

        private void Register_Load(object sender, EventArgs e)
        {
            flag1 = false;
            if (flag)
            {
                limit = "2";
                textBox1.Text = "admin";
                name = "admin";
                textBox1.Enabled = false;
            } 
        }

    }
}

⌨️ 快捷键说明

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