Example #1
0
        private void LoadClients()
        {
            bizMessage bizM       = new bizMessage();
            bizSetting bizS       = new bizSetting();
            int        MaxRecords = int.Parse(bizS.GetSetting("FindClient.MaxRecords"));

            bizClient biz = new bizClient();

            this.ucMessanger1.ClearMessages();
            if (Request.QueryString["gr"] == "ba")
            {
                int?records = 0;
                List <sp_engage_search_clientResult> clients = biz.FindClientInBA(Request.QueryString["sc"]
                                                                                  , Request.QueryString["f1"]
                                                                                  , char.Parse(Request.QueryString["f2"])
                                                                                  , MaxRecords
                                                                                  , ref records);
                this.ucMessanger1.ProcessMessages(biz.MSGS, true);

                if (clients == null)
                {
                    return;
                }

                this.grvClientsBA.DataSource = clients;
                this.grvClientsBA.DataBind();
                this.lblResultCount.Text = clients.Count.ToString();
            }
            else
            {
                int?records = 0;
                List <sp_web_FindClientByFieldResult> clients = biz.FindClientByField(Request.QueryString["sc"]
                                                                                      , Request.QueryString["f1"]
                                                                                      , char.Parse(Request.QueryString["f2"])
                                                                                      , Request.QueryString["gr"]
                                                                                      , MaxRecords
                                                                                      , ref records);
                this.ucMessanger1.ProcessMessages(biz.MSGS, true);

                if (clients == null)
                {
                    return;
                }

                foreach (sp_web_FindClientByFieldResult c in clients)
                {
                    if (c.AccountExecutiveID != "")
                    {
                        using (Timeline.Capture("bizUser.GetAccountExecutive", "AD"))
                        {
                            var u = bizUser.GetSMIAccountExecutiveIdBOAMPSUserName(c.AccountExecutiveID);
                            bizUser.enGageUser exec = bizUser.GetAccountExecutive(u);
                            if (exec != null)
                            {
                                c.DisplayName = exec.DisplayName;
                            }
                            else
                            {
                                c.DisplayName = c.AccountExecutiveID;
                            }
                        }
                    }
                }
                this.grvClients.DataSource = clients;
                this.grvClients.DataBind();
                this.lblResultCount.Text = clients.Count.ToString();
            }

            this.lblSearch.Text      = Request.QueryString["sc"];
            this.btnBack.PostBackUrl = "FindClient.aspx?" +
                                       "sc=" + Request.QueryString["sc"] + "&" +
                                       "f1=" + Request.QueryString["f1"] + "&" +
                                       "f2=" + Request.QueryString["f2"];
        }
