Exemple #1
0
 private int CheckLevelPositionWithPosCode(string empLogin)
 {
     try
     {
         PSEmployee employeeLogin = new PSEmployee();
         employeeLogin = BioBLL.GetEmployeeByCode(empLogin);
         PSEmployeePosition postion = new PSEmployeePosition();
         postion = BioBLL.GetPositionByCode(this.positionCode);
         int levelLogin = employeeLogin.PSEmployeePosition.Level;
         int level      = postion.Level;
         if (levelLogin < level)
         {
             return(1);
         }
         else if (levelLogin == level)
         {
             return(-1);
         }
         else
         {
             return(0);
         }
     }
     catch { return(-2); }
 }
Exemple #2
0
 private int CheckLevelPositionWithEmpCode(string empLogin, string empCode)
 {
     try
     {
         if (empLogin == empCode)
         {
             return(2);
         }
         else
         {
             PSEmployee employeeLogin = new PSEmployee();
             employeeLogin = BioBLL.GetEmployeeByCode(empLogin);
             PSEmployee employee = new PSEmployee();
             employee = BioBLL.GetEmployeeByCode(empCode);
             int levelLogin = employeeLogin.PSEmployeePosition.Level;
             int level      = employee.PSEmployeePosition.Level;
             if (levelLogin < level)
             {
                 return(1);
             }
             else if (levelLogin == level)
             {
                 return(-1);
             }
             else
             {
                 return(0);
             }
         }
     }
     catch { return(-2); }
 }
        private void btnSave_Click(object sender, EventArgs e)
        {
            PSEmployee emp = BioBLL.GetEmployeeByCode(this.empLogin);

            if (emp.Password != BioBLL.GetMD5(txtPassOld.Text))
            {
                XtraMessageBox.Show("Sai mật khẩu cũ. Vui lòng nhập lại!", "iHIS - Bệnh viện điện tử", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtPassOld.Focus();
                return;
            }
            if (string.IsNullOrEmpty(txtPassNew.Text))
            {
                XtraMessageBox.Show("Không được để trống mật khẩu mới", "iHIS - Bệnh viện điện tử", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtPassNew.Focus();
                return;
            }
            if (string.IsNullOrEmpty(txtPassConfirm.Text))
            {
                XtraMessageBox.Show("Không được để trống nhập lại mật khấu mới", "iHIS - Bệnh viện điện tử", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtPassConfirm.Focus();
                return;
            }
            if (txtPassNew.Text != txtPassConfirm.Text)
            {
                XtraMessageBox.Show("Nhập lại mật khẩu mới không trùng nhau", "iHIS - Bệnh viện điện tử", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtPassConfirm.Focus();
                return;
            }
            if (BioBLL.UpdPassEmployee(this.empLogin, txtPassConfirm.Text))
            {
                XtraMessageBox.Show("Cập nhật mật khẩu thành công", "iHIS - Bệnh viện điện tử", MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.ClearText();
            }
            else
            {
                XtraMessageBox.Show("Cập nhật mật khẩu thất bại", "iHIS - Bệnh viện điện tử", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemple #4
0
 private void gridView_Employee_ValidateRow(object sender, DevExpress.XtraGrid.Views.Base.ValidateRowEventArgs e)
 {
     try
     {
         GridView view     = sender as GridView;
         int      rowfocus = e.RowHandle;
         if (string.IsNullOrEmpty(Convert.ToString(view.GetRowCellValue(rowfocus, col_EmployeeName))))
         {
             e.Valid = false;
             view.SetColumnError(col_EmployeeName, "Họ tên nhân viên không được để trống!");
         }
         if (string.IsNullOrEmpty(Convert.ToString(view.GetRowCellValue(rowfocus, col_EmployeeUsername))))
         {
             e.Valid = false;
             view.SetColumnError(col_EmployeeUsername, "Tên đăng nhập được để trống!");
         }
         if (string.IsNullOrEmpty(Convert.ToString(view.GetRowCellValue(rowfocus, col_Employee_Sex))))
         {
             e.Valid = false;
             view.SetColumnError(col_Employee_Sex, "Chưa chọn giới tính!");
         }
         if (string.IsNullOrEmpty(Convert.ToString(view.GetRowCellValue(rowfocus, col_EmployeePosition))))
         {
             e.Valid = false;
             view.SetColumnError(col_EmployeePosition, "Chưa chức danh cho nhân viên!");
         }
         if (string.IsNullOrEmpty(Convert.ToString(view.GetRowCellValue(rowfocus, col_EmployeeGroup))))
         {
             e.Valid = false;
             view.SetColumnError(col_EmployeeGroup, "Chưa nhóm cho nhân viên!");
         }
         if (e.Valid)
         {
             PSEmployee emp = new PSEmployee();
             emp.EmployeeCode = gridView_Employee.GetRowCellValue(e.RowHandle, "EmployeeCode").ToString();
             emp.EmployeeName = gridView_Employee.GetRowCellValue(e.RowHandle, "EmployeeName").ToString();
             if (gridView_Employee.GetRowCellValue(e.RowHandle, "Sex").ToString() != "")
             {
                 emp.Sex = int.Parse(gridView_Employee.GetRowCellValue(e.RowHandle, "Sex").ToString());
             }
             emp.Mobile  = gridView_Employee.GetRowCellValue(e.RowHandle, "Mobile").ToString();
             emp.IDCard  = gridView_Employee.GetRowCellValue(e.RowHandle, "IDCard").ToString();
             emp.Address = gridView_Employee.GetRowCellValue(e.RowHandle, "Address").ToString();
             if (!string.IsNullOrEmpty(gridView_Employee.GetRowCellValue(e.RowHandle, "Birthday").ToString()))
             {
                 emp.Birthday = DateTime.Parse(gridView_Employee.GetRowCellValue(e.RowHandle, "Birthday").ToString());
             }
             emp.PositionCode    = int.Parse(gridView_Employee.GetRowCellValue(e.RowHandle, "PositionCode").ToString());
             emp.CreateDate      = DateTime.Now;
             emp.Username        = gridView_Employee.GetRowCellValue(e.RowHandle, "Username").ToString();
             emp.EmployeeGroupID = int.Parse(gridView_Employee.GetRowCellValue(e.RowHandle, "EmployeeGroupID").ToString());
             if (e.RowHandle < 0)
             {
                 if (!BioBLL.CheckExistUser(emp.Username))
                 {
                     XtraMessageBox.Show("Tên đăng nhập đã tồn tại!", "Bệnh viện điện tử .NET", MessageBoxButtons.OK, MessageBoxIcon.Error);
                     this.gridControl_Employee.DataSource = BioBLL.DTEmployee(string.Empty);
                     return;
                 }
                 if (BioBLL.InsEmployee(emp))
                 {
                     XtraMessageBox.Show("Thêm mới nhân viên thành công!", "Bệnh viện điện tử .NET", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 }
                 else
                 {
                     XtraMessageBox.Show("Thêm nhân viên thất bại!", "Bệnh viện điện tử .NET", MessageBoxButtons.OK, MessageBoxIcon.Error);
                 }
             }
             else
             {
                 PSEmployee empOld = BioBLL.GetEmployeeByCode(emp.EmployeeCode);
                 if (empOld.Username != emp.Username)
                 {
                     if (!BioBLL.CheckExistUser(emp.Username))
                     {
                         XtraMessageBox.Show("Tên đăng nhập đã tồn tại!", "Bệnh viện điện tử .NET", MessageBoxButtons.OK, MessageBoxIcon.Error);
                         this.gridControl_Employee.DataSource = BioBLL.DTEmployee(string.Empty);
                         return;
                     }
                 }
                 if (BioBLL.UpdEmployee(emp))
                 {
                     XtraMessageBox.Show("Cập nhật nhân viên thành công!", "Bệnh viện điện tử .NET", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 }
                 else
                 {
                     XtraMessageBox.Show("Cập nhật nhân viên thất bại!", "Bệnh viện điện tử .NET", MessageBoxButtons.OK, MessageBoxIcon.Error);
                 }
             }
             this.gridControl_Employee.DataSource = BioBLL.DTEmployee(string.Empty);
         }
     }
     catch
     {
         XtraMessageBox.Show("Thao tác thất bại!", "Bệnh viện điện tử .NET", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }