private void AddProvince()
        {
            new System.Threading.Thread(() =>
            {
                if (GetProvinceName() != "")
                {
                    Classes.LocationManager locationManager = new Classes.LocationManager();

                    if (locationManager.CanAddProvince(GetProvinceName()))
                    {
                        SetLoadingState(true);

                        if (locationManager.AddProvince(GetProvinceName()))
                        {
                            DisplayNotifyBox(GetProvinceName() + " Added", GetProvinceName() + " has been added successfully", 2);
                            ClearForm();
                        }
                        else
                        {
                            DisplayNotifyBox("Could not Add", GetProvinceName() + " was not added", 2);
                        }

                        SetLoadingState(false);
                    }
                    else
                    {
                        DisplayNotifyBox("Cannot add " + GetProvinceName(), "A province with the same name already exists", 2);
                    }
                }
                else
                {
                    DisplayNotifyBox("ERROR", "Province name cannot be empty", 2);
                }
            }).Start();
        }
        private void BT_Edit_Click(object sender, RoutedEventArgs e)
        {
            if( TB_NewProvinceName.Text != "")
            {
                if( TB_NewProvinceName.Text.ToString() != provinceToEdit )
                {
                    new System.Threading.Thread(() =>
                        {
                            Classes.LocationManager locationManager = new Classes.LocationManager();

                            if( locationManager.CanAddProvince(GetNewProvinceName()))
                            {
                                Classes.Validation valid = new Classes.Validation();

                                if (valid.TextIsShorterThan(GetNewProvinceName(), 32))
                                {
                                    if (locationManager.ChangeProvinceName(provinceToEdit, GetNewProvinceName()))
                                    {
                                        DisplayNotifyBox(provinceToEdit + " Edited", provinceToEdit + " was changed to " + GetNewProvinceName(), 2);
                                        isEdited = true;
                                    }
                                    else
                                    {
                                        DisplayNotifyBox("Could not edit " + provinceToEdit, provinceToEdit + " was not changed. Please try again", 3);
                                    }

                                    if (isEdited == true)
                                    {
                                        CloseForm();
                                    }
                                }
                                else
                                {
                                    DisplayNotifyBox("ERROR", "Province name must be shorter than 32 character", 5);
                                }

                            }
                            else
                            {
                                DisplayNotifyBox("Province Name Already Exists", "Cannot change " + provinceToEdit + " to " + GetNewProvinceName() + " because " + GetNewProvinceName() + " already exists",3);
                            }

                        }).Start();
                }
                else
                {
                    DisplayNotifyBox("ERROR", "New province name must be different form old province name", 2);
                }
            }
            else
            {
                DisplayNotifyBox("ERROR", "New Province Name cannot be empty", 2);
            }
        }
示例#3
0
        private void BT_Edit_Click(object sender, RoutedEventArgs e)
        {
            if (TB_NewProvinceName.Text != "")
            {
                if (TB_NewProvinceName.Text.ToString() != provinceToEdit)
                {
                    new System.Threading.Thread(() =>
                    {
                        Classes.LocationManager locationManager = new Classes.LocationManager();

                        if (locationManager.CanAddProvince(GetNewProvinceName()))
                        {
                            Classes.Validation valid = new Classes.Validation();

                            if (valid.TextIsShorterThan(GetNewProvinceName(), 32))
                            {
                                if (locationManager.ChangeProvinceName(provinceToEdit, GetNewProvinceName()))
                                {
                                    DisplayNotifyBox(provinceToEdit + " Edited", provinceToEdit + " was changed to " + GetNewProvinceName(), 2);
                                    isEdited = true;
                                }
                                else
                                {
                                    DisplayNotifyBox("Could not edit " + provinceToEdit, provinceToEdit + " was not changed. Please try again", 3);
                                }

                                if (isEdited == true)
                                {
                                    CloseForm();
                                }
                            }
                            else
                            {
                                DisplayNotifyBox("ERROR", "Province name must be shorter than 32 character", 5);
                            }
                        }
                        else
                        {
                            DisplayNotifyBox("Province Name Already Exists", "Cannot change " + provinceToEdit + " to " + GetNewProvinceName() + " because " + GetNewProvinceName() + " already exists", 3);
                        }
                    }).Start();
                }
                else
                {
                    DisplayNotifyBox("ERROR", "New province name must be different form old province name", 2);
                }
            }
            else
            {
                DisplayNotifyBox("ERROR", "New Province Name cannot be empty", 2);
            }
        }
        private void AddProvince()
        {
            new System.Threading.Thread(() =>
                {
                    if( GetProvinceName() != "" )
                    {
                        Classes.LocationManager locationManager = new Classes.LocationManager();
                        Classes.Validation valid = new Classes.Validation();
                        if (valid.TextIsShorterThan(GetProvinceName(), 32))
                        {
                            if (locationManager.CanAddProvince(GetProvinceName()))
                            {
                                SetLoadingState(true);

                                if (locationManager.AddProvince(GetProvinceName()))
                                {
                                    DisplayNotifyBox(GetProvinceName() + " Added", GetProvinceName() + " has been added successfully", 2);
                                    ClearForm();
                                }
                                else
                                {
                                    DisplayNotifyBox("Could not Add", GetProvinceName() + " was not added", 2);
                                }

                                SetLoadingState(false);

                            }
                            else
                            {
                                DisplayNotifyBox("Cannot add " + GetProvinceName(), "A province with the same name already exists", 2);
                            }
                        }
                        else
                        {
                            DisplayNotifyBox("ERROR", "Province name must be shorter than 32 character", 5);
                        }

                    }
                    else
                    {
                        DisplayNotifyBox("ERROR", "Province name cannot be empty",2);
                    }
                }).Start();
        }