private void ExecuteLoad(object obj) { if (obj != null) { short id = Convert.ToInt16(obj); if (!PAList.Any(x => x.PA_ID == id)) { MessageBox.Show("Invalid Id.", MessageBoxCaption, MessageBoxButton.OK, MessageBoxImage.Exclamation); return; } SelectedPA = PAList.FirstOrDefault(x => x.PA_ID == id); } PA = new ParkingArea { PA_ID = SelectedPA.PA_ID, PA_Name = SelectedPA.PA_Name, VehicleType = SelectedPA.VehicleType, Description = SelectedPA.Description, Capacity = SelectedPA.Capacity, UID = SelectedPA.UID, FLOOR = SelectedPA.FLOOR, MinVacantLot = SelectedPA.MinVacantLot }; SetAction(ButtonAction.Selected); }
// Get All Parking Details in Model public List <ParkingArea> GetAllParkingAreaDetails() { List <ParkingArea> list = new List <ParkingArea>(); using (DataTable dt = DBHelper.Select("uspGetParkingAreas", CommandType.StoredProcedure)) { if (dt.Rows.Count > 0) { foreach (DataRow row in dt.Rows) { ParkingArea PA = new ParkingArea { ParkingAreaID = Convert.ToString(row["ParkingAreaID"]), ParkingAreaAccessLevel = Convert.ToInt32(row["ParkingAreaAccessLevel"]), ParkingAreaLocation = Convert.ToString(row["ParkingAreaLocation"]), ParkingAreaName = Convert.ToString(row["ParkingAreaName"]), ParkingAreaCoordinates = Convert.ToString(row["ParkingAreaCoordinates"]) }; list.Add(PA); } } else { list = null; } } return(list); }
public ParkingAreaViewModel() { PA = new ParkingArea(); try { MessageBoxCaption = "Occupency Area Setup"; using (SqlConnection Conn = new SqlConnection(GlobalClass.TConnectionString)) { VTypeList = new ObservableCollection <VehicleType>(Conn.Query <VehicleType>("SELECT VTYPEID, [Description], Capacity, [UID] FROM VehicleType")); PAList = new ObservableCollection <ParkingArea>(Conn.Query <ParkingArea>("SELECT PA_ID, PA_NAME,[Description], Capacity, VehicleType, [FLOOR], MinVacantLot FROM PARKINGAREA")); PAList.CollectionChanged += PAList_CollectionChanged; } foreach (ParkingArea pa in PAList) { pa.VType = VTypeList.First(x => x.VTypeID == pa.VehicleType); } LoadData = new RelayCommand(ExecuteLoad, CanExecuteLoad); NewCommand = new RelayCommand(ExecuteNew); EditCommand = new RelayCommand(ExecuteEdit); SaveCommand = new RelayCommand(ExecuteSave, CanExecuteSave); UndoCommand = new RelayCommand(ExecuteUndo); DeleteCommand = new RelayCommand(ExecuteDelete); SetAction(ButtonAction.Init); } catch (Exception ex) { MessageBox.Show(ex.Message, MessageBoxCaption, MessageBoxButton.OK, MessageBoxImage.Error); } }
public void CanBeInstantiatedCorrectlyWithThreePassPlacesAndTwoLorryPlaces() { var area = new ParkingArea(3, 2); Assert.Equal(5, area.AreaIndexing.Count()); Assert.Equal(3, area.AreaIndexing.Where(x => x.Key.ParkingType == Type.Lorry).Count()); Assert.Equal(2, area.AreaIndexing.Where(x => x.Key.ParkingType == Type.Passenger).Count()); }
//public void RemoveParkingArea(IParkingAreaDeprecated pa) public void RemoveParkingArea(ParkingArea pa) { if (pa.MyEmployees.Contains(this)) { pa.MyEmployees.Remove(this); } if (this.MyParkingAreas.Contains(pa)) { this.MyParkingAreas.Remove(pa); } }
//public void AddParkingArea(IParkingAreaDeprecated pa) public void AddParkingArea(ParkingArea pa) { //pa.MyEmployees.Add(this); if (!pa.MyEmployees.Contains(this)) { //pa.AddEmployee(this);//Causes overflow situation pa.MyEmployees.Add(this); } if (!this.MyParkingAreas.Contains(pa)) { this.MyParkingAreas.Add(pa); } }
public bool UpdateParkingArea(ParkingArea PA) { List <SqlParameter> parameters = new List <SqlParameter>(); foreach (var prop in PA.GetType().GetProperties()) { if (prop.GetValue(PA) != null) { parameters.Add(new SqlParameter("@" + prop.Name.ToString(), prop.GetValue(PA))); } } return(DBHelper.NonQuery("uspUpdateParkingArea", CommandType.StoredProcedure, parameters.ToArray())); }
public bool BLL_AddParkingArea(ParkingArea PA) { return(db.AddParkingArea(PA)); }
public bool BLL_UpdateParkingArea(ParkingArea PA) { return(db.UpdateParkingArea(PA)); }
public static void SeedDataContext(this ParkingSiteDbContext context) { string[] valueLines = System.IO.File.ReadAllLines(@"e:\Value1.CSV"); var parkingSites = new List <ParkingSite>(); foreach (var line in valueLines) { var column = line.Split(','); int i = -1; Int32.TryParse(column[5], out i); ParkingSite p = new ParkingSite { Parm1 = column[1], Parm2 = column[2], Parm3 = column[3], API = column[4], NumberOfSpaces = i }; parkingSites.Add(p); } context.AddRange(parkingSites); context.SaveChanges(); var siteLines = System.IO.File.ReadAllLines(@"e:\Key1.CSV"); var siteAreaKeys = new List <SiteArea>(); foreach (var line in siteLines) { int areaId; var column = line.Split(','); var parkingArea = new ParkingArea { AreaName = column[1] }; context.Add(parkingArea); context.SaveChanges(); var area = context.ParkingAreas.Where(pa => pa.AreaName == parkingArea.AreaName).FirstOrDefault(); if (area != null) { areaId = area.Id; } else { areaId = 0; }; var sites = column[3].Split(' '); foreach (var site in sites) { int i = Int32.Parse(site); string[] siteLine = valueLines[i - 1].Split(','); string sitesId = siteLine[1]; var aSite = context.ParkingSite.Where(s => s.Parm1 == sitesId).FirstOrDefault(); if (aSite != null && areaId != 0) { var siteArea = new SiteArea(); siteArea.AreaId = areaId; siteArea.SiteId = aSite.Id; context.Add(siteArea); context.SaveChanges(); } int z = 0; } } // context.AddRange(parkingAreas); // context.SaveChanges(); int y = 0; }
/// <summary> /// get the variables from external scripts on awake /// </summary> void Awake() { carSetting = FindObjectOfType <CarSetting>(); areaSettings = area.GetComponent <ParkingArea>(); }
private void ExecuteUndo(object obj) { PA = new ParkingArea(); SetAction(ButtonAction.Init); }
public ParkingServiceTests() { var parkingArea = new ParkingArea(2, 2); _parkingService = new ParkingService(parkingArea); }