Exemplo n.º 1
0
        private void button3_Click(object sender, EventArgs e)
        {
            yhzx form = new yhzx();

            form.Show();
            this.Hide();
        }
Exemplo n.º 2
0
        private void button1_Click(object sender, EventArgs e)
        {
            string username = textBox1.Text;
            string password = textBox2.Text;
            string type     = comboBox1.Text;

            if (textBox1.Text == "" || textBox2.Text == "" || comboBox1.Text == "")
            {
                MessageBox.Show("登录账号或密码,身份不能为空!", "警告");
            }
            else
            if (comboBox1.Text == "管理员")
            {
                string        str  = "Data Source=DESKTOP-H6GDTOQ\\SQLEXPRESS;Initial Catalog=slfsql;Integrated Security=True";
                SqlConnection conn = new SqlConnection(str);
                conn.Open();
                string     selectsql = "select * from dlb where username='******'and password='******'";
                SqlCommand cmd       = new SqlCommand(selectsql, conn);
                cmd.CommandType = CommandType.Text;
                SqlDataReader sdr;
                sdr = cmd.ExecuteReader();
                if (sdr.Read())
                {
                    glyjm form = new glyjm();
                    form.Show();
                    this.Hide();
                }
                else
                {
                    MessageBox.Show("登录账号或密码错误!", "提示");
                }
                conn.Close();
            }
            else
            {
                string        str  = "Data Source=DESKTOP-H6GDTOQ\\SQLEXPRESS;Initial Catalog=slfsql;Integrated Security=True";
                SqlConnection conn = new SqlConnection(str);
                conn.Open();
                string     selectsql = "select * from yhdlb where username='******'and password='******'";
                SqlCommand cmd       = new SqlCommand(selectsql, conn);
                cmd.CommandType = CommandType.Text;
                SqlDataReader sdr;
                sdr = cmd.ExecuteReader();
                if (sdr.Read())
                {
                    yhzx form = new yhzx();
                    form.Show();
                    this.Hide();
                }
                else
                {
                    MessageBox.Show("登录账号或密码错误!", "提示");
                }
                conn.Close();
            }
        }