Exemplo n.º 1
0
        //public DataTable CartProducts()
        //{
        //    BLL.BLL balobj = new BLL.BLL();
        //    DataSet ds = new DataSet();
        //    Cart cart = new Cart();

        //    DataTable dt = cart.itemTable();
        //    DataTable dtt = cart.ViewCartTable();
        //    DataTable dtt1 = cart.ViewCartTable();

        //    ds = balobj.Get_Products("");
        //    dt = HttpContext.Current.Session["Cart"] as DataTable;

        //    for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
        //    {
        //        dtt.Rows.Add(ds.Tables[0].Rows[i]["ProductID"].ToString(),
        //                   ds.Tables[0].Rows[i]["Productname"].ToString(),
        //                   GlobalVarables.Image_Url() + ds.Tables[0].Rows[i]["Product_ImgUrl"].ToString(),
        //                   "0",
        //                   ds.Tables[0].Rows[i]["DistributorPrice"].ToString(),
        //                   ds.Tables[0].Rows[i]["DistributorPrice"].ToString());
        //    }
        //    if (dt != null & dtt != null)
        //    {
        //        if (dt.Rows.Count > 0 & dtt.Rows.Count > 0)
        //        {
        //            var result = from dataRows1 in dtt.AsEnumerable()
        //                         join dataRows2 in dt.AsEnumerable()
        //                         on dataRows1.Field<string>("ProductID") equals dataRows2.Field<string>("Productid")
        //                         select dtt1.LoadDataRow(new object[]
        //                    {
        //                        dataRows1.Field<string>("ProductID"),
        //                        dataRows1.Field<string>("Productname"),
        //                        dataRows1.Field<string>("Product_ImgUrl"),
        //                        dataRows2.Field<string>("Quantity"),
        //                        dataRows1.Field<string>("Unitmrpprice"),
        //                        (Convert.ToDouble(dataRows2.Field<string>("Quantity")) * Convert.ToDouble(dataRows1.Field<string>("Unitmrpprice"))).ToString(),
        //                        dataRows2.Field<string>("Size"),
        //                        dataRows2.Field<string>("Color")
        //                    }, false);
        //            return result.CopyToDataTable();
        //        }
        //        else
        //            return dtt1;
        //    }
        //    else
        //        return dtt1;
        //}
        public DataTable CartProducts()
        {
            BLL.BLL balobj = new BLL.BLL();
            DataSet ds     = new DataSet();
            Cart    cart   = new Cart();

            DataTable dt   = cart.itemTable();
            DataTable dtt  = cart.ViewCartTable();
            DataTable dtt1 = cart.ViewCartTable();

            ds = balobj.Get_Products("");
            dt = HttpContext.Current.Session["Cart"] as DataTable;

            for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
            {
                dtt.Rows.Add(ds.Tables[0].Rows[i]["ProductID"].ToString(),
                             ds.Tables[0].Rows[i]["Productname"].ToString(),
                             GlobalVarables.Image_Url() + ds.Tables[0].Rows[i]["Product_ImgUrl"].ToString(),
                             "0",
                             ds.Tables[0].Rows[i]["DistributorPrice"].ToString(),
                             ds.Tables[0].Rows[i]["DistributorPrice"].ToString());
            }
            if (dt != null & dtt != null)
            {
                if (dt.Rows.Count > 0 & dtt.Rows.Count > 0)
                {
                    var result = from dataRows1 in dtt.AsEnumerable()
                                 join dataRows2 in dt.AsEnumerable()
                                 on dataRows1.Field <string>("ProductID") equals dataRows2.Field <string>("Productid")
                                 select dtt1.LoadDataRow(new object[]
                    {
                        dataRows1.Field <string>("ProductID"),
                        dataRows1.Field <string>("Productname"),
                        dataRows1.Field <string>("Product_ImgUrl"),
                        dataRows2.Field <string>("Quantity"),
                        dataRows1.Field <string>("Unitmrpprice"),
                        (Convert.ToDouble(dataRows2.Field <string>("Quantity")) * Convert.ToDouble(dataRows1.Field <string>("Unitmrpprice"))).ToString()
                    }, false);

                    return(result.CopyToDataTable());
                }
                else
                {
                    return(dtt1);
                }
            }
            else
            {
                return(dtt1);
            }
        }