コード例 #1
0
ファイル: Form1.cs プロジェクト: AdamKleisner/DVP3
        //This mehtod allows users to edit items in the list view
        private void NewDialogue_editContact(object sender, EventArgs e)
        {
            //sets new contact class equal to the contact class with the new user info
            contactClass newContact = (sender as AddingContact).newContact;

            //changes the selected items text to the new text the user wanted.
            listView1.SelectedItems[0].Text = newContact.ToString();
            //Changes what image is show with the contact based on the changes the user made
            if (newContact.Mobile)
            {
                listView1.SelectedItems[0].ImageIndex = 0;
            }
            if (newContact.Work)
            {
                listView1.SelectedItems[0].ImageIndex = 1;
            }
            if (newContact.Home)
            {
                listView1.SelectedItems[0].ImageIndex = 2;
            }

            listView1.SelectedItems[0].Tag = newContact;
        }
コード例 #2
0
ファイル: Form1.cs プロジェクト: AdamKleisner/DVP3
        //this method will run when the corresponding subscribtion is hit, will add new contact to list view.
        private void NewDialogue_addContact(object sender, EventArgs e)
        {
            //checking if the number as any letters in it
            if (newDialogue.newContact.Number.ToUpper().Contains('A') || newDialogue.newContact.Number.ToUpper().Contains('B') ||
                newDialogue.newContact.Number.ToUpper().Contains('C') || newDialogue.newContact.Number.ToUpper().Contains('D') ||
                newDialogue.newContact.Number.ToUpper().Contains('E') || newDialogue.newContact.Number.ToUpper().Contains('F') ||
                newDialogue.newContact.Number.ToUpper().Contains('G') || newDialogue.newContact.Number.ToUpper().Contains('H') ||
                newDialogue.newContact.Number.ToUpper().Contains('I') || newDialogue.newContact.Number.ToUpper().Contains('J') ||
                newDialogue.newContact.Number.ToUpper().Contains('K') || newDialogue.newContact.Number.ToUpper().Contains('L') ||
                newDialogue.newContact.Number.ToUpper().Contains('M') || newDialogue.newContact.Number.ToUpper().Contains('N') ||
                newDialogue.newContact.Number.ToUpper().Contains('O') || newDialogue.newContact.Number.ToUpper().Contains('P') ||
                newDialogue.newContact.Number.ToUpper().Contains('Q') || newDialogue.newContact.Number.ToUpper().Contains('R') ||
                newDialogue.newContact.Number.ToUpper().Contains('S') || newDialogue.newContact.Number.ToUpper().Contains('T') ||
                newDialogue.newContact.Number.ToUpper().Contains('U') || newDialogue.newContact.Number.ToUpper().Contains('V') ||
                newDialogue.newContact.Number.ToUpper().Contains('W') || newDialogue.newContact.Number.ToUpper().Contains('X') ||
                newDialogue.newContact.Number.ToUpper().Contains('Y') || newDialogue.newContact.Number.ToUpper().Contains('Z') ||
                newDialogue.newContact.Number.Length <= 9 || newDialogue.newContact.Number.Length == 11 || newDialogue.newContact.Number.Length >= 12)
            {
                //if anything is wrong then the text box will be highlighted in red
                newDialogue.phoneNumberTextBox.BackColor = Color.LightCoral;
            }
            else
            {
                //if the number checks out then the text box will turn green
                newDialogue.phoneNumberTextBox.BackColor = Color.LawnGreen;
            }
            //checking if first name uses any numbers
            if (newDialogue.newContact.FirstName.Contains('0') || newDialogue.newContact.FirstName.Contains('1') ||
                newDialogue.newContact.FirstName.Contains('2') || newDialogue.newContact.FirstName.Contains('3') ||
                newDialogue.newContact.FirstName.Contains('4') || newDialogue.newContact.FirstName.Contains('5') ||
                newDialogue.newContact.FirstName.Contains('6') || newDialogue.newContact.FirstName.Contains('7') ||
                newDialogue.newContact.FirstName.Contains('8') || newDialogue.newContact.FirstName.Contains('9'))
            {
                //if anything is wrong then the text box will be highlighted in red
                newDialogue.firstNameTextBox.BackColor = Color.LightCoral;
            }
            else
            {
                //if the information in the text box information if correct it will turn green
                newDialogue.firstNameTextBox.BackColor = Color.LawnGreen;
            }
            //checking if last name uses any numbers
            if (newDialogue.newContact.LastName.Contains('0') || newDialogue.newContact.LastName.Contains('1') ||
                newDialogue.newContact.LastName.Contains('2') || newDialogue.newContact.LastName.Contains('3') ||
                newDialogue.newContact.LastName.Contains('4') || newDialogue.newContact.LastName.Contains('5') ||
                newDialogue.newContact.LastName.Contains('6') || newDialogue.newContact.LastName.Contains('7') ||
                newDialogue.newContact.LastName.Contains('8') || newDialogue.newContact.LastName.Contains('9'))
            {
                //if anything is wrong then the text box will be highlighted in red
                newDialogue.lastNameTextBox.BackColor = Color.LightCoral;
            }
            else
            {
                //the last name text box will be turned green if the info is correct
                newDialogue.lastNameTextBox.BackColor = Color.LawnGreen;
            }
            //checking to see if email uses the @ and ends with .com/.edu/or .org
            if (!(newDialogue.newContact.Email.Contains('@')))
            {
                //if anything is wrong then the text box will be highlighted in red
                newDialogue.emailTextBox.BackColor = Color.LightCoral;
            }
            else
            {
                //if the email info is correct then the text box will turn green
                newDialogue.emailTextBox.BackColor = Color.LawnGreen;
            }
            //checks to see if the number is the approprite size (the ten is for no dashes and the 12 is for dashes)
            if (!(newDialogue.emailTextBox.BackColor == Color.LightCoral) && !(newDialogue.lastNameTextBox.BackColor == Color.LightCoral) &&
                !(newDialogue.firstNameTextBox.BackColor == Color.LightCoral) && !(newDialogue.phoneNumberTextBox.BackColor == Color.LightCoral))
            {
                //creates new listviewItem in order to add the needed information into the listview
                addContact = new ListViewItem();
                //creates new contact class and sets it equal to the on with all the contact info the user inputed in the other scree,
                contactClass newContact = (sender as AddingContact).newContact;
                //Setting what is written on the list view about the item
                addContact.Text = newContact.ToString();

                //determines which picture it will have based on which phone type radio button is checked.
                if (newContact.Mobile)
                {
                    //if mobile is checked it gives it approprite image
                    addContact.ImageIndex = 0;
                }
                if (newContact.Work)
                {
                    //if mobile is checked it gives it approprite image
                    addContact.ImageIndex = 1;
                }
                if (newContact.Home)
                {
                    //if mobile is checked it gives it approprite image
                    addContact.ImageIndex = 2;
                }
                //creates the tag which is what holds the actual item.
                addContact.Tag = newContact;
                //adds the new listview item into the list view
                listView1.Items.Add(addContact);
                //closes newdialouge if it works properly
                newDialogue.Close();
            }
        }