Ejemplo n.º 1
0
        private void frmExtra_Load(object sender, EventArgs e)
        {
            ulong mask;
            List <KeyValuePair <int, string> > years = new List <KeyValuePair <int, string> >();

            try
            {
                mbr = new clsMembership(_ID, _Promote);

                MembershipTableAdapters.MembershipTypeTableAdapter daMemType = new PFGA_Membership.MembershipTableAdapters.MembershipTypeTableAdapter();
                Membership.MembershipTypeDataTable dtMemType = new Membership.MembershipTypeDataTable();
                daMemType.Fill(dtMemType);

                this.Text                       = String.Format("Card #: {0}", mbr.Card.ToString());
                last_NameTextBox.Text           = mbr.LastName.ToString();
                first_NameTextBox.Text          = mbr.FirstName.ToString();
                birth_DateDateTimePicker.Text   = (mbr.BirthDate.ToString() == "1900-01-01" ? string.Empty : mbr.BirthDate.ToString());
                email_AddressTextBox.Text       = mbr.Email.ToString();
                website_UsernamesTextBox.Text   = mbr.UserName.ToString();
                palTextBox.Text                 = mbr.Pal.ToString();
                pal_Exp_DateDateTimePicker.Text = (mbr.PalExpDate.ToString() == "1900-01-01" ? string.Empty : mbr.PalExpDate.ToString());
                cboWalk.SelectedText            = mbr.Walk.ToString();
                sectionFlagTextBox.Text         = mbr.SectionFlag.ToString();
                txtNotes.Text                   = mbr.Notes;
                txtCardNumber.Text              = mbr.Card.ToString();
                chkSwipe.Checked                = mbr.SwipeCard;
                txtCell.Text                    = (mbr.Cell == null ? string.Empty : mbr.Cell.ToString());
                chkCardMade.Checked             = mbr.CardMade;
                if (mbr.BadgeImage != null)
                {
                    if (mbr.BadgeImage.Length > 0)
                    {
                        Badge.Image = Image.FromStream(new MemoryStream(mbr.BadgeImage));
                    }
                }

                // New Extra Card, Hide Fields
                if (IsExtra || (_ID < 0 && _Promote > 0))
                {
                    this.Text              = String.Format("Card #: {0}", mbr.Card.ToString());
                    last_NameTextBox.Text  = mbr.LastName.ToString();
                    first_NameTextBox.Text = mbr.FirstName.ToString();
                    grpSection.Hide();
                    txtCardNumber.Show();
                    lblCardNumber.Show();
                }
                else if (_ID < 0 && _Promote < 0)
                {
                    txtCardNumber.Show();
                    lblCardNumber.Show();
                }

                if (ulong.TryParse(sectionFlagTextBox.Text.ToString(), out mask))
                {
                    _Sections.Mask = mask;
                }
                else
                {
                    _Sections.ClearField();
                }
            }
            catch (Exception ex)
            {
                ErrorLogger.Log("Error Loading Member Form", ex, true);
            }

            DisplaySections();
        }
