private void GetClientID(string clientEmail) { Classes.DatabaseManager dbManager = new Classes.DatabaseManager(); var tryGetClientID = dbManager.ReturnQuery("SELECT Client_ID FROM Clients WHERE Client_Email = '" + clientEmail + "';"); foreach (var i in tryGetClientID) { clientID = Convert.ToInt32(i[0]); } }
private void LoadAreas() { ClearAreas(); Classes.DatabaseManager dbManager = new Classes.DatabaseManager(); var areas = dbManager.ReturnQuery("SELECT Area_Name FROM Area WHERE Area_City_ID = " + GetCityID(CB_City.SelectedItem.ToString(), CB_Province.SelectedItem.ToString()) + " ORDER BY Area_Name;"); foreach (var i in areas) { InsertArea(i[0]); } }
private void NewPreferences() { new System.Threading.Thread(() => { edited = false; SetLoadingState(true); SetPreferences(); Classes.PreferenceManager preferenceManager = new Classes.PreferenceManager(); Classes.DatabaseManager dbManager = new Classes.DatabaseManager(); if (preferenceManager.CanAddPreference(clientID, minBedrooms, maxBedrooms, minBathrooms, maxBathrooms, minGarages, maxGarages, minPlotSize, maxPlotSize, minHouseSize, maxHouseSize, minPrice, maxPrice, hasPool)) { if (preferenceManager.AddPreference(clientID, minBedrooms, maxBedrooms, minBathrooms, maxBathrooms, minGarages, maxGarages, minPlotSize, maxPlotSize, minHouseSize, maxHouseSize, minPrice, maxPrice, hasPool)) { var preferences = (dbManager.ReturnQuery("SELECT Preference_ID FROM Preference WHERE Preference_Client_ID = " + clientID.ToString() + " ORDER BY Preference_ID ASC;")); foreach (var i in preferences) { preferenceID = Convert.ToInt32(i[0]); } flag = true; for (i = 0; i < CB_PreferedAreas.Items.Count; i++) { if (!preferenceManager.AddPreferenceArea(preferenceID, CB_PreferedAreas.Items[i].ToString())) { flag = false; DisplayNotifyBox("Could not edit", "An error occured while trying to add area " + CB_PreferedAreas.Items[i].ToString(), 4); } } if (flag) { DisplayNotifyBox("Preference Added", "Preference has been added", 3); edited = true; } } else { DisplayNotifyBox("Could not edit", "An error occured while trying to add a new preference. Please try again later", 3); } } else { DisplayNotifyBox("Could not edit", "The preferences as outlined already exists for this client", 4); } SetLoadingState(false); if (edited) { CloseForm(); } }).Start(); }
private void LoadCities() { ClearCities(); ClearAreas(); Classes.DatabaseManager dbManager = new Classes.DatabaseManager(); var cities = dbManager.ReturnQuery("SELECT City_Name FROM City WHERE City_Province_ID = " + GetProvinceID(CB_Province.SelectedItem.ToString()) + " ORDER BY City_Name;"); foreach (var i in cities) { InsertCity(i[0]); } }
private void LoadCurrentPreferences(int inPrefferenceID) { preferenceID = inPrefferenceID; CB_PreferedAreas.Items.Clear(); flag = false; this.Dispatcher.Invoke(() => { SetLoadingState(true); ClearPreferences(); Classes.DatabaseManager dbManager = new Classes.DatabaseManager(); Classes.LocationManager locManager = new Classes.LocationManager(); var preferences = (dbManager.ReturnQuery("SELECT Preference_Min_Bedrooms, Preference_Max_Bedrooms, Preference_Min_Bathrooms, Preference_Max_Bathrooms, Preference_Min_Garages, Preference_Max_Garages, Preference_hasPool, Preference_Min_Plot_Size, Preference_Max_Plot_Size, Preference_Min_House_Size, Preference_Max_House_Size, Preference_Min_Price, Preference_Max_Price FROM Preference WHERE Preference_Client_ID = " + clientID.ToString() + " AND Preference_ID = " + preferenceID.ToString() + ";")); foreach (var i in preferences) { InsertPreferences(Convert.ToInt32(i[0]), Convert.ToInt32(i[1]), Convert.ToInt32(i[2]), Convert.ToInt32(i[3]), Convert.ToInt32(i[4]), Convert.ToInt32(i[5]), Convert.ToInt32(i[6]), Convert.ToInt32(i[7]), Convert.ToInt32(i[8]), Convert.ToInt32(i[9]), Convert.ToInt32(i[10]), Convert.ToInt32(i[11]), Convert.ToInt32(i[12])); } var preferedAreas = (dbManager.ReturnQuery("SELECT Area_ID FROM Preference_Area WHERE Preference_ID = " + preferenceID + " ORDER BY Area_ID;")); foreach (var j in preferedAreas) { flag = true; CB_PreferedAreas.Items.Add(locManager.AreaFullName(Convert.ToInt32(j[0]))); } if (flag) { CB_PreferedAreas.SelectedIndex = 0; BT_RemoveArea.IsEnabled = true; } else { BT_RemoveArea.IsEnabled = false; } SetLoadingState(false); }); }
private void RefreshProvinces() { new System.Threading.Thread(() => { ClearProvincesGrid(); Classes.DatabaseManager dbManager = new Classes.DatabaseManager(); var provinceNames = dbManager.ReturnQuery("SELECT Province_Name FROM Province ORDER BY Province_Name;"); foreach (var province in provinceNames) { InsertIntoProvincesGrid(province[0]); } }).Start(); }
private void LoadCities(int currentProvince) { new System.Threading.Thread(() => { Classes.DatabaseManager dbManger = new Classes.DatabaseManager(); ClearCities(); var cities = dbManger.ReturnQuery("SELECT City_Name FROM City WHERE City_Province_ID =" + currentProvince + " ORDER BY City_Name;"); foreach (var city in cities) { InsertCity(city[0]); } }).Start(); }
private void RefreshAgents() { new System.Threading.Thread(() => { ClearAgentsGrid(); Classes.DatabaseManager dbManager = new Classes.DatabaseManager(); var agentNames = dbManager.ReturnQuery("SELECT Agent_Name, Agent_Surname, Agent_Phone, Agent_Email FROM Agent ORDER BY Agent_Surname, Agent_Name;"); foreach (var agent in agentNames) { InsertIntoAgentsGrid(agent[0], agent[1], agent[2], agent[3]); } }).Start(); }
private void RefreshClients() { new System.Threading.Thread(() => { ClearClientsGrid(); Classes.DatabaseManager dbManager = new Classes.DatabaseManager(); var clientNames = dbManager.ReturnQuery("SELECT Client_Name, Client_Surname, Client_Phone, Client_Email FROM Clients ORDER BY Client_Surname, Client_Name;"); foreach (var client in clientNames) { InsertIntoClientsGrid(client[0], client[1], client[2], client[3]); } }).Start(); }
private void LoadCities() { new System.Threading.Thread(() => { Classes.DatabaseManager dbManger = new Classes.DatabaseManager(); ClearCities(); var cities = dbManger.ReturnQuery("SELECT City_Name, Province_Name FROM City,Province WHERE Province_ID = City_Province_ID ORDER BY Province_Name,City_Name;"); foreach (var city in cities) { InsertCity(city[0], city[1]); } }).Start(); }
private void RefreshCities() { new System.Threading.Thread(() => { ClearCities(); Classes.DatabaseManager dbManager = new Classes.DatabaseManager(); var cities = dbManager.ReturnQuery("SELECT City_Name, Province_Name FROM City,Province WHERE Province_ID = City_Province_ID"); foreach (var city in cities) { InserCityIntoDataGrid(city[0], city[1]); } }).Start(); }
private void LoadProvinces() { ClearProvinces(); ClearCities(); ClearAreas(); Classes.DatabaseManager dbManager = new Classes.DatabaseManager(); var provinces = dbManager.ReturnQuery("SELECT Province_Name FROM Province ORDER BY Province_Name;"); foreach (var i in provinces) { InsertProvince(i[0]); } }
private void LoadProvinces() { new System.Threading.Thread(() => { Classes.DatabaseManager dbManger = new Classes.DatabaseManager(); ClearCities(); var provs = dbManger.ReturnQuery("SELECT Province_Name, Province_ID FROM Province ORDER BY Province_Name;"); foreach (var prov in provs) { InsertProvince(prov[0]); provinceID.Add(Convert.ToInt32(prov[1])); } }).Start(); }
private void RefreshAreas() { new System.Threading.Thread(() => { ClearAreaDataGrid(); Classes.DatabaseManager dbManger = new Classes.DatabaseManager(); var results = dbManger.ReturnQuery("SELECT Area_Name, City_Name , Province_Name FROM Area,City,Province WHERE Area_City_ID = City_ID AND City_Province_ID = Province_ID ORDER BY Province_Name,City_Name,Area_Name;"); foreach (var area in results) { InsertAreaIntoDataGrid(area[0], area[1], area[2]); } }).Start(); }
private void LoadProvinces() { new System.Threading.Thread(() => { SetLoadingState(true); Classes.DatabaseManager dbManager = new Classes.DatabaseManager(); var provinceNames = dbManager.ReturnQuery("SELECT Province_Name FROM Province ORDER BY Province_Name ASC;"); foreach (var province in provinceNames) { InsertProvince(province[0]); } SetLoadingState(false); }).Start(); }
private void LoadProvinces() { new System.Threading.Thread(() => { ClearProvinces(); Classes.DatabaseManager dbManager = new Classes.DatabaseManager(); var provinces = dbManager.ReturnQuery("SELECT Province_Name FROM Province ORDER BY Province_Name ASC;"); foreach (var i in provinces) { Console.WriteLine("Inserting " + i[0]); InsertProvince(i[0]); } }).Start(); }
private void RefreshAdmins() { new System.Threading.Thread(() => { Classes.DatabaseManager dbManager = new Classes.DatabaseManager(); SetSelectedAdmin(""); var adminNames = dbManager.ReturnQuery("SELECT Admin_Username FROM Admin;"); ClearAdminGrid(); foreach (var name in adminNames) { if (name[0] != GetCurrentAdmin()) { InsertIntoAdminGrid(name[0]); } } }).Start(); }
private void LoadPreferencesBox() { SetLoadingState(true); flag = false; CB_Preferences.Items.Clear(); numberOfPreferences = 0; Classes.DatabaseManager dbManager = new Classes.DatabaseManager(); Classes.LocationManager locManager = new Classes.LocationManager(); var preferences = (dbManager.ReturnQuery("SELECT Preference_ID FROM Preference WHERE Preference_Client_ID = " + clientID.ToString() + " ORDER BY Preference_ID;")); foreach (var i in preferences) { numberOfPreferences++; preferenceIDArray[numberOfPreferences - 1] = Convert.ToInt32(i[0]); flag = true; CB_Preferences.Items.Add(numberOfPreferences.ToString()); } if (!flag) { CB_Preferences.Items.Add("1"); CB_Preferences.SelectedIndex = 0; preferenceIDArray[0] = -1; preferenceID = preferenceIDArray[0]; CB_PreferedAreas.Items.Clear(); InsertPreferences(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); BT_DeletePreference.IsEnabled = false; BT_EditExisting.IsEnabled = false; } else { //LoadCurrentPreferences(preferenceIDArray[0]); preferenceID = preferenceIDArray[0]; CB_Preferences.SelectedIndex = 0; BT_DeletePreference.IsEnabled = true; BT_EditExisting.IsEnabled = true; } SetLoadingState(false); }
private void LoadProvinces() { ClearProvinces(); ClearCities(); ClearAreas(); Classes.DatabaseManager dbManager = new Classes.DatabaseManager(); var provinces = dbManager.ReturnQuery("SELECT Province_Name FROM Province ORDER BY Province_Name;"); foreach (var i in provinces) { InsertProvince(i[0]); } }
private void LoadPreferencesBox() { flag = false; CB_Preferences.Items.Clear(); numberOfPreferences = 0; Classes.DatabaseManager dbManager = new Classes.DatabaseManager(); Classes.LocationManager locManager = new Classes.LocationManager(); var preferences = (dbManager.ReturnQuery("SELECT Preference_ID FROM Preference WHERE Preference_Client_ID = " + clientID.ToString() + " ORDER BY Preference_ID;")); foreach (var i in preferences) { numberOfPreferences++; preferenceIDArray[numberOfPreferences - 1] = Convert.ToInt32(i[0]); flag = true; CB_Preferences.Items.Add(numberOfPreferences.ToString()); } if (!flag) { CB_Preferences.Items.Add("1"); CB_Preferences.SelectedIndex = 0; preferenceIDArray[0] = -1; preferenceID = preferenceIDArray[0]; CB_PreferedAreas.Items.Clear(); InsertPreferences(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); BT_DeletePreference.IsEnabled = false; BT_EditExisting.IsEnabled = false; } else { //LoadCurrentPreferences(preferenceIDArray[0]); preferenceID = preferenceIDArray[0]; CB_Preferences.SelectedIndex = 0; BT_DeletePreference.IsEnabled = true; BT_EditExisting.IsEnabled = true; } }
private void LoadCurrentPreferences(int inPrefferenceID) { preferenceID = inPrefferenceID; CB_PreferedAreas.Items.Clear(); flag = false; this.Dispatcher.Invoke(() => { SetLoadingState(true); ClearPreferences(); Classes.DatabaseManager dbManager = new Classes.DatabaseManager(); Classes.LocationManager locManager = new Classes.LocationManager(); var preferences = (dbManager.ReturnQuery("SELECT Preference_Min_Bedrooms, Preference_Max_Bedrooms, Preference_Min_Bathrooms, Preference_Max_Bathrooms, Preference_Min_Garages, Preference_Max_Garages, Preference_hasPool, Preference_Min_Plot_Size, Preference_Max_Plot_Size, Preference_Min_House_Size, Preference_Max_House_Size, Preference_Min_Price, Preference_Max_Price FROM Preference WHERE Preference_Client_ID = " + clientID.ToString() + " AND Preference_ID = " + preferenceID.ToString() + ";")); foreach (var i in preferences) { InsertPreferences(Convert.ToInt32(i[0]), Convert.ToInt32(i[1]), Convert.ToInt32(i[2]), Convert.ToInt32(i[3]), Convert.ToInt32(i[4]), Convert.ToInt32(i[5]), Convert.ToInt32(i[6]), Convert.ToInt32(i[7]), Convert.ToInt32(i[8]), Convert.ToInt32(i[9]), Convert.ToInt32(i[10]), Convert.ToInt32(i[11]), Convert.ToInt32(i[12])); } var preferedAreas = (dbManager.ReturnQuery("SELECT Area_ID FROM Preference_Area WHERE Preference_ID = " + preferenceID + " ORDER BY Area_ID;")); foreach (var j in preferedAreas) { flag = true; CB_PreferedAreas.Items.Add(locManager.AreaFullName(Convert.ToInt32(j[0]))); } if(flag) { CB_PreferedAreas.SelectedIndex = 0; BT_RemoveArea.IsEnabled = true; } else { BT_RemoveArea.IsEnabled = false; } SetLoadingState(false); }); }
private void LoadCities() { ClearCities(); ClearAreas(); Classes.DatabaseManager dbManager = new Classes.DatabaseManager(); var cities = dbManager.ReturnQuery("SELECT City_Name FROM City WHERE City_Province_ID = " + GetProvinceID(CB_Province.SelectedItem.ToString()) + " ORDER BY City_Name;"); foreach (var i in cities) { InsertCity(i[0]); } }
private void LoadAreas() { ClearAreas(); Classes.DatabaseManager dbManager = new Classes.DatabaseManager(); var areas = dbManager.ReturnQuery("SELECT Area_Name FROM Area WHERE Area_City_ID = " + GetCityID(CB_City.SelectedItem.ToString(), CB_Province.SelectedItem.ToString()) + " ORDER BY Area_Name;"); foreach (var i in areas) { InsertArea(i[0]); } }
private void LoadProvinces() { new System.Threading.Thread(() => { ClearProvinces(); Classes.DatabaseManager dbManager = new Classes.DatabaseManager(); var provinces = dbManager.ReturnQuery("SELECT Province_Name FROM Province ORDER BY Province_Name ASC;"); foreach( var i in provinces ) { Console.WriteLine("Inserting " + i[0]); InsertProvince(i[0]); } }).Start(); }
private void RefreshClients() { new System.Threading.Thread(() => { ClearClientsGrid(); Classes.DatabaseManager dbManager = new Classes.DatabaseManager(); var clientNames = dbManager.ReturnQuery("SELECT Client_Name, Client_Surname, Client_Phone, Client_Email FROM Clients ORDER BY Client_Surname, Client_Name;"); foreach (var client in clientNames) { InsertIntoClientsGrid(client[0], client[1], client[2], client[3]); } }).Start(); }
private void RefreshProvinces() { new System.Threading.Thread(() => { ClearProvincesGrid(); Classes.DatabaseManager dbManager = new Classes.DatabaseManager(); var provinceNames = dbManager.ReturnQuery("SELECT Province_Name FROM Province ORDER BY Province_Name;"); foreach( var province in provinceNames) { InsertIntoProvincesGrid(province[0]); } }).Start(); }
private void NewPreferences() { new System.Threading.Thread(() => { edited = false; SetLoadingState(true); SetPreferences(); Classes.PreferenceManager preferenceManager = new Classes.PreferenceManager(); Classes.DatabaseManager dbManager = new Classes.DatabaseManager(); if (preferenceManager.CanAddPreference(clientID, minBedrooms, maxBedrooms, minBathrooms, maxBathrooms, minGarages, maxGarages, minPlotSize, maxPlotSize, minHouseSize, maxHouseSize, minPrice, maxPrice, hasPool)) { if (preferenceManager.AddPreference(clientID, minBedrooms, maxBedrooms, minBathrooms, maxBathrooms, minGarages, maxGarages, minPlotSize, maxPlotSize, minHouseSize, maxHouseSize, minPrice, maxPrice, hasPool)) { var preferences = (dbManager.ReturnQuery("SELECT Preference_ID FROM Preference WHERE Preference_Client_ID = " + clientID.ToString() + " ORDER BY Preference_ID ASC;")); foreach (var i in preferences) { preferenceID = Convert.ToInt32(i[0]); } flag = true; for (i = 0; i < CB_PreferedAreas.Items.Count; i++) { if (!preferenceManager.AddPreferenceArea(preferenceID, CB_PreferedAreas.Items[i].ToString())) { flag = false; DisplayNotifyBox("Could not edit", "An error occured while trying to add area " + CB_PreferedAreas.Items[i].ToString(), 4); } } if (flag) { DisplayNotifyBox("Preference Added", "Preference has been added", 3); edited = true; } } else { DisplayNotifyBox("Could not edit", "An error occured while trying to add a new preference. Please try again later", 3); } } else { DisplayNotifyBox("Could not edit", "The preferences as outlined already exists for this client", 4); } SetLoadingState(false); if (edited) CloseForm(); }).Start(); }
private void RefreshAreas() { new System.Threading.Thread(() => { ClearAreaDataGrid(); Classes.DatabaseManager dbManger = new Classes.DatabaseManager(); var results = dbManger.ReturnQuery("SELECT Area_Name, City_Name , Province_Name FROM Area,City,Province WHERE Area_City_ID = City_ID AND City_Province_ID = Province_ID ORDER BY Province_Name,City_Name,Area_Name;"); foreach (var area in results) { InsertAreaIntoDataGrid(area[0], area[1], area[2]); } }).Start(); }
private void LoadCities() { CB_NewCity.Items.Clear(); new System.Threading.Thread(() => { Classes.DatabaseManager dbManager = new Classes.DatabaseManager(); var cities = dbManager.ReturnQuery("SELECT City_Name,Province_Name FROM City,Province WHERE City_Province_ID = Province_ID ORDER BY Province_Name, City_Name;"); foreach( var city in cities) { InsertCity(city[0], city[1]); } }).Start(); CB_NewCity.SelectedIndex = 0; }
private void RefreshCities() { new System.Threading.Thread(() => { ClearCities(); Classes.DatabaseManager dbManager = new Classes.DatabaseManager(); var cities = dbManager.ReturnQuery("SELECT City_Name, Province_Name FROM City,Province WHERE Province_ID = City_Province_ID ORDER BY City_Name"); foreach( var city in cities) { InserCityIntoDataGrid(city[0], city[1]); } }).Start(); }
private void RefreshAdmins() { new System.Threading.Thread(() => { Classes.DatabaseManager dbManager = new Classes.DatabaseManager(); SetSelectedAdmin(""); var adminNames = dbManager.ReturnQuery("SELECT Admin_Username FROM Admin;"); ClearAdminGrid(); foreach( var name in adminNames ) { if( name[0] != GetCurrentAdmin() ) InsertIntoAdminGrid(name[0]); } }).Start(); }
private void GetClientID(string clientEmail) { Classes.DatabaseManager dbManager = new Classes.DatabaseManager(); var tryGetClientID = dbManager.ReturnQuery("SELECT Client_ID FROM Clients WHERE Client_Email = '" + clientEmail + "';"); foreach (var i in tryGetClientID) { clientID = Convert.ToInt32(i[0]); } }