Exemplo n.º 1
0
        protected void ok_Click(object sender, EventArgs e)
        {
            if (dojoMembershipID == 0)
            {
                obj = new DojoMembership();
            }
            else
            {
                obj = new DojoMembership(dojoMembershipID);
            }

            if (comboMember.SelectedItem != null)
            {
                obj.Member = DojoMember.NewPlaceHolder(int.Parse(comboMember.SelectedValue));
            }
            else
            {
                obj.Member = null;
            }
            obj.StartDate = deStartDate.Date;
            obj.EndDate   = deEndDate.Date;
            if (comboOrganization.SelectedItem != null)
            {
                obj.Organization = DojoOrganization.NewPlaceHolder(int.Parse(comboOrganization.SelectedValue));
            }
            else
            {
                obj.Organization = null;
            }
            obj.OrganizationMemberID = tbOrganizationMemberID.Text;
            if (ddParent.SelectedItem != null && ddParent.SelectedValue != "null")
            {
                obj.Parent = DojoMembership.NewPlaceHolder(int.Parse(ddParent.SelectedValue));
            }
            else
            {
                obj.Parent = null;
            }
            if (comboMemberTypeTemplate.SelectedItem != null)
            {
                obj.MemberTypeTemplate = DojoMemberTypeTemplate.NewPlaceHolder(int.Parse(comboMemberTypeTemplate.SelectedValue));
            }
            else
            {
                obj.MemberTypeTemplate = null;
            }
            if (comboMembershipTemplate.SelectedItem != null)
            {
                obj.MembershipTemplate = DojoMembershipTemplate.NewPlaceHolder(int.Parse(comboMembershipTemplate.SelectedValue));
            }
            else
            {
                obj.MembershipTemplate = null;
            }
            obj.Fee           = decimal.Parse(tbFee.Text);
            obj.PaymentAmount = decimal.Parse(tbPaymentAmount.Text);
            obj.IsProRated    = cbIsProRated.Checked;
            if (ddInvoiceLine.SelectedItem != null && ddInvoiceLine.SelectedValue != "null")
            {
                obj.InvoiceLine = RHInvoiceLine.NewPlaceHolder(int.Parse(ddInvoiceLine.SelectedValue));
            }
            else
            {
                obj.InvoiceLine = null;
            }
            if (editOnAdd)
            {
                dojoMembershipID = obj.Save();
            }
            else
            {
                obj.Save();
            }

            if (resetOnAdd)
            {
                DojoMembership newObj = new DojoMembership();
                if (newObj.Member != null)
                {
                    comboMember.Text = newObj.Member.ToString();
                    foreach (ComponentArt.Web.UI.ComboBoxItem item in comboMember.Items)
                    {
                        if (item.Value == newObj.Member.ID.ToString())
                        {
                            comboMember.SelectedItem = item;
                            break;
                        }
                    }
                }
                else
                {
                    // Necissary to clear prior ViewState - if only we don't need it.
                    comboMember.Text         = string.Empty;
                    comboMember.SelectedItem = null;
                }
                deStartDate.Date = newObj.StartDate;
                deEndDate.Date   = newObj.EndDate;
                if (newObj.Organization != null)
                {
                    comboOrganization.Text = newObj.Organization.ToString();
                    foreach (ComponentArt.Web.UI.ComboBoxItem item in comboOrganization.Items)
                    {
                        if (item.Value == newObj.Organization.ID.ToString())
                        {
                            comboOrganization.SelectedItem = item;
                            break;
                        }
                    }
                }
                else
                {
                    // Necissary to clear prior ViewState - if only we don't need it.
                    comboOrganization.Text         = string.Empty;
                    comboOrganization.SelectedItem = null;
                }
                tbOrganizationMemberID.Text = newObj.OrganizationMemberID;
                if (newObj.Parent != null)
                {
                    foreach (ListItem item in ddParent.Items)
                    {
                        item.Selected = newObj.Parent.ID.ToString() == item.Value;
                    }
                }
                else if (ddParent.Items.Count > 0)
                {
                    ddParent.SelectedIndex = 0;
                }

                if (newObj.MemberTypeTemplate != null)
                {
                    comboMemberTypeTemplate.Text = newObj.MemberTypeTemplate.ToString();
                    foreach (ComponentArt.Web.UI.ComboBoxItem item in comboMemberTypeTemplate.Items)
                    {
                        if (item.Value == newObj.MemberTypeTemplate.ID.ToString())
                        {
                            comboMemberTypeTemplate.SelectedItem = item;
                            break;
                        }
                    }
                }
                else
                {
                    // Necissary to clear prior ViewState - if only we don't need it.
                    comboMemberTypeTemplate.Text         = string.Empty;
                    comboMemberTypeTemplate.SelectedItem = null;
                }
                if (newObj.MembershipTemplate != null)
                {
                    comboMembershipTemplate.Text = newObj.MembershipTemplate.ToString();
                    foreach (ComponentArt.Web.UI.ComboBoxItem item in comboMembershipTemplate.Items)
                    {
                        if (item.Value == newObj.MembershipTemplate.ID.ToString())
                        {
                            comboMembershipTemplate.SelectedItem = item;
                            break;
                        }
                    }
                }
                else
                {
                    // Necissary to clear prior ViewState - if only we don't need it.
                    comboMembershipTemplate.Text         = string.Empty;
                    comboMembershipTemplate.SelectedItem = null;
                }
                ltSessionID.Text       = newObj.SessionID.ToString();
                tbFee.Text             = newObj.Fee.ToString();
                ltPriorMembership.Text = newObj.PriorMembership != null?
                                         newObj.PriorMembership.ToString() : Localization.Strings.StartupMembership;

                tbPaymentAmount.Text = newObj.PaymentAmount.ToString();
                cbIsProRated.Checked = newObj.IsProRated;
                if (newObj.InvoiceLine != null)
                {
                    foreach (ListItem item in ddInvoiceLine.Items)
                    {
                        item.Selected = newObj.InvoiceLine.ID.ToString() == item.Value;
                    }
                }
                else if (ddInvoiceLine.Items.Count > 0)
                {
                    ddInvoiceLine.SelectedIndex = 0;
                }
            }

            OnUpdated(EventArgs.Empty);
        }
