Esempio n. 1
0
        private void SelectPhoneBookComboBox_SelectionChangeCommitted(object sender, EventArgs e)
        {
            Imeniki imenik = new Imeniki();

            PhoneBook        = SelectPhoneBookComboBox.GetItemText(SelectPhoneBookComboBox.SelectedItem);
            PhoneBook_id     = Convert.ToInt32(SelectPhoneBookComboBox.GetItemText(SelectPhoneBookComboBox.SelectedValue));
            imenik.PhoneBook = PhoneBook;
            Display();
        }
Esempio n. 2
0
        private void VpisVBazo()
        {
            try
            {
                if (action == 4)
                {
                    if (AddPhoneBookTextBox.Text != "" || AddPhoneBookTextBox.Text != null)
                    {
                        PhoneBook = AddPhoneBookTextBox.Text;
                    }
                    else
                    {
                        PhoneBook = "";
                    }
                }
                else
                {
                    if (NameTextBox.Text != "" || NameTextBox.Text != null)
                    {
                        FirstName = NameTextBox.Text;
                    }
                    else
                    {
                        FirstName = "";
                    }
                    if (SurnameTextBox.Text != "" || SurnameTextBox.Text != null)
                    {
                        LastName = SurnameTextBox.Text;
                    }
                    else
                    {
                        LastName = "";
                    }
                    if (HomeAddressTextBox.Text != "" || HomeAddressTextBox.Text != null)
                    {
                        HomeAdress = HomeAddressTextBox.Text;
                    }
                    else
                    {
                        HomeAdress = "";
                    }
                    if (PostTextBox.Text != "" || PostTextBox.Text != null)
                    {
                        Post = Convert.ToInt32(PostTextBox.Text);
                    }
                    else
                    {
                        Post = 0000;
                    }
                    if (CityTextBox.Text != "" || CityTextBox.Text != null)
                    {
                        City = CityTextBox.Text;
                    }
                    else
                    {
                        City = "";
                    }
                    if (PhoneNumberTextBox.Text != "" || PhoneNumberTextBox.Text != null)
                    {
                        PhoneNumber = PhoneNumberTextBox.Text;
                    }
                    else
                    {
                        PhoneNumber = "000000000";
                    }
                    if (eMailTextBox.Text != "" || eMailTextBox.Text != null)
                    {
                        eMailAddress = eMailTextBox.Text;
                    }
                    else
                    {
                        eMailAddress = "";
                    }
                }
            }
            catch (Exception ex) // If... if somethings goes wrong
            {
                MessageBox.Show(Convert.ToString(ex));
            }

            Oseba   newOseba  = new Oseba(UserID);
            Oseba   newOseba1 = new Oseba(UserID, FirstName, LastName, HomeAdress, Post, City, PhoneNumber, eMailAddress, PhoneBook_id);
            Oseba   newOseba2 = new Oseba(FirstName, LastName, HomeAdress, Post, City, PhoneNumber, eMailAddress, PhoneBook_id);
            Imeniki newImenik = new Imeniki(PhoneBook_id, PhoneBook);

            switch (action)
            {
            case 1:     //Zatakne se tlele
                //MessageBox.Show("ShowUp");
                Database DodajOsebo = new Database();
                if (DodajOsebo.AddOseba(newOseba2) == true)
                {
                    Display();
                    //MessageBox.Show("Entery Successful!");
                }
                // stavek za klic insert funkcije baze
                break;

            case 2:
                Database UrediOsebo = new Database();
                if (UrediOsebo.UpdateOseba(newOseba1) == true)
                {
                    Display();
                    //MessageBox.Show("Edit Successful!");
                }
                // stavek za klic update funkcije baze
                break;

            case 3:
                Database izbrisOsebe = new Database();
                if (izbrisOsebe.DeleteOseba(newOseba) == true)
                {
                    Display();
                    //MessageBox.Show("Removal Successful!");
                }
                break;

            case 4:
                Database DodajImenik = new Database();
                if (DodajImenik.AddImenik(newImenik) == true)
                {
                    Dropdown();
                    //MessageBox.Show("Entery Successful!");
                }
                break;
            }
            refresh();
        }