//BtnUpdate_Click private void BtnTypeOfWorkUpdate_Click(object sender, EventArgs e) { if (TypeOfWork.NameIsMatch(tbTypeOfWorkName.Text) && TypeOfWork.MeasureUnitIsMatch(tbTypeOfWorkMeasureUnit.Text) && cbTypeOfWorkDimension.SelectedItem != null) { var selectedTypeOfWork = SelectedTypeOfWork(); selectedTypeOfWork.Name = tbTypeOfWorkName.Text; selectedTypeOfWork.MeasureUnit = tbTypeOfWorkMeasureUnit.Text; selectedTypeOfWork.Dim = (Dimension)cbTypeOfWorkDimension.SelectedIndex; try { selectedTypeOfWork.Update(driver); MessageBox.Show($"Изменения сохранены", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information); ShowTypesOfWork(); ShowWorksInActualProject(); ShowVoidTypeOfWork(); gbTypeOfWorkData.Enabled = false; gbAllTypesOfWork.Enabled = true; btnWorkSwitchCancel.Visible = false; btnTypeOfWorkUpdate.Visible = false; } catch (Exception ex) { MessageBox.Show(ex.Message, "Сообщение об ошибке", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { MessageBox.Show("Сохранение данных невозможно, не все поля заполнены корректно", "Сообщение об ошибке", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
//BtnCreate_Click private void BtnTypeOfWorkCreate_Click(object sender, EventArgs e) { if (TypeOfWork.NameIsMatch(tbTypeOfWorkName.Text) && TypeOfWork.MeasureUnitIsMatch(tbTypeOfWorkMeasureUnit.Text) && cbTypeOfWorkDimension.SelectedItem != null) { try { string name = tbTypeOfWorkName.Text; string measureUnit = tbTypeOfWorkMeasureUnit.Text; Dimension dimension = (Dimension)cbTypeOfWorkDimension.SelectedIndex; var typeOfWork = new TypeOfWork(name, measureUnit, dimension); typeOfWork.Create(driver); MessageBox.Show($"Вид работ {tbTypeOfWorkName.Text} сохранен", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information); ShowTypesOfWork(); ShowVoidTypeOfWork(); gbTypeOfWorkData.Enabled = false; btnWorkSwitchCancel.Visible = false; btnTypeOfWorkCreate.Visible = false; } catch (Exception ex) { MessageBox.Show(ex.Message, "Сообщение об ошибке", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { MessageBox.Show("Сохранение данных невозможно, не все поля заполнены корректно", "Сообщение об ошибке", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void TbTypeOfWorkMeasureUnit_TextChanged(object sender, EventArgs e) { lblCheckTypeOfWorkMeasureUnit.Visible = !TypeOfWork.MeasureUnitIsMatch(tbTypeOfWorkMeasureUnit.Text); pbCheckMarkTypeOfWorkMeasureUnit.Visible = TypeOfWork.MeasureUnitIsMatch(tbTypeOfWorkMeasureUnit.Text); }
//TbDate_Click //DtpDate_valueChanged //Tb_TextChanged private void TbTypeOfWorkName_TextChanged(object sender, EventArgs e) { lblCheckTypeOfWorkName.Visible = !TypeOfWork.NameIsMatch(tbTypeOfWorkName.Text); pbCheckMarkTypeOfWorkName.Visible = TypeOfWork.NameIsMatch(tbTypeOfWorkName.Text); }