Esempio n. 1
0
    private void LoadProductDetails()
    {
        LinqToSqlDataContext db = new LinqToSqlDataContext();

        if (this.CategoryID == 0)
        {
            return;
        }

        // show arc description
        arcDescription = (from a in db.ARCs

                          where a.ARCId == Convert.ToInt32(Session[enumSessions.ARC_Id.ToString()].ToString())
                          select a.Description
                          ).SingleOrDefault();

        var products       = db.USP_GetProductsByCategoryAndArc(CategoryID, Convert.ToInt32(Session[enumSessions.ARC_Id.ToString()].ToString()));
        var uniqueProducts = products.GroupBy(x => x.ProductCode).Select(g => g.First());  // product name should be same- so grouping the product by using product names and selecting only one.

        dlProducts.DataSource = uniqueProducts;

        // dlProducts.DataSource =  db.USP_GetProductsByCategoryAndArc(CategoryID, Convert.ToInt32(Session[enumSessions.ARC_Id.ToString()].ToString()));
        dlProducts.DataBind();


        var categoryName = (from cats in db.Categories
                            where cats.CategoryId == CategoryID
                            select cats.CategoryName).Single <string>();

        lblCategoryName.Text = categoryName.ToString();


        db.Dispose();
    }
Esempio n. 2
0
    // void displayManufacturerRadioButtons(RadioButtonList rdbCompanies, int productID)
    //  void displayManufacturerRadioButtons(RadioButtonList rdbCompanies)
    void displayManufacturerRadioButtons(RadioButtonList rdbCompanies, string productCode)
    {
        LinqToSqlDataContext db = new LinqToSqlDataContext();

        var Products    = db.USP_GetProductsByCategoryAndArc(CategoryID, Convert.ToInt32(Session[enumSessions.ARC_Id.ToString()].ToString())).ToList();
        var dccProducts = Products.Where(d => d.IsDCC == true).ToList(); //get only DCC Products


        if (dccProducts != null && dccProducts.Count > 0)
        {
            rdbCompanies.Visible = true;

            for (int i = 0; i < rdbCompanies.Items.Count; i++)
            {
                rdbCompanies.Items[i].Attributes.Add("style", "visibility:hidden");//change made by Priya
            }

            foreach (var dccProduct in dccProducts)
            {
                if (dccProduct.IsDCC == true && dccProduct.ProductCode == productCode)
                // if (dccProduct.IsDCC == true)
                {
                    string dccProductCode = (from p in db.Products
                                             where p.ProductId == dccProduct.ProductId
                                             select p.ProductCode).SingleOrDefault();

                    string DCC_Companyname = (from dcc in db.DCCCompanies
                                              where dcc.Productcode.Contains(dccProductCode)
                                              select dcc.company_name).SingleOrDefault();


                    for (int i = 0; i < rdbCompanies.Items.Count; i++)
                    {
                        if (String.Equals(rdbCompanies.Items[i].Text, rdbCompanies.Items[0].Text))
                        {
                            rdbCompanies.Items[i].Attributes.Add("style", "visibility:visible");
                        }
                        else if (String.Equals(rdbCompanies.Items[i].Text, DCC_Companyname))
                        {
                            rdbCompanies.Items[i].Attributes.Add("style", "visibility:visible");
                        }
                    }
                }
            }
        }
        db.Dispose();
    }
Esempio n. 3
0
        public static List <CategoryDTO> GetCategoriesByArcId(int ARCId)
        {
            List <CategoryDTO> lstCategories = new List <CategoryDTO>();

            try
            {
                LinqToSqlDataContext db = new LinqToSqlDataContext();
                var cats = from categories in db.Categories
                           join arcCat in db.ARC_Category_Maps on categories.CategoryId equals arcCat.CategoryId
                           where
                           (
                    (categories.IsDeleted == false)
                    &&
                    (arcCat.ARCId == ARCId)
                           )
                           orderby categories.ListOrder, categories.CategoryName
                    select new { Code = categories.CategoryCode, Title = categories.CategoryName, categories.CategoryId, categories.DefaultImage, categories.CategoryDesc };


                foreach (var category in cats)
                {
                    var prods = db.USP_GetProductsByCategoryAndArc(category.CategoryId, ARCId);
                    if (prods != null && prods.Count() > 0)
                    {
                        CategoryDTO cat = new CategoryDTO();
                        cat.CategoryCode         = category.Code;
                        cat.CategoryID           = category.CategoryId;
                        cat.CategoryName         = category.Title;
                        cat.CategoryDefaultImage = category.DefaultImage;
                        cat.CategoryDesc         = category.CategoryDesc;
                        lstCategories.Add(cat);
                    }
                }

                db.Dispose();
            }
            catch (Exception objException)
            {
                CSLOrderingARCBAL.LinqToSqlDataContext db;
                db = new CSLOrderingARCBAL.LinqToSqlDataContext();
                db.USP_SaveErrorDetails("Category BAL", "GetCategoriesByArcId", Convert.ToString(objException.Message), Convert.ToString(objException.InnerException), Convert.ToString(objException.StackTrace), String.Empty, String.Empty, false, null);
            }
            return(lstCategories);
        }
Esempio n. 4
0
    private void LoadProductDetails()
    {
        if (this.CategoryID == 0)
        {
            return;
        }

        LinqToSqlDataContext db = new LinqToSqlDataContext();

        dlProducts.DataSource = db.USP_GetProductsByCategoryAndArc(CategoryID, Convert.ToInt32(Session[enumSessions.ARC_Id.ToString()].ToString()));
        dlProducts.DataBind();
        db.Dispose();

        db = new LinqToSqlDataContext();
        var categoryName = (from cats in db.Categories
                            where cats.CategoryId == CategoryID
                            select cats.CategoryName).Single <string>();

        lblCategoryName.Text = categoryName.ToString();
        db.Dispose();
    }