internal static int seleccionarEspaciosDisponibles() { try { configs cf = configs.getInstance(); string dateFormat = cf.getNameStringDB(); SqlCommand command = new SqlCommand(); command.CommandText = "select count (id) from EspacioParqueo where disponible=1 and reservado=0"; command.CommandType = CommandType.Text; string userDB = cf.getUserDB(); string passDB = cf.getPassDB(); string nameDB = cf.getNameDB(); using (DataBase db = DatabaseFactory.createdatabase(nameDB, userDB, passDB)) { int disponibles = Convert.ToInt32(command.ExecuteScalar()); return(disponibles); } } catch (Exception err) { System.ArgumentException argEx = new System.ArgumentException("0x000033", err); throw argEx; } }
internal static int desocuparEspacio() { try { configs cf = configs.getInstance(); string dateFormat = cf.getNameStringDB(); SqlCommand command = new SqlCommand(); command.CommandText = "UPDATE EspacioParqueo SET disponible=1 where id=(select max (id) from EspacioParqueo where disponible=0 and reservado=0)"; command.CommandType = CommandType.Text; string userDB = cf.getUserDB(); string passDB = cf.getPassDB(); string nameDB = cf.getNameDB(); using (DataBase db = DatabaseFactory.createdatabase(nameDB, userDB, passDB)) { int insertado = db.ExecuteNonQuery(command, IsolationLevel.ReadCommitted); if (insertado == 0) { return(-1); } else { return(insertado); } } } catch (Exception err) { System.ArgumentException argEx = new System.ArgumentException("0x000033", err); throw argEx; } }
public int eliminarTarifa(int tipoTarifa) { try { int vuelve; configs cf = configs.getInstance(); string dateFormat = cf.getNameStringDB(); SqlCommand command = new SqlCommand(); command.CommandText = "update Tarifas set estado=0 where tipoTarifa=" + tipoTarifa; command.CommandType = CommandType.Text; string userDB = cf.getUserDB(); string passDB = cf.getPassDB(); string nameDB = cf.getNameDB(); using (DataBase db = DatabaseFactory.createdatabase(nameDB, userDB, passDB)) { vuelve = db.ExecuteNonQuery(command); //db.ExecuteNonQuery(command, IsolationLevel.ReadCommitted); } return(vuelve); } catch (Exception err) { System.ArgumentException argEx = new System.ArgumentException("0x000033", err); throw argEx; } }
internal static DataSet getEspacio(int id) { try { DataSet vuelve = new DataSet(); configs cf = configs.getInstance(); string dateFormat = cf.getNameStringDB(); SqlCommand command = new SqlCommand(); command.Parameters.AddWithValue("@id", id); command.CommandText = "usp_SELECT_EspacioParqueo_ByID"; command.CommandType = CommandType.StoredProcedure; string userDB = cf.getUserDB(); string passDB = cf.getPassDB(); string nameDB = cf.getNameDB(); using (DataBase db = DatabaseFactory.createdatabase(nameDB, userDB, passDB)) { vuelve = db.ExecuteReader(command, "consulta"); //db.ExecuteNonQuery(command, IsolationLevel.ReadCommitted); } return(vuelve); } catch (Exception err) { System.ArgumentException argEx = new System.ArgumentException("0x000033", err); throw argEx; } }
public int insertarTarifa(string descripcion, decimal monto) { try { int vuelve; configs cf = configs.getInstance(); string dateFormat = cf.getNameStringDB(); SqlCommand command = new SqlCommand(); command.Parameters.AddWithValue("@descripcion", descripcion); command.Parameters.AddWithValue("@monto", monto); command.CommandText = "prc_insertarNuevaTarifa"; command.CommandType = CommandType.StoredProcedure; string userDB = cf.getUserDB(); string passDB = cf.getPassDB(); string nameDB = cf.getNameDB(); using (DataBase db = DatabaseFactory.createdatabase(nameDB, userDB, passDB)) { vuelve = db.ExecuteNonQuery(command); //db.ExecuteNonQuery(command, IsolationLevel.ReadCommitted); } return(vuelve); } catch (Exception err) { System.ArgumentException argEx = new System.ArgumentException("0x000033", err); throw argEx; } }
public static List <Tarifa> obtenerTodasTarifa() { try { SqlDataReader vuelve; List <Tarifa> listaTarifas = new List <Tarifa>(); Tarifa tarifa = new Tarifa(); configs cf = configs.getInstance(); string dateFormat = cf.getNameStringDB(); SqlCommand command = new SqlCommand(); command.CommandText = "Select tipoTarifa,monto from Tarifas"; command.CommandType = CommandType.Text; string userDB = cf.getUserDB(); string passDB = cf.getPassDB(); string nameDB = cf.getNameDB(); using (DataBase db = DatabaseFactory.createdatabase(nameDB, userDB, passDB)) { vuelve = db.ExecuteReader(command); while (vuelve.Read()) { int tipo = (int)vuelve["TipoTarifa"]; double monto = (double)vuelve["monto"]; tarifa.tipoTarifa = tipo; tarifa.monto = monto; listaTarifas.Add(tarifa); } } return(listaTarifas); } catch (Exception err) { System.ArgumentException argEx = new System.ArgumentException("0x000033", err); throw argEx; } }
public static int agregarCliente(string cedula, string nombre, string apellido1, string apellido2, string telefono, string placa, int tipoServicio) { try { DataSet vuelve = new DataSet(); configs cf = configs.getInstance(); string dateFormat = cf.getNameStringDB(); SqlCommand command = new SqlCommand(); command.CommandText = "INSERT INTO Clientes(cedula, nombre, apellido1, apellido2, telefono, placa, tipoServicio, estado) VALUES" + "('" + cedula + "','" + nombre + "','" + apellido1 + "','" + apellido2 + "','" + telefono + "','" + placa + "'," + tipoServicio + ",1)"; command.CommandType = CommandType.Text; string userDB = cf.getUserDB(); string passDB = cf.getPassDB(); string nameDB = cf.getNameDB(); using (DataBase db = DatabaseFactory.createdatabase(nameDB, userDB, passDB)) { return(db.ExecuteNonQuery(command, IsolationLevel.ReadCommitted)); } } catch (Exception err) { System.ArgumentException argEx = new System.ArgumentException("0x000033", err); throw argEx; } }
public static SqlDataReader obtenerTodosCliente() { try { SqlDataReader vuelve; configs cf = configs.getInstance(); string dateFormat = cf.getNameStringDB(); SqlCommand command = new SqlCommand(); command.CommandText = "Select c.id ,c.cedula, c.nombre, c.apellido1, c.apellido2, c.telefono, c.placa, c.tipoServicio, c.estado" + " from Clientes"; command.CommandType = CommandType.Text; string userDB = cf.getUserDB(); string passDB = cf.getPassDB(); string nameDB = cf.getNameDB(); using (DataBase db = DatabaseFactory.createdatabase(nameDB, userDB, passDB)) { vuelve = db.ExecuteReader(command); //db.ExecuteNonQuery(command, IsolationLevel.ReadCommitted); } return(vuelve); } catch (Exception err) { System.ArgumentException argEx = new System.ArgumentException("0x000033", err); throw argEx; } }
public static int modificarCliente(int id, string cedula, string nombre, string apellido1, string apellido2, string telefono, string placa, int tipoServicio) { try { int vuelve; configs cf = configs.getInstance(); string dateFormat = cf.getNameStringDB(); SqlCommand command = new SqlCommand(); command.Parameters.AddWithValue("@id", id); command.Parameters.AddWithValue("@cedula", cedula); command.Parameters.AddWithValue("@nombre", nombre); command.Parameters.AddWithValue("@apellido1", apellido1); command.Parameters.AddWithValue("@apellido2", apellido2); command.Parameters.AddWithValue("@telefono", telefono); command.Parameters.AddWithValue("@placa", placa); command.Parameters.AddWithValue("@tipoServicio", tipoServicio); command.CommandText = "usp_Update_ClientesPorMes_ByID"; command.CommandType = CommandType.StoredProcedure; string userDB = cf.getUserDB(); string passDB = cf.getPassDB(); string nameDB = cf.getNameDB(); using (DataBase db = DatabaseFactory.createdatabase(nameDB, userDB, passDB)) { vuelve = db.ExecuteNonQuery(command); //db.ExecuteNonQuery(command, IsolationLevel.ReadCommitted); } return(vuelve); } catch (Exception err) { System.ArgumentException argEx = new System.ArgumentException("0x000033", err); throw argEx; } }
public static Cliente obtenerClientePorId(int id) { Cliente cliente = new Cliente(); try { SqlDataReader vuelve; configs cf = configs.getInstance(); string dateFormat = cf.getNameStringDB(); SqlCommand command = new SqlCommand(); command.Parameters.AddWithValue("@id", id); command.CommandText = "usp_SELECT_ClientesPorMes_ByID"; command.CommandType = CommandType.StoredProcedure; string userDB = cf.getUserDB(); string passDB = cf.getPassDB(); string nameDB = cf.getNameDB(); using (DataBase db = DatabaseFactory.createdatabase(nameDB, userDB, passDB)) { vuelve = db.ExecuteReader(command); //db.ExecuteNonQuery(command, IsolationLevel.ReadCommitted); while (vuelve.Read()) { string cedula = (string)vuelve["cedula"]; string nombre = (string)vuelve["nombre"]; string apellido1 = (string)vuelve["apellido1"]; string apellido2 = (string)vuelve["apellido2"]; string telefono = (string)vuelve["telefono"]; string placa = (string)vuelve["placa"]; string tipoServicio = (string)vuelve["descripcion"]; bool estado = (bool)vuelve["estado"]; cliente.id = id; cliente.cedula = cedula; cliente.nombre = nombre; cliente.apellido1 = apellido1; cliente.apellido2 = apellido2; cliente.telefono = telefono; cliente.placa = placa; cliente.tipoServicio = tipoServicio; cliente.estado = estado; } } return(cliente); } catch (Exception err) { System.ArgumentException argEx = new System.ArgumentException("0x000033", err); throw argEx; } }
internal static int eliminarEspacio() { try { configs cf = configs.getInstance(); string dateFormat = cf.getNameStringDB(); SqlCommand command = new SqlCommand(); command.CommandText = "delete from EspacioParqueo where id=(select min(id) from EspacioParqueo)"; command.CommandType = CommandType.Text; string userDB = cf.getUserDB(); string passDB = cf.getPassDB(); string nameDB = cf.getNameDB(); using (DataBase db = DatabaseFactory.createdatabase(nameDB, userDB, passDB)) { return(db.ExecuteNonQuery(command, IsolationLevel.ReadCommitted)); } } catch (Exception err) { System.ArgumentException argEx = new System.ArgumentException("0x000033", err); throw argEx; } }
public static int eliminarCliente(int id) { try { DataSet vuelve = new DataSet(); configs cf = configs.getInstance(); string dateFormat = cf.getNameStringDB(); SqlCommand command = new SqlCommand(); command.CommandText = "Update Clientes set estado=0 where id=" + id; command.CommandType = CommandType.Text; string userDB = cf.getUserDB(); string passDB = cf.getPassDB(); string nameDB = cf.getNameDB(); using (DataBase db = DatabaseFactory.createdatabase(nameDB, userDB, passDB)) { return(db.ExecuteNonQuery(command, IsolationLevel.ReadCommitted)); } } catch (Exception err) { System.ArgumentException argEx = new System.ArgumentException("0x000033", err); throw argEx; } }