public void EmployeeUpdateByFirst() { EmployeeDto employeeDto = new EmployeeDto { TCompany = new CompanyDto { CompanyID = 2, Name = "Hillgate" }, UserName = "******", Password = "******" }; var employee = ServiceEmployee.FindByUserName(employeeDto); if (employee != null) { System.Diagnostics.Debug.WriteLine(String.Format("Id: {0} -> Name: {1} ", employee.EmployeeID, employee.FirstName + " " + employee.LastName)); employee.LastName = "Almeida Tereza"; ServiceEmployee.UpdateEmployee(employee); foreach (EmployeeDto employeeLoop in ServiceEmployee.GetAllEmployee(new EmployeeDto { TCompany = new CompanyDto { CompanyID = 2, Name = "Hillgate" } })) { System.Diagnostics.Debug.WriteLine("Employees:" + employeeLoop.EmployeeID + "-" + employeeLoop.FirstName + " " + employeeLoop.LastName); } } else { System.Diagnostics.Debug.WriteLine(String.Format("None with name: {0} ", employeeDto.UserName)); //Assert.Fail("Vazio"); } }
private void btnSave_Click(object sender, EventArgs e) { TBL_MP_Master_Employee model = null; ServiceEmployee serviceEmployee = new ServiceEmployee(); try { if (!this.ValidateChildren()) { return; } if (this.EmployeeID == 0) { model = new TBL_MP_Master_Employee(); } else { model = serviceEmployee.GetEmployeeDbRecordByID(this.EmployeeID); } #region GATHER DATA INTO MODEL FROM VIEW model.EmployeeCode = txtEmployeeCode.Text; model.EmployeeName = txtEmployeeName.Text; model.EmailAddress = txtEmail.Text; model.PhoneNo1 = txtMobileNo.Text; model.FK_DepartmentId = ((SelectListItem)cboDepartment.SelectedItem).ID; model.FK_DesignationId = ((SelectListItem)cboDesignation.SelectedItem).ID; model.FK_EmploymentTypeID = ((SelectListItem)cboEmploymentType.SelectedItem).ID; model.isActive = chkIsActive.Checked; model.IsResigned = chkHasResigned.Checked; model.FK_BossID = ((SelectListItem)cboEmployeeBoss.SelectedItem).ID; #endregion if (this.EmployeeID == 0) { //CREATE EMPLOYEE model.FK_CompanyID = Program.CURR_USER.CompanyID; model.FK_YearID = Program.CURR_USER.FinYearID; model.FK_BranchID = Program.CURR_USER.BranchID; model.CreatedBy = Program.CURR_USER.EmployeeID; model.CreatedDateTime = AppCommon.GetServerDateTime(); this.EmployeeID = serviceEmployee.AddNewEmployee(model); } else { model.ModifiedBy = Program.CURR_USER.EmployeeID; model.ModifiedDateTime = AppCommon.GetServerDateTime(); serviceEmployee.UpdateEmployee(model); } this.DialogResult = DialogResult.OK; } catch (Exception ex) { string errMessage = ex.Message; if (ex.InnerException != null) { errMessage += string.Format("\n{0}", ex.InnerException.Message); } MessageBox.Show(errMessage, "frmAddEditEmployee::btnSave_Click", MessageBoxButtons.OK, MessageBoxIcon.Error); } }