예제 #1
0
        private void PopulateDataGrid()
        {
            {
                // Hide Controls
                this.dvEmptyContent.Visible   = false;
                this.dvDataContent.Visible    = false;
                this.dvNoSearchResult.Visible = false;

                // Search text
                string searchText = this.txtSearch.Text.ToLower().Trim();

                // Populate Items
                ClientBO objClient = new ClientBO();

                if (LoggedUser.IsDirectSalesPerson)
                {
                    objClient.Distributor = this.Distributor.ID;
                }
                else if (LoggedUserRoleName == UserRole.DistributorAdministrator || LoggedUserRoleName == UserRole.DistributorCoordinator)
                {
                    objClient.Distributor = this.LoggedCompany.ID;
                }

                List <ClientBO> lstClients;
                if ((searchText != string.Empty) && (searchText != "search"))
                {
                    lstClients = (from o in objClient.SearchObjects().ToList()
                                  where o.Name.ToLower().Contains(searchText) ||
                                  (o.Description != null ? o.Description.ToLower().Contains(searchText) : false)
                                  select o).ToList();
                }
                else
                {
                    lstClients = objClient.SearchObjects().ToList();
                }

                if (lstClients.Count > 0)
                {
                    this.RadGridClient.AllowPaging = (lstClients.Count > this.RadGridClient.PageSize);
                    this.RadGridClient.DataSource  = lstClients;
                    this.RadGridClient.DataBind();
                    Session["ClientDetails"] = lstClients;

                    this.dvDataContent.Visible = true;
                }
                else if ((searchText != string.Empty && searchText != "search"))
                {
                    this.lblSerchKey.Text = searchText + ((searchText != string.Empty) ? " - " : string.Empty);

                    this.dvDataContent.Visible    = true;
                    this.dvNoSearchResult.Visible = true;
                }
                else
                {
                    this.dvEmptyContent.Visible = true;
                    this.btnAddClient.Visible   = false;
                }

                this.RadGridClient.Visible = (lstClients.Count > 0);
            }
        }
예제 #2
0
        /// <summary>
        /// Populate the controls.
        /// </summary>
        private void PopulateControls()
        {
            ViewState["isPopulate"] = false;
            //Header Text
            this.litHeaderText.Text = ((this.QueryID > 0) ? "Edit " : "New ") + this.ActivePage.Heading;

            // Popup Header Text
            this.lblPopupHeaderText.Text = "New Client Type";

            // Populate IsDestributors
            //this.ddlCompany.Items.Add(new ListItem("Select Distributor", "0"));
            //CompanyBO objCompany = new CompanyBO();
            //objCompany.IsDistributor = true;

            //List<CompanyBO> lstCompany = new List<CompanyBO>();
            //lstCompany = (from o in objCompany.SearchObjects().OrderBy(m => m.Name).AsQueryable().ToList<CompanyBO>()
            //              where o.IsDistributor == true
            //              select o).ToList();
            //foreach (CompanyBO company in lstCompany)
            //{
            //    this.ddlCompany.Items.Add(new ListItem(company.Name, company.ID.ToString()));
            //}

            //Populate Clients
            this.ddlClient.Items.Add(new ListItem("Select Client", "0"));

            ClientBO objClient = new ClientBO();

            if (LoggedUser.IsDirectSalesPerson)
            {
                objClient.Distributor = DistributorID;
            }
            else if (LoggedUserRoleName == UserRole.DistributorAdministrator || LoggedUserRoleName == UserRole.DistributorCoordinator)
            {
                objClient.Distributor = LoggedCompany.ID;
            }

            List <ClientBO> lstClient = (from o in objClient.SearchObjects().OrderBy(m => m.Name).AsQueryable().ToList <ClientBO>()
                                         select o).ToList();

            foreach (ClientBO client in lstClient)
            {
                this.ddlClient.Items.Add(new ListItem(client.Name, client.ID.ToString()));
            }

            // Populate CountryBO
            this.ddlCountry.Items.Add(new ListItem("Select Your Country"));
            List <CountryBO> lstCountry = (new CountryBO()).GetAllObject().AsQueryable().OrderBy("ShortName").ToList();

            foreach (CountryBO country in lstCountry)
            {
                this.ddlCountry.Items.Add(new ListItem(country.ShortName, country.ID.ToString()));
            }

            // If QueryId is grater than zero, edit mode.
            if (this.QueryID > 0)
            {
                JobNameBO objJobName = new JobNameBO(this.ObjContext);
                objJobName.ID = this.QueryID;
                objJobName.GetObject();

                this.ddlClient.SelectedValue = objJobName.Client.ToString();
                this.txtName.Text            = objJobName.Name;
                this.txtAddress1.Text        = objJobName.Address;
                this.txtCity.Text            = objJobName.City;
                this.txtState.Text           = objJobName.State;
                this.txtPostalCode.Text      = objJobName.PostalCode;
                if (!string.IsNullOrEmpty(objJobName.Country))
                {
                    this.ddlCountry.Items.FindByText(objJobName.Country).Selected = true; //.SelectedItem.Text = objJobName.Country;
                }
                this.txtPhoneNo1.Text     = objJobName.Phone;
                this.txtEmailAddress.Text = objJobName.Email;
            }
            else
            {
                this.ddlCountry.Items.FindByValue("14").Selected = true;
            }
        }