Ejemplo n.º 1
0
        private void PopulateClientDetails()
        {
            bizMessage bizM = new bizMessage();
            bizSetting bizS = new bizSetting();

            bizClient biz = new bizClient();
            Client    c;

            c = biz.GetClient(Convert.ToInt32(Request.QueryString["cid"]));
            this.ucMessanger1.ProcessMessages(biz.MSGS, true);

            if (c == null)
            {
                return;
            }

            //general
            this.lblClientName.Text       = c.ClientName;
            this.lblOfficeFacsimilie.Text = c.OfficeFacsimilie;
            this.lblOfficePhone.Text      = c.OfficePhone;

            //address
            this.lblAddress.Text = c.Address + ", " + c.Location + " " + c.StateCode + " " + c.PostCode;

            //executive
            var u = bizUser.GetSMIAccountExecutiveIdBOAMPSUserName(c.AccountExecutiveID);

            bizUser.enGageUser exec = bizUser.GetAccountExecutive(u);
            this.ucMessanger1.ProcessMessages(biz.MSGS, false);
            this.lblAccountExecutive.Text = "<b>" + exec.DisplayName + "</b>" + ", " + exec.Branch + " (" + exec.Region + ")";

            //open opportunities
            List <sp_web_ListClientOpenOpportunitiesResult> ooppos = biz.ListClientOpenOpportunities(c.ClientID);

            this.ucMessanger1.ProcessMessages(biz.MSGS, false);
            this.grvOpenOpportunities.DataSource = ooppos;
            this.grvOpenOpportunities.DataBind();
            this.lblOpenOpportunities.Text = ooppos.Count.ToString();

            //open opportunities
            List <sp_web_ListClientClosedOpportunitiesResult> coppos = biz.ListClientClosedOpportunities(c.ClientID);

            this.ucMessanger1.ProcessMessages(biz.MSGS, false);
            this.grvClosedOpportunities.DataSource = coppos;
            this.grvClosedOpportunities.DataBind();
            this.lblClosedOpportunities.Text = coppos.Count.ToString();

            //buttons
            this.btnBack.PostBackUrl = "ViewClient.aspx?cid=" + c.ClientID.ToString();
        }