Example #2
0
        private void LoadClients()
        {
            bizMessage biz = new bizMessage();

            this.ucMessanger1.ClearMessages();
            this.txtSearchCriteria.CssClass = "control";
            //this.ucMessanger1.UnmarkControls(); // todo: doesn't work
            this.grvClientsClientName.Visible = false;
            this.grvClientsAddress.Visible    = false;
            this.grvClientsIndustry.Visible   = false;

            if (this.txtSearchCriteria.Text == "")
            {
                this.ucMessanger1.ProcessMessage(biz.GetMessageText("EmptyField"), Enums.enMsgType.Err, "SearchCriteria", typeof(TextBox), false);
                return;
            }

            bizSetting bizS       = new bizSetting();
            int        MaxRecords = int.Parse(bizS.GetSetting("FindClient.MaxRecords"));

            bizClient bizC    = new bizClient();
            int?      records = 0;
            List <sp_web_FindClientByFieldResult> clients = bizC.FindClientByField(this.txtSearchCriteria.Text
                                                                                   , this.ddlClient.SelectedValue
                                                                                   , char.Parse(this.ddlMatch.SelectedValue)
                                                                                   , null
                                                                                   , MaxRecords
                                                                                   , ref records);

            this.ucMessanger1.ProcessMessages(bizC.MSGS, true);

            if (clients == null)
            {
                return;
            }


            // get all users in AD

            var allusersResult = bizUser.GetUsersAccountExecutives(clients.Select <sp_web_FindClientByFieldResult, string>(x => x.AccountExecutiveID).Distinct().ToList());

            // change all clients
            clients.ForEach(
                x =>
            {
                if (x.AccountExecutiveID != "" && allusersResult.ContainsKey(x.AccountExecutiveID))
                {
                    bizUser.enGageUser exec = allusersResult[x.AccountExecutiveID];    //bizUser.GetAccountExecutive(x.AccountExecutiveID);
                    if (exec != null)
                    {
                        x.DisplayName = exec.DisplayName;
                    }
                    else
                    {
                        x.DisplayName = x.AccountExecutiveID;
                    }
                }
            }

                );

            List <sp_web_FindClientByFieldResult> cn  = clients.Where(c => c.Match == "client").ToList();
            List <sp_web_FindClientByFieldResult> add = clients.Where(c => c.Match == "address").ToList();
            List <sp_web_FindClientByFieldResult> ind = clients.Where(c => c.Match == "industry").ToList();

            if (records == 0)
            {
                this.btnAdd.Visible = true;

                this.tdHeaderCN.Visible  = false;
                this.tdFooterCN.Visible  = false;
                this.tdHeaderAD.Visible  = false;
                this.tdFooterAD.Visible  = false;
                this.tdHeaderIND.Visible = false;
                this.tdFooterIND.Visible = false;
                this.ucMessanger1.ProcessMessage("enGage: " + biz.GetMessageText("NoClientsFound"), Enums.enMsgType.Warn, "", null, false);
                // change the new postpack url
                btnAdd.PostBackUrl += "?name=" + HttpUtility.UrlEncode(this.txtSearchCriteria.Text);
                return;
            }

            if (records > 0 && records <= MaxRecords)
            {
                this.btnAdd.Visible = true;

                /*foreach (sp_web_FindClientByFieldResult c in cn)
                 * {
                 *  if (c.AccountExecutiveID != "")
                 *  {
                 *      bizUser.enGageUser exec = bizUser.GetAccountExecutive(c.AccountExecutiveID);
                 *      if (exec != null)
                 *          c.DisplayName = exec.DisplayName;
                 *      else
                 *          c.DisplayName = c.AccountExecutiveID;
                 *  }
                 * }
                 * foreach (sp_web_FindClientByFieldResult c in add)
                 * {
                 *  if (c.AccountExecutiveID != "")
                 *  {
                 *      bizUser.enGageUser exec = bizUser.GetAccountExecutive(c.AccountExecutiveID);
                 *      if (exec != null)
                 *          c.DisplayName = exec.DisplayName;
                 *      else
                 *          c.DisplayName = c.AccountExecutiveID;
                 *  }
                 * }
                 * foreach (sp_web_FindClientByFieldResult c in ind)
                 * {
                 *  if (c.AccountExecutiveID != "")
                 *  {
                 *      bizUser.enGageUser exec = bizUser.GetAccountExecutive(c.AccountExecutiveID);
                 *      if (exec != null)
                 *          c.DisplayName = exec.DisplayName;
                 *      else
                 *          c.DisplayName = c.AccountExecutiveID;
                 *  }
                 * }*/

                if (cn.Count == 0)
                {
                    this.tdHeaderCN.Visible           = false;
                    this.grvClientsClientName.Visible = false;
                    this.tdFooterCN.Visible           = false;
                }
                else
                {
                    this.lblResultCountCN.Text           = cn.Count.ToString();
                    this.lblSearchCN.Text                = this.txtSearchCriteria.Text;
                    this.tdHeaderCN.Visible              = true;
                    this.grvClientsClientName.DataSource = cn;
                    this.grvClientsClientName.DataBind();
                    this.grvClientsClientName.Visible = true;
                    this.tdFooterCN.Visible           = true;
                    this.lnkCN.Enabled = true;
                    if (cn.Count <= this.grvClientsClientName.PageSize)
                    {
                        this.lnkCN.Enabled = false;
                    }
                }
                if (add.Count == 0)
                {
                    this.tdHeaderAD.Visible        = false;
                    this.grvClientsAddress.Visible = false;
                    this.tdFooterAD.Visible        = false;
                }
                else
                {
                    this.lblResultCountAD.Text        = add.Count.ToString();
                    this.lblSearchAD.Text             = this.txtSearchCriteria.Text;
                    this.tdHeaderAD.Visible           = true;
                    this.grvClientsAddress.DataSource = add;
                    this.grvClientsAddress.DataBind();
                    this.grvClientsAddress.Visible = true;
                    this.tdFooterAD.Visible        = true;
                    this.lnkAD.Enabled             = true;
                    if (add.Count <= this.grvClientsAddress.PageSize)
                    {
                        this.lnkAD.Enabled = false;
                    }
                }
                if (ind.Count == 0)
                {
                    this.tdHeaderIND.Visible        = false;
                    this.grvClientsIndustry.Visible = false;
                    this.tdFooterIND.Visible        = false;
                }
                else
                {
                    this.lblResultCountIND.Text        = ind.Count.ToString();
                    this.lblSearchIND.Text             = this.txtSearchCriteria.Text;
                    this.tdHeaderIND.Visible           = true;
                    this.grvClientsIndustry.DataSource = ind;
                    this.grvClientsIndustry.DataBind();
                    this.grvClientsIndustry.Visible = true;
                    this.tdFooterIND.Visible        = true;
                    this.lnkIND.Enabled             = true;
                    if (ind.Count <= this.grvClientsIndustry.PageSize)
                    {
                        this.lnkIND.Enabled = false;
                    }
                }

                if (records == MaxRecords)
                {
                    this.ucMessanger1.ProcessMessage("enGage: " + biz.GetMessageText("MaxClientsReached"), Enums.enMsgType.Warn, "", null, false);
                }

                return;
            }
            if (records > MaxRecords)
            {
                this.btnAdd.Visible = false;

                this.tdHeaderCN.Visible  = false;
                this.tdFooterCN.Visible  = false;
                this.tdHeaderAD.Visible  = false;
                this.tdFooterAD.Visible  = false;
                this.tdHeaderIND.Visible = false;
                this.tdFooterIND.Visible = false;
                this.ucMessanger1.ProcessMessage("enGage: " + biz.GetMessageText("TooManyClientsFound"), Enums.enMsgType.Warn, "", null, false);
                return;
            }
        }