Beispiel #1
0
        private void btnEditHoTen_Click(object sender, EventArgs e)
        {
            if (AppState.state == Actions.NOTHING && currentEditButton == null)
            {
                currentEditButton       = sender as Guna2Button;
                currentEditButton.Image = Presentation_Layer.Properties.Resources.accept;
                AppState.state          = Actions.EDIT;
                tbHoTen.Enabled         = true;

                this.AcceptButton = sender as Guna2Button;
            }
            else if (AppState.state == Actions.EDIT && currentEditButton == sender as Guna2Button)
            {
                try
                {
                    string x = tbHoTen.Text;
                    tbHoTen.Enabled         = false;
                    currentEditButton.Image = Presentation_Layer.Properties.Resources.edit;
                    currentEditButton       = null;
                    AppState.state          = Actions.NOTHING;
                    User.Name = x;
                    if (BLL_UserLogin.UpdateUserInFor())
                    {
                        Notification.Show("Cập nhật thông tin thành công", Status.SUCCESS);
                    }

                    this.AcceptButton = null;
                }
                catch (Exception ex)
                {
                    Notification.Show(ex.Message, Status.WARNING);
                }
            }
        }
Beispiel #2
0
 public override void RefreshData()
 {
     if (AppState.state != Actions.NOTHING)
     {
         return;
     }
     BLL_UserLogin.LoadUserInfor();
     Notification.Show("Tải lại thông tin người dùng", Status.SUCCESS);
     reload();
 }
Beispiel #3
0
        private void btnEditNgaySinh_Click(object sender, EventArgs e)
        {
            if (AppState.state == Actions.NOTHING && currentEditButton == null)
            {
                currentEditButton       = sender as Guna2Button;
                currentEditButton.Image = Presentation_Layer.Properties.Resources.accept;
                AppState.state          = Actions.EDIT;
                tbNgaySinh.Enabled      = true;

                this.AcceptButton = sender as Guna2Button;
            }
            else if (AppState.state == Actions.EDIT && currentEditButton == sender as Guna2Button)
            {
                try
                {
                    string x       = tbNgaySinh.Text;
                    string pattern = @"^(?:(?:31(\/|-|\.)(?:0?[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0?[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:29(\/|-|\.)0?2\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:0?[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0?[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$";
                    if (Regex.IsMatch(x, pattern))
                    {
                        tbNgaySinh.Enabled      = false;
                        currentEditButton.Image = Presentation_Layer.Properties.Resources.edit;
                        currentEditButton       = null;
                        AppState.state          = Actions.NOTHING;
                        User.NgaySinh           = DateTime.ParseExact(x, "dd/MM/yyyy", null);
                        if (BLL_UserLogin.UpdateUserInFor())
                        {
                            Notification.Show("Cập nhật thông tin thành công", Status.SUCCESS);
                        }

                        this.AcceptButton = null;
                    }
                    else
                    {
                        Notification.Show("Sai định dạng ngày tháng", Status.WARNING);
                        showWarning("Sai Định Dạng", "Bạn cần nhập đúng định dạng ngày tháng");
                    }
                }
                catch (Exception ex)
                {
                    Notification.Show(ex.Message, Status.WARNING);
                    showWarning("Sai Định Dạng", "Bạn cần nhập đúng định dạng ngày tháng");
                }
            }
        }
Beispiel #4
0
        private void btnEditSDT_Click(object sender, EventArgs e)
        {
            if (AppState.state == Actions.NOTHING && currentEditButton == null)
            {
                currentEditButton       = sender as Guna2Button;
                currentEditButton.Image = Presentation_Layer.Properties.Resources.accept;
                AppState.state          = Actions.EDIT;
                tbDienThoai.Enabled     = true;

                this.AcceptButton = sender as Guna2Button;
            }
            else if (AppState.state == Actions.EDIT && currentEditButton == sender as Guna2Button)
            {
                try
                {
                    string x       = tbDienThoai.Text;
                    string pattern = @"\d+";
                    if (Regex.IsMatch(x, pattern))
                    {
                        tbDienThoai.Enabled     = false;
                        currentEditButton.Image = Presentation_Layer.Properties.Resources.edit;
                        currentEditButton       = null;
                        AppState.state          = Actions.NOTHING;
                        User.DienThoai          = x;
                        if (BLL_UserLogin.UpdateUserInFor())
                        {
                            Notification.Show("Cập nhật thông tin thành công", Status.SUCCESS);
                        }

                        this.AcceptButton = null;
                    }
                    else
                    {
                        Notification.Show("Sai định dạng số điện thoại", Status.WARNING);
                        showWarning("Sai Định Dạng", "Bạn cần nhập đúng định dạng số điện thoại");
                    }
                }
                catch (Exception ex)
                {
                    Notification.Show(ex.Message, Status.WARNING);
                }
            }
        }
Beispiel #5
0
 private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
 {
     if (tbPassword.Text != BLL_UserLogin.GetPassword(tbUsername.Text))
     {
         saveLogin(tbUsername.Text, "", false);
         backgroundWorker1.ReportProgress(0);
     }
     else
     {
         if (checkBox.Checked)
         {
             saveLogin(tbUsername.Text, tbPassword.Text, checkBox.Checked);
         }
         else
         {
             saveLogin(tbUsername.Text, "", checkBox.Checked);
         }
         backgroundWorker1.ReportProgress(1);
     }
 }
Beispiel #6
0
 private void backgroundWorker1_ProgressChanged(object sender, ProgressChangedEventArgs e)
 {
     if (e.ProgressPercentage == 0)
     {
         lbNoti.Text = "Sai tài khoản hoặc mật khẩu";
         lbNoti.Show();
         timer.Stop();
         btnLogin.Checked = false;
         btnLogin.Text    = ls[0];
     }
     else if (e.ProgressPercentage == 1)
     {
         BLL_UserLogin.LoadUserLogin(tbUsername.Text, tbPassword.Text);
         BLL_UserLogin.LoadUserPer();
         BLL_UserLogin.LoadUserInfor();
         BLL_ThamSo.LoadThamSo();
         lbNoti.Text = "Đăng nhập thành công!";
         lbNoti.Show();
         frmMain frm = new frmMain();
         frm.Show();
         this.BringToFront();
         backgroundWorker.RunWorkerAsync();
     }
 }