Ejemplo n.º 1
0
        public int DeleteProduct(int Product_ID)
        {
            Ent_Product ent = new Ent_Product();

            ent.Product_ID = Product_ID;

            //HttpCookie UserID = Request.Cookies["User_ID"];
            //var UserId = UserID != null ? UserID.Value.Split('=')[1] : "";
            //ent.Modified_By = Convert.ToInt32(UserId);
            ent.Modified_By = 1;
            DateTime indianTime = TimeZoneInfo.ConvertTimeFromUtc(DateTime.UtcNow, INDIAN_ZONE);
            DateTime indiTime   = Convert.ToDateTime(indianTime.ToString("yyyy-MM-dd h:m:s"));

            ent.Modified_Date = indiTime;
            SafeTransaction trans = new SafeTransaction();
            int             i     = balProduct.DeleteProduct(ent, trans);

            if (i > 0)
            {
                trans.Commit();
            }
            else
            {
                trans.Rollback();
            }

            return(i);
        }
Ejemplo n.º 2
0
        public ActionResult AddProduct()
        {
            int ProductId = Request.QueryString["ProductId"] != null?Convert.ToInt32(Request.QueryString["ProductId"]) : 0;

            Ent_Product ent = new Ent_Product();

            List <Ent_Category> listCategory = new List <Ent_Category>();

            listCategory         = balCategory.SelectCategoryList(0, "");
            ViewBag.listCategory = listCategory;

            if (ProductId != 0)
            {
                ent = balProduct.SelectProduct(ProductId);

                List <Ent_SubCategory> listSubCategory = new List <Ent_SubCategory>();
                listSubCategory         = balCategory.SelectSubCategoryList(ent.Category_ID);
                ViewBag.listSubCategory = listSubCategory;
            }
            else
            {
                List <Ent_SubCategory> listSubCategory = new List <Ent_SubCategory>();
                listSubCategory         = balCategory.SelectSubCategoryList(listCategory[0].Category_ID);
                ViewBag.listSubCategory = listSubCategory;
            }

            List <Ent_Brand> listBrand = new List <Ent_Brand>();

            listBrand         = balMaster.SelectBrandList(0);
            ViewBag.listBrand = listBrand;

            return(View(ent));
        }
Ejemplo n.º 3
0
        public int DeleteProduct(Ent_Product ent, SafeTransaction trans)
        {
            int dataResult;

            try
            {
                Dal_Product dal = new Dal_Product();
                dataResult = dal.DeleteProduct(ent, trans);
                return(dataResult);
            }
            catch
            {
                return(-1);
            }
        }
Ejemplo n.º 4
0
        //Select Product By ID
        public Ent_Product SelectProduct(int productId)
        {
            Ent_Product result = new Ent_Product();

            try
            {
                Dal_Product dal = new Dal_Product();
                result = dal.SelectProduct(productId);
                return(result);
            }
            catch
            {
                return(result);
            }
        }
Ejemplo n.º 5
0
        public int SaveProduct(Ent_Product entGuest, SafeTransaction trans)
        {
            int dataResult = 0;

            try
            {
                Dal_Product dal = new Dal_Product();
                dataResult = dal.SaveProduct(entGuest, trans);
                return(dataResult);
            }
            catch
            {
                return(0);
            }
        }
