Exemple #1
0
 private void button1_Click(object sender, EventArgs e)
 {
     try
     {
         connect.myConnection.Open();
         SqlCommand myCommand = new SqlCommand("INSERT INTO COURSES (NAME_COURSE, COST_COURSE, PERIOD_COURSE) VALUES(@NAME_COURSE, @COST_COURSE, @PERIOD_COURSE)", connect.myConnection);
         myCommand.Parameters.AddWithValue("NAME_COURSE", txtNomeCurso.Text);
         myCommand.Parameters.AddWithValue("COST_COURSE", Convert.ToDouble(txtValorCurso.Text));
         myCommand.Parameters.AddWithValue("PERIOD_COURSE", txtPeriodoCurso.Text);
         myCommand.ExecuteNonQuery();
         InterfaceOperations.ClearTextBoxes(this.Controls);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
     finally
     {
         connect.myConnection.Close();
     }
 }
Exemple #2
0
        private void btnInDep_Click(object sender, EventArgs e)
        {
            try
            {
                connect.myConnection.Open();
                SqlCommand myCommand = new SqlCommand("INSERT INTO Dependentes (Dep_Name, Dep_DOB, ID) values (@Dep_Name, @Dep_DOB, @ID)", connect.myConnection);
                myCommand.Parameters.AddWithValue("Dep_Name", txtDepName.Text);
                myCommand.Parameters.AddWithValue("Dep_DOB", Convert.ToDateTime(txtDepDOB.Text));
                myCommand.Parameters.AddWithValue("ID", Convert.ToInt16(comboBox1.SelectedValue));
                myCommand.ExecuteNonQuery();
                InterfaceOperations.ClearTextBoxes(this.Controls);
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            finally
            {
                connect.myConnection.Close();
            }
        }
Exemple #3
0
 private void btnInsert_Click(object sender, EventArgs e)
 {
     try
     {
         connect.myConnection.Open();
         SqlCommand myCommand = new SqlCommand("INSERT INTO PESSOAS (Fname, Lname, Phone, DOB) values (@Fname, @Lname, @Phone, @DOB)", connect.myConnection);
         myCommand.Parameters.AddWithValue("Fname", txtFName.Text);
         myCommand.Parameters.AddWithValue("Lname", txtLName.Text);
         myCommand.Parameters.AddWithValue("Phone", txtPhone.Text);
         myCommand.Parameters.AddWithValue("DOB", Convert.ToDateTime(txtDOB.Text));
         myCommand.ExecuteNonQuery();
         InterfaceOperations.ClearTextBoxes(this.Controls);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
     finally
     {
         connect.myConnection.Close();
     }
 }
Exemple #4
0
 private void btnSelect_Click(object sender, EventArgs e)
 {
     try
     {
         connect.myConnection.Open();
         SqlCommand myCommand   = new SqlCommand("SELECT * FROM PESSOAS");
         var        dataAdapter = new SqlDataAdapter(myCommand.CommandText, connect.myConnection);
         var        ds          = new DataSet();
         dataAdapter.Fill(ds);
         dataGridView1.ReadOnly   = true;
         dataGridView1.DataSource = ds.Tables[0];
         InterfaceOperations.ClearTextBoxes(this.Controls);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
     finally
     {
         connect.myConnection.Close();
     }
 }
Exemple #5
0
 private void btnDelete_Click(object sender, EventArgs e)
 {
     try
     {
         connect.myConnection.Open();
         SqlCommand myCommand = new SqlCommand("DELETE PESSOAS WHERE ID = @ID", connect.myConnection);
         myCommand.Parameters.AddWithValue("ID", ID);
         myCommand.Parameters.AddWithValue("Fname", txtFName.Text);
         myCommand.Parameters.AddWithValue("Lname", txtLName.Text);
         myCommand.Parameters.AddWithValue("Phone", txtPhone.Text);
         myCommand.Parameters.AddWithValue("DOB", Convert.ToDateTime(txtDOB.Text));
         myCommand.ExecuteNonQuery();
         InterfaceOperations.ClearTextBoxes(this.Controls);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
     finally
     {
         connect.myConnection.Close();
     }
 }