Beispiel #1
0
        private void Login_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
                if (txtUser.Text == "" || txtPass.Text == "")
                {
                    MessageBox.Show("Please, Input Username or Password!", "Notice!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                else
                {
                    con = new Connect();
                    int       check = 0;
                    DataTable table = null;
                    table = new DataTable();
                    table = con.laybang("SELECT * from R_User");
                    DataRow mr = null;

                    for (int i = 0; i < table.Rows.Count; i++)
                    {
                        try
                        {
                            mr = table.Rows[i];
                            string password    = con.EncodePasswordToBase64(txtPass.Text);
                            string passwordnew = mr["Password"].ToString();
                            string user        = mr["UserName"].ToString();
                            if (txtUser.Text == mr["UserName"].ToString() && password == mr["Password"].ToString())
                            {
                                check = 1;
                                this.Hide();
                                int userid = Convert.ToInt32(mr["ID"].ToString());
                                RestaurentManagementSystem main = new RestaurentManagementSystem(userid);
                                main.ShowDialog();
                            }
                        }
                        catch (Exception ex)
                        {
                            throw ex;
                        }
                    }
                    if (check == 0)
                    {
                        MessageBox.Show("UserName or Password incorrect!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
        }
Beispiel #2
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            if (txtUser.Text == "" || txtPass.Text == "")
            {
                MessageBox.Show("Bạn chưa nhập Tài khoản hoặc Mật khẩu", "Notice!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else
            {
                con = new Connect();
                int       check = 0;
                DataTable table = null;
                table = new DataTable();
                table = con.laybang("SELECT * from R_User");
                DataRow mr = null;

                for (int i = 0; i < table.Rows.Count; i++)
                {
                    try
                    {
                        mr = table.Rows[i];
                        string password    = con.EncodePasswordToBase64(txtPass.Text);
                        string passwordnew = mr["Password"].ToString();
                        string user        = mr["UserName"].ToString();
                        if (txtUser.Text == mr["UserName"].ToString() && password == mr["Password"].ToString())
                        {
                            check = 1;
                            this.Hide();
                            int userid = Convert.ToInt32(mr["ID"].ToString());
                            RestaurentManagementSystem main = new RestaurentManagementSystem(userid);
                            main.ShowDialog();
                        }
                    }
                    catch (Exception ex)
                    {
                        throw ex;
                    }
                }
                if (check == 0)
                {
                    MessageBox.Show("Tài khoản hoặc Mật khẩu chưa đúng", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Beispiel #3
0
 private void btnLogin_Click(object sender, EventArgs e)
 {
     if (txtUser.Text == "" || txtPass.Text == "")
     {
         MessageBox.Show("Please, Input Username or Password!", "Notice!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
     else
     {
         int       check = 0;
         DataTable table = cls.GetAccount();
         DataRow   mr    = null;
         mr = table.Rows[0];
         for (int i = 0; i < table.Rows.Count; i++)
         {
             if (txtUser.Text == mr["UserName"].ToString() && txtPass.Text == mr["Password"].ToString())
             {
                 check = 1;
                 if (mr["Status"].ToString() != null)
                 {
                     role = "admin";
                     MessageBox.Show("Welcome to Admin", "Login Successfully!", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                     this.Hide();
                     RestaurentManagementSystem main = new RestaurentManagementSystem();
                     main.ShowDialog();
                 }
                 else
                 {
                     role = "user";
                     MessageBox.Show("Welcome to User", "Login Successfully!", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                     this.Hide();
                     RestaurentManagementSystem main = new RestaurentManagementSystem();
                     main.ShowDialog();
                 }
             }
         }
         if (check == 0)
         {
             MessageBox.Show("UserName or Password incorrect!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
 }