Ejemplo n.º 6
0
        public List <Ent_Product> SelectProductFilter(int Category_ID, int SubCategory_ID, string condition)
        {
            List <Ent_Product> result = new List <Ent_Product>();
            Ent_Product        ent    = new Ent_Product();

            try
            {
                using (SqlCommand cmd = new SqlCommand("EC_SelectProductFilter", con))
                {
                    if (con.State == ConnectionState.Closed)
                    {
                        con.Open();
                    }
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.Add(new SqlParameter("@Category_ID", Category_ID));
                    cmd.Parameters.Add(new SqlParameter("@SubCategory_ID", SubCategory_ID));
                    cmd.Parameters.Add(new SqlParameter("@condition", condition));
                    IDataReader dr = cmd.ExecuteReader();
                    while (dr.Read())
                    {
                        ent                              = new Ent_Product();
                        ent.Product_ID                   = Convert.ToInt32(dr["Product_ID"]);
                        ent.Product_Name                 = Convert.ToString(dr["Product_Name"]);
                        ent.Product_SubText              = Convert.ToString(dr["Product_SubText"]);
                        ent.Category_ID                  = Convert.ToInt32(dr["Category_ID"]);
                        ent.entCategory.Category_Name    = Convert.ToString(dr["Category_Name"]);
                        ent.SubCategory_ID               = Convert.ToInt32(dr["SubCategory_ID"]);
                        ent.entSubCategory.Category_Name = Convert.ToString(dr["SubCategory_Name"]);
                        ent.Brand_ID                     = Convert.ToInt32(dr["Brand_ID"]);
                        ent.entBrand.Brand_Name          = Convert.ToString(dr["Brand_Name"]);
                        ent.Product_Description          = Convert.ToString(dr["Product_Description"]);
                        ent.Product_Price                = float.Parse(dr["Product_Price"].ToString());
                        ent.Product_Discount             = float.Parse(dr["Product_Discount"].ToString());
                        ent.Product_Image                = Convert.ToString(dr["Product_Image"]);
                        result.Add(ent);
                    }
                }
            }
            catch (Exception ex)
            {
                InsertException(ex.Message, "SelectProductList", Category_ID);
            }
            finally
            {
                con.Close();
            }
            return(result);
        }
