private void BtnSectionOfBuildingRejectWork_Click(object sender, EventArgs e) { if (actualProject.State != ProjectState.Actual) { MessageBox.Show("Учет работ возможен только для текущего проекта", "Сообщение об ошибке", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } DateTime dateOfReject = dtpManagerModelLogDate.Value; int idWorkInProject = SelectedWorkInProjectInSectionOfBuilding().Id; var selectedCells = dgvManagerModel.SelectedCells; List <WorkByElement> workByElements = new List <WorkByElement>(); foreach (DataGridViewCell cell in selectedCells) { int idElement = (int)cell.Tag; if (ElementHasWork(idElement, idWorkInProject)) { var workByElement = GetWorkByElement(idElement, idWorkInProject); if (workByElement.RejectCheck(dateOfReject, driver)) { workByElements.Add(workByElement); } } } if (workByElements.Count == 0) { MessageBox.Show($"Нет элементов для отклонения работ", "Отклонение работ", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } var inputBox = new InputBox("Комментарий к отклонению работ", "Введите текст комментария", "от 3 до 100 символов кириллицей", Color.Red, BaseWithName.NameIsMatch); inputBox.ShowDialog(); if (inputBox.DialogResult == DialogResult.Cancel) { return; } string comment = ""; try { comment = inputBox.Input; WorkByElement.CreateWorkLogsReject(workByElements, actualUser.Id, dateOfReject, comment, driver); managerModel.ShowWorkInModel(SelectedWorkInProjectInSectionOfBuilding()); ShowActualProject(); ShowProjects(); ShowWorksInProjectInSectionOfBuilding(); MessageBox.Show($"Работа отклонена для {workByElements.Count} элементов", "Отклонение работ", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception ex) { MessageBox.Show(ex.Message, "Сообщение об ошибке", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
//BtnCreate_Click private void BtnWorkerCompleteWork_Click(object sender, EventArgs e) { if (SelectedWorkerProject().State == ProjectState.Canceled || SelectedWorkerProject().State == ProjectState.Completed) { MessageBox.Show("Изменение отмененого или завершенного проекта не возможно", "Сообщение об ошибке", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } DateTime date = dtpWorkerDateOfComplete.Value; var project = SelectedWorkerProject(); if (!project.DateOfCompleteWorkIsChecked(date)) { MessageBox.Show($"Выполнение работ не возможно в указанную дату", "Выполнение работы", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } int idWorkInProject = SelectedWorkerWorkInProject().Id; var selectedCells = dgvWorkerModel.SelectedCells; List <WorkByElement> workByElements = new List <WorkByElement>(); try { foreach (DataGridViewCell cell in selectedCells) { int idElement = (int)cell.Tag; if (ElementHasWork(idElement, idWorkInProject)) { var workByElement = GetWorkByElement(idElement, idWorkInProject); if (workByElement.CompleteCheck(date, driver)) { workByElements.Add(workByElement); } } } if (workByElements.Count == 0) { MessageBox.Show($"Нет элементов для выполнения работы", "Выполнение работы", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } WorkByElement.CreateWorkLogsComplete( workByElements, actualUser.Id, date, driver); ShowWorkerProjects(); ShowUserData(); workerModel.ShowModel(SelectedWorkerSectionOfBuilding()); workerModel.ShowWorkInModel(SelectedWorkerWorkInProject()); ShowWorkerWorksInProject(); MessageBox.Show($"Выполнение работы для {workByElements.Count} элементов", "Выполнение работы", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception ex) { MessageBox.Show(ex.Message, "Сообщение об ошибке", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void BtnWorkerCompleteWorkCancel_Click(object sender, EventArgs e) { if (SelectedWorkerProject().State == ProjectState.Canceled || SelectedWorkerProject().State == ProjectState.Completed) { MessageBox.Show("Изменение отмененого или завершенного проекта не возможно", "Сообщение об ошибке", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } int idWorkInProject = SelectedWorkerWorkInProject().Id; var selectedCells = dgvWorkerModel.SelectedCells; List <WorkLog> completeWorkLogs = new List <WorkLog>(); try { foreach (DataGridViewCell cell in selectedCells) { int idElement = (int)cell.Tag; if (ElementHasWork(idElement, idWorkInProject)) { var workByElement = GetWorkByElement(idElement, idWorkInProject); WorkLog workLog = workByElement.GetCompleteLog2Delete(actualUser.Id, driver); if (workLog.Id != -1) { completeWorkLogs.Add(workLog); } } } if (completeWorkLogs.Count == 0) { MessageBox.Show($"Нет элементов для отмены выполнения", "Отмена выполнения", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } WorkByElement.DeleteWorkLogsComplete(completeWorkLogs, driver); ShowWorkerProjects(); ShowUserData(); workerModel.ShowModel(SelectedWorkerSectionOfBuilding()); workerModel.ShowWorkInModel(SelectedWorkerWorkInProject()); ShowWorkerWorksInProject(); MessageBox.Show($"Отмена выполнения работы для {completeWorkLogs.Count} элементов", "Отмена выполнения", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception ex) { MessageBox.Show(ex.Message, "Сообщение об ошибке", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private WorkByElement GetWorkByElement(int idElement, int idWorkInProject) { var workByElement = new WorkByElement(); try { workByElement = driver.GetWorkByElement(idElement, idWorkInProject); } catch (Exception ex) { MessageBox.Show(ex.Message, "Сообщение об ошибке", MessageBoxButtons.OK, MessageBoxIcon.Error); } return(workByElement); }
private void BtnSectionOfBuildingAcceptWorkCancel_Click(object sender, EventArgs e) { if (actualProject.State != ProjectState.Actual) { MessageBox.Show("Учет работ возможен только для текущего проекта", "Сообщение об ошибке", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } int idWorkInProject = SelectedWorkInProjectInSectionOfBuilding().Id; var selectedCells = dgvManagerModel.SelectedCells; List <WorkLog> acceptWorkLogs = new List <WorkLog>(); try { foreach (DataGridViewCell cell in selectedCells) { int idElement = (int)cell.Tag; if (ElementHasWork(idElement, idWorkInProject)) { var workByElement = GetWorkByElement(idElement, idWorkInProject); WorkLog workLog = workByElement.GetAcceptLog2Delete(actualUser.Id, driver); if (workLog.Id != -1) { acceptWorkLogs.Add(workLog); } } } if (acceptWorkLogs.Count == 0) { MessageBox.Show($"Нет элементов для отмены приемки", "Отмена приемки", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } WorkByElement.DeleteWorkLogsAccept(acceptWorkLogs, driver); managerModel.ShowWorkInModel(SelectedWorkInProjectInSectionOfBuilding()); ShowActualProject(); ShowProjects(); ShowWorksInProjectInSectionOfBuilding(); MessageBox.Show($"Отменa приемки работы для {acceptWorkLogs.Count} элементов", "Отмена приемки", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception ex) { MessageBox.Show(ex.Message, "Сообщение об ошибке", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void BtnSectionOfBuildingAcceptWork_Click(object sender, EventArgs e) { if (actualProject.State != ProjectState.Actual) { MessageBox.Show("Учет работ возможен только для текущего проекта", "Сообщение об ошибке", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } DateTime dateOfAccept = dtpManagerModelLogDate.Value; int idWorkInProject = SelectedWorkInProjectInSectionOfBuilding().Id; var selectedCells = dgvManagerModel.SelectedCells; List <WorkByElement> workByElements = new List <WorkByElement>(); foreach (DataGridViewCell cell in selectedCells) { int idElement = (int)cell.Tag; if (ElementHasWork(idElement, idWorkInProject)) { var workByElement = GetWorkByElement(idElement, idWorkInProject); if (workByElement.AcceptCheck(dateOfAccept, driver)) { workByElements.Add(workByElement); } } } if (workByElements.Count == 0) { MessageBox.Show($"Нет элементов для приемки работ", "Приемка работ", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } try { WorkByElement.CreateWorkLogsAccept(workByElements, actualUser.Id, dateOfAccept, driver); managerModel.ShowWorkInModel(SelectedWorkInProjectInSectionOfBuilding()); ShowWorksInProjectInSectionOfBuilding(); ShowActualProject(); ShowProjects(); MessageBox.Show($"Работа принята для {workByElements.Count} элементов", "Приемка работ", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception ex) { MessageBox.Show(ex.Message, "Сообщение об ошибке", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void ShowWorkLog(WorkByElement workByElement) { if (workByElement.State == WorkState.Planned) { dgvWorkLog.Rows.Clear(); return; } var workLogs = mainForm.ReadWorkLogs(workByElement.Id); mainForm.ClearAndSetHeightDgv(dgvWorkLog, 98, workLogs.Length); foreach (WorkLog workLog in workLogs) { var user = mainForm.ReadUser(workLog.IdUser); dgvWorkLog.Rows.Add(workLog.Id, workLog.Date.Date, workLog.GetTypeString(), user.Name, workLog.Comment); } }
private decimal GetValueWorkByElement(WorkByElement workByElement) { decimal valueByWork = -1; if (workByElement.Id == -1) { return(valueByWork); } try { valueByWork = workByElement.GetValue(driver); } catch (Exception ex) { MessageBox.Show(ex.Message, "Сообщение об ошибке", MessageBoxButtons.OK, MessageBoxIcon.Error); } return(valueByWork); }
private void BtnSectionOfBuildingCancelWork_Click(object sender, EventArgs e) { if (actualProject.State == ProjectState.Canceled || actualProject.State == ProjectState.Completed) { MessageBox.Show("Изменение отмененого или завершенного проекта не возможно", "Сообщение об ошибке", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } int idWorkInProject = SelectedWorkInProjectInSectionOfBuilding().Id; var selectedCells = dgvManagerModel.SelectedCells; List <WorkByElement> workByElements2Delete = new List <WorkByElement>(); foreach (DataGridViewCell cell in selectedCells) { int idElement = (int)cell.Tag; if (ElementHasWork(idElement, idWorkInProject)) { workByElements2Delete.Add(new WorkByElement(idElement, idWorkInProject)); } } try { WorkByElement.DeleteWorkByElements(workByElements2Delete, driver); managerModel.ShowWorkInModel(SelectedWorkInProjectInSectionOfBuilding()); ShowWorksInProjectInSectionOfBuilding(); ShowActualProject(); ShowProjects(); MessageBox.Show( $"Назначение работы отменено для {workByElements2Delete.Count} элементов", "Назначение работы", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception ex) { MessageBox.Show(ex.Message, "Сообщение об ошибке", MessageBoxButtons.OK, MessageBoxIcon.Error); } }