Beispiel #1
0
        private void btnAddGroup_Click(object sender, EventArgs e)
        {
            if (txtGroupID.Text == "")
            {
                MessageBox.Show("ID can't blank", "Add contact", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            if (txtGroupName.Text == "")
            {
                MessageBox.Show("Please import group name", "Add contact", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                GROUP  gr   = new GROUP();
                string name = txtGroupName.Text;
                string id   = txtGroupID.Text;

                if (!gr.groupExist(name, "add", id))
                {
                    try
                    {
                        if (gr.insertGroup(id, name))
                        {
                            MessageBox.Show("New Group added", "Add Group", MessageBoxButtons.OK, MessageBoxIcon.Information);

                            LoadGroup();
                            loadNewGroup();
                        }
                    }
                    catch
                    {
                        MessageBox.Show("Error", "Add Group", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                else
                {
                    MessageBox.Show("Group name already exist", "Add Group", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
        private void buttonAddGroup_Click(object sender, EventArgs e)
        {
            if (textBoxGId.Text.Trim() == "" || textBoxGName.Text.Trim() == "")
            {
                MessageBox.Show("Empty Fields", "Add Group", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            GROUP  group  = new GROUP();
            int    id     = Convert.ToInt32(textBoxGId.Text);
            string fname  = textBoxGName.Text;
            int    userid = Globals.GlobalUserId;

            if (group.checkID(Convert.ToInt32(textBoxGId.Text)))
            {
                if (group.groupExist(fname, "add", userid))
                {
                    if (group.insertGroup(id, fname, userid))
                    {
                        MessageBox.Show("New Group Added", "Add Group", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        fillCombo();
                    }
                    else
                    {
                        MessageBox.Show("Error", "Add Group", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                else
                {
                    MessageBox.Show("This Group Already Exists, Try Another One", "Add Group", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
                MessageBox.Show("This ID Already Exists, Try Another One", "Add Group", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }