Esempio n. 1
0
        //Выход с формы удаления мастеров
        private void buttonCancel_Click(object sender, EventArgs e)
        {
            FormViewMasters viewMasters = new FormViewMasters();

            viewMasters.Show();
            this.Close();
        }
Esempio n. 2
0
        //Открытие формы просмотра мастеров
        private void buttonShowMasters_Click(object sender, EventArgs e)
        {
            FormViewMasters viewMasters = new FormViewMasters();

            viewMasters.Show();
            this.Hide();
        }
Esempio n. 3
0
 private void buttonDel_Click(object sender, EventArgs e)
 {
     //Проверка на ввод ID мастера
     if (textBoxEnterID.Text == "")
     {
         DialogResult result = MessageBox.Show("Введите ID мастера которого хотите удалить", "Внимание!", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly);
         if (result == DialogResult.OK)
         {
             textBoxEnterID.Focus();
         }
     }
     //Выполнение удаления мастера, если он введен
     else
     {
         using (SqlConnection con = new SqlConnection(@"Data Source=DESKTOP-KU11OGM\SQLEXPRESS;Initial Catalog=Workshop;Integrated Security=True"))
         {
             try
             {
                 int IDMaster = Convert.ToInt32(textBoxEnterID.Text);
                 con.Open();
                 SqlCommand cmdMasters          = con.CreateCommand();
                 SqlCommand cmdPassportMasters  = con.CreateCommand();
                 SqlCommand cmdEducationMasters = con.CreateCommand();
                 //Удаление данных мастера
                 cmdMasters.CommandText          = "DELETE FROM [Masters] WHERE MasterID = '" + IDMaster + "'";
                 cmdPassportMasters.CommandText  = "DELETE FROM [MastersPassportData] WHERE MasterID = '" + IDMaster + "'";
                 cmdEducationMasters.CommandText = "DELETE FROM [MastersEducation] WHERE MasterID = '" + IDMaster + "'";
                 //Подверждение удаления мастера
                 DialogResult result = MessageBox.Show("Удалить мастера?", "Удаление мастера", MessageBoxButtons.YesNo, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly);
                 if (result == DialogResult.Yes)
                 {
                     cmdPassportMasters.ExecuteNonQuery();
                     cmdEducationMasters.ExecuteNonQuery();
                     cmdMasters.ExecuteNonQuery();
                     FormViewMasters viewMasters = new FormViewMasters();
                     viewMasters.Show();
                     this.Close();
                 }
             }
             catch (Exception ex)
             {
                 MessageBox.Show(Convert.ToString(ex));
             }
             finally
             {
                 con.Close();
             }
         }
     }
 }
Esempio n. 4
0
 private void buttonAdd_Click(object sender, EventArgs e)
 {
     // Проверка на заполнение всех данных
     if (textBoxSurname.Text == "" || textBoxDataSNILS.Text == "" || textBoxName.Text == "" || textBoxSpecialization.Text == "" || textBoxPasportNomber.Text == "" || textBoxPassportIssued.Text == "" || textBoxRegistredAt.Text == "" || textBoxPassportSeries.Text == "" || textBoxTelephone.Text == "" || comboBoxFormEducation.Text == "" || comboBoxKindOfEducation.Text == "" || textBoxPassword.Text == "" || textBoxMail.Text == "")
     {
         buttonAdd.Enabled = false;
         MessageBox.Show("Заполните все данные");
     }
     if (dateTimePickerDateStartEducation.Value == dateTimePickerDateEndEducation.Value)
     {
         MessageBox.Show("Начало обучения не может совпадать с его окончанием");
     }
     else
     {
         using (SqlConnection con = new SqlConnection(@"Data Source=DESKTOP-KU11OGM\SQLEXPRESS;Initial Catalog=Workshop;Integrated Security=True"))
         {
             try
             {
                 con.Open();
                 SqlCommand cmdMasters          = con.CreateCommand();
                 SqlCommand cmdPassportMasters  = con.CreateCommand();
                 SqlCommand cmdEducationMasters = con.CreateCommand();
                 //Добавление данных в таблицу Masters
                 cmdMasters.CommandText = "insert into [Masters] values ('" + Data.ValueIDMaster + "','" + textBoxSurname.Text + "','" + textBoxName.Text + "','" + textBoxPatronymic.Text + "','" + dateTimePickerDateOfBirth.Value + "','" + textBoxDataSNILS.Text + "','" + textBoxSpecialization.Text + "','" + textBoxMail.Text + "','" + textBoxTelephone.Text + "','" + textBoxPassword.Text + "','" + DateTime.Now + "')";
                 //Добавление данных в таблицу MastersPasportData
                 cmdPassportMasters.CommandText = "insert into [MastersPassportData] values ('" + Data.ValueIDMaster + "', '" + textBoxPassportSeries.Text + "','" + textBoxPasportNomber.Text + "','" + dateTimePickerExtraditionDate.Value + "','" + textBoxPassportIssued.Text + "','" + textBoxRegistredAt.Text + "')";
                 //Добавление данных в таблицу MastersEduccation
                 cmdEducationMasters.CommandText = "insert into [MastersEducation] values ('" + Data.ValueIDMaster + "','" + comboBoxKindOfEducation.Text + "','" + comboBoxFormEducation.Text + "','" + dateTimePickerDateStartEducation.Value + "','" + dateTimePickerDateEndEducation.Value + "')";
                 cmdMasters.ExecuteNonQuery();
                 cmdPassportMasters.ExecuteNonQuery();
                 cmdEducationMasters.ExecuteNonQuery();
                 FormViewMasters viewMasters = new FormViewMasters();
                 viewMasters.Show();
                 this.Close();
             }
             catch (Exception ex)
             {
                 MessageBox.Show(Convert.ToString(ex));
             }
             finally
             {
                 con.Close();
             }
         }
     }
 }