Exemple #1
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            if (CheckAll())
            {
                Member objMember = new Member();

                objMember.joindate      = dtpJoinDate.Value;
                objMember.firstname     = txtFirstName.Text.Trim();
                objMember.lastname      = txtLastName.Text.Trim();
                objMember.address       = txtAddress.Text.Trim();
                objMember.city          = txtCity.Text.Trim();
                objMember.state         = txtState.Text.Trim();
                objMember.zipcode       = txtZipCode.Text.Trim();
                objMember.phone         = txtPhone.Text.Trim();
                objMember.member_status = rdoActive.Checked ? "A" : "I";
                objMember.login_name    = txtLoginName.Text.Trim();
                objMember.password      = txtPassword.Text.Trim();
                objMember.email         = txtEmail.Text.Trim();
                if (rdoEmail.Checked)
                {
                    objMember.contact_method = 1;
                }
                else if (rdoFacebook.Checked)
                {
                    objMember.contact_method = 2;
                }
                else if (rdoPhoneText.Checked)
                {
                    objMember.contact_method = 3;
                }
                else if (rdoTwitter.Checked)
                {
                    objMember.contact_method = 4;
                }
                else
                {
                    objMember.contact_method = 0;
                }

                objMember.subscription_id = (int)cmbSubscriptionID.SelectedValue;
                objMember.photo           = imageLocation;
                try
                {
                    bool status = Members.AddMember(objMember);
                    if (status)
                    {
                        MessageBox.Show(MsgBoxHelper.Inserted("Member"), "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        memberList = Members.GetMembers();
                        memberDataGridView.DataSource = memberList;
                        txtNumber.Text = objMember.number.ToString();
                    }
                    else
                    {
                        MessageBox.Show(MsgBoxHelper.Inserted("Member not"), "Failure", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Failure", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Exemple #2
0
        private void frmMember_Load(object sender, EventArgs e)
        {
            try
            {
                memberList = Members.GetMembers();
                memberDataGridView.DataSource = memberList;

                List <Subscription> subscriptionList = Subscriptions.GetSubscriptions();
                cmbSubscriptionID.DataSource    = subscriptionList;
                cmbSubscriptionID.DisplayMember = Subscriptions.extra;
                cmbSubscriptionID.ValueMember   = Subscriptions.key;
                cmbSubscriptionID.SelectedIndex = -1;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Failure", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            ToolTip toolTip = new ToolTip();

            toolTip.SetToolTip(btnAdd, "Add all Member fields");
            toolTip.SetToolTip(btnBrowse, "Browse by Member Number");
            toolTip.SetToolTip(btnUpdate, "Update all Member fields");
            toolTip.SetToolTip(btnDelete, "Delete Member Number");
            toolTip.SetToolTip(btnClear, "Clear all Member fields");

            toolTip.SetToolTip(txtNumber, Member.numberTip);
            toolTip.SetToolTip(lblNumber, Member.numberTip);

            toolTip.SetToolTip(dtpJoinDate, Member.joindateTip);
            toolTip.SetToolTip(lblJoinDate, Member.joindateTip);

            toolTip.SetToolTip(txtFirstName, Member.firstnameTip);
            toolTip.SetToolTip(lblFirstName, Member.firstnameTip);

            toolTip.SetToolTip(txtLastName, Member.lastnameTip);
            toolTip.SetToolTip(lblLastName, Member.lastnameTip);

            toolTip.SetToolTip(txtAddress, Member.addressTip);
            toolTip.SetToolTip(lblAddress, Member.addressTip);

            toolTip.SetToolTip(txtCity, Member.cityTip);
            toolTip.SetToolTip(lblCity, Member.cityTip);

            toolTip.SetToolTip(txtState, Member.stateTip);
            toolTip.SetToolTip(lblState, Member.stateTip);

            toolTip.SetToolTip(txtZipCode, Member.zipcodeTip);
            toolTip.SetToolTip(lblZipCode, Member.zipcodeTip);

            toolTip.SetToolTip(txtPhone, Member.phoneTip);
            toolTip.SetToolTip(lblPhone, Member.phoneTip);


            toolTip.SetToolTip(txtLoginName, Member.login_nameTip);
            toolTip.SetToolTip(lblLoginName, Member.login_nameTip);

            toolTip.SetToolTip(txtPassword, Member.passwordTip);
            toolTip.SetToolTip(lblPassword, Member.passwordTip);

            toolTip.SetToolTip(txtEmail, Member.emailTip);
            toolTip.SetToolTip(lblEmail, Member.emailTip);

            toolTip.SetToolTip(grpContactMethod, Member.contact_methodTip);

            toolTip.SetToolTip(cmbSubscriptionID, Member.subscription_idTip);
            toolTip.SetToolTip(lblSubscriptionID, Member.subscription_idTip);

            memberDataGridView.Width  = 43 + 10 * 100 + 17;
            memberDataGridView.Height = 23 + 4 * 22 + 17;
        }
Exemple #3
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            int number;

            if (!Int32.TryParse(txtNumber.Text.Trim(), out number))
            {
                MessageBox.Show(MsgBoxHelper.MustBe(lblNumber.Text), "Invalid " + lblNumber.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtNumber.Focus();
            }
            else
            {
                if (number > short.MaxValue)     // 32767
                {
                    MessageBox.Show(MsgBoxHelper.LTETmax(lblNumber.Text), "Invalid " + lblNumber.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    txtNumber.Focus();
                }
                else if (number < short.MinValue)//-32768
                {
                    MessageBox.Show(MsgBoxHelper.GTETmin(lblNumber.Text), "Invalid " + lblNumber.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    txtNumber.Focus();
                }
                else if (CheckAll())
                {
                    Member objMember = new Member();

                    Int32.TryParse(txtNumber.Text.Trim(), out number);
                    objMember.number        = number;
                    objMember.joindate      = dtpJoinDate.Value;
                    objMember.firstname     = txtFirstName.Text.Trim();
                    objMember.lastname      = txtLastName.Text.Trim();
                    objMember.address       = txtAddress.Text.Trim();
                    objMember.city          = txtCity.Text.Trim();
                    objMember.state         = txtState.Text.Trim();
                    objMember.zipcode       = txtZipCode.Text.Trim();
                    objMember.phone         = txtPhone.Text.Trim();
                    objMember.member_status = rdoActive.Checked ? "A" : "I";
                    objMember.login_name    = txtLoginName.Text.Trim();
                    objMember.password      = txtPassword.Text.Trim();
                    objMember.email         = txtEmail.Text.Trim();

                    if (rdoEmail.Checked)
                    {
                        objMember.contact_method = 1;
                    }
                    else if (rdoFacebook.Checked)
                    {
                        objMember.contact_method = 2;
                    }
                    else if (rdoPhoneText.Checked)
                    {
                        objMember.contact_method = 3;
                    }
                    else if (rdoTwitter.Checked)
                    {
                        objMember.contact_method = 4;
                    }
                    else
                    {
                        objMember.contact_method = 0;
                    }

                    objMember.subscription_id = (int)cmbSubscriptionID.SelectedValue;
                    objMember.photo           = imageLocation;
                    try
                    {
                        bool status = Members.UpdateMember(objMember);
                        if (status)
                        {
                            MessageBox.Show(MsgBoxHelper.Updated("Member"), "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            memberList = Members.GetMembers();
                            memberDataGridView.DataSource = memberList;
                        }
                        else
                        {
                            MessageBox.Show(MsgBoxHelper.Updated("Member not"), "Failure", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message, "Failure", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
        }
Exemple #4
0
        private void btnBrowse_Click(object sender, EventArgs e)
        {
            int number;

            if (!Int32.TryParse(txtNumber.Text.Trim(), out number))
            {
                MessageBox.Show(MsgBoxHelper.MustBe(lblNumber.Text), "Invalid " + lblNumber.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtNumber.Focus();
            }
            else
            {
                if (number > short.MaxValue)     // 32767
                {
                    MessageBox.Show(MsgBoxHelper.LTETmax(lblNumber.Text), "Invalid " + lblNumber.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    txtNumber.Focus();
                }
                else if (number < short.MinValue)//-32768
                {
                    MessageBox.Show(MsgBoxHelper.GTETmin(lblNumber.Text), "Invalid " + lblNumber.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    txtNumber.Focus();
                }
                else
                {
                    Member objMember;

                    try
                    {
                        objMember = Members.GetMember(number);
                        if (objMember == null)
                        {
                            MessageBox.Show(MsgBoxHelper.Selected("Member " + lblNumber.Text + " " + number), "Failure", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                        else
                        {
                            dtpJoinDate.Value = objMember.joindate;
                            txtFirstName.Text = objMember.firstname.Trim();
                            txtLastName.Text  = objMember.lastname.Trim();
                            txtAddress.Text   = objMember.address.Trim();
                            txtCity.Text      = objMember.city.Trim();
                            txtState.Text     = objMember.state;
                            txtZipCode.Text   = objMember.zipcode;
                            txtPhone.Text     = objMember.phone;
                            if (objMember.member_status == "A")
                            {
                                rdoActive.Checked = true;
                            }
                            else
                            {
                                rdoInactive.Checked = true;
                            }
                            txtLoginName.Text = objMember.login_name;
                            txtPassword.Text  = objMember.password;
                            txtEmail.Text     = objMember.email;

                            if (objMember.contact_method == 1)
                            {
                                rdoEmail.Checked = true;
                            }
                            else if (objMember.contact_method == 2)
                            {
                                rdoFacebook.Checked = true;
                            }
                            else if (objMember.contact_method == 3)
                            {
                                rdoPhoneText.Checked = true;
                            }
                            else if (objMember.contact_method == 4)
                            {
                                rdoTwitter.Checked = true;
                            }
                            else
                            {
                                objMember.contact_method = 0;
                            }

                            cmbSubscriptionID.SelectedValue = objMember.subscription_id;
                            imageLocation = objMember.photo;
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message, "Failure", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
        }