コード例 #1
0
 private void Сохранить_Click(object sender, EventArgs e)
 {
     if (string.IsNullOrEmpty(textBoxFIO.Text))
     {
         MessageBox.Show("Введите ФИО", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
         return;
     }
     if (string.IsNullOrEmpty(textBoxCity.Text))
     {
         MessageBox.Show("Введите Город", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
         return;
     }
     if (string.IsNullOrEmpty(textBoxPlace.Text))
     {
         MessageBox.Show("Введите Место рождения", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
         return;
     }
     if (string.IsNullOrEmpty(textBoxPhone.Text))
     {
         MessageBox.Show("Введите Номер телефона", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
         return;
     }
     if (string.IsNullOrEmpty(comboBoxType.Text))
     {
         MessageBox.Show("Введите Тип документа", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
         return;
     }
     if (string.IsNullOrEmpty(textBoxSeries.Text))
     {
         MessageBox.Show("Введите Серию", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
         return;
     }
     if (string.IsNullOrEmpty(textBoxNumber.Text))
     {
         MessageBox.Show("Введите Номер документа", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
         return;
     }
     if (string.IsNullOrEmpty(textBoxIssues.Text))
     {
         MessageBox.Show("Введите кем выдан", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
         return;
     }
     try
     {
         logic.CreateOrUpdate(new ClientBindingModel
         {
             Id             = id,
             FIO            = textBoxFIO.Text,
             DateBirthday   = dateTimePicker.Value,
             City           = textBoxCity.Text,
             PlaceResident  = textBoxPlace.Text,
             Phone          = Convert.ToInt32(textBoxNumber.Text),
             TypeDocument   = comboBoxType.Text,
             Series         = Convert.ToInt32(textBoxSeries.Text),
             NumberDocument = Convert.ToInt32(textBoxNumber.Text),
             Issued         = textBoxIssues.Text,
         });
         MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
         DialogResult = DialogResult.OK;
         Close();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }