Example #1
0
        private void DangNhap()
        {
            #region Kiem tra dieu kien
            if (string.IsNullOrEmpty(txtTenTruyCap.Text.Trim()))
            {
                XtraMessageBox.Show("Bạn chưa nhập tên truy cập.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                txtTenTruyCap.Focus();
                return;
            }
            #endregion

            try
            {
                TaiKhoan.TAI_KHOAN_HIEN_TAI = _dataTaiKhoan.LayDuLieu(txtTenTruyCap.Text, txtMatKhau.Text);
                if (TaiKhoan.TAI_KHOAN_HIEN_TAI == null)
                {
                    XtraMessageBox.Show("Không tìm thấy tên truy cập trong hệ thống.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    txtTenTruyCap.Focus();
                }
                else if (TaiKhoan.TAI_KHOAN_HIEN_TAI.MatKhau == "")   //Sai mật khẩu vẫn lấy ra tài khoản như mật khẩu sẽ là chuỗi rỗng
                {
                    XtraMessageBox.Show("Sai mật khẩu.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    txtMatKhau.Focus();
                }
                else if (!TaiKhoan.TAI_KHOAN_HIEN_TAI.TrangThai)
                {
                    XtraMessageBox.Show("Tên truy cập này đang bị khóa.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    txtTenTruyCap.Focus();
                    return;
                }
                else
                {
                    Close();
                    //DevExpress.LookAndFeel.UserLookAndFeel.Default.SetSkinStyle(UserInfo.User.SkinName);
                    //UserInfo.SkinName = UserInfo.User.SkinName;
                    Core.AppSystem.InitControl();
                    //UserInfo.LoginType = UserTypes.None;
                    frmThongTin frm = new frmThongTin {
                        MdiParent = frmMain.Instance
                    };
                    frm.Show();
                }
                //if (UserInfo.IsSystemLogin(txtTenTruyCap.Text, txtMatKhau.Text))
                //{
                //    Close();
                //    //DevExpress.LookAndFeel.UserLookAndFeel.Default.SetSkinStyle(UserInfo.SkinName);
                //    AppSystem.InitSystem();
                //    UserInfo.LoginType = UserTypes.System;
                //    frmThongTin frm = new frmThongTin { MdiParent = frmMain.Instance };
                //    frm.Show();
                //}
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + "\n" + ex.StackTrace);
            }
        }
Example #2
0
        private bool DangNhap(string user, string pass)
        {
            //if (user == "") return false;

            //Gắn tên đăng nhập để lưu log
            //PMS.Data.Utility.userID = UserInfo.UserName;

            //bool? isValid = UserInfo.IsLogin(user, pass);

            //if (isValid != null)
            //{
            //    if (isValid == true)
            //    {
            //        if (UserInfo.User.TrangThai == true)
            //        {
            //            return false;
            //        }

            //AppSystem.InitControl();
            //UserInfo.LoginType = PMS.Common.UserTypes.None;
            frmThongTin frm = new frmThongTin {
                MdiParent = frmMain.Instance
            };

            frm.Show();
            //Init cache
            //    }
            //    else
            //    {
            //        return false;
            //    }
            //}
            //else
            //{
            //    if (UserInfo.IsSystemValid(user))
            //    {
            //        if (UserInfo.IsSystemLogin(user, pass))
            //        {
            //            Close();
            //            //DevExpress.LookAndFeel.UserLookAndFeel.Default.SetSkinStyle(UserInfo.SkinName);
            //            AppSystem.InitSystem();
            //            UserInfo.LoginType = PMS.Common.UserTypes.System;
            //            frmThongTin frm = new frmThongTin { MdiParent = frmMain.Instance };
            //            frm.Show();
            //        }
            //        else
            //        {
            //            return false;
            //        }
            //    }
            //    else
            //    {
            //        return false;
            //    }
            //}
            return(true);
        }