public ParkingEntry(ParkingEntryEntity e) { EntryID = e.EntryID; SlotID = e.SlotID; VehicleNumber = e.VehicleNumber; TimeIn = e.TimeIn; TimeOut = e.TimeOut; TotalAmount = e.TotalAmount; }
public ParkingEntryViewModel(string slotid) { Entries = new ObservableCollection <ParkingEntry>(); try { ParkingEntryEntity e = ParkingEntryService.GetCurrentParkingEntryInfo(slotid); Entries.Add(new ParkingEntry(e)); } catch (Exception ex) { throw ex; } }
public static ParkingEntryEntity GetCurrentParkingEntryInfo(string slotid) { NpgsqlConnection con = new NpgsqlConnection(connString); try { con.Open(); string q1 = "select currententryid from \"ParkingSlot\" where slotid=@sid"; NpgsqlCommand cmd1 = new NpgsqlCommand(q1, con); cmd1.Parameters.AddWithValue("@sid", slotid); string entryid = cmd1.ExecuteScalar().ToString(); if (entryid == null) { throw new Exception("No entry present for Slot ID = " + slotid); } string q2 = "SELECT entryid, slotid, vehiclenumber, timein, timeout, amount FROM \"ParkingEntry\" where entryid=@eid"; NpgsqlCommand cmd2 = new NpgsqlCommand(q2, con); cmd2.Parameters.AddWithValue("@eid", entryid); NpgsqlDataReader reader = cmd2.ExecuteReader(); if (reader.Read()) { //string slotid = reader.GetString(1); int vehNum = reader.GetInt32(2); DateTime timein = reader.GetDateTime(3); DateTime timeout = DateTime.MinValue; if (!reader.IsDBNull(4)) { timeout = reader.GetDateTime(4); } decimal amount = 0; if (!reader.IsDBNull(5)) { amount = reader.GetDecimal(5); } ParkingEntryEntity e = new ParkingEntryEntity { EntryID = entryid, SlotID = slotid, TimeIn = timein, TimeOut = timeout, TotalAmount = amount, VehicleNumber = vehNum }; return(e); } throw new Exception("No entry found for Entry ID : " + entryid); } catch (Exception ex) { throw ex; } finally { con.Close(); } }