private void CMDCancel_Click(object sender, EventArgs e)
        {
            option_contact lForm1 = (option_contact)this.Owner;//把Form2的父窗口指針賦給lForm1

            lForm1.ReContact = null;
            Close();
        }
Example #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            option_contact lForm1 = (option_contact)this.Owner;//把Form2的父窗口指針賦給lForm1

            lForm1.ReGroup = null;

            this.Close();
        }
Example #3
0
        private void CMDApply_Click(object sender, EventArgs e)
        {
            option_contact lForm1 = (option_contact)this.Owner;//把Form2的父窗口指針賦給lForm1

            lForm1.ReGroup = groupTextbox.Text;

            if (CMD == "edit")
            {
                for (int i = 0; i < memoryData.GroupContact2.Count; i++)
                {
                    ContactGroup2 edit = (ContactGroup2)memoryData.GroupContact2[i];
                    if (edit.groupname == groupName)
                    {
                        edit.groupname = groupTextbox.Text;
                        edit.groupmember.Clear();

                        for (int cc = 0; cc < memoryData.contact.Count; cc++)
                        {
                            Contactstruct add = (Contactstruct)memoryData.contact[cc];
                            edit.groupmember.Add(add);
                        }

                        memoryData.GroupContact2[i] = edit;

                        break;
                    }
                }
            }
            else if (CMD == "add")
            {
                ContactGroup2 addGroup = new ContactGroup2();
                addGroup.groupname   = groupTextbox.Text;
                addGroup.groupmember = new ArrayList();

                for (int cc = 0; cc < memoryData.contact.Count; cc++)
                {
                    Contactstruct add = (Contactstruct)memoryData.contact[cc];
                    addGroup.groupmember.Add(add);
                }

                memoryData.GroupContact2.Add(addGroup);
            }


            lForm1.ReGroup = groupTextbox.Text;

            this.Close();
        }
        private void CMDApply_Click(object sender, EventArgs e)
        {
            if (contactMail.Text != "" && contactName.Text != "")
            {
                Boolean adname = true;
                for (int i = 0; i < memoryData.contact.Count; i++)
                {
                    Contactstruct tar = (Contactstruct)memoryData.contact[i];
                    if (tar.name == contactName.Text)
                    {
                        adname = false;
                        break;
                    }
                }

                option_contact lForm1 = (option_contact)this.Owner;//把Form2的父窗口指針賦給lForm1
                lForm1.ReContact = contactName.Text;
                if (CMD == "add")
                {
                    if (adname == true)
                    {
                        Contactstruct add = new Contactstruct();
                        add.name        = contactName.Text;
                        add.mail        = contactMail.Text;
                        add.phone       = contactPhone.Text;
                        add.description = contactDescription.Text;
                        memoryData.contact.Add(add);

                        ContactGroup2 tar = (ContactGroup2)memoryData.GroupContact2[0];

                        tar.groupmember.Add(add);

                        memoryData.GroupContact2[0] = tar;
                    }
                    else
                    {
                        lForm1.ReContact = null;
                        adname           = true;
                        MessageBox.Show("contact name already in use.");
                    }
                }
                else if (CMD == "edit")
                {
                    for (int i = 0; i < memoryData.contact.Count; i++)
                    {
                        Contactstruct edit = (Contactstruct)memoryData.contact[i];
                        if (edit.name == contact)
                        {
                            string oldname = edit.name;
                            edit.name             = contactName.Text;
                            edit.mail             = contactMail.Text;
                            edit.phone            = contactPhone.Text;
                            edit.description      = contactDescription.Text;
                            memoryData.contact[i] = edit;

                            if (memoryData.GroupContact2.Count != 0)
                            {
                                for (int a = 0; a < memoryData.GroupContact2.Count; a++)
                                {
                                    ContactGroup2 editTarget = (ContactGroup2)memoryData.GroupContact2[a];
                                    for (int b = 0; b < editTarget.groupmember.Count; b++)
                                    {
                                        Contactstruct editContact = (Contactstruct)editTarget.groupmember[b];
                                        if (editContact.name == oldname)
                                        {
                                            editContact.name          = contactName.Text;
                                            editContact.mail          = contactMail.Text;
                                            editContact.phone         = contactPhone.Text;
                                            editContact.description   = contactDescription.Text;
                                            editTarget.groupmember[b] = editContact;
                                        }
                                    }
                                    memoryData.GroupContact2[a] = editTarget;
                                }
                            }
                        }
                    }
                }


                this.Close();
            }
            else
            {
                MessageBox.Show("★ can't empty!");
            }
        }