Exemplo n.º 2
0
        protected void ok_Click(object sender, EventArgs e)
        {
            if (dojoMembershipID == 0)
            {
                obj = new DojoMembership();
            }
            else
            {
                obj = new DojoMembership(dojoMembershipID);
            }

            obj.StartDate            = deStartDate.Date;
            obj.EndDate              = deEndDate.Date;
            obj.OrganizationMemberID = tbOrganizationMemberID.Text;

            if (msMember.SelectedItem != null && msMember.SelectedItem.Value != "Null")
            {
                obj.Member = DojoMember.NewPlaceHolder(
                    int.Parse(msMember.SelectedItem.Value));
            }
            else
            {
                obj.Member = null;
            }

            if (msMemberType.SelectedItem != null && msMemberType.SelectedItem.Value != "Null")
            {
                obj.MemberType = DojoMemberType.NewPlaceHolder(
                    int.Parse(msMemberType.SelectedItem.Value));
            }
            else
            {
                obj.MemberType = null;
            }

            if (msOrganization.SelectedItem != null && msOrganization.SelectedItem.Value != "Null")
            {
                obj.Organization = DojoOrganization.NewPlaceHolder(
                    int.Parse(msOrganization.SelectedItem.Value));
            }
            else
            {
                obj.Organization = null;
            }

            if (msParentMembership.SelectedItem != null && msParentMembership.SelectedItem.Value != "Null")
            {
                obj.ParentMembership = DojoMembership.NewPlaceHolder(
                    int.Parse(msParentMembership.SelectedItem.Value));
            }
            else
            {
                obj.ParentMembership = null;
            }

            if (msSourceTemplate.SelectedItem != null && msSourceTemplate.SelectedItem.Value != "Null")
            {
                obj.SourceTemplate = DojoMembershipTemplate.NewPlaceHolder(
                    int.Parse(msSourceTemplate.SelectedItem.Value));
            }
            else
            {
                obj.SourceTemplate = null;
            }

            if (msInvoiceLine.SelectedItem != null && msInvoiceLine.SelectedItem.Value != "Null")
            {
                obj.InvoiceLine = RHInvoiceLine.NewPlaceHolder(
                    int.Parse(msInvoiceLine.SelectedItem.Value));
            }
            else
            {
                obj.InvoiceLine = null;
            }

            if (editOnAdd)
            {
                dojoMembershipID = obj.Save();
            }
            else
            {
                obj.Save();
            }

            if (resetOnAdd)
            {
                deStartDate.Date                 = DateTime.Now;
                deEndDate.Date                   = DateTime.Now;
                tbOrganizationMemberID.Text      = string.Empty;
                msMember.SelectedIndex           = 0;
                msMemberType.SelectedIndex       = 0;
                msOrganization.SelectedIndex     = 0;
                msParentMembership.SelectedIndex = 0;
                msSourceTemplate.SelectedIndex   = 0;
                msInvoiceLine.SelectedIndex      = 0;
            }

            OnUpdated(EventArgs.Empty);
        }