private void Button1_Click(object sender, EventArgs e)
 {
     try
     {
         UpdateCurrentBrigade = "update d__Brigade " +
                                "set Name = '" + textBox1.Text.Trim() + "', " +
                                "Surname = '" + textBox2.Text.Trim() + "'," +
                                "Lastname = '" + textBox3.Text.Trim() + "', " +
                                "FIO = '" + textBox2.Text.Trim() + ' ' + textBox1.Text.Substring(0, 1) + '.' + textBox3.Text.Substring(0, 1) + '.' + "'" +
                                "where ID = " + selectID;
         DataTable dtbl = new DataTable();
         dtbl = DbConnection.DBConnect(UpdateCurrentBrigade);
         this.Close();
         MessageBox.Show("Запись изменена!", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
         BrigadeForm main = this.Owner as BrigadeForm;
         main.Refreshh();
     }
     catch (SqlException ex)
     {
         MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     catch (Exception exp)
     {
         MessageBox.Show(exp.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
示例#2
0
 private void BtnAdd_Click(object sender, EventArgs e)
 {
     try
     {
         AddNewBrigade = "insert into d__Brigade values('" + textBox1.Text.Trim() + "','" + textBox2.Text.Trim() + "','" + textBox3.Text.Trim() + "','" + textBox2.Text.Trim() + ' ' + textBox1.Text.Substring(0, 1) + '.' + textBox3.Text.Substring(0, 1) + '.' + "')";
         DataTable dataTable = new DataTable();
         dataTable = DbConnection.DBConnect(AddNewBrigade);
         this.Close();
         MessageBox.Show("Сотрудник добавлен!", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
         BrigadeForm main = this.Owner as BrigadeForm;
         main.Refreshh();
     }
     catch (SqlException ex)
     {
         MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     catch (Exception exp)
     {
         MessageBox.Show(exp.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }