示例#1
0
        private void txtUsername_KeyPress(object sender, KeyPressEventArgs e)
        {
            balEmployee        balEmployee  = new balEmployee();
            List <dtoEmployee> dtoEmployees = new List <dtoEmployee>();

            try
            {
                if (e.KeyChar == (char)13)
                {
                    if (txtUsername.Text != frmLogin.UserLogin.EmployeeID.ToString())
                    {
                        throw new Exception("Sai thông tin đăng nhập, vui lòng nhập lại!");
                    }
                    else if (txtUsername.Text == "" || txtPass.Text == "" || txtNewPass.Text == "" || txtConfirmPass.Text == "")
                    {
                        throw new Exception("Vui lòng nhập đầy đủ thông tin tài khoản!");
                    }
                    else if (!balEmployee.Login(Convert.ToInt32(txtUsername.Text), txtPass.Text))
                    {
                        throw new Exception("Sai thông tin đăng nhập, vui lòng nhập lại!");
                    }
                    else if (txtNewPass.Text != txtConfirmPass.Text)
                    {
                        throw new Exception("Mật khẩu mới và xác nhận không khớp!");
                    }
                    else
                    {
                        balEmployee.UpdatePassword(Convert.ToInt32(txtUsername.Text), txtNewPass.Text);
                        txtPass.Text        = "";
                        txtConfirmPass.Text = "";
                        txtNewPass.Text     = "";
                        XtraMessageBox.Show("Đổi mật khẩu thành công!", "Successful", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        this.Hide();
                    }
                }
            }
            catch (Exception ex)
            {
                XtraMessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void btnEditInfor_Click(object sender, EventArgs e)
        {
            frmMainPage.EmployeeTemp.EmployeeID          = Convert.ToInt32(txtEmployeeID.Text);
            frmMainPage.EmployeeTemp.Gender              = txtGender.Text;
            frmMainPage.EmployeeTemp.EmployeeFullName    = txtFullName.Text;
            frmMainPage.EmployeeTemp.EmployeeBirthday    = Convert.ToDateTime(txtBirthDay.Text);
            frmMainPage.EmployeeTemp.EmployeeAddress     = txtAddress.Text;
            frmMainPage.EmployeeTemp.EmployeePhoneNumber = txtPhoneNumber.Text;
            frmMainPage.EmployeeTemp.EmployeeEmail       = txtEmail.Text;
            frmMainPage.EmployeeTemp.StartDay            = Convert.ToDateTime(txtStartDay1.Text);
            frmMainPage.EmployeeTemp.JobtitleName        = txtJobTitle1.Text;
            frmMainPage.EmployeeTemp.BasicSalary         = Convert.ToDecimal(txtBasicSalary1.Text);
            frmMainPage.EmployeeTemp.CoefficientsSalary  = Convert.ToInt32(txtCoe.Text);
            frmMainPage.EmployeeTemp.PositionAllowance   = Convert.ToDecimal(txtPosi.Text);
            frmMainPage.EmployeeTemp.Major = txtMajor1.Text;
            balEmployee employee = new balEmployee();
            int         count    = employee.UpdateFromView(frmMainPage.EmployeeTemp);
            string      mess     = "Thông tin nhân viên đã được update thành công!" + "\nSố hàng đã được update: " + count.ToString();

            XtraMessageBox.Show(mess, "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
示例#3
0
        private void txtUsername_KeyPress(object sender, KeyPressEventArgs e)
        {
            balEmployee             balEmployee     = new balEmployee();
            balViewEmployee         balViewEmployee = new balViewEmployee();
            List <dtoViewEmployees> listEmployee    = balViewEmployee.GetViewEmployees();

            try
            {
                if (e.KeyChar == (char)13)
                {
                    if (txtUsername.Text == "" || txtPass.Text == "")
                    {
                        throw new Exception("Vui lòng nhập đầy đủ thông tin đăng nhập!");
                    }
                    else if (!balEmployee.Login(Convert.ToInt32(txtUsername.Text), txtPass.Text))
                    {
                        throw new Exception("Sai thông tin đăng nhập, vui lòng nhập lại!");
                    }
                    else
                    {
                        flag = true;
                        foreach (dtoViewEmployees i in listEmployee)
                        {
                            if (Convert.ToInt32(txtUsername.Text) == i.EmployeeID)
                            {
                                UserLogin = i;
                            }
                        }
                        txtPass.Text = "";
                        XtraMessageBox.Show("Đăng nhập thành công!", "Successful", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        this.Hide();
                    }
                }
            }
            catch (Exception ex)
            {
                XtraMessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }