예제 #1
0
        private void toolStripButton7_Click(object sender, EventArgs e)
        {
            fTrangChu main = new fTrangChu();

            this.Hide();
            main.Show();
        }
예제 #2
0
        private void btnDangNhap_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(txtTenDangNhap.Text))
            {
                MetroFramework.MetroMessageBox.Show(this, "Bạn chưa nhập dữ liệu", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                txtTenDangNhap.Focus();
            }

            try
            {
                using (QuanLyKhoEntities db = new QuanLyKhoEntities())
                {
                    var query = from c in db.ADMINs
                                where c.tendangnhap == txtTenDangNhap.Text && c.matkhau == txtMatKhau.Text
                                select c;
                    if (query.SingleOrDefault() != null)
                    {
                        this.Hide();
                        fTrangChu frmMain = new fTrangChu(txtTenDangNhap.Text);
                        frmMain.ShowDialog();
                        frmMain.SuKien += DongForm;
                        frmMain.KichHoat();
                    }
                    else
                    {
                        MetroFramework.MetroMessageBox.Show(this, "Tên đăng nhập hoặc mật khẩu không đúng!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
            }
            catch (Exception ex)
            {
                MetroFramework.MetroMessageBox.Show(this, ex.Message, "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
        }