示例#1
0
    protected void cmdOK_Click(object sender, EventArgs e)
    {
        ClearErrors();
        try
        {
            if (!ValidateUIRequirements()) return;
            MoveArguments arguments = new MoveArguments
                                                 {
                                                     SourceContact = Contact,
                                                     SourceAccount = Contact.Account,
                                                     TargetAccount = (IAccount) lueTargetAccount.LookupResultValue,
                                                     UseSourceContactInfo = chkUseSourceAddressPhn.Checked
                                                 };
            //Add the move/reassign options for each of the items
            //Activity Options
            MoveItemOption moveOption = rdbMoveActivity.Checked
                                            ? new MoveItemOption { Entity = "Activity", MoveToAccount = true, ReassignTo = arguments.TargetAccount.Id }
                                            : new MoveItemOption { Entity = "Activity", ReassignTo = (lueReassignActivity.LookupResultValue as IContact).Id, MoveToAccount = false };
            arguments.Items.Add(moveOption);

            //History/Notes Options
            moveOption = rdbMoveHistory.Checked
                             ? new MoveItemOption { Entity = "History", MoveToAccount = true, ReassignTo = arguments.TargetAccount.Id }
                             : new MoveItemOption { Entity = "History", ReassignTo = (lueReassignNotesHistory.LookupResultValue as IContact).Id, MoveToAccount = false };
            arguments.Items.Add(moveOption);

            object openItemsReassignContact = lueReassignOpenItems.LookupResultValue != null ? (lueReassignOpenItems.LookupResultValue as IContact).Id : null;
            object closedItemsReassignContact = lueReassignClosedItems.LookupResultValue != null ? (lueReassignClosedItems.LookupResultValue as IContact).Id : null;
            object openSupportItemsReassignContact = lueReassignSupportItems.LookupResultValue != null
                                                         ? (lueReassignSupportItems.LookupResultValue as IContact).Id
                                                         : null;
            //Attachment Options
            moveOption = new MoveItemOption
            {
                Entity = "Attachment",
                ReassignTo = openItemsReassignContact,
                MoveToAccount = false
            };
            arguments.Items.Add(moveOption);

            //Literature Requests Options
            moveOption = new MoveItemOption
            {
                Entity = "LitRequest",
                OpenItemsOnly = true,
                ClosedItemsOnly = true,
                ReassignTo = openItemsReassignContact,
                ReassignToClosed = closedItemsReassignContact,
                MoveToAccount = false
            };
            arguments.Items.Add(moveOption);

            //Opportunity Options
            moveOption = new MoveItemOption
                             {
                                 Entity = "OpportunityContact",
                                 OpenItemsOnly = true,
                                 ClosedItemsOnly = true,
                                 ReassignTo = openItemsReassignContact,
                                 ReassignToClosed = closedItemsReassignContact,
                                 MoveToAccount = false
                             };
            arguments.Items.Add(moveOption);

            //Sales Order Options
            moveOption = new MoveItemOption
            {
                Entity = "SalesOrder",
                OpenItemsOnly = true,
                ReassignTo = openItemsReassignContact,
                MoveToAccount = false
            };
            arguments.Items.Add(moveOption);

            //Ticket Options
            moveOption = new MoveItemOption
            {
                Entity = "Ticket",
                ReassignTo = openSupportItemsReassignContact,
                OpenItemsOnly = true,
                MoveToAccount = false
            };
            arguments.Items.Add(moveOption);
            //Return Options
            moveOption = new MoveItemOption
            {
                Entity = "Return",
                ReassignTo = openSupportItemsReassignContact,
                OpenItemsOnly = true,
                MoveToAccount = false
            };
            arguments.Items.Add(moveOption);
            //Contract Options
            moveOption = new MoveItemOption
            {
                Entity = "Contract",
                ReassignTo = openSupportItemsReassignContact,
                OpenItemsOnly = true,
                MoveToAccount = false
            };
            arguments.Items.Add(moveOption);

            Contact.MoveContact(arguments);

            // redirect back to page so new info can be displayed
            if (Contact.Id != null)
            {
                Response.Redirect(string.Format("Contact.aspx?entityId={0}", (Contact.Id)), false);
            }
        }
        catch (Exception ex)
        {
            string sSlxErrorId = null;
            var sMsg = ErrorHelper.GetClientErrorHtmlMessage(ex, ref sSlxErrorId);
            if (!string.IsNullOrEmpty(sSlxErrorId))
            {
                log.Error(ErrorHelper.AppendSlxErrorId("The call to SmartParts_Contact_MoveContact.cmdOK_Click failed", sSlxErrorId),
                          ex);
            }
            DialogService.ShowHtmlMessage(sMsg, ErrorHelper.IsDevelopmentContext() ? 600 : -1,
                                          ErrorHelper.IsDevelopmentContext() ? 800 : -1);
        }
    }
