private void TbTypeOfElementLength_TextChanged(object sender, EventArgs e) { lblCheckTypeOfElementLength.Visible = !TypeOfElement.DecimalIsMatch(tbTypeOfElementLength.Text); pbCheckMarkTypeOfElementLength.Visible = TypeOfElement.DecimalIsMatch(tbTypeOfElementLength.Text); }
//TbDate_Click //DtpDate_valueChanged //Tb_TextChanged private void TbTypeOfElementName_TextChanged(object sender, EventArgs e) { lblCheckTypeOfElementName.Visible = !TypeOfElement.NameIsMatch(tbTypeOfElementName.Text); pbCheckMarkTypeOfElementName.Visible = TypeOfElement.NameIsMatch(tbTypeOfElementName.Text); }
//BtnUpdate_Click private void BtnTypeOfElementUpdate_Click(object sender, EventArgs e) { var typeOfElement = SelectedTypeOfElement(); if (typeOfElement.Id == -1) { return; } if (TypeOfElement.NameIsMatch(tbTypeOfElementName.Text) && TypeOfElement.DecimalIsMatch(tbTypeOfElementSquare.Text) && TypeOfElement.DecimalIsMatch(tbTypeOfElementHeight.Text) && TypeOfElement.DecimalIsMatch(tbTypeOfElementLength.Text) && SelectedElementPictureInTypeOfElement().Id != 0) { typeOfElement.Name = tbTypeOfElementName.Text; typeOfElement.Square = Convert.ToDecimal(tbTypeOfElementSquare.Text); typeOfElement.Height = Convert.ToDecimal(tbTypeOfElementHeight.Text); typeOfElement.Length = Convert.ToDecimal(tbTypeOfElementLength.Text); typeOfElement.IdElementPicture = SelectedElementPictureInTypeOfElement().Id; try { typeOfElement.Update(driver); MessageBox.Show("Изменения сохранены", "Сохранение данных", MessageBoxButtons.OK, MessageBoxIcon.Information); ShowVoidTypeOfElement(); ShowAllTypesOfElement(); gbTypeOfElementData.Enabled = false; gbAllTypesOfElement.Enabled = true; btnTypeOfElementUpdate.Visible = false; btnTypeOfElementSwitchCancel.Visible = false; } catch (Exception ex) { MessageBox.Show(ex.Message, "Сообщение об ошибке", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { MessageBox.Show("Сохранение данных невозможно, не все поля заполнены корректно", "Сообщение об ошибке", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
//BtnCreate_Click private void BtnTypeOfElementCreate_Click(object sender, EventArgs e) { if (TypeOfElement.NameIsMatch(tbTypeOfElementName.Text) && TypeOfElement.DecimalIsMatch(tbTypeOfElementSquare.Text) && TypeOfElement.DecimalIsMatch(tbTypeOfElementHeight.Text) && TypeOfElement.DecimalIsMatch(tbTypeOfElementLength.Text) && SelectedElementPictureInTypeOfElement().Id != -1) { string name = tbTypeOfElementName.Text; decimal square = Convert.ToDecimal(tbTypeOfElementSquare.Text); decimal height = Convert.ToDecimal(tbTypeOfElementHeight.Text); decimal length = Convert.ToDecimal(tbTypeOfElementLength.Text); int idElementPicture = SelectedElementPictureInTypeOfElement().Id; TypeOfElement typeOfElement = new TypeOfElement( name, idElementPicture, square, height, length); try { typeOfElement.Create(driver); MessageBox.Show("Элемент фасада сохранен", "Сохранение данных", MessageBoxButtons.OK, MessageBoxIcon.Information); ShowVoidTypeOfElement(); ShowAllTypesOfElement(); gbTypeOfElementData.Enabled = false; btnTypeOfElementCreate.Visible = false; btnTypeOfElementSwitchCancel.Visible = false; } catch (Exception ex) { MessageBox.Show(ex.Message, "Сообщение об ошибке", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { MessageBox.Show("Сохранение данных невозможно, не все поля заполнены корректно", "Сообщение об ошибке", MessageBoxButtons.OK, MessageBoxIcon.Error); } }