public List<CdPlane> ListarAvion() { List<CdPlane> listaavion = new List<CdPlane>(); MyConnection myConnection = new MyConnection(); SqlConnection conexion = myConnection.CreateConnection(); SqlCommand comando = myConnection.CreateCommand(conexion); SqlDataReader pl; comando.CommandText = "sp_listPlane"; comando.CommandType = CommandType.StoredProcedure; try { conexion.Open(); pl = comando.ExecuteReader(); while (pl.Read()) { CdPlane creaavion = new CdPlane(); creaavion.IdPlane = (int)pl["ID"]; creaavion.Marca = (string)pl["Marca"]; creaavion.QtyAsiento = (int)pl["CantidadAsientos"]; listaavion.Add(creaavion); } } catch (SqlException ex) { Console.WriteLine(ex.Message); } conexion.Close(); return listaavion; }
public void GuardarTickete(CdTicket tickete) { MyConnection myConnection = new MyConnection(); SqlConnection conexion = myConnection.CreateConnection(); SqlCommand comando = myConnection.CreateCommand(conexion); SqlDataReader tq; comando.CommandText = "sp_RegisterTicket"; comando.CommandType = CommandType.StoredProcedure; comando.Parameters.AddWithValue("@pPrice ", tickete.Price); comando.Parameters.AddWithValue("@pCurrency", tickete.Currency); comando.Parameters.AddWithValue("@pTicketState", tickete.TicketState); comando.Parameters.AddWithValue("@pIdClient", tickete.IdClient); comando.Parameters.AddWithValue("@pIdFlight", tickete.IdFlight); comando.Parameters.AddWithValue("@pNumSeat", tickete.NumSeat); try { conexion.Open(); comando.ExecuteNonQuery(); } catch (SqlException ex) { Console.WriteLine(ex.Message); } conexion.Close(); }
public void GuardarTickete(CdFlight flight) { MyConnection myConnection = new MyConnection(); SqlConnection conexion = myConnection.CreateConnection(); SqlCommand comando = myConnection.CreateCommand(conexion); SqlDataReader fl; comando.CommandText = "sp_RegisterFlight"; comando.CommandType = CommandType.StoredProcedure; comando.Parameters.AddWithValue("@idTicket ", flight.IdTicket); comando.Parameters.AddWithValue("@idPlane", flight.IdPlane); comando.Parameters.AddWithValue("@origen", flight.Origen); comando.Parameters.AddWithValue("@destino", flight.Destino); comando.Parameters.AddWithValue("@horaPartida", flight.HoraPartida); comando.Parameters.AddWithValue("@horaLlegada", flight.HoraLlegada); conexion.Open(); fl = comando.ExecuteReader(); conexion.Close(); }
public void GuardarCliente(CdClient persona) { MyConnection myConnection = new MyConnection(); SqlConnection conexion = myConnection.CreateConnection(); SqlCommand comando = myConnection.CreateCommand(conexion); SqlDataReader cliente; comando.CommandText = GUARDAR_Cliente; comando.CommandType = CommandType.StoredProcedure; comando.Parameters.Add(new SqlParameter("@pId", persona.Id)); comando.Parameters.Add(new SqlParameter("@pName ", persona.Name)); comando.Parameters.Add(new SqlParameter("@pLastname", persona.Lastname)); //comando.Parameters.Add(new SqlParameter("@pAapellido2", persona.Apellido2)); comando.Parameters.Add(new SqlParameter("@pEmail", persona.Email)); comando.Parameters.Add(new SqlParameter("@pPhone", persona.Phone)); comando.Parameters.Add(new SqlParameter("@pClientState", persona.ClientState)); comando.Parameters.Add(new SqlParameter("@pClientType", persona.ClientType)); conexion.Open(); cliente = comando.ExecuteReader(); conexion.Close(); }
public void ModifyCliente(CdClient mdfPersona) { MyConnection myConnection = new MyConnection(); SqlConnection conexion = myConnection.CreateConnection(); SqlCommand comando = myConnection.CreateCommand(conexion); SqlDataReader cliente; comando.CommandText = Modify_Cliente; comando.CommandType = CommandType.StoredProcedure; comando.Parameters.Add(new SqlParameter("@pId", mdfPersona.Id)); comando.Parameters.Add(new SqlParameter("@pName ", mdfPersona.Name)); comando.Parameters.Add(new SqlParameter("@pLastname", mdfPersona.Lastname)); comando.Parameters.Add(new SqlParameter("@pEmail", mdfPersona.Email)); comando.Parameters.Add(new SqlParameter("@pPhone", mdfPersona.Phone)); comando.Parameters.Add(new SqlParameter("@pClientState", mdfPersona.ClientState)); comando.Parameters.Add(new SqlParameter("@pClientType", mdfPersona.ClientType)); comando.Parameters.Add(new SqlParameter("@pStatus_db", mdfPersona.Status)); conexion.Open(); cliente = comando.ExecuteReader(); conexion.Close(); }