示例#1
0
        private void listBox_City_DoubleClick(object sender, EventArgs e)
        {
            CityArr cityarr = new CityArr();

            cityarr.Fill();

            if (!cityarr.IsContains(textBox_Name.Text) && CheckForm())
            {
                //There is a valid city to insert that will be erased.
                DialogResult dr = MessageBox.Show("המידע שהכנסת יכול להתווסף כעיר\nהאם אתה רוצה לשמור אותה?", "אזהרה!", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1, MessageBoxOptions.RtlReading);
                if (dr == DialogResult.No)
                {
                    CityToForm(listBox_City.SelectedItem as City);
                    CheckForm();
                }
                else if (dr == DialogResult.Yes)
                {
                    Button_Save_Click(button_Save, EventArgs.Empty);
                    CityToForm(listBox_City.SelectedItem as City);
                    CheckForm();
                }
            }
            else
            {
                CityToForm(listBox_City.SelectedItem as City);
                CheckForm();
            }
        }
示例#2
0
        private void label_Id_TextChanged(object sender, EventArgs e)
        {
            int id = int.Parse(label_Id.Text);

            if (id != 0)
            {
                groupBox_City.Text = "ערוך עיר קיימת";

                CityArr cityarr = new CityArr();
                cityarr.Fill();
                cityarr = cityarr.Filter("", id);
                if (cityarr.Count > 0)
                {
                    SelectedCity = cityarr[0] as City;
                }
                else
                {
                    SelectedCity = City.Empty;
                }
            }
            else
            {
                groupBox_City.Text = "הוסף עיר חדשה";
                SelectedCity       = City.Empty;
            }
        }
        public void CityArrToForm(City curCity, ComboBox comobox)
        {
            //ממירה את הטנ "מ אוסף ישובים לטופס

            CityArr cityArr = new CityArr();

            //הוספת ישוב ברירת מחדל - בחר ישוב
            //יצירת מופע חדש של ישוב עם מזהה מינוס 1 ושם מתאים

            City cityDefault = new City();

            cityDefault.ID   = -1;
            cityDefault.Name = "בחר עיר";

            //הוספת הישוב לאוסף הישובים - אותו נציב במקור הנתונים של תיבת הבחירה
            cityArr.Add(cityDefault);

            cityArr.Fill();

            comobox.DataSource    = cityArr;
            comobox.ValueMember   = "Id";
            comobox.DisplayMember = "Name";

            if (curCity != null)
            {
                comobox.SelectedValue = curCity.ID;
            }
        }
示例#4
0
        private void textBox_Filter_TextChanged(object sender, EventArgs e)
        {
            CityArr cityArr = new CityArr();

            cityArr.Fill();

            cityArr = cityArr.Filter(textBox_Filter.Text);
            cityArr.Remove("+");

            listBox_City.DataSource = cityArr;
        }
        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);
                    }
                }
            }
        }
示例#6
0
        private void comboBox_City_Leave(object sender, EventArgs e)
        {
            CityArr cityArr = comboBox_City.DataSource as CityArr;

            if (!cityArr.IsContains(comboBox_City.Text))
            {
                comboBox_City.BackColor = Color.Red;
            }
            else
            {
                comboBox_City.BackColor = Color.White;
            }
        }
示例#7
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");
             }
         }
     }
 }
        private void CityArrToForm()
        {
            CityArr cityArr = new CityArr();

            cityArr.Fill();
            cityArr.Insert(0, City.Empty);

            comboBox_City.DataSource         = cityArr;
            comboBox_City.ValueMember        = "Id";
            comboBox_City.DisplayMember      = "Name";
            comboBox_City.AutoCompleteMode   = AutoCompleteMode.SuggestAppend;
            comboBox_City.AutoCompleteSource = AutoCompleteSource.ListItems;
            comboBox_City.SelectedValue      = 0;
        }
示例#9
0
        private void CityArrToForm(City curCity)
        {
            CityArr cityArr = new CityArr();

            cityArr.Fill();

            listbox_City.DataSource    = cityArr;
            listbox_City.ValueMember   = "Id";
            listbox_City.DisplayMember = "Name";

            if (curCity != null)
            {
                listbox_City.SelectedValue = curCity.Id;
            }
        }
示例#10
0
        public void CityArrToForm(City curCity)
        {
            CityArr cityArr = new CityArr();

            cityArr.Fill();

            cmb_City.DataSource    = cityArr;
            cmb_City.ValueMember   = "Id";
            cmb_City.DisplayMember = "Name";

            if (curCity != null)
            {
                cmb_City.SelectedValue = curCity.Id;
            }
        }
