protected override void OnPreRender(EventArgs e)
        {
            base.OnPreRender(e);

            //set the default value
            String personId = this.Request.QueryString["personId"];
            String roleId   = this.Request.QueryString["roleId"];
            String orgId    = this.Request.QueryString["orgId"];
            String oppId    = this.Request.QueryString["oppId"];

            if (personId != null)
            {
                Person Person = Person.FetchById(personId);
                this.Contact.FieldValue              = Person.PrincipalRole.Id;
                this.Contact.FieldText               = Person.PrincipalRole.PersonName;
                this.BookerAddressId.FieldValue      = Person.PrincipalRole.AddressId;
                this.OrgName.FieldValue              = Person.PrincipalRole.OrganisationId;
                this.OrgName.FieldText               = Person.PrincipalRole.Organisation.Name;
                this.InvoiceContact.FieldValue       = Person.PrincipalRole.Id;
                this.InvoiceContact.FieldText        = Person.PrincipalRole.PersonName;
                this.InvoicePersonId.FieldValue      = Person.Id;
                this.InvoiceAddressId.FieldValue     = Person.PrincipalRole.AddressId;
                this.InvOrgName.FieldValue           = Person.PrincipalRole.OrganisationId;
                this.InvOrgName.FieldText            = Person.PrincipalRole.Organisation.Name;
                this.Payment.AddressId.FieldValue    = Person.PrincipalRole.AddressId;
                this.Payment.Organisation.FieldValue = Person.PrincipalRole.OrganisationId;
                this.Payment.Organisation.FieldText  = Person.PrincipalRole.Organisation.Name;
                this.Payment.Person.FieldValue       = Person.PrincipalRole.Id;
                this.Payment.Person.FieldText        = Person.PrincipalRole.PersonName;
            }
            if (roleId != null)
            {
                Role Role = Role.FetchById(roleId);
                this.Contact.FieldValue              = Role.Id;
                this.Contact.FieldText               = Role.PersonName;
                this.BookerAddressId.FieldValue      = Role.AddressId;
                this.OrgName.FieldValue              = Role.OrganisationId;
                this.OrgName.FieldText               = Role.Organisation.Name;
                this.InvoiceContact.FieldValue       = Role.Id;
                this.InvoiceContact.FieldText        = Role.PersonName;
                this.InvoicePersonId.FieldValue      = Role.PersonId;
                this.InvoiceAddressId.FieldValue     = Role.AddressId;
                this.InvOrgName.FieldValue           = Role.OrganisationId;
                this.InvOrgName.FieldText            = Role.Organisation.Name;
                this.Payment.AddressId.FieldValue    = Role.AddressId;
                this.Payment.Organisation.FieldValue = Role.OrganisationId;
                this.Payment.Organisation.FieldText  = Role.Organisation.Name;
                this.Payment.Person.FieldValue       = Role.Id;
                this.Payment.Person.FieldText        = Role.PersonName;
            }
            if (orgId != null)
            {
                Organisation Organisation = Organisation.FetchById(orgId);
                this.BookerAddressId.FieldValue      = Organisation.PrincipalAddress.Id;
                this.OrgName.FieldValue              = Organisation.Id;
                this.OrgName.FieldText               = Organisation.Name;
                this.InvoiceAddressId.FieldValue     = Organisation.PrincipalAddress.Id;
                this.InvOrgName.FieldValue           = Organisation.Id;
                this.InvOrgName.FieldText            = Organisation.Name;
                this.Payment.AddressId.FieldValue    = Organisation.PrincipalAddress.Id;
                this.Payment.Organisation.FieldValue = Organisation.Id;
                this.Payment.Organisation.FieldText  = Organisation.Name;
            }
            if (oppId != null)
            {
                Opportunity Opp = Opportunity.FetchById(oppId);
                this.OpportunityId.FieldValue        = oppId;
                this.Contact.FieldValue              = Opp.ClientOppXref.RoleId;
                this.Contact.FieldText               = Opp.ClientOppXref.SalesPerson;
                this.BookerAddressId.FieldValue      = Opp.ClientOppXref.Role.AddressId;
                this.OrgName.FieldValue              = Opp.ClientOppXref.OrganisationId;
                this.OrgName.FieldText               = Opp.ClientOppXref.OrgName;
                this.InvoiceContact.FieldValue       = Opp.ClientOppXref.RoleId;
                this.InvoiceContact.FieldText        = Opp.ClientOppXref.SalesPerson;
                this.InvoicePersonId.FieldValue      = Opp.ClientOppXref.Role.PersonId;
                this.InvoiceAddressId.FieldValue     = Opp.ClientOppXref.Role.AddressId;
                this.InvOrgName.FieldValue           = Opp.ClientOppXref.OrganisationId;
                this.InvOrgName.FieldText            = Opp.ClientOppXref.OrgName;
                this.Payment.AddressId.FieldValue    = Opp.ClientOppXref.Role.AddressId;
                this.Payment.Organisation.FieldValue = Opp.ClientOppXref.OrganisationId;
                this.Payment.Organisation.FieldText  = Opp.ClientOppXref.OrgName;
                this.Payment.Person.FieldValue       = Opp.ClientOppXref.RoleId;
                this.Payment.Person.FieldText        = Opp.ClientOppXref.SalesPerson;
            }


            // Selecting a person should pre-populate the organisation and the payee person
            this.InvoiceContact.ClientOnChange += "if (" + this.InvoiceContact.ClientID + ".getData() && " + this.InvoiceContact.ClientID + @".getData().organisation) {
                " + this.InvOrgName.ClientID + @".setValue(this.getData().organisation.id, this.getData().organisation.name);
                $('#" + this.InvoiceAddressId.ClientID + @"Field').val(this.getData().address.id);
                $('#" + this.InvoicePersonId.ClientID + @"Field').val(this.getData().pnId);
            }; " + this.Payment.Person.ClientID + @".setValue(this.getValue(), this.getText());";

            // Selecting an organisation should clear the person (if the person does not match the selected organisation) and should also pre-populate the payee organisation
            this.InvOrgName.ClientOnChange += "if (" + this.InvOrgName.ClientID + ".getValue() && !(" + this.InvoiceContact.ClientID + ".getData() && " + this.InvoiceContact.ClientID + ".getData().organisation && " + this.InvoiceContact.ClientID + ".getData().organisation.id && " + this.InvoiceContact.ClientID + ".getData().organisation.id == " + this.InvOrgName.ClientID + @".getValue())) {
                " + this.InvoiceContact.ClientID + @".setValue(null);
            }; " + this.Payment.Organisation.ClientID + @".setValue(this.getValue(), this.getText());";

            // Selecting a person should pre-populate the organisation
            this.Contact.ClientOnChange += "if (" + this.Contact.ClientID + ".getData() && " + this.Contact.ClientID + @".getData().organisation) {
                " + this.OrgName.ClientID + @".setValue(this.getData().organisation.id, this.getData().organisation.name);
                 $('#" + this.BookerAddressId.ClientID + @"Field').val(this.getData().address.id);
                $('#" + this.Payment.AddressId.ClientID + @"Field').val(this.getData().address.id);
              if (!" + this.InvoiceContact.ClientID + @".getData()) {  
                " + this.InvOrgName.ClientID + @".setValue(this.getData().organisation.id, this.getData().organisation.name);
                " + this.InvoiceContact.ClientID + @".setValue(this.getValue(), this.getText());
                $('#" + this.InvoicePersonId.ClientID + @"Field').val(this.getData().pnId);
                $('#" + this.InvoiceAddressId.ClientID + @"Field').val(this.getData().address.id);
              }
            };
            newDonationDetails.functions.setGridUrl();";

            // Selecting an organisation should clear the person (if the person does not match the selected organisation)
            this.OrgName.ClientOnChange += "if (" + this.OrgName.ClientID + ".getValue() && !(" + this.Contact.ClientID + ".getData().organisation && " + this.Contact.ClientID + ".getData().organisation.id && " + this.Contact.ClientID + ".getData().organisation.id == " + this.OrgName.ClientID + @".getValue())) {
                " + this.Contact.ClientID + @".setValue(null);
            }; ";

            // Display the payment/directdebit pages depending upon the payment method selected.
            this.SellCompName.ClientOnChange += "newDonationDetails.functions.setGridUrl()";
            //this.PaymentMethod.ClientOnChange += "newDonationDetails.functions.togglePages();";
            //this.PaymentMethod.ClientOnChange += this.Payment.PaymentType.ClientID + ".setValue(" + this.PaymentMethod.ClientID + @".getData());";
            this.Payment.SellingCompany.ClientOnChange += "newDonationDetails.functions.togglePages();";
            this.Payment.PaymentType.ClientOnChange    += "newDonationDetails.functions.togglePages();";
        }
