示例#1
0
        private void LoginButton_Click(object sender, EventArgs e)//点击登录按钮后发生的动作
        {
            string userId          = textBox2.Text;
            string userPwd         = textBox1.Text;
            string selectStatement = "select * from worker where " +
                                     "worker_id = \"" + userId + "\" " + "and worker_pwd = \"" +
                                     userPwd + "\" and not exists ( select * from client where user_id = \"" + userId + "\" " + " and user_pwd = \"" + userPwd + "\")";

            com = new MySqlCommand(selectStatement, con);
            com.ExecuteNonQuery();
            MySqlDataReader dataReader = com.ExecuteReader();

            if (!dataReader.HasRows)
            {
                com = new MySqlCommand("select * from client where user_id = \"" + userId + "\" " + " and user_pwd = \"" + userPwd + "\"", con);
                dataReader.Close();
                com.ExecuteNonQuery();
                dataReader = com.ExecuteReader();
                if (dataReader.HasRows)
                {
                    dataReader.Read();
                    User user = new User(dataReader, con, this);
                    user.Show();
                    this.Visible = false;
                }
                else
                {
                    MetroFramework.MetroMessageBox.Show(this, "用户名或密码错误", "登录失败");
                    dataReader.Close();
                }
            }
            else if (dataReader.HasRows)
            {
                dataReader.Read();
                if (dataReader.GetString("worker_occupt") == "warehouser")
                {
                    WareHouseManager ware_houser = new WareHouseManager(dataReader, this);
                    ware_houser.Show();
                    this.Visible = false;
                }
                else if (dataReader.GetString("worker_occupt") == "deliver")
                {
                    DeliverManager deliver = new DeliverManager(dataReader, this);
                    deliver.Show();
                    this.Visible = false;
                }
                else if (dataReader.GetString("worker_occupt") == "receiver")
                {
                    ReceiveManager receiver = new ReceiveManager(dataReader, this);
                    receiver.Show();
                    this.Visible = false;
                }
                else if (dataReader.GetString("worker_occupt") == "adminer")
                {
                    dataReader.Close();
                    Admin adminer = new Admin(this);
                    adminer.Show();
                    this.Visible = false;
                }
            }
            else
            {
                MetroFramework.MetroMessageBox.Show(this, "用户名或密码错误", "登录失败");
            }
        }
示例#2
0
 private void LoginButton_Click(object sender, EventArgs e)//点击登录按钮后发生的动作
 {
     string userId = textBox2.Text;
     string userPwd = textBox1.Text;
     string selectStatement = "select * from worker where " +
         "worker_id = \"" + userId + "\" " + "and worker_pwd = \"" +
         userPwd + "\" and not exists ( select * from client where user_id = \"" + userId + "\" " + " and user_pwd = \"" + userPwd +"\")";
     com = new MySqlCommand(selectStatement, con);
     com.ExecuteNonQuery();
     MySqlDataReader dataReader = com.ExecuteReader();
     if (!dataReader.HasRows)
     {
         com = new MySqlCommand("select * from client where user_id = \"" + userId + "\" " + " and user_pwd = \"" + userPwd + "\"", con);
         dataReader.Close();
         com.ExecuteNonQuery();
         dataReader = com.ExecuteReader();
         if (dataReader.HasRows)
         {
             dataReader.Read();
             User user = new User(dataReader, con,this);
             user.Show();
             this.Visible = false;
         }
         else
         {
             MetroFramework.MetroMessageBox.Show(this, "用户名或密码错误", "登录失败");
             dataReader.Close();
         }
     }
     else if (dataReader.HasRows)
     {
         dataReader.Read();
         if (dataReader.GetString("worker_occupt") == "warehouser")
         {
             WareHouseManager ware_houser = new WareHouseManager(dataReader,this);
             ware_houser.Show();
             this.Visible = false;
         }
         else if(dataReader.GetString("worker_occupt") == "deliver")
         {
             DeliverManager deliver = new DeliverManager(dataReader,this);
             deliver.Show();
             this.Visible = false;
         }
         else if(dataReader.GetString("worker_occupt") == "receiver")
         {
             ReceiveManager receiver = new ReceiveManager(dataReader,this);
             receiver.Show();
             this.Visible = false;
         }
         else if(dataReader.GetString("worker_occupt") == "adminer")
         {
             dataReader.Close();
             Admin adminer = new Admin(this);
             adminer.Show();
             this.Visible = false;
         }
     }
     else
     {
         MetroFramework.MetroMessageBox.Show(this, "用户名或密码错误", "登录失败");
     }
 }