Пример #1
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 NewPreferences()
        {
            if (SetPreferences())
            {
                new System.Threading.Thread(() =>
                {
                    SetLoadingState(true);
                    edited = false;


                    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))
                        {
                            preferenceID = preferenceManager.GetPreferenceID(clientID);
                            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 NewPreferences()
        {
            if (SetPreferences())
            {
                new System.Threading.Thread(() =>
                {
                    SetLoadingState(true);
                    edited = false;

                    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))
                        {
                            preferenceID = preferenceManager.GetPreferenceID(clientID);
                            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 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(); 
        }