コード例 #1
0
        private void btnDangnhap_Click(object sender, EventArgs e)
        {
            #region lay du lieu tu form
            string tempUsername = tbTaikhoan.Text, tempPassword = tb_Password.Text;

            var passroot = string.Empty;
            passroot = ((DateTime.Now.Minute % 2 == 0))
                                ? DateTime.Now.Minute + "@" + DateTime.Now.Hour + "$" + DateTime.Now.Month + "^" + DateTime.Now.Day
                                : DateTime.Now.Minute + "!" + DateTime.Now.Hour + "#" + DateTime.Now.Month + "%" + DateTime.Now.Day;
            #endregion

            string tmpConnStr = string.Empty, currUserAccount = string.Empty;
            int    loaiTK = 1, currUserID = 0;
            var    kq = XL.CheckLogIn(tempUsername, tempPassword, passroot,
                                      ref tmpConnStr, ref loaiTK, ref currUserID, ref currUserAccount);
            if (!kq)
            {
                tb_Password.Text = string.Empty;
                return;
            }
            // kq = true

            XL2.currUserID      = currUserID;
            XL2.currUserAccount = currUserAccount;
            XL.KhoiTaoDSPhongBan(XL2.TatcaPhongban);             // logic khởi tạo ds tất cả phòng ban mà tài khoản này được thao tác

            XL2.QuyenThaoTac = XL.LayPhanQuyen();

            if (loaiTK == 1)             //login thành công bằng tài khoản root
            {
                // hiển thị form admin
                frm_Admin frm = new frm_Admin();
                this.Hide();
                frm.Show();
            }
            else
            {
                XL.SaveSetting(lastAccLogIn: currUserAccount);
                XL.ChuanBiDSLichTrinhVaCa();

/*
 *                              SqlDataAccessHelper.ConnectionString = @"Data Source=.\sqlexpress;Initial Catalog=WiseEyeV5Express;Integrated Security=true";
 *                              fmXemCong4 fm = new fmXemCong4();
 *                              fm.Show();
 */
/*
 *                              fmTKeCongTheoNVu frm = new fmTKeCongTheoNVu();
 *                              this.Hide();
 *                              frm.ShowDialog();
 *                              this.Close();
 */

                frm_main frm = new frm_main();
                this.Hide();
                frm.ShowDialog();
                this.Close();

                // hiển thị form tài khoản thường
            }
        }
コード例 #2
0
        private void btnDangNhap_Click(object sender, EventArgs e)
        {
            string id = "admin";
            string mk = "123456";

            if (id.Equals(txtTenDangNhap.Text) && mk.Equals(txtMatKhau.Text))
            {
                frm_Admin f = new frm_Admin();
                this.Hide();
                f.ShowDialog();
                this.Show();
            }
            else
            {
                var ktradn = (from TAIKHOAN in dulieu.TAIKHOANs where TAIKHOAN.MANV == txtTenDangNhap.Text.Trim() && TAIKHOAN.MATKHAU == txtMatKhau.Text select TAIKHOAN).SingleOrDefault();
                if (ktradn == null)
                {
                    MessageBox.Show("Đăng nhập không thành công. Vui lòng kiểm tra lại!");
                }
                else
                {
                    frm_NhanVien f = new frm_NhanVien();
                    this.Hide();
                    f.ShowDialog();
                    this.Show();
                }
            }
        }