private void btnThoat_Click(object sender, EventArgs e)
        {
            this.Hide();
            Frm_Main_Admin Ad = new Frm_Main_Admin(label14.Text);

            Ad.Show();
        }
예제 #2
0
        private void btnMenu_Click(object sender, EventArgs e)
        {
            this.Hide();
            Frm_Main_Admin admin = new Frm_Main_Admin();

            admin.Show();
        }
        //------------------------------------------------------------------------------
        // btn Menu
        private void btnMenu_Click(object sender, EventArgs e)
        {
            Frm_Main_Admin admin = new Frm_Main_Admin(label26.Text);

            admin.Show();
            this.Hide();
            Visible = false;
        }
예제 #4
0
        public void DangNhap()
        {
            try
            {
                sqlcon.Open();
                string user = txtTenDangNhap.Text;
                string pass = txtMatKhau.Text;

                // Mã hóa mật khẩu
                string str    = "";
                Byte[] buffer = System.Text.Encoding.UTF8.GetBytes(pass);
                MD5CryptoServiceProvider md = new MD5CryptoServiceProvider();
                buffer = md.ComputeHash(buffer);
                foreach (Byte b in buffer)
                {
                    str += b.ToString("X2");
                }
                // Dò tìm SĐT khách hàng và ID nhân viên
                string sql = "SELECT COUNT (*) FROM [KTPM].[dbo].[Info_Secret] "
                             + "WHERE (Phone_Cus=@phone COLLATE SQL_Latin1_General_CP1_CS_AS AND Password=@pass COLLATE SQL_Latin1_General_CP1_CS_AS)"
                             + "OR (ID_Emp=@id COLLATE SQL_Latin1_General_CP1_CS_AS AND Password=@pass COLLATE SQL_Latin1_General_CP1_CS_AS)";
                SqlCommand cmd = new SqlCommand(sql, sqlcon);
                cmd.Parameters.Add(new SqlParameter("@phone", user));
                cmd.Parameters.Add(new SqlParameter("@id", user));
                cmd.Parameters.Add(new SqlParameter("@pass", str));
                int x = (int)cmd.ExecuteScalar();
                if (x == 1)
                {
                    string     sql_Permision = "SELECT COUNT (*) FROM [KTPM].[dbo].[Info_Secret] WHERE Phone_Cus=@phone AND Permision=@per";
                    SqlCommand cmd_Permision = new SqlCommand(sql_Permision, sqlcon);
                    cmd_Permision.Parameters.Add(new SqlParameter("@phone", user));
                    cmd_Permision.Parameters.AddWithValue("@per", "Guess");
                    int y = (int)cmd_Permision.ExecuteScalar();
                    if (y == 1)
                    {
                        LoginFlag = true;
                        this.Hide();
                        Frm_Main_Customers cus = new Frm_Main_Customers();
                        cus.Show();
                    }
                    else
                    {
                        LoginFlag = true;
                        this.Hide();
                        Frm_Main_Admin admin = new Frm_Main_Admin(txtTenDangNhap.Text);
                        admin.Show();
                    }
                }
                else
                {
                    LoginFlag = false;
                    MessageBox.Show(" User or Password is incorrect . \n Please try again!", "ERROR");
                }
            }
            catch (Exception)
            {
                LoginFlag = false;
                MessageBox.Show("Error Connection!", "Try Again");
            }
            finally
            {
                sqlcon.Close();
            }
        }