示例#2
0
    protected void cmdOK_Click(object sender, EventArgs e)
    {
        ClearErrors();
        try
        {
            if (!ValidateUIRequirements())
            {
                return;
            }
            MoveArguments arguments = new MoveArguments
            {
                SourceContact        = Contact,
                SourceAccount        = Contact.Account,
                TargetAccount        = (IAccount)lueTargetAccount.LookupResultValue,
                UseSourceContactInfo = chkUseSourceAddressPhn.Checked
            };
            //Add the move/reassign options for each of the items
            //Activity Options
            MoveItemOption moveOption = rdbMoveActivity.Checked
                                            ? new MoveItemOption {
                Entity = "Activity", MoveToAccount = true, ReassignTo = arguments.TargetAccount.Id
            }
                                            : new MoveItemOption {
                Entity = "Activity", ReassignTo = (lueReassignActivity.LookupResultValue as IContact).Id, MoveToAccount = false
            };
            arguments.Items.Add(moveOption);

            //History/Notes Options
            moveOption = rdbMoveHistory.Checked
                             ? new MoveItemOption {
                Entity = "History", MoveToAccount = true, ReassignTo = arguments.TargetAccount.Id
            }
                             : new MoveItemOption {
                Entity = "History", ReassignTo = (lueReassignNotesHistory.LookupResultValue as IContact).Id, MoveToAccount = false
            };
            arguments.Items.Add(moveOption);

            object openItemsReassignContact        = lueReassignOpenItems.LookupResultValue != null ? (lueReassignOpenItems.LookupResultValue as IContact).Id : null;
            object closedItemsReassignContact      = lueReassignClosedItems.LookupResultValue != null ? (lueReassignClosedItems.LookupResultValue as IContact).Id : null;
            object openSupportItemsReassignContact = lueReassignSupportItems.LookupResultValue != null
                                                         ? (lueReassignSupportItems.LookupResultValue as IContact).Id
                                                         : null;
            //Attachment Options
            moveOption = new MoveItemOption
            {
                Entity        = "Attachment",
                ReassignTo    = openItemsReassignContact,
                MoveToAccount = false
            };
            arguments.Items.Add(moveOption);

            //Literature Requests Options
            moveOption = new MoveItemOption
            {
                Entity           = "LitRequest",
                OpenItemsOnly    = true,
                ClosedItemsOnly  = true,
                ReassignTo       = openItemsReassignContact,
                ReassignToClosed = closedItemsReassignContact,
                MoveToAccount    = false
            };
            arguments.Items.Add(moveOption);

            //Opportunity Options
            moveOption = new MoveItemOption
            {
                Entity           = "OpportunityContact",
                OpenItemsOnly    = true,
                ClosedItemsOnly  = true,
                ReassignTo       = openItemsReassignContact,
                ReassignToClosed = closedItemsReassignContact,
                MoveToAccount    = false
            };
            arguments.Items.Add(moveOption);

            //Sales Order Options
            moveOption = new MoveItemOption
            {
                Entity        = "SalesOrder",
                OpenItemsOnly = true,
                ReassignTo    = openItemsReassignContact,
                MoveToAccount = false
            };
            arguments.Items.Add(moveOption);

            //Ticket Options
            moveOption = new MoveItemOption
            {
                Entity        = "Ticket",
                ReassignTo    = openSupportItemsReassignContact,
                OpenItemsOnly = true,
                MoveToAccount = false
            };
            arguments.Items.Add(moveOption);
            //Return Options
            moveOption = new MoveItemOption
            {
                Entity        = "Return",
                ReassignTo    = openSupportItemsReassignContact,
                OpenItemsOnly = true,
                MoveToAccount = false
            };
            arguments.Items.Add(moveOption);
            //Contract Options
            moveOption = new MoveItemOption
            {
                Entity        = "Contract",
                ReassignTo    = openSupportItemsReassignContact,
                OpenItemsOnly = true,
                MoveToAccount = false
            };
            arguments.Items.Add(moveOption);

            Contact.MoveContact(arguments);

            // redirect back to page so new info can be displayed
            if (Contact.Id != null)
            {
                Response.Redirect(string.Format("Contact.aspx?entityId={0}", (Contact.Id)), false);
            }
        }
        catch (Exception ex)
        {
            string sSlxErrorId = null;
            var    sMsg        = ErrorHelper.GetClientErrorHtmlMessage(ex, ref sSlxErrorId);
            if (!string.IsNullOrEmpty(sSlxErrorId))
            {
                log.Error(ErrorHelper.AppendSlxErrorId("The call to SmartParts_Contact_MoveContact.cmdOK_Click failed", sSlxErrorId),
                          ex);
            }
            DialogService.ShowHtmlMessage(sMsg, ErrorHelper.IsDevelopmentContext() ? 600 : -1,
                                          ErrorHelper.IsDevelopmentContext() ? 800 : -1);
        }
    }