Ejemplo n.º 7
0
        public ActionResult DeleteCart(int CartID)
        {
            List <Ent_OrderDetail> list = (List <Ent_OrderDetail>)Session["Cart"];
            Ent_Product            ent  = new Ent_Product();

            ent = balProduct.SelectProduct(CartID);
            var qty = list.Where(l => l.Product_ID == CartID).FirstOrDefault().Quantity;

            Session["Cart"] = list.Where(l => l.Product_ID != CartID).ToList <Ent_OrderDetail>();

            int count = list.Count - 1;

            Session["SubTotal"] = Convert.ToInt32(Session["SubTotal"]) - ((ent.Product_Price - ent.Product_Discount) * qty);
            Session["Total"]    = Convert.ToInt32(Session["Total"]) - ((ent.Product_Price - ent.Product_Discount) * qty);
            if (list.Count == 1)
            {
                Session["Cart"]     = null;
                Session["Total"]    = "0.00";
                Session["SubTotal"] = "0.00";
                Session["Shipping"] = "0.00";
            }

            HttpCookie Guest_ID = Request.Cookies["Guest_ID"];
            string     GuestID  = Guest_ID != null?Guest_ID.Value.Split('=')[1] : "";

            if (!string.IsNullOrEmpty(GuestID))
            {
                SafeTransaction trans  = new SafeTransaction();
                int             result = balOrder.DeleteCart(CartID, Convert.ToInt32(GuestID), trans);
                if (result > 0)
                {
                    trans.Commit();
                }
                else
                {
                    trans.Rollback();
                }
            }
            string[] Result = { count.ToString(), Session["Total"].ToString(), Session["SubTotal"].ToString() };

            return(Json(Result, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 8
0
        // GET: Category
        public int SaveProduct(Ent_Product model)
        {
            SafeTransaction trans      = new SafeTransaction();
            DateTime        indianTime = TimeZoneInfo.ConvertTimeFromUtc(DateTime.UtcNow, INDIAN_ZONE);
            DateTime        indiTime   = Convert.ToDateTime(indianTime.ToString("yyyy-MM-dd h:m:s"));

            model.Created_Date = indiTime;
            //HttpCookie C_UserID = Request.Cookies["User_ID"];
            //string User_ID = C_UserID != null ? C_UserID.Value.Split('=')[1] : "";
            //model.Created_By = Convert.ToInt32(User_ID);
            model.Created_By = 1;

            HttpFileCollectionBase files = Request.Files;

            if (files.Count > 0)
            {
                HttpPostedFileBase file = files["Product_ImageFile"];
                if (file != null)
                {
                    file.SaveAs(Server.MapPath("~/ProductImages/" + model.Product_Image));
                    model.Product_Image = model.Product_Image;
                }
            }
            else if (!System.IO.File.Exists(Server.MapPath("~/ProductImages/" + model.Product_Image)))
            {
                model.Product_Image = "";
            }
            int i = balProduct.SaveProduct(model, trans);

            if (i > 0)
            {
                trans.Commit();
            }
            else
            {
                trans.Rollback();
            }

            return(i);
        }
Ejemplo n.º 9
0
        public int DeleteProduct(Ent_Product ent, SafeTransaction trans)
        {
            int dataResult  = 0;
            int dataresult1 = 0;

            try
            {
                if (con.State == ConnectionState.Closed)
                {
                    con.Open();
                }
                using (SqlCommand cmd = new SqlCommand("EC_DeleteProduct", trans.DatabaseConnection, trans.Transaction))
                {
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.Add(new SqlParameter("@Product_ID", ent.Product_ID));
                    cmd.Parameters.Add(new SqlParameter("@Modified_By", ent.Modified_By));
                    cmd.Parameters.Add(new SqlParameter("@Modified_Date", ent.Modified_Date));
                    try
                    {
                        dataResult = Convert.ToInt32(cmd.ExecuteScalar());
                        cmd.Dispose();
                    }
                    catch (Exception e)
                    {
                        InsertException(e.Message, "DeleteProduct", ent.Product_ID);
                        dataResult = -1;
                    }
                }

                if (dataResult > 0)
                {
                    using (SqlCommand cmd = new SqlCommand("EC_InsertLog", trans.DatabaseConnection, trans.Transaction))
                    {
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.Parameters.Add(new SqlParameter("@Created_By", ent.Modified_By));
                        cmd.Parameters.Add(new SqlParameter("@Created_Date", ent.Modified_Date));
                        cmd.Parameters.Add(new SqlParameter("@Primary_Id", ent.Product_ID));
                        cmd.Parameters.Add(new SqlParameter("@Log_Action", "Delete Product"));
                        cmd.Parameters.Add(new SqlParameter("@Log_Status", "Admin"));

                        try
                        {
                            dataresult1 = Convert.ToInt32(cmd.ExecuteScalar());
                            if (dataresult1 > 0)
                            {
                                cmd.Dispose();
                            }
                        }
                        catch (Exception ex)
                        {
                            dataresult1 = -2;
                        }
                    }
                }
            }
            catch (Exception)
            {
                dataResult = -1;
            }
            finally
            {
                con.Close();
            }
            return(dataResult);
        }
Ejemplo n.º 10
0
        public int SaveProduct(Ent_Product ent, SafeTransaction trans)
        {
            int dataresult  = 0;
            int dataresult1 = 0;

            try
            {
                if (con.State == ConnectionState.Closed)
                {
                    con.Open();
                }
                //Insert To category Main Table
                using (SqlCommand cmd = new SqlCommand("EC_InsertProduct", trans.DatabaseConnection, trans.Transaction))
                {
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.Add(new SqlParameter("@Product_ID", ent.Product_ID));
                    cmd.Parameters.Add(new SqlParameter("@Product_Name", ent.Product_Name));
                    cmd.Parameters.Add(new SqlParameter("@Product_SubText", ent.Product_SubText));
                    cmd.Parameters.Add(new SqlParameter("@Category_ID", ent.Category_ID));
                    cmd.Parameters.Add(new SqlParameter("@SubCategory_ID", ent.SubCategory_ID));
                    cmd.Parameters.Add(new SqlParameter("@Brand_ID", ent.Brand_ID));
                    cmd.Parameters.Add(new SqlParameter("@Product_Description", ent.Product_Description));
                    cmd.Parameters.Add(new SqlParameter("@Product_Price", ent.Product_Price));
                    cmd.Parameters.Add(new SqlParameter("@Product_Discount", ent.Product_Discount));
                    cmd.Parameters.Add(new SqlParameter("@Product_Image", ent.Product_Image));
                    cmd.Parameters.Add(new SqlParameter("@Created_Date", ent.Created_Date));
                    cmd.Parameters.Add(new SqlParameter("@Created_By", ent.Created_By));
                    try
                    {
                        dataresult = Convert.ToInt32(cmd.ExecuteScalar());
                        if (dataresult > 0)
                        {
                            cmd.Dispose();
                        }
                    }
                    catch (Exception ex)
                    {
                        //General gl = new General();
                        //gl.UpdateErrorLog(Ex, "CreateDietPlan");

                        dataresult = -2;
                        InsertException(ex.Message, "SaveProduct", ent.Product_ID);
                    }
                }


                if (dataresult > 0)
                {
                    using (SqlCommand cmd = new SqlCommand("EC_InsertLog", trans.DatabaseConnection, trans.Transaction))
                    {
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.Parameters.Add(new SqlParameter("@Created_By", ent.Created_By));
                        cmd.Parameters.Add(new SqlParameter("@Created_Date", ent.Created_Date));
                        cmd.Parameters.Add(new SqlParameter("@Primary_Id", dataresult));
                        if (ent.Product_ID > 0)
                        {
                            cmd.Parameters.Add(new SqlParameter("@Log_Action", "Update Product"));
                        }
                        else
                        {
                            cmd.Parameters.Add(new SqlParameter("@Log_Action", "Insert Product"));
                        }
                        cmd.Parameters.Add(new SqlParameter("@Log_Status", "Admin"));

                        try
                        {
                            dataresult1 = Convert.ToInt32(cmd.ExecuteScalar());
                            if (dataresult1 > 0)
                            {
                                cmd.Dispose();
                            }
                        }
                        catch (Exception ex)
                        {
                            dataresult1 = -2;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                dataresult1 = -2;
            }
            finally { con.Close(); }

            return(dataresult);
        }
Ejemplo n.º 11
0
        // GET: Order
        public int AddToCart(int Product_ID)
        {
            Ent_Product ent = new Ent_Product();

            ent = balProduct.SelectProduct(Product_ID);
            HttpCookie Guest_ID = Request.Cookies["Guest_ID"];
            int        GuestID  = Guest_ID != null?Convert.ToInt32(Guest_ID.Value.Split('=')[1]) : 0;

            int qty    = 1;
            int cartid = 0;

            if (Session["Cart"] == null)
            {
                List <Ent_OrderDetail> item = new List <Ent_OrderDetail>();
                item.Add(new Ent_OrderDetail()
                {
                    Product_ID    = Product_ID,
                    Product_Name  = ent.Product_Name,
                    Quantity      = 1,
                    Product_Price = ent.Product_Price - ent.Product_Discount,
                    Product_Image = ent.Product_Image,
                    Product_Total = ent.Product_Price - ent.Product_Discount,
                });
                Session["Cart"]     = item;
                Session["SubTotal"] = ent.Product_Price - ent.Product_Discount;
                Session["Total"]    = ent.Product_Price - ent.Product_Discount;
            }
            else
            {
                List <Ent_OrderDetail> item = (List <Ent_OrderDetail>)Session["Cart"];
                bool has = item.Any(x => x.Product_ID == Product_ID);
                if (has == false)
                {
                    item.Add(new Ent_OrderDetail()
                    {
                        Product_ID    = Product_ID,
                        Product_Name  = ent.Product_Name,
                        Quantity      = 1,
                        Product_Price = ent.Product_Price - ent.Product_Discount,
                        Product_Image = ent.Product_Image,
                        Product_Total = ent.Product_Price - ent.Product_Discount,
                    });
                }
                else
                {
                    item.Where(w => w.Product_ID == Product_ID).ToList().ForEach(i => { i.Quantity = i.Quantity + 1; i.Product_Total = ((i.Quantity) * i.Product_Price); });
                    qty    = item.Where(l => l.Product_ID == Product_ID).FirstOrDefault().Quantity;
                    cartid = 1;
                }
                Session["Cart"]     = item;
                Session["SubTotal"] = Convert.ToInt32(Session["SubTotal"]) + (ent.Product_Price - ent.Product_Discount);
                Session["Total"]    = Convert.ToInt32(Session["Total"]) + (ent.Product_Price - ent.Product_Discount);
            }
            if (GuestID != 0)
            {
                Ent_OrderDetail entP = new Ent_OrderDetail();
                entP.Cart_ID    = cartid;
                entP.Product_ID = Product_ID;
                entP.Quantity   = qty;
                entP.Guest_ID   = Convert.ToInt32(GuestID);
                SafeTransaction trans  = new SafeTransaction();
                int             result = balOrder.InsertCart(entP, trans);
                if (result > 0)
                {
                    trans.Commit();
                }
                else
                {
                    trans.Rollback();
                }
            }


            return(1);
        }