예제 #1
0
        private void btnAddCompany_Click(object sender, EventArgs e)
        {
            //if (UserOnWorkMode) {
            //    MessageBox.Show("You are currently working on a company. Please kindly close it first before selecting new companies.", "Bright Sales", MessageBoxButtons.OK, MessageBoxIcon.Information);
            //    return;
            //}

            WaitDialog.Show(ParentForm, "Loading components...");
            AddSubCampaignAccount _ucSubCampaignAccount = new AddSubCampaignAccount();
            _ucSubCampaignAccount.cmdAddToSubCampaign_OnClick += new AddSubCampaignAccount.cmdAddToSubCampaignOnClickHandler(_ucSubCampaignAccount_cmdAddToSubCampaign_OnClick);
            PopupDialog _dlgPopup = new PopupDialog();
            //_ucSubCampaignAccount.CampaignListModule = this;
            _dlgPopup.FormBorderStyle = FormBorderStyle.FixedSingle;
            _dlgPopup.MinimizeBox = false;
            _dlgPopup.MaximizeBox = false;
            _dlgPopup.StartPosition = FormStartPosition.CenterScreen;
            _dlgPopup.Text = "Add Companies";
            _dlgPopup.Controls.Add(_ucSubCampaignAccount);
            _dlgPopup.ClientSize = new Size(_ucSubCampaignAccount.Width + 2, _ucSubCampaignAccount.Height + 2);
            WaitDialog.Close();
            _dlgPopup.ShowDialog(this.ParentForm);
        }
예제 #2
0
        private void _ucSubCampaignAccount_cmdAddToSubCampaign_OnClick(object sender, AddSubCampaignAccount.AddSubCampaignAccountEventArgs e)
        {
            /**
             * process accounts and contacts to be added to sub-campaign
             */
            List<int> _ToAddAcctIds = new List<int>();
            List<int> _ToAddContactIds = new List<int>();
            List<AccountContactIds> _lstSubCampaignContactIds = new List<AccountContactIds>();
            bool _PerformGridUpdate = false;

            using (BrightPlatformEntities _efDbModel = new BrightPlatformEntities(UserSession.EntityConnection)) {
                m_FinalListId = (int)_efDbModel.final_lists.FirstOrDefault(i => i.sub_campaign_id == SubCampaignId).id;

                /**
                 * get the list of account contacts when view mode is in company mode only
                 */
                //if (CampaignListMode == CampaignList.eCampaignListMode.CompaniesOnly) {
                _lstSubCampaignContactIds = (
                    from _efeSubCampaignContactList in _efDbModel.sub_campaign_contact_lists
                    join _efeAccountContact in _efDbModel.account_contacts on _efeSubCampaignContactList.contact_id equals _efeAccountContact.contact_id
                    where _efeSubCampaignContactList.final_list_id == m_FinalListId
                    select new AccountContactIds {
                        AccountId = _efeAccountContact.account_id,
                        ContactId = _efeSubCampaignContactList.contact_id
                    }
                ).ToList();
                //}

                foreach (int _AcctId in e.lstAcctIds) {
                    /**
                     * if account does not exist, add to list.
                     */

                    /*
                     * https://brightvision.jira.com/browse/PLATFORM-2583
                     * DAN: Commented as to allow adding of account even if CampaignListMode is Companies and Contacts
                     *
                    */
                    //if (m_BrightSalesProperty.CampaignList.CampaignListMode == SelectionProperty.CampaignListMode.CompaniesOnly)
                        if (_efDbModel.sub_campaign_account_lists.FirstOrDefault(i =>
                            i.final_list_id == m_FinalListId &&
                            i.account_id == _AcctId) == null)
                            _ToAddAcctIds.Add(_AcctId);

                    /**
                     * contacts per account.
                     */
                    List<int> _lstContactIds = (
                        from _efAcctContact in _efDbModel.account_contacts
                        where _efAcctContact.account_id == _AcctId
                        select _efAcctContact.contact_id
                    ).ToList();

                    /**
                     * check if contact exist, if not, add to list.
                     */
                    foreach (int _ContactId in _lstContactIds) {
                        if (_lstSubCampaignContactIds.Find(i => i.AccountId == _AcctId && i.ContactId == _ContactId) == null)
                            if (_efDbModel.contacts.FirstOrDefault(i => i.id == _ContactId && i.active) != null)
                                _ToAddContactIds.Add(_ContactId);
                    }
                }
            }

            if (_ToAddAcctIds.Count > 0) {
                ObjectCallList.AddCompaniesToSubCampaign(_ToAddAcctIds, SubCampaignId, string.Format("Added by {0}", UserSession.CurrentUser.UserFullName));
                _PerformGridUpdate = true;
            }

            if (_ToAddContactIds.Count > 0) {
                ObjectCallList.AddContactsToSubCampaign(_ToAddContactIds, SubCampaignId);
                _PerformGridUpdate = true;
            }

            if (_PerformGridUpdate) {
                cbxFilterMeLastUser.Checked = false;
                cbxShowOnlyNonFinished.Checked = false;
                m_DoneLoadingCampaignList = false;
                //m_ChangingCampaignList = true;
                this.LoadCampaignList(eCampaignListLoadCallee.AddAccount);
                //m_ChangingCampaignList = false;
                m_DoneLoadingCampaignList = true;
            }
        }
예제 #3
0
 private void cmdAddCompany_Click(object sender, EventArgs e)
 {
     WaitDialog.Show(ParentForm, "Loading...");
     AddSubCampaignAccount _ucSubCampaignAccount = new AddSubCampaignAccount();
     PopupDialog _dlgPopup = new PopupDialog();
     //_ucSubCampaignAccount.ParentController = this;
     _dlgPopup.FormBorderStyle = FormBorderStyle.FixedSingle;
     _dlgPopup.MinimizeBox = false;
     _dlgPopup.MaximizeBox = false;
     _dlgPopup.StartPosition = FormStartPosition.CenterScreen;
     _dlgPopup.Text = "Add Companies";
     _dlgPopup.Controls.Add(_ucSubCampaignAccount);
     _dlgPopup.ClientSize = new Size(_ucSubCampaignAccount.Width + 2, _ucSubCampaignAccount.Height + 2);
     WaitDialog.Close();
     _dlgPopup.ShowDialog(this.ParentForm);
 }