Ejemplo n.º 2
0
        private void frmMember_Load(object sender, EventArgs e)
        {
            ulong mask;
            ulong pMask;
            int   curYear;
            List <KeyValuePair <int, string> > years = new List <KeyValuePair <int, string> >();

            try
            {
                mbr = new clsMembership(_ID, _Promote);

                MembershipTableAdapters.MembershipTypeTableAdapter daMemType = new PFGA_Membership.MembershipTableAdapters.MembershipTypeTableAdapter();
                Membership.MembershipTypeDataTable dtMemType = new Membership.MembershipTypeDataTable();
                daMemType.Fill(dtMemType);
                cboMemberType.DataSource    = dtMemType;
                cboMemberType.DisplayMember = "Membership Type";
                cboMemberType.ValueMember   = "MembershipTypeID";

                if (DateTime.Today.Month >= 1 && DateTime.Today.Month < 8)
                {
                    curYear = DateTime.Today.Year - 1;
                }
                else
                {
                    curYear = DateTime.Today.Year;
                }

                for (int c = curYear; c > 2008; c--)
                {
                    years.Add(new KeyValuePair <int, string>(c, string.Format("{0} - {1}", c, c + 1)));
                }
                cboPaid.DataSource    = years;
                cboPaid.ValueMember   = "Key";
                cboPaid.DisplayMember = "Value";

                MembershipTableAdapters.PaymentTypeTableAdapter daPayType = new MembershipTableAdapters.PaymentTypeTableAdapter();
                Membership.PaymentTypeDataTable dtPayType = new Membership.PaymentTypeDataTable();
                daPayType.Fill(dtPayType);
                RadioButton[] RadioButtons;
                int           index = 0;
                RadioButtons = new RadioButton[dtPayType.Rows.Count];
                foreach (DataRow row in dtPayType)
                {
                    RadioButtons[index]          = new RadioButton();
                    RadioButtons[index].Name     = "chkPayment" + Convert.ToString(index);
                    RadioButtons[index].Text     = row["PaymentType"].ToString();
                    RadioButtons[index].AutoSize = true;
                    RadioButtons[index].Tag      = int.Parse(row["PaymentTypeId"].ToString());
                    RadioButtons[index].Location = new System.Drawing.Point((RadioButtons[index].Width * index) + 5, 15);
                    grpPayType.Controls.Add(RadioButtons[index]);
                    index++;
                }
                RadioButtons[0].Checked = true;

                string Heading = string.Empty;;
                if (mbr.MasterRecord < 0)
                {
                    Heading = String.Format("Card #: {0}", mbr.Card.ToString());
                }
                else
                {
                    Heading = string.Format("Card #: {0}, Account: {1}", mbr.Card.ToString(), mbr.MasterRecordName);
                }
                this.Text                       = Heading;
                last_NameTextBox.Text           = mbr.LastName.ToString();
                first_NameTextBox.Text          = mbr.FirstName.ToString();
                birth_DateDateTimePicker.Text   = (mbr.BirthDate.ToString() == "1900-01-01" ? string.Empty : mbr.BirthDate.ToString());
                addressTextBox.Text             = mbr.Address.ToString();
                city__ProvTextBox.Text          = mbr.CityProv.ToString();
                postalTextBox.Text              = mbr.Postal.ToString();
                phoneTextBox.Text               = mbr.Phone.ToString();
                email_AddressTextBox.Text       = mbr.Email.ToString();
                website_UsernamesTextBox.Text   = mbr.UserName.ToString();
                palTextBox.Text                 = mbr.Pal.ToString();
                pal_Exp_DateDateTimePicker.Text = (mbr.PalExpDate.ToString() == "1900-01-01" ? string.Empty : mbr.PalExpDate.ToString());
                cboMemberType.SelectedValue     = mbr.MemberTypeID;
                date_JoinedDateTimePicker.Text  = (mbr.JoinedDate.ToString() == "1900-01-01" ? string.Empty : mbr.JoinedDate.ToString());
                cboWalk.SelectedText            = mbr.Walk.ToString();
                sectionFlagTextBox.Text         = mbr.SectionFlag.ToString();
                noBackTrackCheckBox.Checked     = mbr.NoBackTrack;
                noEmailingCheckBox.Checked      = mbr.NoEmail;
                chkActive.Checked               = mbr.Active;
                txtNotes.Text                   = mbr.Notes;
                txtCardNumber.Text              = mbr.Card.ToString();
                txtSponsor.Text                 = mbr.Sponsor;
                chkSwipe.Checked                = mbr.SwipeCard;
                chkExecutive.Checked            = mbr.Executive;
                txtCell.Text                    = (mbr.Cell == null ? string.Empty : mbr.Cell.ToString());
                txtOther.Text                   = mbr.ParticipationOther;
                txtParticipateFlag.Text         = mbr.Participation.ToString();
                chkCardMade.Checked             = mbr.CardMade;
                if (mbr.BadgeImage != null)
                {
                    if (mbr.BadgeImage.Length > 0)
                    {
                        Badge.Image = Image.FromStream(new MemoryStream(mbr.BadgeImage));
                    }
                }


                // Existing Member
                if (_ID > 0)
                {
                    #region PaidHistory
                    dgPaidHistory.AutoGenerateColumns = false;

                    DataGridViewTextBoxColumn dgcYearPaid = new DataGridViewTextBoxColumn();
                    dgcYearPaid.Name             = "YearPaid";
                    dgcYearPaid.Visible          = false;
                    dgcYearPaid.SortMode         = DataGridViewColumnSortMode.Programmatic;
                    dgcYearPaid.DataPropertyName = "YearPaid";
                    dgPaidHistory.Columns.Add(dgcYearPaid);
                    dgPaidHistory.Columns["YearPaid"].Visible = false;

                    DataGridViewTextBoxColumn dgcMembershipYear = new DataGridViewTextBoxColumn();
                    dgcMembershipYear.Name             = "MembershipYear";
                    dgcMembershipYear.HeaderText       = "Year Paid";
                    dgcMembershipYear.DataPropertyName = "MembershipYear";
                    dgcMembershipYear.SortMode         = DataGridViewColumnSortMode.Programmatic;
                    dgPaidHistory.Columns.Add(dgcMembershipYear);

                    // Create DeleteButton
                    DataGridViewButtonColumn dgcDelButton = new DataGridViewButtonColumn();
                    dgcDelButton.Name        = "colDelete";
                    dgcDelButton.HeaderText  = "";
                    dgcDelButton.Text        = "û";
                    dgcDelButton.ToolTipText = "Delete Row";
                    dgcDelButton.UseColumnTextForButtonValue = true;
                    dgcDelButton.DefaultCellStyle.Font       = new Font("WingDings", 14);
                    dgcDelButton.DefaultCellStyle.ForeColor  = Color.Red;
                    dgcDelButton.DefaultCellStyle.Alignment  = DataGridViewContentAlignment.MiddleCenter;
                    dgcDelButton.Width = 20;
                    dgPaidHistory.Columns.Add(dgcDelButton);

                    DataView dvPaidHistory = new DataView(mbr.PaidHistory);
                    dvPaidHistory.Sort      = "YearPaid DESC";
                    dvPaidHistory.RowFilter = "Deleted = False";

                    dgPaidHistory.DataSource = dvPaidHistory;
                    #endregion

                    #region Extra Cards
                    dgExtraCards.AutoGenerateColumns = false;

                    DataGridViewTextBoxColumn dgcID = new DataGridViewTextBoxColumn();
                    dgcID.Name             = "ID";
                    dgcID.Visible          = false;
                    dgcID.DataPropertyName = "ID";
                    dgExtraCards.Columns.Add(dgcID);

                    DataGridViewTextBoxColumn dgcName = new DataGridViewTextBoxColumn();
                    dgcName.Name             = "Name";
                    dgcName.HeaderText       = "Name";
                    dgcName.DataPropertyName = "Name";
                    dgcName.Width            = 500;
                    dgExtraCards.Columns.Add(dgcName);

                    DataGridViewImageButtonDeleteColumn dgRemove = new DataGridViewImageButtonDeleteColumn();
                    dgRemove.Name        = "colDelete";
                    dgRemove.HeaderText  = "";
                    dgRemove.Text        = "Delete";
                    dgRemove.ToolTipText = "";
                    dgRemove.UseColumnTextForButtonValue = true;
                    dgRemove.DefaultCellStyle.Alignment  = DataGridViewContentAlignment.MiddleCenter;
                    dgExtraCards.Columns.Add(dgRemove);

                    DataGridViewImageButtonPromoteColumn dgPromote = new DataGridViewImageButtonPromoteColumn();
                    dgPromote.Name        = "colPromote";
                    dgPromote.HeaderText  = "";
                    dgPromote.Text        = "Promote to Member";
                    dgPromote.ToolTipText = "Promote";
                    dgPromote.UseColumnTextForButtonValue = true;
                    dgExtraCards.Columns.Add(dgPromote);

                    DataGridViewImageButtonEditColumn dgEdit = new DataGridViewImageButtonEditColumn();
                    dgEdit.Name        = "colEdit";
                    dgEdit.HeaderText  = "";
                    dgEdit.Text        = "Edit";
                    dgEdit.ToolTipText = "Edit";
                    dgEdit.UseColumnTextForButtonValue = true;
                    dgExtraCards.Columns.Add(dgEdit);

                    DataView dvExtraCards = new DataView(mbr.ExtraCards);
                    dvExtraCards.RowFilter  = "Deleted = False AND Promote = False";
                    dgExtraCards.DataSource = dvExtraCards;
                    #endregion
                }

                // New Extra Card, Hide Fields
                if (IsExtra || (_ID < 0 && _Promote > 0))
                {
                    this.Text              = String.Format("Card #: {0}", mbr.Card.ToString());
                    last_NameTextBox.Text  = mbr.LastName.ToString();
                    first_NameTextBox.Text = mbr.FirstName.ToString();
                    addressTextBox.Hide();
                    city__ProvTextBox.Hide();
                    postalTextBox.Hide();
                    phoneTextBox.Hide();
                    website_UsernamesTextBox.Hide();
                    date_JoinedDateTimePicker.Hide();
                    grpSection.Hide();
                    noBackTrackCheckBox.Hide();
                    noEmailingCheckBox.Hide();
                    chkActive.Hide();
                    tabControl1.TabPages.Remove(tabPaid);
                    tabControl1.TabPages.Remove(tabExtra);
                    grpParticipate.Hide();
                    txtCardNumber.Show();
                    lblCardNumber.Show();
                }
                else if (_ID < 0 && _Promote < 0)
                {
                    tabPaid.Hide();
                    tabExtra.Hide();
                    txtCardNumber.Show();
                    lblCardNumber.Show();
                }

                if (ulong.TryParse(sectionFlagTextBox.Text.ToString(), out mask))
                {
                    _Sections.Mask = mask;
                }
                else
                {
                    _Sections.ClearField();
                }

                if (ulong.TryParse(txtParticipateFlag.Text, out pMask))
                {
                    _Participation.Mask = pMask;
                }
                else
                {
                    _Participation.ClearField();
                }
            }
            catch (Exception ex)
            {
                ErrorLogger.Log("Error Loading Member Form", ex, true);
            }

            DisplaySections();
            DisplayParticipation();
        }