Exemplo n.º 1
0
        /// <summary>
        /// load du lieu len form
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        /// <summary>
        /// bat su kien dang nhap tai khoan
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                TaiKhoanDTO tk = new TaiKhoanDTO();
                tk.username = txtusername.Text;
                tk.password = txtpassword.Text;
                //tk.ma_cv = cbxCV.SelectedValue.ToString();
                tk.trang_thai = true;
                if (TaiKhoanBUS.Dang_nhap(tk) != "")
                {
                    string quyenhan = TaiKhoanBUS.Dang_nhap(tk);
                    switch (quyenhan)
                    {
                    case "BH":
                        this.Hide();
                        frmBanHang bh = new frmBanHang();
                        bh.Show();
                        bh.STR = txtusername.Text;
                        break;

                    case "NH":
                        this.Hide();
                        NhapHang nh = new NhapHang();
                        nh.Show();
                        nh.STR = txtusername.Text;
                        break;

                    case "QL":
                        this.Hide();
                        QuanLy ql = new QuanLy();
                        ql.Show();
                        ql.STR = txtusername.Text;
                        break;

                    default:
                        MessageBox.Show("Error!", "Thông báo", MessageBoxButtons.OK);
                        break;
                    }
                }
                else
                {
                    MessageBox.Show("Tài khoản của bạn có người đã đăng nhập hoặc bạn nhập sai thông tin !", "Thông báo", MessageBoxButtons.OK);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }