public bool AcceptCheck(DateTime dateOfAccept, IDriverDB driver) { if (State != WorkState.Completed) { return(false); } return(driver.CheckDateOfAccept(dateOfAccept, id)); }
public bool CompleteCheck(DateTime dateOfComplete, IDriverDB driver) { if (State != WorkState.Planned && State != WorkState.Rejected) { return(false); } return(driver.CheckDateOfComplete(dateOfComplete, id)); }
public Element[][] GetFloors(IDriverDB driver) { Element[][] floors = new Element[quantityByHeight][]; for (int i = 0; i < quantityByHeight; i++) { floors[i] = GetElementsByFloor(i, driver); } return(floors); }
public override void Update(IDriverDB driver) { if (IsInElements(driver)) { throw new Exception( "Изменение невозможно. Элемент включен в проект."); } driver.UpdateTypeOfElement(this); }
public bool UserWorksIsPaid(int idUser, IDriverDB driver) { decimal acceptedWorksByUser = driver.GetAmountAcceptedWorkByProjectAndUser(id, idUser); if (acceptedWorksByUser == 0) { return(true); } decimal paymentsByUser = driver.GetAmountPaymentsByUserAndProject(id, idUser); return(paymentsByUser >= acceptedWorksByUser); }
public MainForm(IDriverDB driver, IHashPasswordCreator hashPasswordCreator) { InitializeComponent(); this.driver = driver; this.hashPasswordCreator = hashPasswordCreator; actualUser = new User(); workerModel = new ModelOfFacade(dgvWorkerModel, this); workerWorkLog = new WorkLogGroup(this, workerModel, dgvWorkerWorkLog, dgvWorkerWorksInProject, lblWorkerElementHeight, lblWorkerElementLenght, lblWorkerElementSquare, lblWorkerWorkByElementMultiplicity, lblWorkerWorkByElementAmount); managerModel = new ModelOfFacade(dgvManagerModel, this); managerWorkLog = new WorkLogGroup(this, managerModel, dgvManagerWorkLog, dgvSectionOfBuildingWorkInProject, lblManagerModeHeight, lblManagerModelLength, lblManagerModelSquare, lblManagerModelMultiplicity, lblManagerModelAmount); var entryForm = new Entry(driver, hashPasswordCreator); Application.Run(entryForm); try { actualUser = entryForm.actualUser; } catch { MessageBox.Show("Ошибка! Вход в систему не возможен", "Сообщение об ошибке", MessageBoxButtons.OK, MessageBoxIcon.Error); Close(); return; } if (actualUser.Id == -1) { MessageBox.Show("Ошибка! Вход в систему не возможен", "Сообщение об ошибке", MessageBoxButtons.OK, MessageBoxIcon.Error); Close(); return; } Image checkMark = Properties.Resources.checkMark; SetPictures(checkMark); ShowlabelActualUserName(); ShowUsers(); ShowClients(); actualProject = new Project(); ShowActualProject(); ShowAllEntities(); ShowWorkerProjects(); if (!actualUser.ManagerAccess) { WorkerMode(); } }
public void Complete(DateTime dateOfComplete, IDriverDB driver) { if (CompleteCheck(dateOfComplete, driver)) { state = ProjectState.Completed; DateOfComplete = dateOfComplete; Update(driver); } else { throw new Exception("Завершение проекта невозможно"); } }
public Element[] GetElementsByFloor(int numberOfFloor, IDriverDB driver) { if (numberOfFloor > quantityByHeight) { throw new Exception("Запрошенный этаж превышает этажность здания"); } else if (numberOfFloor < 0) { throw new Exception("Номер этажа не может быть отрицательным"); } int idSec = this.id; return(driver.ReadAllElementsFromSectionOfBuildingByFloor(id, numberOfFloor)); }
public WorkLog GetRejectLog2Delete(int idActualUser, IDriverDB driver) { if (State != WorkState.Rejected) { return(new WorkLog()); } WorkLog rejectLog2Delete = driver.GetLastRejectLog(id); if (idActualUser == rejectLog2Delete.IdUser) { return(rejectLog2Delete); } return(new WorkLog()); }
public WorkLog GetAcceptLog2Delete(int idActualUser, IDriverDB driver) { if (State != WorkState.Accepted) { return(new WorkLog()); } WorkLog acceptLog2Delete = driver.GetAcceptLog(id); if (idActualUser == acceptLog2Delete.IdUser) { return(acceptLog2Delete); } return(new WorkLog()); }
public WorkLog GetCompleteLog2Delete(int idActualUser, IDriverDB driver) { if (State != WorkState.Completed) { return(new WorkLog()); } WorkLog lastCompleteLog = driver.GetLastCompleteLog(id); if (idActualUser == lastCompleteLog.IdUser) { return(lastCompleteLog); } return(new WorkLog()); }
public void Start(DateTime dateOfStart, DateTime plannedDateOfComplete, IDriverDB driver) { if (!DatesOfStartAndPlanIsChecked(dateOfStart, plannedDateOfComplete)) { throw new Exception("Дата окончания должна быть позднее даты начала"); } if (state != ProjectState.Planned) { throw new Exception("Старт возможен только для планируемого проекта"); } state = ProjectState.Actual; PlannedDateOfComplete = plannedDateOfComplete; DateOfStart = dateOfStart; Update(driver); }
public void DeleteUser(IDriverDB driver, User user) { if (user.GetPaymentsAmountByProject(id, driver) > 0) { throw new Exception( "Удаление невозможно. Имеются платежи в отношении удалаяемого исполнителя."); } if (user.GetAmountCompletedWorkByProject(id, driver) > 0 || user.GetAmountAcceptedWorkByProject(id, driver) > 0 || user.GetAmountRejectedWorkByProject(id, driver) > 0) { throw new Exception( "Удаление невозможно. Имеются учтенные работы удалаяемого исполнителя."); } driver.DeleteUserFromProject(user.Id, this.Id); }
public bool CompleteCheck(DateTime dateOfComplete, IDriverDB driver) { if (state != ProjectState.Actual || !DateOfCompleteCheck(dateOfComplete, driver) || !AllWorksAccepted(driver)) { return(false); } var usersInProject = ReadUsersByProject(driver); foreach (User user in usersInProject) { if (!UserWorksIsPaid(user.Id, driver)) { return(false); } } return(true); }
public bool CheckUserInProject(IDriverDB driver) { int idUserInProject = -1; try { idUserInProject = driver.GetIdUserInProject(IdUser, IdProject); } catch (Exception ex) { throw new Exception(ex.Message); } if (idUserInProject == -1) { return(false); } else { return(true); } }
public override void Delete(IDriverDB driver) { driver.DeleteUser(id); }
public override void Update(IDriverDB driver) { driver.UpdateUser(this); }
public override void Create(IDriverDB driver) { driver.CreateUser(this); }
public decimal GetAmountRejectedWorkByProject(int idProject, IDriverDB driver) { return(Decimal.Round(driver.GetAmountRejectedWorkByProjectAndUser(idProject, id), 2)); }
public decimal GetPaymentsAmountByProject(int idProject, IDriverDB driver) { return(driver.GetAmountPaymentsByUserAndProject(idProject, id)); }
public Payment[] GetPaymentsByProject(int idProject, IDriverDB driver) { return(driver.ReadPaymentsByUserAndProject(idProject, id)); }
public override void Delete(IDriverDB driver) { driver.DeleteTypeOfElement(this.Id); }
public override void Update(IDriverDB driver) { driver.UpdateElementPicture(this); }
private bool IsInElements(IDriverDB driver) { return(driver.IsTypeOfElementInElements(id)); }
public Image GetPicture(IDriverDB driver) { return(driver.ReadElementPicture(this.IdElementPicture).Picture); }
public Project[] GetProjects(IDriverDB driver) { return(driver.ReadAllProjectByUser(id)); }
public override void Create(IDriverDB driver) { driver.CreateTypeOfElement(this); }
public abstract void Delete(IDriverDB driver);
public override void Delete(IDriverDB driver) { driver.DeleteElementPicture(this.Id); }
public DriverController(IDriverDB driverDB, IGeoLocator geoLocator) { DriverDB = driverDB; GeoLocator = geoLocator; }