/// <summary> /// Generate a UserName and Password /// </summary> /// <param name="employeeID">employeeID</param> public void GenerateUserNameAndPassword(int employeeID) { try { // Get the details of the employee using the employee id EmployeeDL employee = new EmployeeDL(employeeID, true); // Store the Employee's Company ID in a hidden variable //hdfEmployeeCompanyID.Value = employee.CompanyID.ToString(); hdfEmployeeCompanyID.Value = employee.CompanyID.cxToString(); // Store the Employee's Office Email Id in a hidden variable hdfOfficeEmailID.Value = employee.OfficeEmailID; // Generate the user name - company id + employee code //txtUserName.Text = employee.CompanyID.ToString().Trim() + employee.EmployeeCode.Trim(); txtUserName.Text = employee.CompanyID.cxToString().Trim() + employee.EmployeeCode.cxToString().Trim(); // Generate the user password - Utilities objPwd = new Utilities(); if (employee.Dob != null) { DateTime dob = (DateTime)employee.Dob; txtPassword.Text = objPwd.EncryptText(Convert.ToString(dob.ToString("dd") + employee.EmployeeCode.ToString() + dob.ToString("MM"))); } } catch (Exception ex) { ErrorLog.LogErrorMessageToDB("AddEditUser.aspx", "", "GenerateUserNameAndPassword", ex.Message.ToString(), new ACEConnection()); } }
/// <summary> /// Values of the form are set /// </summary private void AssignValues() { try { // Assign the User Details to the Form Labels lblUserNameValue.Text = _currentUser.UserName.ToString(); Utilities objPwd = new Utilities(); lblPasswordValue.Text = objPwd.DecryptText(_currentUser.Password); if (_currentUser.EmployeeID != 0) { EmployeeDL employee = new EmployeeDL(_currentUser.EmployeeID, true); //lblEmployeeCodeValue.Text = Common.CheckBlank(employee.EmployeeCode); //lblEmployeeNameValue.Text = Common.CheckBlank(employee.EmployeeName); lblEmployeeCodeValue.Text = employee.EmployeeCode.cxToString(); lblEmployeeNameValue.Text = employee.EmployeeName.cxToString(); chkIsValidValue.Checked = _currentUser.IsValid; } // Assign the list of User Companies to the grid gvUserCompanies.DataSource = _currentUser.UserCompanies; gvUserCompanies.DataBind(); } catch (Exception ex) { ErrorLog.LogErrorMessageToDB("ViewUser.aspx", "", "AssignValues", ex.Message.ToString(), new ACEConnection()); } }
public void updateData(EmployeeBL empBL) { EmployeeDL empDL = new EmployeeDL(); empDL.Updatedata(empBL); empDL = null; }
public void insertData(EmployeeBL empBL) { EmployeeDL empDL = new EmployeeDL(); empDL.insertdata(empBL); empDL = null; }
protected override void Validate(Employee entity) { base.Validate(entity); if (entity is Employee) { var employee = entity as Employee; EmployeeDL employeeDL = new EmployeeDL(); // Validate dữ liệu: // 1. Đã nhập mã hay chưa? nếu chưa nhập thì đưa ra cảnh báo lỗi: //if (string.IsNullOrEmpty(employee.EmployeeCode)) //{ // throw new GuardException<Employee>("Mã nhân viên không được phép để trống.", employee); //} // 2. Check mã khách hàng đã tồn tại hay chưa? var isExists = employeeDL.CheckEmployeeCodeExist(employee.EmployeeCode); if (isExists == true) { throw new GuardException <Employee>("Mã nhân viên đã tồn tại trong hệ thống, vui lòng kiểm tra lại", null); } // 3. Kiểm tra Email có đúng định dạng hay không? //var emailTemplate = @"[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?"; //if (!Regex.IsMatch(employee.Email, emailTemplate)) //{ //throw new GuardException<Employee>("Email không đúng định dạng, vui lòng kiểm tra lại", null); //} // 4. Kiểm tra Mã đơn vị đã nhập hay chưa? //if (string.IsNullOrEmpty(employee.DepartmentId.ToString())) //{ // throw new GuardException<Employee>("Tên đơn vị không được phép để trống.", employee); //} } }
public void DeleteData(EmployeeBL empBL) { EmployeeDL empDL = new EmployeeDL(); empDL.Deletedata(empBL); empDL = null; }
/// <summary> /// To get the list of available employees (in the current selected company) /// </summary> /// <param name="searchText">The text to search</param> private void GetEmployeeDetails(string searchText, bool activatedDeactivated) { try { // Get the list of employees EmployeeDL employeeDetails = new EmployeeDL(); DataView dView = employeeDetails.GetEmployeeByCompanyID(_companyID, searchText, activatedDeactivated).Tables[0].DefaultView; dView.Sort = ViewState["SortExpression"].ToString() + " " + ViewState["SortDirection"].ToString(); if (dView.Table.Rows.Count == 0) { dView.Table.Rows.Add(dView.Table.NewRow()); gvEmployeeDetails.DataSource = dView; gvEmployeeDetails.DataBind(); int columncount = gvEmployeeDetails.Rows[0].Cells.Count; gvEmployeeDetails.Rows[0].Cells.Clear(); gvEmployeeDetails.Rows[0].Cells.Add(new TableCell()); gvEmployeeDetails.Rows[0].Cells[0].ColumnSpan = columncount; gvEmployeeDetails.Rows[0].Cells[0].Attributes.CssStyle.Add("text-align", "Center"); gvEmployeeDetails.Rows[0].Cells[0].Attributes.CssStyle.Add("font-weight", "bold"); gvEmployeeDetails.Rows[0].Cells[0].Text = "Currently there are no entries to display"; } else { gvEmployeeDetails.DataSource = dView; gvEmployeeDetails.DataBind(); } } catch (Exception ex) { ErrorLog.LogErrorMessageToDB("ManageEmployee.aspx", "", "GetEmployeeDetails(string searchText)", ex.Message.ToString(), new ACEConnection()); } }
private static void RegisterDependencies(Container container) { SqlConnection con = new SqlConnection(@"Data Source=B283LCOK\SQLEXPRESS;Initial Catalog=EmployeeDB;Integrated Security=True"); EmployeeDL empdl = new EmployeeDL(con); container.Register <IEmployeeBL, EmployeeBL>(Lifestyle.Scoped); container.Register <IEmployeeDL> (() => new EmployeeDL(con), Lifestyle.Scoped); }
// GET: Employee public ActionResult Index(int id) { Employee employee = new Employee(); EmployeeDL employeeDL = new EmployeeDL(); employee = employeeDL.GetEmployee(id); return(View(employee)); }
public void Actualiza(EmployeeBE pItem) { try { EmployeeDL Employee = new EmployeeDL(); Employee.Actualiza(pItem); } catch (Exception ex) { throw ex; } }
public List <EmployeeBE> ListaCargo(string Cargo) { try { EmployeeDL Employee = new EmployeeDL(); return(Employee.ListaCargo(Cargo)); } catch (Exception ex) { throw ex; } }
public List <EmployeeBE> ListaCombo(int IdCompany) { try { EmployeeDL Employee = new EmployeeDL(); return(Employee.ListaCombo(IdCompany)); } catch (Exception ex) { throw ex; } }
public int SeleccionaBusquedaCount(int IdEmpresa, int IdSituacion, string pFiltro) { try { EmployeeDL Employee = new EmployeeDL(); return(Employee.SeleccionaBusquedaCount(IdEmpresa, IdSituacion, pFiltro)); } catch (Exception ex) { throw ex; } }
public void Elimina(EmployeeBE pItem) { try { EmployeeDL Employee = new EmployeeDL(); Employee.Elimina(pItem); } catch (Exception ex) { throw ex; } }
public List <EmployeeBE> ListaTodosActivo(int IdEmpresa, int IdArea) { try { EmployeeDL Employee = new EmployeeDL(); return(Employee.ListaTodosActivo(IdEmpresa, IdArea)); } catch (Exception ex) { throw ex; } }
public void Inserta(EmployeeBE pItem) { try { EmployeeDL Employee = new EmployeeDL(); Employee.Inserta(pItem); } catch (Exception ex) { throw ex; } }
public List <EmployeeBE> SeleccionaBusqueda(int IdEmpresa, int IdSituacion, string pFiltro, int Pagina, int CantidadRegistro) { try { EmployeeDL Employee = new EmployeeDL(); return(Employee.SeleccionaBusqueda(IdEmpresa, IdSituacion, pFiltro, Pagina, CantidadRegistro)); } catch (Exception ex) { throw ex; } }
public EmployeeBE SeleccionaDescripcion(int IdEmpresa, int IdArea, string DescEmployee) { try { EmployeeDL Employee = new EmployeeDL(); EmployeeBE objEmp = Employee.SeleccionaDescripcion(IdEmpresa, IdArea, DescEmployee); return(objEmp); } catch (Exception ex) { throw ex; } }
public void SaveEmployee_DL(string name, string address, int age, int jobId) { SqlConnection con = new SqlConnection(@"Data Source=B283LCOK\SQLEXPRESS;Initial Catalog=EmployeeDB;Integrated Security=True"); EmployeeDetails empDet = new EmployeeDetails() { Name = name, Address = address, Age = age, EmployeeJobID = jobId }; var dlayer = new EmployeeDL(con); dlayer.SaveEmployeeTest(empDet); }
public EmployeeBE SeleccionaNumeroDocumento(string Dni) { try { EmployeeDL Employee = new EmployeeDL(); EmployeeBE objEmp = Employee.SeleccionaNumeroDocumento(Dni); return(objEmp); } catch (Exception ex) { throw ex; } }
public void EmployeeDL_GetAll_Return_Empty() { //arrange List <Employee> employees = null; List <EmployeeDto> expectedValue = null; var dl = new EmployeeDL(_mockEmployeeRepository.Object, _mockMapper.Object); _mockEmployeeRepository.Setup(x => x.All()).Returns((List <Employee>)null); _mockMapper.Setup(x => x.Map <IEnumerable <EmployeeDto> >(employees)).Returns(expectedValue); //act var result = dl.GetAll(); //assert Assert.AreEqual(expectedValue, result); }
public static List<Employee> GetAllEmployeeBL() { List<Employee> employeeList = null; try { EmployeeDL employeeDL = new EmployeeDL(); employeeList = employeeDL.GetAllEmployeeDAL(); } catch (EmsException ex) { throw ex; } catch (Exception ex) { throw ex; } return employeeList; }
/// <summary> /// Values of the form are set /// </summary private void AssignValues() { try { // Assign the User Details to the Form Controls txtUserID.Text = _currentUser.UserID.ToString(); txtUserName.Text = _currentUser.UserName.ToString(); txtPassword.Text = Common.CheckBlank(_currentUser.Password); if (_currentUser.EmployeeID != 0) { EmployeeDL employee = new EmployeeDL(_currentUser.EmployeeID, true); lblEmployeeName.Text = employee.EmployeeName; //lblEmployeeCode.Text = employee.EmployeeCode.ToString(); //lblEmployeeID.Text = employee.EmployeeID.ToString(); lblEmployeeCode.Text = employee.EmployeeCode.cxToString(); lblEmployeeID.Text = employee.EmployeeID.cxToString(); hdfOfficeEmailID.Value = employee.OfficeEmailID; // Generate a User Name and Password GenerateUserNameAndPassword(employee.EmployeeID); } chkValid.Checked = _currentUser.IsValid; // Assign the list of User Companies to the grid gvUserCompanies.DataSource = _currentUser.UserCompanies; gvUserCompanies.DataBind(); if (txtUserID.Text.ToString() != "0" && txtUserID.Text.ToString() != "") { tcntAllUserTabs.Visible = true; } } catch (Exception ex) { ErrorLog.LogErrorMessageToDB("AddEditUser.aspx", "", "AssignValues", ex.Message.ToString(), new ACEConnection()); } }
public static Employee SearchEmployeeBL(int EmployeeID) { Guest searchEmployee = null; try { EmployeeDL employeeDL = new EmployeeDL(); searchEmployee = employeeDL.SearchEmployeeDAL(EmployeeID); } catch (EmsException ex) { throw ex; } catch (Exception ex) { throw ex; } return searchEmployee; }
public void EmployeeDL_GetAll_Return_List() { //arrange var employees = new List <Employee> { new Employee { Id = 1, FirstName = "John", LastName = "Smith" }, new Employee { Id = 2, FirstName = "Mark", LastName = "Stan" }, new Employee { Id = 3, FirstName = "Eric", LastName = "Lee" }, new Employee { Id = 4, FirstName = "Grace", LastName = "Rock" } }; var expectedValue = new List <EmployeeDto> { new EmployeeDto { Id = 1, FirstName = "John", LastName = "Smith" }, new EmployeeDto { Id = 2, FirstName = "Mark", LastName = "Stan" }, new EmployeeDto { Id = 3, FirstName = "Eric", LastName = "Lee" }, new EmployeeDto { Id = 4, FirstName = "Grace", LastName = "Rock" } }; var dl = new EmployeeDL(_mockEmployeeRepository.Object, _mockMapper.Object); _mockEmployeeRepository.Setup(x => x.All()).Returns(employees); _mockMapper.Setup(x => x.Map <IEnumerable <EmployeeDto> >(employees)).Returns(expectedValue); //act var result = dl.GetAll(); //assert Assert.AreEqual(expectedValue.Count, result.Count()); }
/// <summary> /// gvEmployeeDetails_RowEditing /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void gvEmployeeDetails_RowEditing(object sender, GridViewEditEventArgs e) { try { // Get the selected row's employee id int employeeIDToEdit = Convert.ToInt32(gvEmployeeDetails.DataKeys[e.NewEditIndex].Value); txtSearchID.Text = ""; // Transfer Control to Add / Edit Employee Form with the employee id as querystring _currentEmployee = new EmployeeDL(employeeIDToEdit, true); txtEmployeeID.Text = _currentEmployee.EmployeeID.ToString();; txtEmployeeCode.Text = _currentEmployee.EmployeeCode; txtEmployeeInitial.Text = _currentEmployee.Initial; txtEmployeeName.Text = _currentEmployee.FName; if (_currentEmployee.GenderID != 0) { ddlGender.SelectedValue = Convert.ToString(_currentEmployee.GenderID); } DateTime dTime; dTime = Convert.ToDateTime(_currentEmployee.Dob); txtDOB.Text = Common.CheckBlank(Convert.ToString(dTime.ToString(_dateFormat))); dTime = Convert.ToDateTime(_currentEmployee.Doj); txtDOJ.Text = Common.CheckBlank(Convert.ToString(dTime.ToString(_dateFormat))); if (_currentEmployee.DepartmentID != 0) { ddlDepartment.SelectedValue = Convert.ToString(_currentEmployee.DepartmentID); } trRole.Visible = false; txtEmployeeCode.Enabled = false; txtOfficeMailID.Text = _currentEmployee.OfficeEmailID; lblPopupHeading.Text = "Edit Employee"; mpeManageEmployee.Show(); e.Cancel = true; } catch (Exception ex) { ErrorLog.LogErrorMessageToDB("ManageEmployee.aspx", "", "gvEmployeeDetails_RowEditing", ex.Message.ToString(), new ACEConnection()); } }
public void InsertaMasivo(List <EmployeeBE> pListaEmployee) { try { using (TransactionScope ts = new TransactionScope()) { EmployeeDL objEmployee = new EmployeeDL(); foreach (EmployeeBE item in pListaEmployee) { objEmployee.InsertaMasivo(item); } ts.Complete(); } } catch (Exception ex) { throw ex; } }
public static bool AddEmployeeBL(Employee newEmployee) { bool employeeAdded = false; try { if (ValidateEmployee(newEmployee)) { employeeDL employeeDL = new EmployeeDL(); employeeAdded = employeeDL.AddemployeeDL(newEmployee); } } catch (EmsException) { throw; } catch (Exception ex) { throw ex; } return employeeAdded; }
public DataSet GetEmployeeData() { EmployeeDL empDL = new EmployeeDL(); return(empDL.Get_Employees()); }
public EmployeeBL() { employeeDL = new EmployeeDL(); }