Beispiel #2
0
        protected override void OnPreRender(EventArgs e)
        {
            base.OnPreRender(e);
            //set the default value
            String personId = this.Request.QueryString["personId"];
            String roleId   = this.Request.QueryString["roleId"];
            String orgId    = this.Request.QueryString["orgId"];
            String oppId    = this.Request.QueryString["oppId"];

            //roleId = "131";

            if (personId != null)
            {
                Person Person = Person.FetchById(personId);
                this.Contact.FieldValue         = Person.PrincipalRole.Id;
                this.Contact.FieldText          = Person.PrincipalRole.PersonName;
                this.BookerAddressId.FieldValue = Person.PrincipalRole.AddressId;
                this.OrgName.FieldValue         = Person.PrincipalRole.OrganisationId;
                this.OrgName.FieldText          = Person.PrincipalRole.Organisation.Name;
                this.BookingAddress.FieldValue  = Person.PrincipalRole.Address.MailString;
            }

            if (roleId != null)
            {
                Role Role = Role.FetchById(roleId);
                this.Contact.FieldValue         = Role.Id;
                this.Contact.FieldText          = Role.PersonName;
                this.BookerAddressId.FieldValue = Role.AddressId;
                this.OrgName.FieldValue         = Role.OrganisationId;
                this.OrgName.FieldText          = Role.Organisation.Name;
                this.BookingAddress.FieldValue  = Role.Address.MailString;
            }
            if (orgId != null)
            {
                Organisation Organisation = Organisation.FetchById(orgId);
                this.OrgName.FieldValue = Organisation.Id;
                this.OrgName.FieldText  = Organisation.Name;
            }
            if (oppId != null)
            {
                Opportunity Opp = Opportunity.FetchById(oppId);
                this.OpportunityId.FieldValue   = oppId;
                this.Contact.FieldValue         = Opp.ClientOppXref.RoleId;
                this.Contact.FieldText          = Opp.ClientOppXref.SalesPerson;
                this.BookerAddressId.FieldValue = Opp.ClientOppXref.Role.AddressId;
                this.OrgName.FieldValue         = Opp.ClientOppXref.OrganisationId;
                this.OrgName.FieldText          = Opp.ClientOppXref.OrgName;
                this.BookingAddress.FieldValue  = Opp.ClientOppXref.Role.Address.MailString;
            }
            //if we have defaulted our booker, get AR number and everything ready

            // Selecting a person should pre-populate the organisation
            this.Contact.ClientOnChange += "if (" + this.Contact.ClientID + ".getData() && " + this.Contact.ClientID + @".getData().organisation) {
                " + this.OrgName.ClientID + @".setValue(this.getData().organisation.id, this.getData().organisation.name);
                 $('#" + this.BookerAddressId.ClientID + @"Field').val(this.getData().address.id);
                 $('#" + this.BookingAddress.ClientID + @"Field').val(this.getData().address.mailstring);
                 if(this.getData().organisation.id == ''){
                        $('#Content_Content_ctl01_AddressSearch').hide();
                    }else{
                        $('#Content_Content_ctl01_AddressSearch').show();
                    }
            };
            newBookingDetails.functions.getARNumbers();";

            this.Account.ClientOnChange        += "newBookingDetails.functions.getBillingContacts()";
            this.InvoiceContact.ClientOnChange += "newBookingDetails.functions.setInvoiceDetails()";

            // Selecting an organisation should clear the person (if the person does not match the selected organisation)
            this.OrgName.ClientOnChange += "if (" + this.OrgName.ClientID + ".getValue() && !(" + this.Contact.ClientID + ".getData().organisation && " + this.Contact.ClientID + ".getData().organisation.id && " + this.Contact.ClientID + ".getData().organisation.id == " + this.OrgName.ClientID + @".getValue())) {
                " + this.Contact.ClientID + @".setValue(null);
                 $('#" + this.BookerAddressId.ClientID + @"Field').val(this.getData().add_id);
                 $('#" + this.BookingAddress.ClientID + @"Field').val(this.getData().add_mailstring);
            }; ";

            // Display the payment depending upon the payment method selected.
            this.SellCompName.ClientOnChange += "newBookingDetails.functions.getVATCalculation()";
            //this.PaymentMethod.ClientOnChange += "newBookingDetails.functions.togglePages();";
            //this.PaymentMethod.ClientOnChange += this.Payment.PaymentType.ClientID + ".setValue(" + this.PaymentMethod.ClientID + @".getData());";
            this.Payment.SellingCompany.ClientOnChange += "newBookingDetails.functions.togglePages();";
            this.Payment.PaymentType.ClientOnChange    += "newBookingDetails.functions.togglePages();";
        }
