Ejemplo n.º 1
0
        private void button_save_Click(object sender, EventArgs e)
        {
            if (!CheckForm())
            {
                MessageBox.Show("Fill all the mandatory fields!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            else
            {
                City city = FormToCity();
                if (city.ID == 0)
                {
                    CityArr oldCityArr = new CityArr();
                    oldCityArr.Fill();
                    if (!oldCityArr.IsContain(city.CityName))
                    {
                        if (city.Insert())
                        {
                            MessageBox.Show("Thank you for you registration!");
                            CityArr cityArr = new CityArr();
                            cityArr.Fill();
                            city = cityArr.GetCityWithMaxId();
                            CityArrToForm(city);
                        }

                        else
                        {
                            MessageBox.Show("Couldn't add the city", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }

                    else
                    {
                        MessageBox.Show("City already existing");
                    }
                }

                else
                {
                    if (city.Update())
                    {
                        MessageBox.Show("Update succesfully", "Update", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        CityArrToForm(city);
                    }

                    else
                    {
                        MessageBox.Show("Couldn't update the city", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
        }
Ejemplo n.º 2
0
 private void button_save_Click(object sender, EventArgs e)
 {
     if (!CheckGood())
     {
         MessageBox.Show("You didn't write right", "TRY AGAIN", MessageBoxButtons.RetryCancel, MessageBoxIcon.Error);
         All_White();
     }
     else
     {
         City city = FormToCity();
         if (city.ID == 0)
         {
             CityArr oldCityArr = new CityArr();
             oldCityArr.Fill();
             if (!oldCityArr.IsContain(city.CityName))
             {
                 if (city.Insert())
                 {
                     MessageBox.Show("City Details Saved");
                     Clean_Form();
                     CityArr cityArr = new CityArr();
                     cityArr.Fill();
                     city = cityArr.GetCityWithMaxId();
                     CityArrToForm(city);
                 }
                 else
                 {
                     MessageBox.Show("Cannot Save City Details");
                 }
             }
             else
             {
                 MessageBox.Show("City already existing");
             }
         }
         else
         {
             if (city.Update())
             {
                 MessageBox.Show("City Details UPDATED");
                 Clean_Form();
                 CityArrToForm(null);
             }
             else
             {
                 MessageBox.Show("Cannot UPDATE City Details");
             }
         }
     }
 }
Ejemplo n.º 3
0
        private void btn_Save_Click(object sender, EventArgs e)
        {
            if (CheckForm())
            {
                City city = new City();
                city = FormToCity();

                CityArr oldCityArr = new CityArr();
                oldCityArr.Fill();

                if (!oldCityArr.IsContain(city.Name))
                {
                    if (city.Id == 0)
                    {
                        if (city.Insert())
                        {
                            MessageBox.Show("Data saved successfully", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            ClearForm();

                            CityArr cityArr = new CityArr();
                            cityArr.Fill();
                            city = cityArr.GetCityWithMaxId();

                            CityArrToForm(city);
                        }
                    }
                    else
                    {
                        if (city.Update())
                        {
                            MessageBox.Show("Data updated successfully", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            ClearForm();

                            CityArr cityArr = new CityArr();
                            cityArr.Fill();
                            city = cityArr.GetCityWithMaxId();
                            CityArrToForm(city);
                        }
                    }
                }
                else
                {
                    MessageBox.Show("City already exsits", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    ClearForm();
                }
            }
        }