Ejemplo n.º 2
0
        private void PopulateClientDetails()
        {
            bizMessage bizM = new bizMessage();
            bizSetting bizS = new bizSetting();

            bizClient biz = new bizClient();
            Client    c;

            c = biz.GetClient(Convert.ToInt32(Request.QueryString["cid"]));
            this.ucMessanger1.ProcessMessages(biz.MSGS, true);

            if (c == null)
            {
                return;
            }

            //general
            this.lblClientCode.Text     = c.ClientCode;
            this.lblClientName.Text     = c.ClientName;
            this.lblRegisteredName.Text = c.RegisteredName;
            this.lblInsuredName.Text    = c.InsuredName;
            if (c.ABNACN != null)
            {
                this.lblABNACN.Text = c.ABNACN;
            }
            this.lblSource.Text           = c.Source;
            this.lblOfficeFacsimilie.Text = c.OfficeFacsimilie;
            this.lblOfficePhone.Text      = c.OfficePhone;

            //address
            if (c.Address == null)
            {
                this.lblAddress.Text     = "no address";
                this.lblAddress.CssClass = "page-text-nodata";
            }
            else
            {
                this.lblAddress.Text = c.Address + ", " + c.Location + " " + c.StateCode + " " + c.PostCode;
            }

            //industry
            if (c.AnzsicCode != null)
            {
                this.lblIndustry.Text = c.Industry.IndustryName + " (" + c.Industry.AnzsicCode + ")";
            }
            if (c.AssociationCode != null)
            {
                this.lblAssociationName.Text         = c.Association.AssociationName;
                this.lblAssociationMemberNumber.Text = c.AssociationMemberNumber;
            }

            //executive
            var u = bizUser.GetSMIAccountExecutiveIdBOAMPSUserName(c.AccountExecutiveID);

            bizUser.enGageUser exec = bizUser.GetAccountExecutive(u);
            this.ucMessanger1.ProcessMessages(biz.MSGS, false);
            if (exec != null)
            {
                this.lblAccountExecutive.Text = "<b>" + exec.DisplayName + "</b>" + ", " + exec.Branch + " (" + exec.Region + ")";
            }
            else
            {
                this.lblAccountExecutive.Text = "<b>" + c.AccountExecutiveID + "</b>" + ", Unknown Branch (Unknown Region)";
            }
            //contacts
            bizContact     bizC = new bizContact();
            List <Contact> cons = c.Contacts.Where(co => co.Inactive == false).ToList();

            this.grvContacts.DataSource = cons;
            this.ucMessanger1.ProcessMessages(bizC.MSGS, false);
            this.grvContacts.DataBind();
            this.lblActiveContacts.Text   = cons.Count.ToString();
            this.lblInactiveContacts.Text = (c.Contacts.Count - cons.Count).ToString();

            //opportunities
            List <sp_web_ListClientOpenOpportunitiesResult> oppos = biz.ListClientOpenOpportunities(c.ClientID);

            this.grvOpportunities.DataSource = oppos;
            this.ucMessanger1.ProcessMessages(bizC.MSGS, false);
            this.grvOpportunities.DataBind();
            this.lblOpenOpportunities.Text = oppos.Count.ToString();
            List <sp_web_ListClientClosedOpportunitiesResult> coppos = biz.ListClientClosedOpportunities(c.ClientID);

            this.lblClosedOpportunities.Text = (coppos.Count).ToString();

            //audit
            ((Main)Master).HeaderDetails = "Client added by "
                                           + bizActiveDirectory.GetUserFullName(c.AddedBy)
                                           + " (" + string.Format("{0:dd-MMM-yy}", c.Added) + ")";

            if (c.Modified.HasValue == true)
            {
                ((Main)Master).HeaderDetails += " / modified by "
                                                + bizActiveDirectory.GetUserFullName(c.ModifiedBy)
                                                + " (" + string.Format("{0:dd-MMM-yy}", c.Modified.Value) + ")";
            }

            //buttons
            this.hplContactsSeeAll.NavigateUrl = "ClientContactsAll.aspx?cid=" + c.ClientID.ToString();
            if (c.Contacts.Count - cons.Count == 0)
            {
                this.hplContactsSeeAll.Enabled = false;
            }
            this.hplOpportunitiesSeeAll.NavigateUrl = "ClientOpportunitiesAll.aspx?cid=" + c.ClientID.ToString();
            if (coppos.Count == 0)
            {
                this.hplOpportunitiesSeeAll.Enabled = false;
            }
            this.btnAddContact.PostBackUrl     = "AddContact.aspx?cid=" + c.ClientID.ToString();
            this.btnAddOpportunity.PostBackUrl = "AddOpportunity.aspx?cid=" + c.ClientID.ToString();
            if (c.Inactive == true)
            {
                this.lblClientName.Enabled       = false;
                this.lblOfficePhone.Enabled      = false;
                this.lblAddress.Enabled          = false;
                this.lblOfficeFacsimilie.Enabled = false;
                this.btnAddContact.Enabled       = false;
                this.btnAddOpportunity.Enabled   = false;
                this.btnActiveInactive.Text      = "Activate";
                this.btnEditClient.Enabled       = false;
            }
            else
            {
                this.lblClientName.Enabled       = true;
                this.lblOfficePhone.Enabled      = true;
                this.lblAddress.Enabled          = true;
                this.lblOfficeFacsimilie.Enabled = true;
                this.btnAddContact.Enabled       = true;
                this.btnAddOpportunity.Enabled   = true;
                this.btnActiveInactive.Text      = "Inactivate";
                this.btnEditClient.Enabled       = true;
            }
            this.btnEditClient.PostBackUrl = "EditClient.aspx?cid=" + c.ClientID.ToString();
            this.btnTransfer.PostBackUrl   = "TransferClient.aspx?cid=" + c.ClientID.ToString();

            // SECURITY
            //sp_web_GetUserByIDResult exec = biz.GetAccountExecutive(c.AccountExecutiveID);
            //this.ucMessanger1.ProcessMessages(biz.MSGS, false);
            bizUser.enGageUser user = (bizUser.enGageUser)Session["USER"];
            switch (user.Role)
            {
            case (int)Enums.enUserRole.Executive:
                if (user.Branch == exec.Branch)
                {
                    if (exec == null)
                    {
                    }
                    else if (user.DisplayName != exec.DisplayName)
                    {
                        DisableButtons();
                        DisableGrids();
                    }
                }
                else
                {
                    Response.Redirect("~/FindClient.aspx", false);
                    return;
                }
                break;

            case (int)Enums.enUserRole.Branch:
                if (exec == null)
                {
                }
                else if (user.Branch == exec.Branch)
                {
                    if (user.DisplayName != exec.DisplayName)
                    {
                        //DisableButtons();
                        //DisableGrids();
                    }
                }
                else
                {
                    Response.Redirect("~/FindClient.aspx", false);
                    return;
                }
                break;

            case (int)Enums.enUserRole.Region:
                if (exec == null)
                {
                    DisableButtons();
                    DisableGrids();
                }
                else if (user.Region == exec.Region)
                {
                    if (user.DisplayName != exec.DisplayName)
                    {
                        DisableButtons();
                        DisableGrids();
                    }
                }
                else
                {
                    Response.Redirect("~/FindClient.aspx", false);
                    return;
                }
                break;

            case (int)Enums.enUserRole.Company:
                if (exec == null)
                {
                    DisableButtons();
                    DisableGrids();
                }
                else if (user.DisplayName != exec.DisplayName)
                {
                    DisableButtons();
                    DisableGrids();
                }
                break;

            case (int)Enums.enUserRole.Administrator:
                // full access
                break;
            }
        }