Exemplo n.º 1
0
 private void btnModificar_Click(object sender, EventArgs e)
 {
     try
     {
         frmMenu mn    = new frmMenu();
         string  query = "Update organos Set nombre_organo='" + txtNombreOrg.Text + "', peso='" + txtPeso.Text + "', fecha_extraccion='" + txtFecha.Text + "', id_donador='" + txtIdDonador.Text
                         + "' where id_organo='" + txtID.Text + "' ;";
         MySqlConnection conn = new MySqlConnection(mn.ConexDBGlobal);
         MySqlCommand    cmd  = new MySqlCommand(query, conn);
         MySqlDataReader Read;
         conn.Open();
         Read = cmd.ExecuteReader();
         MessageBox.Show("Datos Actualizados");
         while (Read.Read())
         {
         }
         conn.Close();
         this.Close();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Exemplo n.º 2
0
 private void btnAgregar_Click(object sender, EventArgs e)
 {
     try
     {
         frmMenu mn    = new frmMenu();
         string  query = "Insert Into organos Values('" + txtID.Text + "', '" + txtNombreOrg.Text + "', '" + txtPeso.Text
                         + "', '" + txtFecha.Text + "', '" + txtIdDonador.Text + "') ;";
         MySqlConnection MyConn2    = new MySqlConnection(mn.ConexDBGlobal);
         MySqlCommand    MyCommand2 = new MySqlCommand(query, MyConn2);
         MySqlDataReader MyReader2;
         MyConn2.Open();
         MyReader2 = MyCommand2.ExecuteReader();
         MessageBox.Show("Datos Guardados!");
         this.Close();
         while (MyReader2.Read())
         {
         }
         MyConn2.Close();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }