private void btnGuardarAvion_Click_2(object sender, EventArgs e)
{
if ((cmbtipoAvion.Text != "") && (txtaerolinea.Text != "") && (txtmatricula.Text != "") && (txtmodelo.Text != ""))
{
try
{
int icodigoAvion;
int icodTipoA;
using (clasconexion.funobtenerConexion())
{
//PROGRAMADOR Y ANALISTA: Pamela Jacqueline Selman David
string squery = "SELECT COUNT(*) As Cant FROM AEROLINEA.MaAVION ";
MySqlCommand cmd = new MySqlCommand(squery, clasconexion.funobtenerConexion());
icodigoAvion = (Convert.ToInt32(cmd.ExecuteScalar())) + 1;
//Programador y analista: Jose Alberto Oxcal Ley
string scodTipoA = "Select ncodtipoavion as Codigo FROM TrTIPOAVION WHERE vdescripciontipoavion='" + cmbtipoAvion.Text + "'";
MySqlCommand cmdcodTipoA = new MySqlCommand(scodTipoA, clasconexion.funobtenerConexion());
icodTipoA = Convert.ToInt32(cmdcodTipoA.ExecuteScalar());
string sinsertaravion = "INSERT INTO MaAVION (ncodavion,vaerolinea,vmodelo,vmatricula,vdisponibilidad,ncodtipoavion)" +
"VALUES(" + icodigoAvion + ",'" + txtaerolinea.Text + "','" + txtmodelo.Text + "','" + txtmatricula.Text + "','ACTIVO'," + icodTipoA + ")";
MySqlCommand cmd1 = new MySqlCommand(sinsertaravion, clasconexion.funobtenerConexion());
MySqlDataReader MyReader;
MyReader = cmd1.ExecuteReader();
MessageBox.Show("AVION ALMACENADO");
clasconexion.funobtenerConexion().Close();
funlimpiar();
funconsultarAviones();
}
}
catch (Exception ex) { MessageBox.Show(ex.Message); }
}
else { MessageBox.Show("CAMPOS VACIOS"); }
}