private void TbWorkInProjectMultiplicity_TextChanged(object sender, EventArgs e) { lblWorkInProjectCheckMultiplicity.Visible = !WorkInProject.DecimalIsMatch(tbWorkInProjectMultiplicity.Text); pbCheckMarkWorkInProjectMultiplicity.Visible = WorkInProject.DecimalIsMatch(tbWorkInProjectMultiplicity.Text); }
private void TbWorkInProjectPrice_TextChanged(object sender, EventArgs e) { lblWorkInProjectCheckPrice.Visible = !WorkInProject.DecimalIsMatch(tbWorkInProjectPrice.Text); pbCheckMarkWorkInProjectPrice.Visible = WorkInProject.DecimalIsMatch(tbWorkInProjectPrice.Text); }
private void BtnWorkInProjectUpdate_Click(object sender, EventArgs e) { if (WorkInProject.DecimalIsMatch(tbWorkInProjectPrice.Text) && WorkInProject.DecimalIsMatch(tbWorkInProjectMultiplicity.Text)) { try { var workInProject = SelectedWorkInProject(); if (workInProject.Id == -1) { MessageBox.Show( "Сохранение данных невозможно, ошибка чтения из базы данных", "Сообщение об ошибке", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } workInProject.Price = Convert.ToDecimal(tbWorkInProjectPrice.Text); workInProject.Multiplicity = Convert.ToDecimal(tbWorkInProjectMultiplicity.Text); workInProject.Update(driver); MessageBox.Show($"Изменения сохранены", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information); ShowWorksInActualProject(); ShowVoidTypeOfWork(); gbAllTypesOfWork.Enabled = true; gbWorksInActualProject.Enabled = true; gbWorkInProjectData.Visible = false; gbTypeOfWorkData.Height = 217; btnWorkSwitchCancel.Visible = false; btnWorkInProjectUpdate.Visible = false; tbWorkInProjectMultiplicity.Enabled = false; } catch (Exception ex) { MessageBox.Show(ex.Message, "Сообщение об ошибке", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { MessageBox.Show("Сохранение данных невозможно, не все поля заполнены корректно", "Сообщение об ошибке", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public void ShowWorkInModel(WorkInProject workInProject) { for (int i = 0; i < dgvModel.RowCount; i++) { for (int j = 0; j < dgvModel.ColumnCount; j++) { int idElement = (int)dgvModel.Rows[i].Cells[j].Tag; if (mainForm.ElementHasWork(idElement, workInProject.Id)) { var workByElement = mainForm.GetWorkByElement(idElement, workInProject.Id); dgvModel.Rows[i].Cells[j].Style.BackColor = workByElement.GetColorByState(); } else { dgvModel.Rows[i].Cells[j].Style.BackColor = Color.Empty; } } } }
private decimal GetSomeValueWorkBySectionOfBuilding( WorkInProject workInProject, SectionOfBuilding sectionOfBuilding, Func <WorkInProject, IDriverDB, decimal> GetValue) { decimal valueByWork = -1; if (sectionOfBuilding.Id == -1) { return(valueByWork); } try { valueByWork = GetValue(workInProject, driver); } catch (Exception ex) { MessageBox.Show(ex.Message, "Сообщение об ошибке", MessageBoxButtons.OK, MessageBoxIcon.Error); } return(valueByWork); }
private void BtnWorkInProjectCreate_Click(object sender, EventArgs e) { if (WorkInProject.DecimalIsMatch(tbWorkInProjectPrice.Text) && WorkInProject.DecimalIsMatch(tbWorkInProjectMultiplicity.Text)) { try { var selectedTypeOfWork = SelectedTypeOfWork(); decimal price = Convert.ToDecimal(tbWorkInProjectPrice.Text); decimal multiplicity = Convert.ToDecimal(tbWorkInProjectMultiplicity.Text); var workInProject = new WorkInProject(actualProject.Id, selectedTypeOfWork.Id, price, multiplicity); workInProject.Create(driver); MessageBox.Show( $"Вид работ {selectedTypeOfWork.Name} добавлен в текущий проект", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information); ShowWorksInActualProject(); ShowVoidTypeOfWork(); gbAllTypesOfWork.Enabled = true; gbWorkInProjectData.Visible = false; gbTypeOfWorkData.Height = 217; btnWorkSwitchCancel.Visible = false; btnWorkInProjectCreate.Visible = false; } catch (Exception ex) { MessageBox.Show(ex.Message, "Сообщение об ошибке", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { MessageBox.Show("Сохранение данных невозможно, не все поля заполнены корректно", "Сообщение об ошибке", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public decimal GetValueByRejectedWork(WorkInProject workInProject, IDriverDB driver) { return(driver.GetValueByStateWorkFromSectionOfBuilding(workInProject, id, WorkState.Rejected)); }
public decimal GetValueByWork(WorkInProject workInProject, IDriverDB driver) { return(driver.GetValueByWorkFromSectionOfBuilding(workInProject, id)); }
private decimal GetValueRejectedWorkBySectionOfBuilding(WorkInProject workInProject, SectionOfBuilding sectionOfBuilding) { return(GetSomeValueWorkBySectionOfBuilding(workInProject, sectionOfBuilding, sectionOfBuilding.GetValueByRejectedWork)); }