示例#11
0
        private void SaveButtonClick(object sender, EventArgs e)
        {
            //Client client = new Client();

            if (!CheckForm())
            {
                MessageBox.Show("נא מלא את הפרטים החסרים", "השלמת פרטים", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                City city = FormToCity();
                if (city.ID == 0)
                {
                    //ללקוח יש מזהה אפס – זהו לקוח חדש )טרם נוצרה לו רשומה באקסס ולכן עדיין לא קיבל מספור אוטומטי של המזהה(.
                    //הוספת לקוח חדש

                    if (city.Insert())
                    {
                        MessageBox.Show("הוסף בהצלחה", "הוספת עיר", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                    }
                    else
                    {
                        MessageBox.Show("שגיאה בהוספה", "הוספת עיר", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                    CityArr cityArr = new CityArr();
                    cityArr.Fill();
                    city = cityArr.GetCityWithMaxId();
                }
                else
                {
                    //עדכון לקוח קיים

                    if (city.Update())
                    {
                        MessageBox.Show("עודכן בהצלחה", "עידכון עיר", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                        //כיוון שמדובר על ישוב חדש, ניעזר במזהה הגבוה ביותר = הישוב האחרון שנוסף לטבלה
                        CityArr cityArr = new CityArr();
                        cityArr.Fill();
                        city = cityArr.GetCityWithMaxId();
                    }
                    else
                    {
                        MessageBox.Show("שגיאה בהוספה", "עידכון עיר", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                CityArrToForm(city);
            }
        }
示例#12
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();
                }
            }
        }
示例#13
0
        private void CityArrToForm(City curCity)
        {
            //ממירה את הטנ"מ אוסף לקוחות לטופס
            CityArr CityArr = new CityArr();

            CityArr.Fill();
            listBox_City.DataSource    = CityArr;
            listBox_City.ValueMember   = "ID";
            listBox_City.DisplayMember = "CityName";

            //אם נשלח לפעולה ישוב ,הצבתו בתיבת הבחירה של ישובים בטופס

            if (curCity != null)
            {
                listBox_City.SelectedValue = curCity.ID;
            }
        }
示例#14
0
        private void button_Delete_Click(object sender, EventArgs e)
        {
            if (label_Id.Text == "0")
            {
                MessageBox.Show("לא נבחרה עיר למחיקה.", "שגיאה", MessageBoxButtons.OK, MessageBoxIcon.Stop, MessageBoxDefaultButton.Button1, MessageBoxOptions.RtlReading);
                return;
            }


            //remove the city
            CityArr cityArr = new CityArr();

            cityArr.Fill();
            cityArr = cityArr.Filter("", int.Parse(label_Id.Text));

            if (cityArr.Count == 0)
            {
                MessageBox.Show("קרתה תקלה במציאת העיר בבסיס הנתונים.\nאנא סגור והדלק את התוכנה.", "שגיאה", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, MessageBoxOptions.RtlReading);
                return;
            }

            City city = cityArr[0] as City;

            if (MessageBox.Show("האם אתה בטוח שאתה רוצה למחוק את העיר שבחרת?\nפעולה זאת הינה בלתי הפיכה!", "אזהרה", MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2) == DialogResult.Yes)
            {
                NomineeArr clientArr = new NomineeArr();
                clientArr.Fill();
                if (clientArr.DoesCityExist(city))
                {
                    MessageBox.Show("לא ניתן למחוק את העיר.\n העיר שנבחרה משוייכת למועמדים קיימים במערכת.", "בעיה", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1, MessageBoxOptions.RtlReading);
                }
                else
                {
                    if (city.Delete())
                    {
                        CityToForm(null);
                        CityArrToForm(null);
                        MessageBox.Show("העיר נמחקה בהצלחה", "הצלחה", MessageBoxButtons.OK, MessageBoxIcon.None, MessageBoxDefaultButton.Button1, MessageBoxOptions.RtlReading);
                    }
                    else
                    {
                        MessageBox.Show("ישנה תקלה במחיקת העיר מבסיס הנתונים.\n העיר לא נמחקה כלל.", "תקלה!", MessageBoxButtons.AbortRetryIgnore, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, MessageBoxOptions.RtlReading);
                    }
                }
            }
        }
示例#15
0
        private void CityArrToForm(City curCity)
        {
            CityArr cityArr = new CityArr();

            cityArr.Fill();

            listBox_City.DataSource    = cityArr;
            listBox_City.ValueMember   = "Id";
            listBox_City.DisplayMember = "Name";
            if (curCity != null)
            {
                listBox_City.SelectedValue = curCity;
            }
            else
            {
                listBox_City.ClearSelected();
            }
            CityToForm(curCity);
        }
示例#16
0
        public void CityArrToForm(City curCity)
        {
            //ממירה את הטנ"מ אוסף ישובים לטופס

            CityArr cityArr     = new CityArr();
            City    cityDefault = new City();

            cityDefault.ID       = -1;
            cityDefault.CityName = "Choice city";
            cityArr.Add(cityDefault);

            cityArr.Fill();
            comboBox_city.DataSource    = cityArr;
            comboBox_city.ValueMember   = "ID";
            comboBox_city.DisplayMember = "CityName";
            if (curCity != null)
            {
                comboBox_city.SelectedValue = curCity.ID;
            }
        }
示例#17
0
        private void CityArrToForm(City curCity)
        {
            CityArr cityArr = new CityArr();

            cityArr.Fill();
            cityArr.Insert(0, City.Empty);
            cityArr.Insert(1, City.AddingFormButton);

            comboBox_City.SelectedIndexChanged -= comboBox_City_SelectedIndexChanged;
            comboBox_City.DataSource            = cityArr;
            comboBox_City.ValueMember           = "Id";
            comboBox_City.DisplayMember         = "Name";
            comboBox_City.AutoCompleteMode      = AutoCompleteMode.SuggestAppend;
            comboBox_City.AutoCompleteSource    = AutoCompleteSource.ListItems;
            comboBox_City.SelectedIndexChanged += comboBox_City_SelectedIndexChanged;
            if (curCity != null)
            {
                comboBox_City.SelectedValue = curCity.Id;
            }
            else
            {
                comboBox_City.Text = "";
            }
        }
示例#18
0
        /// <summary>
        /// Check the final data on the form and if it is ok, then it sends the data to the database.
        /// </summary>
        private void Button_Save_Click(object sender, EventArgs e)
        {
            DialogResult dialogResult;

            if (!CheckForm())
            {
                //The entered information is not valid.
                dialogResult = MessageBox.Show("המידע שסיפקת אינו תקין.\nאנא תקן את השדות האדומים על מנת להמשיך", "אזהרה", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1, MessageBoxOptions.RtlReading);
            }

            else
            {
                //The information was valid

                City city = FormToCity();//Make a city object from the information on the form.

                if (city.Id == 0)
                {
                    CityArr oldCityArr = new CityArr();
                    oldCityArr.Fill();
                    if (!oldCityArr.IsContains(city.Name))
                    {
                        if (city.Insert())//Try to insert the new city to the database.
                        {
                            //The insertion of the city data was successfull.
                            CityArr cityArr = new CityArr();
                            cityArr.Fill();
                            CityArrToForm(cityArr.GetCityWithMaxId());
                            dialogResult = MessageBox.Show("העיר נוספה בהצלחה", "יאי!", MessageBoxButtons.OK, MessageBoxIcon.None, MessageBoxDefaultButton.Button1, MessageBoxOptions.RtlReading);
                        }
                        else
                        {
                            //There was a problem insreting the data to the database.
                            dialogResult = MessageBox.Show("קרתה תקלה בעת שמירת העיר בבסיס הנתונים", "תקלה", MessageBoxButtons.AbortRetryIgnore, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, MessageBoxOptions.RtlReading);
                        }
                    }
                    else
                    {
                        dialogResult = MessageBox.Show("העיר שאתה מנסה להוסיף כבר קיימת במערכת!", "הפעולה נמנעה", MessageBoxButtons.OKCancel, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1, MessageBoxOptions.RtlReading);
                    }
                }
                else
                {
                    if (textBox_Name.Text != SelectedCity.Name)
                    {
                        if (city.Update())
                        {
                            CityArr cityArr = new CityArr();
                            cityArr.Fill();
                            CityArrToForm(cityArr.GetCityWithMaxId());
                            dialogResult = MessageBox.Show("העיר עודכנה בהצלחה", "יאי!", MessageBoxButtons.OK, MessageBoxIcon.None, MessageBoxDefaultButton.Button1, MessageBoxOptions.RtlReading);
                        }
                        else
                        {
                            dialogResult = MessageBox.Show("קרתה תקלה בעת עדכון העיר בבסיס הנתונים", "תקלה", MessageBoxButtons.AbortRetryIgnore, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, MessageBoxOptions.RtlReading);
                        }
                    }
                    else
                    {
                        dialogResult = DialogResult.OK;
                    }
                }
            }

            //MessageBox results actions:
            switch (dialogResult)
            {
            case DialogResult.OK:    //Do nothing
                break;

            case DialogResult.Cancel:    //Clear all of the text and "restart".
            {
                CityToForm(null);
                break;
            }

            case DialogResult.Abort:    //Close the form
            {
                Environment.Exit(0);
                break;
            }

            case DialogResult.Retry:
            {
                Button_Save_Click(null, null);        //Try again.
                break;
            }

            case DialogResult.Ignore:    //Do nothing.
                break;

            default:
                break;
            }
        }//<<<<<<<<<<<<<<<<<<-------------------------