Exemple #1
0
        void SendEmail()
        {
            var rows = (ICollection <CrmCampaignMemberClient>)dgEmailList.GetVisibleRows();

            if (rows.Count == 0)
            {
                return;
            }

            var cwSendEmail = new CwSendEmail(api);

            cwSendEmail.Closed += async delegate
            {
                if (cwSendEmail.DialogResult == true && cwSendEmail.CompanySMTP != null)
                {
                    var        crmAPI = new CrmAPI(api);
                    ErrorCodes res;
                    if (cwSendEmail.SendTestEmail)
                    {
                        res = await crmAPI.SendMailTest(cwSendEmail.CompanySMTP, cwSendEmail.Email, cwSendEmail.Name);
                    }
                    else
                    {
                        res = await crmAPI.SendMail(cwSendEmail.CompanySMTP, rows, cwSendEmail.FollowUp);
                    }
                    UtilDisplay.ShowErrorCode(res);
                }
            };
            cwSendEmail.Show();
        }
Exemple #2
0
        void localMenu_OnItemClicked(string ActionType)
        {
            var selectedItem = dgCrmCampaignGrid.SelectedItem as CrmCampaignClient;

            switch (ActionType)
            {
            case "AddRow":
                object[] param = new object[2];
                param[0] = api;
                param[1] = null;
                AddDockItem(TabControls.CrmCampaignPage2, param, Uniconta.ClientTools.Localization.lookup("Campaign"), "Add_16x16.png");
                break;

            case "EditRow":
                if (selectedItem != null)
                {
                    string header = string.Format("{0}:{1}", Uniconta.ClientTools.Localization.lookup("Campaign"), selectedItem.Name);
                    AddDockItem(TabControls.CrmCampaignPage2, selectedItem, header);
                }
                break;

            case "AddNote":
                if (selectedItem != null)
                {
                    AddDockItem(TabControls.UserNotesPage, dgCrmCampaignGrid.syncEntity);
                }
                break;

            case "AddDoc":
                if (selectedItem != null)
                {
                    AddDockItem(TabControls.UserDocsPage, dgCrmCampaignGrid.syncEntity, string.Format("{0}: {1}", Uniconta.ClientTools.Localization.lookup("Documents"), selectedItem._Name));
                }
                break;

            case "CreateEmailList":
                if (selectedItem == null)
                {
                    return;
                }
                var createTitle = string.Format(Uniconta.ClientTools.Localization.lookup("CreateOBJ"), Uniconta.ClientTools.Localization.lookup("EmailList"));
                AddDockItem(TabControls.CreateEmailListPage, selectedItem, string.Format("{0}:{2} {1:g}", createTitle, selectedItem.Created, Uniconta.ClientTools.Localization.lookup("Campaign")));
                break;

            case "ShowEmailList":
                if (selectedItem == null)
                {
                    return;
                }
                var showTitle = string.Format(Uniconta.ClientTools.Localization.lookup("showOBJ"), Uniconta.ClientTools.Localization.lookup("EmailList"));
                AddDockItem(TabControls.EmailListPage, selectedItem, string.Format("{0}:{2} {1:g}", showTitle, selectedItem.Created, Uniconta.ClientTools.Localization.lookup("Campaign")));
                break;

            case "DeleteEmailList":
                if (selectedItem != null)
                {
                    DeleteEmailList(selectedItem);
                }
                break;

            case "FollowUp":
                if (selectedItem != null)
                {
                    var header = string.Format("{0}:{2} {1}", Uniconta.ClientTools.Localization.lookup("FollowUp"), selectedItem._Name, Uniconta.ClientTools.Localization.lookup("Campaign"));
                    AddDockItem(TabControls.CrmFollowUpPage, dgCrmCampaignGrid.syncEntity, header);
                }
                break;

            case "AddFollowUp":
                if (selectedItem == null)
                {
                    return;
                }
                object[] fuParam = new object[2];
                fuParam[0] = api;
                fuParam[1] = selectedItem;
                AddDockItem(TabControls.CrmCampaignFollowUp, fuParam, true, String.Format(Uniconta.ClientTools.Localization.lookup("AddOBJ"), Uniconta.ClientTools.Localization.lookup("FollowUp")), "Add_16x16.png");
                break;

            case "SendEmail":
                if (selectedItem == null)
                {
                    return;
                }
                var cwSendEmail = new CwSendEmail(api);
                cwSendEmail.ShowAttachments();
                cwSendEmail.Closed += async delegate
                {
                    if (cwSendEmail.DialogResult == true && cwSendEmail.CompanySMTP != null)
                    {
                        var        crmAPI = new CrmAPI(api);
                        ErrorCodes res;
                        if (cwSendEmail.SendTestEmail)
                        {
                            res = await crmAPI.SendMailTest(cwSendEmail.CompanySMTP, cwSendEmail.Email, cwSendEmail.Name, selectedItem, cwSendEmail.IncludeAttachements);
                        }
                        else
                        {
                            res = await crmAPI.SendMail(cwSendEmail.CompanySMTP, selectedItem, cwSendEmail.FollowUp, cwSendEmail.IncludeAttachements);
                        }
                        UtilDisplay.ShowErrorCode(res);
                    }
                };
                cwSendEmail.Show();
                break;

            default:
                gridRibbon_BaseActions(ActionType);
                break;
            }
        }