private void TbSectionOfBuildingQuantityByWidth_TextChanged(object sender, EventArgs e) { lblCheckSectionOfBuildingQuantityByWidth.Visible = !SectionOfBuilding.IntIsMatch(tbSectionOfBuildingQuantityByWidth.Text); pbCheckMarkSectionOfBuildingQuantityByWidth.Visible = SectionOfBuilding.IntIsMatch(tbSectionOfBuildingQuantityByWidth.Text); }
//BtnCreate_Click private void BtnSectionOfBuildingCreate_Click(object sender, EventArgs e) { if (SectionOfBuilding.NameIsMatch(tbSectionOfBuildingName.Text) && SectionOfBuilding.IntIsMatch(tbSectionOfBuildingQuantityByHeight.Text) && SectionOfBuilding.IntIsMatch(tbSectionOfBuildingQuantityByWidth.Text)) { string name = tbSectionOfBuildingName.Text; int quantityByHeight = Convert.ToInt32(tbSectionOfBuildingQuantityByHeight.Text); int quantityByWidth = Convert.ToInt32(tbSectionOfBuildingQuantityByWidth.Text); if (quantityByHeight == 0 || quantityByWidth == 0) { MessageBox.Show("Невозможно создать модель с нулевым количеством элементов", "Сообщение об ошибке", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } var sectionOfBuilding = new SectionOfBuilding(name, actualProject.Id, quantityByHeight, quantityByWidth); try { sectionOfBuilding.CreateWithElements(driver); MessageBox.Show("Модель фасада сохранена", "Сохранение модели", MessageBoxButtons.OK, MessageBoxIcon.Information); ShowActualProject(); ShowVoidSectionOfBuilding(); managerModel.ShowModel(SelectedSectionOfBuilding()); gbSectionOfBuildingData.Enabled = false; gbSectionOfBuildingData.Visible = false; SectionOfBuildingModel.Visible = true; btnSectionOfBuildingCreate.Visible = false; btnSectionOfBuildingSwitchCancel.Visible = false; } catch (Exception ex) { MessageBox.Show(ex.Message, "Сообщение об ошибке", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { MessageBox.Show("Сохранение данных невозможно, не все поля заполнены корректно", "Сообщение об ошибке", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
//BtnUpdate_Click private void BtnSectionOfBuildingUpdate_Click(object sender, EventArgs e) { var sectionOfBuilding = SelectedSectionOfBuilding(); if (SectionOfBuilding.NameIsMatch(tbSectionOfBuildingName.Text) && SectionOfBuilding.IntIsMatch(tbSectionOfBuildingQuantityByHeight.Text) && SectionOfBuilding.IntIsMatch(tbSectionOfBuildingQuantityByWidth.Text)) { sectionOfBuilding.Name = tbSectionOfBuildingName.Text; sectionOfBuilding.QuantityByHeight = Convert.ToInt32(tbSectionOfBuildingQuantityByHeight.Text); sectionOfBuilding.QuantityByWidth = Convert.ToInt32(tbSectionOfBuildingQuantityByWidth.Text); try { sectionOfBuilding.Update(driver); MessageBox.Show("Изменения сохранены", "Сохранение модели", MessageBoxButtons.OK, MessageBoxIcon.Information); ShowActualProject(); ShowSectionsOfBuildingInActualPriject(); ShowSelectedSectionOfBuilding(); managerModel.ShowModel(SelectedSectionOfBuilding()); gbSectionOfBuildingData.Enabled = false; gbSectionOfBuildingData.Visible = false; SectionOfBuildingModel.Visible = true; gbAllSectionsOfBuilding.Enabled = true; tbSectionOfBuildingQuantityByHeight.Enabled = true; tbSectionOfBuildingQuantityByWidth.Enabled = true; btnSectionOfBuildingUpdate.Visible = false; btnSectionOfBuildingSwitchCancel.Visible = false; } catch (Exception ex) { MessageBox.Show(ex.Message, "Сообщение об ошибке", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { MessageBox.Show("Сохранение данных невозможно, не все поля заполнены корректно", "Сообщение об ошибке", MessageBoxButtons.OK, MessageBoxIcon.Error); } }