Ejemplo n.º 1
0
        private void btnManageContact_Click_1(object sender, EventArgs e)
        {
            ContactView contactViewManage = new ContactView(loggedInUser);

            this.Hide();
            contactViewManage.ShowDialog();
            this.Close();
        }
        private void button_action_delete(object sender, EventArgs e)
        {
            if (sender is Button)
            {
                Button temp = (Button)sender;
                // FlowLayoutPanel flowLayout = (FlowLayoutPanel)temp.Parent;
                TableLayoutPanel tableLayoutPanel = (TableLayoutPanel)temp.Parent;
                //   MessageBox.Show(sender.ToString());
                TableLayoutPanel tableLayoutPanel1 = (TableLayoutPanel)tableLayoutPanel.Parent;

                ContactDisplayController contactDisplayController = (ContactDisplayController)tableLayoutPanel1.Parent;

                string name = contactDisplayController.name;
                string id   = contactDisplayController.id;

                int userId = loggedInUser.Id;

                //MessageBox.Show(name + email + mobileNo);
                if (MessageBox.Show("Do you wish to delete Contact " + name, "",
                                    MessageBoxButtons.YesNo, MessageBoxIcon.Question,
                                    MessageBoxDefaultButton.Button1) == System.Windows.Forms.DialogResult.Yes)
                {
                    ContactModel contact = new ContactModel();

                    contact.UserId    = userId;
                    contact.ContactId = Convert.ToInt32(id);

                    ContactModelManager contactModelManager = new ContactModelManager();
                    Boolean             deleteStatus        = contactModelManager.deleteContact(contact);


                    if (deleteStatus)
                    {
                        MessageBox.Show("Successfully deleted Contact");
                        ContactView contactView = new ContactView(loggedInUser);
                        this.Hide();
                        contactView.ShowDialog();
                        this.Close();
                    }
                    else
                    {
                        MessageBox.Show("Current Contact Already use in some events please Go back and delete events");
                    }
                }
            }
        }