public override bool Commit() { if (!IsValid()) { return(false); } Domain.Employee emp = (Domain.Employee)Entity; if (emp.FirstName != teFirstName.Text) { emp.FirstName = teFirstName.Text; Modified = true; } if (emp.LastName != teSecondName.Text) { emp.LastName = teSecondName.Text; Modified = true; } if (emp.PersID != tePersonalID.Text) { emp.PersID = tePersonalID.Text; Modified = true; } return(true); }
public override void Edit() { if (Context != null && FocusedEntity != null && Context.CurrentStore != null) { List <Domain.StoreToWorld> lst = null; lst = swController.GetListByStoreId(Context.CurrentStore.ID); if (lst.Count == 0) { lst = ClientEnvironment.StoreToWorldService.FindAllForStore(Context.CurrentStore.ID); swController.AddList(lst); } using (FormAssignEmployeeToWorld assignform = new FormAssignEmployeeToWorld()) { Domain.Employee empl = Context.CurrentEmployee; Context.CurrentRelation = FocusedEntity; assignform.SetWorldList(swController.GetListByStoreId(Context.CurrentStore.ID)); assignform.Entity = Context; if (assignform.ShowDialog() == DialogResult.OK) { LoadEmployeeRelation(); //m_Relations.ResetItemById(Context.CurrentRelation.ID); } } } }
public void FireDeleteEntity() { if (Context != null && FocusedEntity != null && DeleteEnabled) { EmployeeLongTimeAbsence newAbsence = FocusedEntity; if (QuestionMessageYes(GetLocalized("QuestionRemoveEmplLongTimeAbsence"))) { try { ClientEnvironment.EmployeeLongTimeAbsenceService.DeleteByID(newAbsence.ID); EmployeesLongTimeAbsence.RemoveEntityById(newAbsence.ID); Domain.Employee employee = Context.EmployeeList.GetItemByID(newAbsence.EmployeeID); if (employee != null && newAbsence.BeginTime <= DateTime.Today && newAbsence.EndTime >= DateTime.Today) { employee.LongTimeAbsenceExist = false; Context.EmployeeList.ResetItemById(employee.ID); } } catch (EntityException ex) { ErrorMessage(GetLocalized("CantDeleteEmployeeLongTimeAbsence")); } } } }
public void NewExternalEmployee() { if (EntityStore != null) { using (FormExternalEmployee formEmployee = new FormExternalEmployee()) { Domain.Employee newEmployee = ClientEnvironment.EmployeeService.CreateEntity(); newEmployee.ContractBegin = DateTime.Today; newEmployee.ContractEnd = DateTimeSql.SmallDatetimeMax; newEmployee.MainStoreID = EntityStore.ID; formEmployee.Entity = newEmployee; formEmployee.FilterDate = Context.CurrentAsOfDate; if (formEmployee.ShowDialog() == DialogResult.OK) { Context.EmployeeList.Add((Domain.Employee)formEmployee.Entity); bandedGridViewEmployees.RefreshData(); FireChangeEmployeeList(); } } } }
public override void Add() { if (Context != null && FocusedEntity != null && Context.CurrentStore != null) { List <Domain.StoreToWorld> lst = null; lst = swController.GetListByStoreId(Context.CurrentStore.ID); if (lst.Count == 0) { lst = ClientEnvironment.StoreToWorldService.FindAllForStore(Context.CurrentStore.ID); swController.AddList(lst); } using (FormAssignEmployeeToWorld assignform = new FormAssignEmployeeToWorld()) { Domain.Employee empl = Context.CurrentEmployee; EmployeeRelation relation = new EmployeeRelation(); relation.EmployeeID = empl.ID; relation.EmployeeName = empl.FullName; relation.WorldID = 0; if (FocusedEntity != null) { relation.WorldID = FocusedEntity.WorldID; relation.BeginTime = FocusedEntity.BeginTime; if (relation.BeginTime < DateTime.Today) { relation.BeginTime = DateTime.Today; } relation.EndTime = FocusedEntity.EndTime; if (relation.BeginTime > relation.EndTime) { relation.EndTime = Contract.DateTimeSql.SmallDatetimeMax; } } Context.CurrentRelation = relation; assignform.SetWorldList(swController.GetListByStoreId(Context.CurrentStore.ID)); assignform.Entity = Context; if (assignform.ShowDialog() == DialogResult.OK) { LoadEmployeeRelation(); if (Context.Relations != null) { Domain.Employee employee = ClientEnvironment.EmployeeService.GetEmployeeByID(empl.ID, DateTime.Now); if (Context.EmployeeList != null && employee != null) { Context.EmployeeList.SetEntity(employee); } } } } } }
private void gridViewEmployee_RowStyle(object sender, RowStyleEventArgs e) { Domain.Employee empl = GetEntityByRowHandle(e.RowHandle); if (empl != null) { if (!empl.Import) //external employee { e.Appearance.BackColor = Color.Aqua; } if (IsContractExpired(empl, AsOfDate)) { e.Appearance.BackColor = Color.Gray; } else if (empl.StoreID != empl.MainStoreID) { if (empl.StoreID == Context.CurrentStore.ID) // employee from another store { e.Appearance.BackColor = Color.Coral; } else if (empl.MainStoreID == Context.CurrentStore.ID) // employee work on another store { e.Appearance.BackColor = Color.Yellow; } } else if (empl.LongTimeAbsenceExist) { e.Appearance.BackColor = Color.Goldenrod; } } }
public async Task <Result <long> > CreateEmployee(CreateEmployeeDTO dto) { var name = Name.Create(dto.Name); if (name.IsFailure) { return(Result.Failure <long>(name.Error)); } var employee = new Domain.Employee(name.Value) { Surname = dto.Surname, Patronymic = dto.Patronymic, BirthDate = dto.BirthDate, Position = dto.Position, Organization = dto.Organization, }; var contacts = this.GetContactsFromDTO(dto.Contacts); if (contacts.IsFailure) { return(Result.Failure <long>($"Can't update contacts due to errors: {contacts.Error}")); } employee.AddContacts(contacts.Value); await this.dbContext.Employees.AddAsync(employee); await this.dbContext.SaveChangesAsync(); return(Result.Success(employee.Id)); }
public Domain.Employee GetEmployeeById(int id) { Domain.Employee employee = new Domain.Employee(); using (var context = new MVC_CRUDEntities()) { employee = context.Employees.Where(x => x.Id == id) .Select(x => new Domain.Employee { Address = x.Address, DepartmentId = x.DepartmentId, BirthDate = x.BirthDate, Email = x.Email, FirstName = x.FirstName, Gender = x.Gender, Id = x.Id, LastName = x.LastName, Phone = x.Phone, Department = new Domain.Department { DepartmentName = x.Department.DepartmentName, Id = x.Department.Id } }).FirstOrDefault(); } return(employee); }
public override void Bind() { Domain.Employee emp = (Domain.Employee)Entity; teFirstName.Text = emp.FirstName; teSecondName.Text = emp.LastName; tePersonalID.Text = emp.PersID; }
public static void Copy(Domain.Employee source, Domain.Employee dest) { BaseEntity.CopyTo(source, dest); /*dest.ID = source.ID; * dest.StoreID = source.StoreID; * dest.Import = source.Import; * dest.CreateDate = source.CreateDate; * dest.LastName = source.LastName; * dest.MainStoreID = source.MainStoreID; * dest.NewHolidays = source.NewHolidays; * dest.OldHolidays = source.OldHolidays; * dest.PersID = source.PersID; * dest.SpareHolidaysExc = source.SpareHolidaysExc; * dest.SpareHolidaysInc = source.SpareHolidaysInc; * dest.WorldID = source.WorldID; * dest.UsedHolidays = source.UsedHolidays; * dest.HWGR_ID = source.HWGR_ID; * dest.AvailableHolidays = source.AvailableHolidays; * dest.BalanceHours = source.BalanceHours; * dest.ContractBegin = source.ContractBegin; * dest.ContractEnd = source.ContractEnd; * dest.ContractWorkingHours = source.ContractWorkingHours; * dest.FirstName = source.FirstName; * dest.EmployeeContractID = source.EmployeeContractID; * dest.EmployeeRelationsID = source.EmployeeRelationsID; * dest.BeginTime = source.BeginTime; * dest.EndTime = source.EndTime; */ }
protected virtual void OnEmployeeSelected(Domain.Employee empl) { Entity = empl; if (empl != null && EmployeeSelected != null) { EmployeeSelected(empl); } }
private Domain.Employee GetEntityByRowHandle(int rowHandle) { Domain.Employee entity = null; if (bandedGridViewEmployees.IsDataRow(rowHandle)) { entity = (Domain.Employee)bandedGridViewEmployees.GetRow(rowHandle); } return(entity); }
public bool IsContractExpired(Domain.Employee employee, DateTime asForDate) { if (employee != null) { return(!DateTimeHelper.Between(asForDate, employee.ContractBegin, employee.ContractEnd)); } return(true); //return (employee != null && employee.ContractEnd.Date < asForDate.Date); }
Domain.Employee GetEntityByRowHandle(int rowHandle) { Domain.Employee entity = null; if (gridViewEntities.IsDataRow(rowHandle)) { entity = (Domain.Employee)gridViewEntities.GetRow(rowHandle); } return(entity); }
private Domain.Employee GetRowByRowHandle(int rowHandle) { Domain.Employee empl = null; if (gridViewEmployee.IsDataRow(rowHandle)) { empl = (Domain.Employee)gridViewEmployee.GetRow(gridViewEmployee.FocusedRowHandle); } return(empl); }
/// <summary> /// Gets the one. /// </summary> /// <param name="id">The id.</param> /// <returns></returns> public Sample.Domain.Employee GetOne(int id) { var employee = this.db.Employees.FirstOrDefault(x => x.EmployeeID == id); if (employee != null) { Mapper.CreateMap <Employee, Sample.Domain.Employee>(); Domain.Employee instance = Mapper.Map <Sample.Domain.Employee>(employee); return(instance); } return(null); }
private IEmployeeFactory LoadFactory(Domain.Employee employee) { EmployeeType choice; if (Enum.TryParse <EmployeeType>(employee.ContractTypeName, out choice)) { return(index[choice]); } else { throw new KeyNotFoundException($"The contract type {employee.ContractTypeName} is not sopported"); } }
private void gridControlEmployee_MouseDoubleClick(object sender, MouseEventArgs e) { GridHitInfo info = gridViewEmployee.CalcHitInfo(e.X, e.Y); if (info.InRowCell && gridViewEmployee.IsDataRow(info.RowHandle)) { Domain.Employee entity = GetRowByRowHandle(info.RowHandle); if (entity != null) { FireAssignEmployee(entity); } } }
public void ShouldGetHourlySalaryEmployee() { //act dataEmployee.ContractTypeName = "HourlySalaryEmployee"; var employee = new Domain.Employee(dataEmployee); //assert Assert.AreEqual(dataEmployee.Id, employee.Id); Assert.AreEqual(dataEmployee.Name, employee.Name); Assert.AreEqual(dataEmployee.RoleDescription, employee.Role.Description); Assert.AreEqual(dataEmployee.RoleId, employee.Role.Id); Assert.AreEqual(employee.Contract.GetType(), typeof(HourlyContract)); }
private void gridControl_MouseDoubleClick(object sender, MouseEventArgs e) { GridHitInfo info = gridViewEntities.CalcHitInfo(e.X, e.Y); if (info.InRowCell && gridViewEntities.IsDataRow(info.RowHandle)) { Domain.Employee entity = GetEntityByRowHandle(info.RowHandle); if (entity != null) { OnEmployeeSelected(entity); } } }
public void AssignToWorld() { if (EntityStore != null && FocusedEntity != null) { List <StoreToWorld> lst = GetStoreWorldList(EntityStore.ID); using (FormAssignEmployeeToWorld assignform = new FormAssignEmployeeToWorld()) { Domain.Employee empl = FocusedEntity; Context.CurrentEmployee = empl; EmployeeRelation relation = new EmployeeRelation(); relation.EmployeeID = empl.ID; relation.EmployeeName = empl.FullName; relation.StoreID = Context.CurrentStore.ID; relation.WorldID = empl.WorldID; relation.BeginTime = DateTime.Today; relation.EndTime = empl.ContractEnd; if (IsDeligatedEmployee && empl.EndTime.HasValue) { relation.EndTime = empl.EndTime.Value; } Context.CurrentRelation = relation; assignform.SetWorldList(_swController.GetListByStoreId(EntityStore.ID)); assignform.Entity = Context; if (assignform.ShowDialog() == DialogResult.OK) { Domain.Employee employee = ClientEnvironment.EmployeeService.GetEmployeeByID(empl.ID, DateTime.Today); if (employee != null) { Context.EmployeeList.SetEntity(employee); } } } } }
public void EditExternalEmployee() { if (EntityStore != null && FocusedEntity != null && !FocusedEntity.Import) { Domain.Employee empl = FocusedEntity; using (FormExternalEmployee formEmployee = new FormExternalEmployee()) { formEmployee.FilterDate = Context.CurrentAsOfDate; formEmployee.Entity = empl; if (formEmployee.ShowDialog() == DialogResult.OK) { Context.EmployeeList.ResetItemById(empl.ID); } } } }
public void Employee_SmokeTest() { var newEmployee = new Domain.Employee("Ivan"); var contact = Contact.Create(ContactType.Skype, "live:nickname"); newEmployee.AddContact(contact.Value); dbContext.Employees.Add(newEmployee); dbContext.SaveChanges(); var queriedEmployee = dbContext.Employees.Single(employee => employee.Id == newEmployee.Id); Assert.IsNotNull(queriedEmployee); dbContext.Remove(newEmployee); dbContext.SaveChanges(); }
public async Task Consume(ConsumeContext <CreateEmployeeRequest> consumeContext) { var employee = new Domain.Employee { Name = consumeContext.Message.Name }; await _context.Employees.AddAsync(employee); await _context.SaveChangesAsync(); await consumeContext.Publish(new EmployeeCreatedEvent { EmployeeId = employee.Id }); await consumeContext.RespondAsync(new CreateEmployeeResponse { Name = consumeContext.Message.Name, Id = employee.Id }); }
public void DelegateToStore() { if (EntityStore != null && FocusedEntity != null) { using (FormAssignEmployeeToStore form = new FormAssignEmployeeToStore()) { form.Entity = FocusedEntity; if (form.ShowDialog() == DialogResult.OK) { Domain.Employee empl = ClientEnvironment.EmployeeService.GetEmployeeByID(FocusedEntity.ID, DateTime.Today); if (empl != null) { Context.EmployeeList.SetEntity(empl); } } } } }
public void DeleteExternalEmployee() { if (EntityStore != null && FocusedEntity != null && !FocusedEntity.Import) { Domain.Employee empl = FocusedEntity; if (QuestionMessageYes(GetLocalized("QuestionDeleteExtEmployee"))) { try { ClientEnvironment.EmployeeService.DeleteByID(empl.ID); Context.EmployeeList.RemoveEntityById(empl.ID); FireChangeEmployeeList(); } catch (ValidationException) { ErrorMessage(GetLocalized("ErrorCantDeleteExtEmployee")); return; } } } }
public int SaveEmployee(Domain.Employee employee) { Employee employeeData; using (var context = new MVC_CRUDEntities()) { //context.Entry(employee).State = employee.Id == 0 ? EntityState.Added : EntityState.Modified; if (employee.Id != 0) { employeeData = context.Employees.Where(x => x.Id == employee.Id).FirstOrDefault(); } else { employeeData = new Employee(); context.Employees.Add(employeeData); } if (employeeData != null) { employeeData.Address = employee.Address; employeeData.BirthDate = employee.BirthDate; employeeData.DepartmentId = employee.DepartmentId; employeeData.Email = employee.Email; employeeData.FirstName = employee.FirstName; employeeData.Gender = employee.Gender; employeeData.LastName = employee.LastName; employeeData.Phone = employee.Phone; } context.SaveChanges(); } return(employeeData.Id); }
public override bool Commit() { if (IsValid()) { if (IsModified()) { Employee empl = EmployeeHelper.CreateCopy(EntityEmployee); empl.MainStoreID = StoreId; empl.PersID = PersonalID; empl.PersNumber = PersonalNumber; empl.FirstName = FirstName; empl.LastName = LastName; empl.OldHolidays = OldHolidays; empl.BalanceHours = EmployeeBalanceHours; empl.NewHolidays = NewHolidays; empl.AvailableHolidays = empl.NewHolidays + empl.OldHolidays; empl.ContractBegin = BeginTime; empl.ContractEnd = EndTime; empl.ContractWorkingHours = ContractHoursPerWeek; empl.WorldID = WorldId; Domain.Employee newEmpl = null; try { decimal balance = empl.BalanceHours; empl.BalanceHours *= 60; if (empl.IsNew) { empl.CreateDate = DateTime.Today; //newEmpl = ClientEnvironment.EmployeeService.Save(empl); } else { //newEmpl = ClientEnvironment.EmployeeService.SaveOrUpdate(empl); } newEmpl = ClientEnvironment.EmployeeService.SaveExternalEmployee(empl, FilterDate); EmployeeHelper.Copy(newEmpl, EntityEmployee); EntityEmployee.BalanceHours = balance; //if (empl.IsNew) //{ // if (EntityEmployee.WorldID == null) // { // WorldDictionary wd = new WorldDictionary (); // wd.Refresh (); // EntityEmployee.WorldID = wd.GetAdministarionWorld(); // } // if (EntityEmployee.StoreID <= 0) // { // EntityEmployee.StoreID = StoreId; // } //} Modified = true; } catch (ValidationException ex) { string message = Localizer.GetLocalized(ex.Message); if (String.IsNullOrEmpty(message)) { message = ex.Message; } ErrorMessage(message); return(false); } catch (EntityException ex) { ProcessEntityException(ex); return(false); } } return(base.Commit()); } return(false); }
public override bool Commit() { if (IsValid() && !Context.SuspendedCall) { if (IsModified()) { try { EmployeeLongTimeAbsence safeCopy = new EmployeeLongTimeAbsence(); CopyAbsence(Context.EmployeeAbsence, safeCopy); FillAbsence(safeCopy); safeCopy = ClientEnvironment.EmployeeService.EmployeeTimeService.SaveLongTimeAbsence(safeCopy); CopyAbsence(safeCopy, Context.EmployeeAbsence); Domain.Employee empl = Context.EmployeeList.GetItemByID(safeCopy.EmployeeID); if (empl != null) { Context.EmployeeAbsence.EmployeeFullName = empl.FullName; // // If new long time absence falls on today, set LongTimeAbsenceExtits flag to employee // if (Context.EmployeeAbsence.BeginTime <= DateTime.Today && Context.EmployeeAbsence.EndTime >= DateTime.Today) { empl.LongTimeAbsenceExist = true; } } Context.EmployeeAbsence.LongTimeAbsenceName = m_ListAbsence.GetAbsenceName(Context.EmployeeAbsence.LongTimeAbsenceID); Modified = true; return(base.Commit()); } catch (ValidationException) { ErrorMessage(GetLocalized("ErrorLongTimeAbsenceRange")); //ProcessEntityException(ex); return(false); } catch (EntityException ex) { ProcessEntityException(ex); return(false); } } return(true); } else if (Context.SuspendedCall) { Context.EmployeeAbsence.EmployeeID = (long)gridLookUpEditEmployees.EditValue; Context.EmployeeAbsence.LongTimeAbsenceID = (long)lookUpAbsence.EditValue; Context.EmployeeAbsence.BeginTime = deBeginDate.DateTime; Context.EmployeeAbsence.EndTime = deEndDate.DateTime; return(Modified = true); } return(false); }
private void gridViewEmployee_CellValueChanged(object sender, CellValueChangedEventArgs e) { if (!EnabledEdit) { return; } if (e.Column == gridColumn_NewHolidays || e.Column == gridColumn_OldHolidays || e.Column == gridColumn_EmployeeBalanceHours || e.Column == gc_AllIn) { Domain.Employee empl = GetEntityByRowHandle(e.RowHandle); if (empl != null) { if (e.Column == gridColumn_NewHolidays || e.Column == gridColumn_OldHolidays) { //ClientEnvironment.EmployeeService.SaveEmployeeHolidays(empl.ID, empl.OldHolidays, // empl.NewHolidays, null, null, null); EmployeeHolidaysInfo new_info = new EmployeeHolidaysInfo(empl.ID, (short)DateTimeHelper.GetYearByDate(AsOfDate)); new_info.FillFromEmployee(empl); new_info = ClientEnvironment.EmployeeService.SaveEmployeeHolidays(new_info);// SaveEmployeeHolidays(empl.ID, empl.OldHolidays, //empl.NewHolidays, null, null, null); if (new_info != null) { new_info.FillEmployee(empl); //empl.AvailableHolidays = empl.OldHolidays + empl.NewHolidays; Context.EmployeeList.ResetItemById(empl.ID); } } else if (e.Column == gridColumn_EmployeeBalanceHours) { ClientEnvironment.EmployeeService.SaveEmployeeSaldo(empl.ID, empl.BalanceHours * 60); } else if (e.Column == gc_AllIn) { if (Context.CurrentAsOfDate < DateTime.Today) { ErrorMessage(GetLocalized("ErrorChangingAllInInPast")); empl.AllIn = !empl.AllIn; Context.EmployeeList.ResetItemById(empl.ID); return; } if (QuestionMessageYes(GetLocalized("QuestionChangeAllIn"))) { ClientEnvironment.EmployeeAllInService.InsertAllIn(empl.ID, Context.CurrentAsOfDate, empl.AllIn); } else { empl.AllIn = !empl.AllIn; Context.EmployeeList.ResetItemById(empl.ID); } } //ClientEnvironment.EmployeeService.SaveOrUpdate(empl); } } }