Exemple #1
0
        private void btnUpdateUser_Click(object sender, EventArgs e)
        {
            if (txtUser.Text == "")
            {
                XtraMessageBox.Show("Bạn chưa nhập tên đăng nhập", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Error);

                return;
            }
            if (txtPassword.Text == "")
            {
                XtraMessageBox.Show("Bạn chưa nhập mật khẩu", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (lueChucVu.Text == "")
            {
                XtraMessageBox.Show("Bạn chưa chọn chức vụ", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            try
            {
                var user = new USER()
                {
                    UserName   = txtUser.Text,
                    Password   = txtPassword.Text,
                    ChucVu     = lueChucVu.EditValue.ToString(),
                    MoTaChucVu = lueChucVu.Text,
                    ten        = txtHoTen.Text,
                    DiaChi     = txtAddress.Text,
                    SoDT       = txtNumberPhone.Text,
                };

                string msg    = "";
                var    result = new USERSBll().saveUser(user, ref msg);

                XtraMessageBox.Show("Cập nhật thông tin tài khoản thành công !", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                LoadData();
                ClearDisplay();
                return;
            }
            catch (Exception ex)
            {
                XtraMessageBox.Show(ex.Message, "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Error);

                return;
            }
        }
Exemple #2
0
 private void btnOK_Click(object sender, EventArgs e)
 {
     if (txtNewPass.Text == string.Empty || txtOldPass.Text == string.Empty || txtRegisPass.Text == string.Empty)
     {
         XtraMessageBox.Show("Vui lòng nhập đầy đủ thông tin!", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
     else
     if (txtOldPass.Text != Properties.Settings.Default.PasswordLog)
     {
         lbOld.Text = "Mật khẩu cũ không chính xác";
     }
     else
     if (txtNewPass.Text != txtRegisPass.Text)
     {
         return;
     }
     else
     if (txtOldPass.Text == txtNewPass.Text)
     {
         return;
     }
     else
     {
         try
         {
             string msg  = "";
             var    USER = new USERSBll().ChangePassword(NameLog, txtNewPass.Text, ref msg);
             if (msg == "success")
             {
                 Properties.Settings.Default.PasswordLog = USER.Password;
                 XtraMessageBox.Show("Đổi mật khẩu thành công!", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 this.Close();
             }
             else
             {
                 XtraMessageBox.Show(msg, "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
         }
         catch (Exception ex)
         {
             XtraMessageBox.Show(ex.Message, "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
 }
Exemple #3
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            try
            {
                if (txtUser.Text == string.Empty || txtPassword.Text == string.Empty)
                {
                    XtraMessageBox.Show("Vui lòng nhập đầy đủ thông tin!", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                else
                {
                    try
                    {
                        var outmess    = string.Empty;
                        var checkLogin = new USERSBll().Login(txtUser.Text, txtPassword.Text, ref outmess);
                        UserName = txtUser.Text;
                        if (checkLogin != null)
                        {
                            if (checkSave.Checked)
                            {
                                Properties.Settings.Default.user     = txtUser.Text;
                                Properties.Settings.Default.password = txtPassword.Text;
                                Properties.Settings.Default.Save();
                            }
                            else
                            {
                                Properties.Settings.Default.user     = "";
                                Properties.Settings.Default.password = "";
                                Properties.Settings.Default.Save();
                            }
                            XtraMessageBox.Show("Đăng nhập thành công!", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            Properties.Settings.Default.NameLog     = txtUser.Text;
                            Properties.Settings.Default.PasswordLog = txtPassword.Text;
                            this.Hide();
                            frmMain main = new frmMain();
                            main.Decentralization(checkLogin.ChucVu);
                            main.ShowDialog();

                            txtUser.Text     = "";
                            txtPassword.Text = "";
                            this.Show();
                        }
                        else
                        {
                            XtraMessageBox.Show("Tài khoản hoặc mật khẩu không chính xác!", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            this.Show();
                            return;
                        }
                    }
                    catch
                    {
                        XtraMessageBox.Show("Đăng nhập thất bại!", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        this.Show();
                        return;
                    }
                }
            }
            catch
            {
                XtraMessageBox.Show("Đăng nhập thất bại!", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
        }