Beispiel #3
0
        protected override void OnPreRender(EventArgs e)
        {
            base.OnPreRender(e);

            this.SellingCompanyName.DataSource = Common.SellingCompany.FetchAll();
            if (this.DataSource == null)
            {
                this.SellingCompanyName.FieldValue = CurrentSession.User.SellingCompanyId;
            }

            string pRefid   = this.Request.QueryString["refid"];
            string pRefmode = this.Request.QueryString["refmode"];

            if (!string.IsNullOrEmpty(pRefmode))
            {
                ActivityList.ActivityListMode eRefMode = (ActivityList.ActivityListMode)Enum.Parse(typeof(ActivityList.ActivityListMode), pRefmode);

                if ((int)eRefMode < 0)
                {
                    Controls.PopupField pField = EndUser;
                    string personFirstName     = "";
                    string personSurname       = "";
                    string orgName             = "";

                    // If opening for Role, set EndUser or SalesPerson to that role on insert, depending on if this is our user
                    if (eRefMode == ActivityList.ActivityListMode.PROLE_ID)
                    {
                        if (this.DataSource == null)
                        {
                            Role pRole = Role.FetchById(pRefid);

                            if (this.DataSource != null && this.DataSource.EndUser.PersonRoleId != pRefid && this.DataSource.SalesPerson.PersonRoleId == pRefid)
                            {
                                pField = SalesPerson;
                            }

                            personFirstName = pRole.Person.FirstName;
                            personSurname   = pRole.Person.Surname;
                            orgName         = pRole.Organisation.Name;

                            if (pRole.Person.OurPerson.HasValue && pRole.Person.OurPerson.Value == 1)
                            {
                                SalesPerson.FieldValue = pRefid;
                                SalesPerson.FieldText  = pRole.PersonName;
                            }
                            else
                            {
                                EndUser.FieldValue = pRefid;
                                EndUser.FieldText  = pRole.PersonName;
                            }
                        }
                    }
                    // Else if opening for Person, limit the picklist to Roles for that person only.
                    // Limit the sales person picklist rather than the end user if they are the match to the passed person on update.
                    else if (eRefMode == ActivityList.ActivityListMode.PN_ID)
                    {
                        Person pPerson = Person.FetchById(pRefid);

                        if (this.DataSource != null && this.DataSource.EndUser.PersonId != pRefid && this.DataSource.SalesPerson.PersonId == pRefid)
                        {
                            pField = SalesPerson;
                        }

                        personFirstName = pPerson.FirstName;
                        personSurname   = pPerson.Surname;

                        // .. and (if inserting) set the end user or sales person to the principal role for the person.
                        if (this.DataSource == null)
                        {
                            if (pPerson.OurPerson.HasValue && pPerson.OurPerson.Value == 1)
                            {
                                SalesPerson.FieldValue = pPerson.PrincipalRole.Id;
                                SalesPerson.FieldText  = pPerson.PrincipalRole.PersonName;
                            }
                            else
                            {
                                EndUser.FieldValue          = pPerson.PrincipalRole.Id;
                                EndUser.FieldText           = pPerson.PrincipalRole.PersonName;
                                EndUser_PersonID.FieldValue = pPerson.Id;
                                EndUser_PnName.FieldValue   = pPerson.FullName;
                            }
                        }
                    }
                    // Else if opening for Organisation, show Roles for that organisaction only
                    else if (eRefMode == ActivityList.ActivityListMode.ORG_ID)
                    {
                        Organisation pOrg = Organisation.FetchById(pRefid);

                        if (this.DataSource != null && this.DataSource.EndUser.OrganisationId != pRefid && this.DataSource.SalesPerson.OrganisationId == pRefid)
                        {
                            pField = SalesPerson;
                        }

                        orgName = pOrg.Name;
                    }
                    // Else if opening for Opportunity, assume the end user has a role in the client organisation.
                    else if (eRefMode == ActivityList.ActivityListMode.OPP_ID)
                    {
                        Opportunity pOpp = Opportunity.FetchById(pRefid);

                        orgName = pOpp.ClientOppXref.Organisation.Name;
                        //if(this.DataSource !=null && this.DataSource.EndUser)
                    }

                    if (!string.IsNullOrEmpty(personFirstName))
                    {
                        pField.Filters.Add(new Web.Controls.PopupFieldFilter()
                        {
                            Type          = Web.Controls.PopupFieldFilterTypes.Value,
                            ParameterName = "personFirstName",
                            Value         = personFirstName
                        });
                    }
                    if (!string.IsNullOrEmpty(personSurname))
                    {
                        pField.Filters.Add(new Web.Controls.PopupFieldFilter()
                        {
                            Type          = Web.Controls.PopupFieldFilterTypes.Value,
                            ParameterName = "personSurname",
                            Value         = personSurname
                        });
                    }
                    if (!string.IsNullOrEmpty(orgName))
                    {
                        pField.Filters.Add(new Web.Controls.PopupFieldFilter()
                        {
                            Type          = Web.Controls.PopupFieldFilterTypes.Value,
                            ParameterName = "orgText",
                            Value         = orgName
                        });
                    }
                }
            }



            string pType = this.Request.QueryString["reftype"];

            if (pType == "Letter")
            {
                Type.DataSource = Code.FetchAllByType("ACT").Where(c => c.Value1 == "Letter" || c.Value1 == "Email" || c.Value1 == "Phone");
            }
            else if (pType == "D-")
            {
                Type.DataSource = Code.FetchAllByType("ACT").Where(c => c.Value1.StartsWith("D-"));
            }

            if (this.SalesPerson.FieldValue.Length == 0)
            {
                this.SalesPerson.FieldValue = CurrentSession.User.Person.PrincipalRole.Id;
                this.SalesPerson.FieldText  = CurrentSession.User.Person.PrincipalRole.PersonName;
            }

            if (this.StartDate.FieldValue.ToString() == "")
            {
                this.StartDate.FieldValue = DateTime.Now.Date;
                this.StartTime.FieldValue = DateTime.Now;
            }
        }