Good afternoon, I have a procedure to show available vehicles for a certain period, but it is not working, this is the code that I have in the layers persistence and logic.
Persistence:
//public static List<Vehiculo> disponible(DateTime Ini, DateTime Fin)
//{
// List<Vehiculo> vehiculodis = new List<Vehiculo>();
// string letmatv = "", marca = "", modelo = "", anclaje = "", tipo = "";
// int nrosmatv = 0, año = 0, cantP = 0, costo = 0, carg = 0;
// DateTime inicio = Ini;
// DateTime final = Fin;
// DateTime i;
// DateTime f;
// Alquiler aA = null;
// Vehiculo v = null;
// Utilitario U = null;
// string x = null;
// SqlConnection oconexion = new SqlConnection(conexion.STR);
// SqlCommand oComando = new SqlCommand("VehiculosDisponiblesPeriodo", oconexion);
// oComando.CommandType = CommandType.StoredProcedure;
// SqlParameter oComando1 = new SqlParameter("@desde", inicio);
// SqlParameter oComando2 = new SqlParameter("@hasta", final);
// oComando.Parameters.Add(oComando1);
// oComando.Parameters.Add(oComando2);
// SqlDataReader oreader;
// try
// {
// oconexion.Open();
// oreader = oComando.ExecuteReader();
// if (oreader.Read())
// {
// letmatv = (string)oreader["LetrasMatV"];
// nrosmatv = (int)oreader["NrosMatV"];
// marca = (string)oreader["marcaV"];
// modelo = (string)oreader["modeloV"];
// año = (int)oreader["añoV"];
// cantP = (int)oreader["cantPV"];
// costo = (int)oreader["costoDV"];
// i = (DateTime)oreader["fechaIni"];
// f = (DateTime)oreader["fechaFin"];
// aA = new Alquiler(i, f, v);
// }
// vehiculodis.Add(aA);
// return vehiculodis;
// }
// catch (Exception ex)
// {
// throw ex;
// }
// finally
// {
// oconexion.Close();
// }
Logica:
//public static List<Alquiler> dispo(DateTime ini, DateTime fin)
//{
// List<Alquiler> oAux = persistenciaAlquiler.//disponible(ini, fin);
// return oAux;
//}
Webform:
protected void btnDis_Click(object sender, EventArgs e)
{
try
{
DateTime ini;
DateTime fin;
ini = Convert.ToDateTime(txtIni.Text);
fin = Convert.ToDateTime(txtFin.Text);
List<string> disponible = logicaAlquiler.dispo(ini, fin);
for (int i = 0; i < disponible.Count; i++)
{
lstDis.Items.Add(disponible[i].ToString());
}