private void EditArea(string oldName, string newName, string oldCity, string newCity, string oldProvince, string newProvince) { new System.Threading.Thread(() => { bool edited = false; SetLoadingState(true); Classes.LocationManager locationManager = new Classes.LocationManager(); if (locationManager.CanAddArea(newName, newCity, newProvince)) { if (locationManager.EditArea(oldName, newName, oldCity, newCity, oldProvince, newProvince)) { DisplayNotifyBox("Edited", oldName + "," + oldCity + "," + oldProvince + " changed to " + newName + "," + newCity + "," + newProvince, 3); edited = true; } else { DisplayNotifyBox("Could not edit", "En error occured. Please try again later", 3); } } else { DisplayNotifyBox("Could not edit", "Cannot change " + oldName + "," + oldCity + "," + oldProvince + " to " + newName + "," + newCity + "," + newProvince + " because " + newName + "," + newCity + "," + newProvince + " already exists", 4); } SetLoadingState(false); if (edited) { CloseForm(); } }).Start(); }
private void AddArea() { new System.Threading.Thread(() => { if (GetAreaName() != "") { Classes.LocationManager locationManager = new Classes.LocationManager(); SetLoadingState(true); if (locationManager.CanAddArea(GetAreaName(), GetCityName(), GetProvinceName())) { if (locationManager.AddArea(GetAreaName(), GetCityName(), GetProvinceName())) { DisplayNotifyBox("Area Added", GetAreaName() + "," + GetCityName() + "," + GetProvinceName() + " was added", 3); ClearForm(); } else { DisplayNotifyBox("Could not add", "Area not added please try again", 3); } } else { DisplayNotifyBox("Cannot Add", GetAreaName() + " already exists in " + GetCityName() + "," + GetProvinceName(), 3); } SetLoadingState(false); } else { DisplayNotifyBox("ERROR", "Area name cannot be empty", 3); } }).Start(); }
private void AddArea() { new System.Threading.Thread(() => { if( GetAreaName() != "") { Classes.LocationManager locationManager = new Classes.LocationManager(); SetLoadingState(true); if( locationManager.CanAddArea(GetAreaName(),GetCityName(),GetProvinceName()) ) { if (locationManager.AddArea(GetAreaName(), GetCityName(), GetProvinceName())) { DisplayNotifyBox("Area Added", GetAreaName() + "," + GetCityName() + "," + GetProvinceName() + " was added", 3); ClearForm(); } else { DisplayNotifyBox("Could not add", "Area not added please try again", 3); } } else { DisplayNotifyBox("Cannot Add", GetAreaName() + " already exists in " + GetCityName() + "," + GetProvinceName(), 3); } SetLoadingState(false); } else { DisplayNotifyBox("ERROR", "Area name cannot be empty", 3); } }).Start(); }
private void EditArea(string oldName, string newName, string oldCity , string newCity, string oldProvince, string newProvince) { new System.Threading.Thread(() => { bool edited = false; SetLoadingState(true); Classes.LocationManager locationManager = new Classes.LocationManager(); Classes.Validation valid = new Classes.Validation(); if (valid.TextIsShorterThan(newName, 32)) { if (locationManager.CanAddArea(newName, newCity, newProvince)) { if (locationManager.EditArea(oldName, newName, oldCity, newCity, oldProvince, newProvince)) { DisplayNotifyBox("Edited", oldName + "," + oldCity + "," + oldProvince + " changed to " + newName + "," + newCity + "," + newProvince, 3); edited = true; } else { DisplayNotifyBox("Could not edit", "En error occured. Please try again later", 3); } } else { DisplayNotifyBox("Could not edit", "Cannot change " + oldName + "," + oldCity + "," + oldProvince + " to " + newName + "," + newCity + "," + newProvince + " because " + newName + "," + newCity + "," + newProvince + " already exists", 4); } } else { DisplayNotifyBox("ERROR", "Area name must be shorter than 32 character", 5); } SetLoadingState(false); if (edited) CloseForm(); }).Start(); }