Esempio n. 1
0
        /// <summary>
        /// 카트리스트 데이터를 기준으로 Cart 업데이트
        /// </summary>
        /// <param name="cart"></param>
        public void SetCartMasterData(ref SHOPPING_CART cart)
        {
            var Itemlist = cart.ITEM_LIST;
            var query    = Itemlist.GroupBy(g => true)
                           .Select(s => new
            {
                ITEM_DISCOUNT_AMT = s.Sum(s1 => s1.DISCOUNT_AMT)
                ,
                TOTAL_AMT = s.Sum(s1 => s1.SALES_AMT)
                ,
                BEFORE_AMT = s.Sum(s1 => s1.COST)
                ,
                ITEM_CNT = s.Sum(s1 => s1.CNT)
            }).FirstOrDefault();



            if (query != null)
            {
                cart.ITEM_DISCOUNT_AMT = query.ITEM_DISCOUNT_AMT;
                cart.BEFORE_AMT        = query.BEFORE_AMT;
                cart.TOTAL_AMT         = query.TOTAL_AMT;
                cart.ITEM_CNT          = query.ITEM_CNT;
            }
            cart.ITEM_LIST = Itemlist;
        }
Esempio n. 2
0
        /// <summary>
        /// 카트 수량 변경 또는 삭제
        /// </summary>
        /// <returns></returns>
        public JsonResult CartUpdateOrDel(SHOPPING_ITEM Param, string saveType = "U")
        {
            string cartListHtml = string.Empty, msg = string.Empty, totAmt = string.Empty;

            try
            {
                SHOPPING_CART        cart     = SessionHelper.LoginInfo.SHOPPING_CART;
                List <SHOPPING_ITEM> itemlist = cart.ITEM_LIST;

                if (itemlist != null && saveType.ToUpper() == "D")
                {
                    itemlist.RemoveAll(x => x.ITEM_GROUP_NAME == Param.ITEM_GROUP_NAME && x.ITEM_CODE == Param.ITEM_CODE);
                }
                if (itemlist != null && saveType.ToUpper() == "U")
                {
                    foreach (var item in itemlist.Where(w => w.ITEM_CODE == Param.ITEM_CODE && w.ITEM_GROUP_NAME == Param.ITEM_GROUP_NAME))
                    {
                        item.CNT       = Param.CNT;
                        item.SALES_AMT = item.CNT * item.PRICE;
                    }
                }
                this.SetCartMasterData(ref cart);
                totAmt = String.Format(SessionHelper.LoginInfo.CultureInfo, "{0:C}", cart.TOTAL_AMT);
                string viewName = "/Views/Theme/" + SessionHelper.LoginInfo.STORE.THEME_NAME + "/Order/PatialView/pv_CartList.cshtml";
                cartListHtml = GlobalMvc.Common.RenderPartialViewToString(this, viewName, new { });
            }
            catch (Exception ex) { msg = ex.Message; }

            return(new JsonResult {
                Data = new { CartListHtml = cartListHtml, TOT_AMT = totAmt, error_message = msg }
            });
        }
Esempio n. 3
0
 public void Delete(SHOPPING_CART Entity, bool Attach = true)
 {
     if (Attach)
     {
         Context.SHOPPING_CART.Attach(Entity);
     }
     Context.SHOPPING_CART.DeleteObject(Entity);
 }
Esempio n. 4
0
        public void Update(SHOPPING_CART Entity)
        {
            Context.SHOPPING_CART.Attach(Entity);
            var entry = Context.ObjectStateManager.GetObjectStateEntry(Entity);

            entry.SetModifiedProperty("Quantity");
            entry.SetModifiedProperty("DateAdded");
        }
Esempio n. 5
0
        public void Insert(SHOPPING_CART Entity)
        {
            if (String.IsNullOrWhiteSpace(Entity.ID))
            {
                throw new Exception("Entity key null or empty or white space.");
            }

            Context.SHOPPING_CART.AddObject(Entity);
        }
Esempio n. 6
0
        // GET: Order
        /// <summary>
        /// 장바구니 추가
        /// </summary>
        /// <param name="Param"></param>
        /// <returns></returns>
        public JsonResult ShoppingCartAdd(SHOPPING_ITEM Param)
        {
            string msg          = string.Empty;
            string cartListHtml = string.Empty;
            string totAmt       = String.Format(SessionHelper.LoginInfo.CultureInfo, "{0:C}", 0);

            try
            {
                SHOPPING_CART cart = new SHOPPING_CART();
                if (SessionHelper.LoginInfo.SHOPPING_CART == null)
                {
                    cart = new SHOPPING_CART();
                }
                else
                {
                    cart = SessionHelper.LoginInfo.SHOPPING_CART;
                }

                if (Param != null)
                {
                    List <SHOPPING_ITEM> Itemlist = new List <SHOPPING_ITEM>();
                    if (cart.ITEM_LIST == null)
                    {
                        Itemlist = new List <SHOPPING_ITEM>();
                    }
                    else
                    {
                        Itemlist = cart.ITEM_LIST;
                    }
                    bool chkAdd = false;
                    foreach (var item in Itemlist.Where(w => w.ITEM_CODE == Param.ITEM_CODE && w.ITEM_GROUP_NAME == Param.ITEM_GROUP_NAME))
                    {
                        item.CNT       = item.CNT + 1;
                        item.SALES_AMT = item.CNT * item.PRICE;
                        chkAdd         = true;
                    }
                    if (!chkAdd)
                    {
                        Param.SALES_AMT = Param.PRICE; Itemlist.Add(Param);
                    }
                    cart.ITEM_LIST = Itemlist;
                    this.SetCartMasterData(ref cart);

                    totAmt = String.Format(SessionHelper.LoginInfo.CultureInfo, "{0:C}", cart.TOTAL_AMT);


                    SessionHelper.LoginInfo.SHOPPING_CART = cart;
                }
            }catch (Exception ex)
            {
                msg = ex.Message;
            }
            return(new JsonResult {
                Data = new { TOT_AMT = totAmt, error_message = msg }
            });
        }
Esempio n. 7
0
        public void Update(SHOPPING_CART Entity, int PreviousQuantity)
        {
            PRODUCT_ATTRIBUTE prodAttr = _productDAO.GetProductAttributeById(Entity.ProdAttrID);

            Context.PRODUCT_ATTRIBUTE.Detach(prodAttr);

            if (PreviousQuantity != Entity.Quantity)
            {
                int difference = Entity.Quantity - PreviousQuantity;

                // using the version that was initially retrieved from db
                // if another user modified this record an OptimisticConcurrencyException will be raised only if the new quantity is greater than the old
                // so there is the risk of a negative availability

                // if difference is negative, products are being "returned to warehouse" so the
                // concurrency check is not needed.
                if ((prodAttr.Availability - difference) < 0)
                {
                    //TODO think what to do with version
                    // set the version that was read when the product-attribute was first retrieved from user interface
                    // the entity must be detached in order to set it's concurrency-check attribute (version in this case)
                    prodAttr.Version = Entity.ProductAttributeVersion;
                }
                prodAttr.Availability -= difference;
                _productDAO.UpdateProductAttribute(prodAttr);
            }

            Entity.PRODUCT_ATTRIBUTE = null;
            _shoppingCartDAO.Update(Entity);
            try
            {
                if (prodAttr.Availability < 0)
                {
                    throw new System.Data.OptimisticConcurrencyException("Product availability negative.");
                }
                Context.SaveChanges();
            }
            catch (System.Data.OptimisticConcurrencyException)
            {
                // when an optimistic exception is raised, the old quantity is restored the old quantity
                Entity.Quantity = PreviousQuantity;
                throw;
            }
            finally
            {
                Context.Refresh(RefreshMode.StoreWins, prodAttr);
                Context.Refresh(RefreshMode.StoreWins, Entity);
                Entity.PRODUCT_ATTRIBUTE = prodAttr;

                // setting the new version for further modifications
                Entity.ProductAttributeVersion = prodAttr.Version;
            }
        }
Esempio n. 8
0
        protected void ddlQty_SelectedIndexChanged(object sender, EventArgs e)
        {
            DropDownList ddl = sender as DropDownList;
            int          selectedQty;

            if (Int32.TryParse(ddl.SelectedValue, out selectedQty))
            {
                RepeaterItem item  = (RepeaterItem)ddl.NamingContainer;
                HiddenField  field = (HiddenField)item.FindControl("ProdAttrID");
                int          prodAttrId;
                if (Int32.TryParse(field.Value, out prodAttrId))
                {
                    SessionCart cart = CartSession.Find(c => c.ProductAttributeId == prodAttrId);
                    if (cart != null)
                    {
                        // we already have the right version in the session variable cartsession
                        int           oldQuantity = cart.Quantity;
                        SHOPPING_CART shopping    = new SHOPPING_CART()
                        {
                            ID = cart.Id, ProdAttrID = prodAttrId
                        };
                        // session var
                        cart.Quantity  = selectedQty;
                        cart.DateAdded = DateTime.Now;

                        shopping.Quantity  = selectedQty;
                        shopping.DateAdded = DateTime.Now;
                        shopping.ProductAttributeVersion = cart.ProductAttributeVersion;

                        LinkButton lnk = (LinkButton)item.FindControl("lnkEdit");

                        try
                        {
                            ApplicationContext.Current.Carts.Update(shopping, oldQuantity);
                            lblMessage.Text = String.Empty;
                        }
                        catch (Exception ex)
                        {
                            BasePage.Log(ex, ex.Message, ex.StackTrace, "Cart Control");
                            updAvailListInOptimisticScenario(ddl, prodAttrId, oldQuantity, selectedQty, lnk);
                        }
                        finally
                        {
                            DataBind();
                            ddl.Visible = false;
                            lnk.Visible = true;
                        }
                    }
                }
            }
        }
Esempio n. 9
0
        public void Delete(SHOPPING_CART Entity)
        {
            // first "put back" the product that was in cart
            // version is not needed as the availability is incremented, so no risk
            PRODUCT_ATTRIBUTE prodAttr = _productDAO.GetProductAttributeById(Entity.ProdAttrID);

            prodAttr.Availability += Entity.Quantity;
            _productDAO.UpdateProductAttribute(prodAttr, false);

            // second remove item from cart
            _shoppingCartDAO.Delete(Entity, false);

            // then save if everything was successful
            Context.SaveChanges();
        }
Esempio n. 10
0
        public void Execute()
        {
            try
            {
                List <string> cartIDs = ApplicationContext.Current.Carts.GetExpiredCarts();
                StringBuilder logMsg  = new StringBuilder();
                if (cartIDs != null && cartIDs.Count > 0)
                {
                    foreach (string cart in cartIDs)
                    {
                        logMsg.Append("CartID: " + cart);
                        int?    cartItems  = ApplicationContext.Current.Carts.GetShoppingCartTotalItems(cart);
                        decimal?cartAmount = ApplicationContext.Current.Carts.GetShoppingCartTotalAmount(cart);

                        SHOPPING_CART sc = ApplicationContext.Current.Carts.GetShoppingCartItems(cart).FirstOrDefault();
                        if (sc != null)
                        {
                            logMsg.Append(", Customer: " + sc.CustomerName);
                            logMsg.Append(", Campaign: " + sc.CampaignName);
                        }
                        // logging
                        if (cartItems.HasValue && cartAmount.HasValue)
                        {
                            logMsg.Append(", Items: " + cartItems.Value + ", Amount: " + cartAmount.Value);
                        }
                        log(logMsg.ToString());

                        // returning in stock the items that were in the cart
                        ApplicationContext.Current.Carts.DeleteShoppingCart(cart);
                    }
                }
            }
            catch (Exception ex)
            {
                string message = ex.Message;
                if (ex.InnerException != null)
                {
                    message += "/nInner: " + ex.InnerException.Message;
                }
                log(message);
            }
        }
Esempio n. 11
0
        public void Insert(SHOPPING_CART Entity)
        {
            PRODUCT_ATTRIBUTE prodAttr = _productDAO.GetProductAttributeById(Entity.ProdAttrID);

            Context.PRODUCT_ATTRIBUTE.Detach(prodAttr);

            prodAttr.Availability -= Entity.Quantity;
            if (prodAttr.Availability < 0)
            {
                // partial verification, the exception is raised only if the resulting availability is less than 0
                // using the version that was initially retrieved from db
                // if another user modified this record an OptimisticConcurrencyException will be raised
                prodAttr.Version = Entity.ProductAttributeVersion;
            }

            _productDAO.UpdateProductAttribute(prodAttr);

            _shoppingCartDAO.Insert(Entity);
            try
            {
                if (prodAttr.Availability < 0)
                {
                    throw new System.Data.OptimisticConcurrencyException("Product availability negative.");
                }
                Context.SaveChanges();
            }
            catch (System.Data.OptimisticConcurrencyException ex)
            {
                throw;
            }
            finally
            {
                Context.Refresh(RefreshMode.StoreWins, prodAttr);
                Entity.PRODUCT_ATTRIBUTE = prodAttr;

                // setting the new version for further modifications
                Entity.ProductAttributeVersion = prodAttr.Version;
            }
        }
Esempio n. 12
0
        protected void rptDetails_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            RepeaterItem item = e.Item;

            // we need only items, footer and header aren't considered
            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                DropDownList  ddlSize = (DropDownList)item.FindControl("ddlSize");
                SHOPPING_CART cart    = (SHOPPING_CART)item.DataItem;

                // loading size ddl, actually it's not possible to modify the choosen size
                List <FZAttributeAvailability> list; // = ApplicationContext.Current.Products.GetProductAttributeValues(cart.ProductID.Value);
                list = new List <FZAttributeAvailability>();
                list.Insert(0, new FZAttributeAvailability()
                {
                    Id = cart.ProdAttrID, Value = cart.ProductAttribute
                });
                ddlSize.DataSource = list;
                ddlSize.DataBind();
                ddlSize.SelectedValue = cart.ProdAttrID.ToString();

                List <int>        qtyList;
                PRODUCT_ATTRIBUTE prodAttr = ApplicationContext.Current.Products.GetProductAvailability(cart.ProdAttrID, out qtyList, cart.Quantity);

                DropDownList ddlQty = (DropDownList)item.FindControl("ddlQty");
                ddlQty.DataSource = qtyList;
                ddlQty.DataBind();
                ddlQty.SelectedValue = cart.Quantity.ToString();
            }
            else if (e.Item.ItemType == ListItemType.Footer)
            {
                // total amount in footer
                Label lblSubTotal = (Label)item.FindControl("lblSubTotal");
                lblSubTotal.Text = TotalAmount().ToString("N2");
            }
        }
        public string StoreOnlineCartReservationSave(T_STORE_RESERVATION Param, LOGIN_INFO login = null)
        {
            string       msg        = string.Empty;
            Int64        nSALE_CODE = 0;
            OrderService service    = new OrderService(db);

            try
            {
                using (TransactionScope tran = new TransactionScope())
                {
                    if (login != null && login.SHOPPING_CART != null && (login.SHOPPING_CART.ITEM_LIST != null && login.SHOPPING_CART.ITEM_LIST.Count() > 0))
                    {
                        Param.STORE_CODE = login.STORE_CODE;
                        SHOPPING_CART cart      = login.SHOPPING_CART;
                        string        sSaleData = service.SaleSave(new T_SALE
                        {
                            SALE_CODE           = 0,
                            BILL_NO             = "",
                            STORE_CODE          = (int)Param.STORE_CODE,
                            MEMBER_CODE         = login.MEMBER.MEMBER_CODE,
                            TOT_TAX             = cart.TOT_TAX,
                            TAX1                = cart.TAX1,
                            TAX2                = cart.TAX2,
                            TAX3                = cart.TAX3,
                            DELIVERY_FEE        = login.SHOPPING_CART.DELIVERY_FEE,
                            TIP_AMT             = (login.SHOPPING_CART.TIP_LIST == null) ? 0 : login.SHOPPING_CART.TIP_LIST.Sum(s => s.TOT_TIP_TAX),
                            ADD_AMT             = login.SHOPPING_CART.ITEM_LIST.Sum(s => s.ADD_ITEM_LIST == null ? 0 : s.ADD_ITEM_LIST.Sum(ss => ss.PRICE)),
                            ITEM_DISCOUNT_AMT   = (login.SHOPPING_CART.DISCOUNT_LIST == null ? 0 : login.SHOPPING_CART.DISCOUNT_LIST.Where(w => w.ITEM_SEQ != null && w.ITEM_SEQ > 0).Sum(s => s.DISCOUNT_AMT)),
                            ORDER_DISCOUNT_TYPE = cart.ORDER_DISCOUNT_TYPE,
                            ORDER_DISCOUNT_AMT  = cart.ORDER_DISCOUNT_AMT,
                            SALE_AMT            = cart.TOTAL_AMT,
                            REMARK              = "",
                            INSERT_CODE         = (int)login.MEMBER.MEMBER_CODE
                        });

                        if (sSaleData.Contains("Error =>"))
                        {
                            return(sSaleData);
                        }
                        else
                        {
                            if (sSaleData.Split(':').Count() == 2)
                            {
                                nSALE_CODE = Convert.ToInt64(sSaleData.Split(':')[1]);
                            }
                        }

                        #region >> 매출 아이템 정보 등록
                        if (cart.ITEM_LIST != null)
                        {
                            foreach (SHOPPING_ITEM itemData in cart.ITEM_LIST)
                            {
                                T_SALE_ITEM itemSaveData = new T_SALE_ITEM {
                                };

                                itemSaveData.SALE_CODE     = nSALE_CODE;
                                itemSaveData.ITEM_SEQ      = itemData.ITEM_SEQ;
                                itemSaveData.ITEM_CODE     = itemData.ITEM_CODE;
                                itemSaveData.ITEM_NAME     = itemData.ITEM_NAME;
                                itemSaveData.ITEM_TYPE     = itemData.ITEM_TYPE;
                                itemSaveData.COST          = itemData.COST;
                                itemSaveData.TOT_TAX       = itemData.TOT_TAX;
                                itemSaveData.TAX1          = itemData.TAX1;
                                itemSaveData.TAX2          = itemData.TAX2;
                                itemSaveData.TAX3          = itemData.TAX3;
                                itemSaveData.CNT           = itemData.CNT;
                                itemSaveData.PRICE         = itemData.PRICE;
                                itemSaveData.DISCOUNT_TYPE = itemData.DISCOUNT_TYPE;
                                itemSaveData.DISCOUNT_AMT  = itemData.DISCOUNT_AMT;
                                itemSaveData.TOPPING_CODE  = itemData.TOPPING_CODE;
                                itemSaveData.REMARK        = itemData.MEMO;
                                itemSaveData.INSERT_CODE   = (int)login.MEMBER.MEMBER_CODE;
                                #region >> 세트메뉴정보 및 토핑 정보 등록
                                if (itemData.ADD_ITEM_LIST != null && itemData.ADD_ITEM_LIST.Count() > 0)
                                {
                                    foreach (T_SALE_ITEM_ADD addData in itemData.ADD_ITEM_LIST)
                                    {
                                        addData.SALE_CODE   = nSALE_CODE;
                                        addData.ITEM_SEQ    = itemData.ITEM_SEQ;
                                        addData.INSERT_CODE = (int)login.MEMBER.MEMBER_CODE;
                                        msg = service.SaleItemAddSave(addData);
                                        if (!string.IsNullOrEmpty(msg))
                                        {
                                            return(msg);
                                        }
                                    }
                                }
                                #endregion

                                msg = service.SaleItemSave(itemSaveData);
                                if (!string.IsNullOrEmpty(msg))
                                {
                                    return(msg);
                                }
                            }
                        }
                        #endregion

                        #region >>  쿠폰 사용정보 등록
                        if (login.SHOPPING_CART.COUPON_LIST != null && login.SHOPPING_CART.COUPON_LIST.Count() > 0)
                        {
                            //SALE_CODE
                            foreach (CART_COUPON_USE couponData in login.SHOPPING_CART.COUPON_LIST)
                            {
                                T_SALE_COUPON coupon = service.GetCouponList(new T_SALE_COUPON_COND {
                                    COUPON_CODE = couponData.COUPON_CODE
                                }).FirstOrDefault();
                                if (coupon == null)
                                {
                                    return("해당쿠폰은 유효하지 않은 쿠폰입니다.");
                                }

                                if (Convert.ToInt32(couponData.USE_DATE) < Convert.ToInt32(coupon.FR_DATE))
                                {
                                    return("해당쿠폰은 유효하지 않은 쿠폰입니다. 사용가능일 : " + coupon.FR_DATE.ToFormatDate() + "~" + coupon.TO_DATE.ToFormatDate());
                                }

                                if (coupon.USE_YN)
                                {
                                    return("이미 사용된 쿠폰입니다.(사용가능매장 : " + coupon.STORE_NAME + " 사용일:" + coupon.USE_DATE + ")");
                                }

                                if (coupon.COMPANY_CODE != null && coupon.COMPANY_CODE != couponData.COMPANY_CODE)
                                {
                                    return("해당업체에서는 사용이 불가능합니다..(사용가능업체 : " + coupon.COMPANY_NAME + " 사용가능일:" + Global.Format.ConvertFromToFormatDate(coupon.FR_DATE, coupon.TO_DATE) + ")");
                                }

                                if (coupon.STORE_CODE != null && coupon.STORE_CODE != couponData.STORE_CODE)
                                {
                                    return("해당업체에서는 사용이 불가능합니다..(사용가능매장 : " + coupon.STORE_CODE + " 사용가능일:" + Global.Format.ConvertFromToFormatDate(coupon.FR_DATE, coupon.TO_DATE) + ")");
                                }

                                if (coupon.ITEM_GROUP_CODE != null && coupon.ITEM_GROUP_CODE != couponData.ITEM_GROUP_CODE)
                                {
                                    return("해당품목그룹은 사용이 불가능합니다..(사용가능품목그룹 : " + coupon.ITEM_GROUP_NAME + " 사용가능일:" + Global.Format.ConvertFromToFormatDate(coupon.FR_DATE, coupon.TO_DATE) + ")");
                                }
                                if (coupon.ITEM_CODE != null && coupon.ITEM_CODE != couponData.ITEM_CODE)
                                {
                                    return("해당품목은 사용이 불가능합니다..(사용가능품목 : " + coupon.ITEM_NAME + " 사용가능일:" + Global.Format.ConvertFromToFormatDate(coupon.FR_DATE, coupon.TO_DATE) + ")");
                                }

                                couponData.SALE_CODE    = nSALE_CODE;
                                coupon.SALE_CODE        = couponData.SALE_CODE;
                                coupon.SALE_ITEM_SEQ    = couponData.SALE_ITEM_SEQ;
                                coupon.ITEM_CODE        = couponData.ITEM_CODE;
                                coupon.USE_DATE         = couponData.USE_DATE;
                                coupon.USE_YN           = couponData.USE_YN;
                                coupon.DISCOUNT_RATE    = coupon.DISCOUNT_RATE;
                                coupon.USE_DISCOUNT_AMT = coupon.DISCOUNT_AMT;
                                coupon.INSERT_CODE      = login.MEMBER.MEMBER_CODE;

                                msg = service.SaleCouponSave(coupon);

                                if (string.IsNullOrEmpty(msg))
                                {
                                    return(msg);
                                }
                            }
                        }
                        #endregion

                        #region >> 할인정보 등록
                        if (cart.DISCOUNT_LIST != null && cart.DISCOUNT_LIST.Count() > 0)
                        {
                            foreach (T_SALE_DISCOUNT disData in cart.DISCOUNT_LIST)
                            {
                                disData.SALE_CODE   = nSALE_CODE;
                                disData.INSERT_CODE = (int)login.MEMBER.MEMBER_CODE;
                                msg = service.SaleDiscountSave(disData);
                                if (!string.IsNullOrEmpty(msg))
                                {
                                    return(msg);
                                }
                            }
                        }
                        #endregion

                        #region >> 팁 정보 등록
                        if (cart.TIP_LIST != null && cart.TIP_LIST.Count() > 0)
                        {
                            foreach (T_SALE_TIP disData in cart.TIP_LIST)
                            {
                                disData.SALE_CODE   = nSALE_CODE;
                                disData.INSERT_CODE = (int)login.MEMBER.MEMBER_CODE;
                                msg = service.SaleTipSave(disData);
                                if (!string.IsNullOrEmpty(msg))
                                {
                                    return(msg);
                                }
                            }
                        }
                        #endregion
                    }

                    string sql = Global.DBAgent.LoadSQL(sqlBasePath + "HomePage\\T_STORE_RESERVATION.xml", "StoreReservationSave"
                                                        , Param.IDX.ToString("0")
                                                        , Param.STORE_CODE.ToString()
                                                        , Param.REG_DATE.ToString(DateTime.Now.ToString("yyyyMMddHHmmdd"))
                                                        , Param.REQUEST_DATE.ToString("")
                                                        , Param.NAME.ToString("")
                                                        , Param.EMAIL.ToString("")
                                                        , Param.PHONE.ToString("")
                                                        , Param.PEOPLE_NUMBER.ToString("")
                                                        , Param.CONTENT.ToString("")
                                                        , Param.REMARK.ToString("")
                                                        , Param.STATUS.ToString("1")
                                                        , nSALE_CODE.ToString()
                                                        , Param.INSERT_CODE.ToString("0")
                                                        );

                    db.ExecuteCommand(sql);
                    tran.Complete();
                }
            }
            catch (Exception ex)
            {
                msg = ex.Message;
            }
            return(msg);
        }
Esempio n. 14
0
 public List <SHOPPING_CART> Search(SHOPPING_CART Entity, int PageSize, int PageIndex, out int TotalRecords, string OrderExp, Util.SortDirection SortDirection)
 {
     return(_shoppingCartDAO.Search(Entity, PageSize, PageIndex, out TotalRecords, OrderExp, SortDirection));
 }
Esempio n. 15
0
        public void DeleteById(String Id, int ProdAttrID)
        {
            SHOPPING_CART cart = _shoppingCartDAO.GetById(Id, ProdAttrID);

            Delete(cart);
        }
Esempio n. 16
0
 public void Delete(SHOPPING_CART Entity)
 {
     Delete(Entity, true);
 }
Esempio n. 17
0
 public void Update(SHOPPING_CART Entity)
 {
     Update(Entity, Entity.Quantity);
 }
Esempio n. 18
0
        public List <SHOPPING_CART> Search(SHOPPING_CART Entity, int PageSize, int PageIndex, out int TotalRecords, string OrderExp, Util.SortDirection SortDirection)
        {
            var result = Context.SHOPPING_CART.AsQueryable();

            if (Entity != null)
            {
                if (!String.IsNullOrWhiteSpace(Entity.ProductName))
                {
                    result = result.Where(s => s.PRODUCT_ATTRIBUTE.PRODUCT.Name.Contains(Entity.ProductName));
                }

                if (!String.IsNullOrWhiteSpace(Entity.CampaignName))
                {
                    result = result.Where(s => s.CAMPAIGN.Name.Contains(Entity.CampaignName));
                }

                if (!String.IsNullOrWhiteSpace(Entity.CustomerName))
                {
                    result = result.Where(s => (s.CUSTOMER.Name + " " + s.CUSTOMER.Surname).Contains(Entity.CustomerName));
                }

                if (Entity.SearchStartDate.HasValue)
                {
                    result = result.Where(s => s.DateAdded >= Entity.SearchStartDate.Value);
                }

                if (Entity.CampaignID != 0)
                {
                    result = result.Where(s => s.CampaignID == Entity.CampaignID);
                }

                if (!String.IsNullOrWhiteSpace(Entity.ID))
                {
                    result = result.Where(s => s.ID == Entity.ID);
                }
            }

            TotalRecords = result.Count();

            if (!String.IsNullOrEmpty(OrderExp) && OrderExp.Equals("ProductName"))
            {
                if (SortDirection == SortDirection.Ascending)
                {
                    result = result.OrderBy(s => s.PRODUCT_ATTRIBUTE.PRODUCT.Name);
                }
                else
                {
                    result = result.OrderByDescending(s => s.PRODUCT_ATTRIBUTE.PRODUCT.Name);
                }
            }
            else if (!String.IsNullOrEmpty(OrderExp) && OrderExp.Equals("CustomerName"))
            {
                if (SortDirection == SortDirection.Ascending)
                {
                    result = result.OrderBy(s => s.CUSTOMER.Name).ThenBy(s => s.CUSTOMER.Surname);
                }
                else
                {
                    result = result.OrderByDescending(s => s.CUSTOMER.Name).ThenBy(s => s.CUSTOMER.Surname);
                }
            }
            else if (!String.IsNullOrEmpty(OrderExp) && OrderExp.Equals("CampaignName"))
            {
                if (SortDirection == SortDirection.Ascending)
                {
                    result = result.OrderBy(s => s.CAMPAIGN.Name);
                }
                else
                {
                    result = result.OrderByDescending(s => s.CAMPAIGN.Name);
                }
            }
            else
            {
                GenericSorterCaller <SHOPPING_CART> sorter = new GenericSorterCaller <SHOPPING_CART>();
                result = sorter.Sort(result, String.IsNullOrEmpty(OrderExp) ? "ID" : OrderExp, SortDirection);
            }
            // pagination
            return(result.Skip(PageIndex * PageSize).Take(PageSize).ToList());
        }
Esempio n. 19
0
        protected void lnkAddToBasket_Click(object sender, EventArgs e)
        {
            string CartID = String.Empty;

            Guid g = Guid.NewGuid();
            UniqueIdGenerator unique = UniqueIdGenerator.GetInstance();
            string            cartId = unique.GetBase32UniqueId(g.ToByteArray(), 20).ToLower();

            if (CartSession == null || CartSession.Count == 0)
            {
                CartID      = cartId;
                CartSession = new List <SessionCart>();
            }
            else
            {
                List <SessionCart> cSession    = CartSession.OrderByDescending(c => c.DateAdded).ToList();
                SessionCart        sessionCart = cSession.First();
                if (sessionCart.DateAdded.AddMinutes(Configuration.CartExpirationValue) < DateTime.Now)
                {
                    RefreshCart();
                    CartID = cartId;
                }
                else
                {
                    CartID = CartSession.First().Id;
                }
            }

            SHOPPING_CART cart = new SHOPPING_CART();

            cart.ID         = CartID;
            cart.FrontEnd   = true;
            cart.CampaignID = CampaignID;
            cart.CustomerID = CurrentCustomer.Id;
            cart.DateAdded  = DateTime.Now;
            cart.ProductID  = ProductID;
            int num = 0;

            if (!Int32.TryParse(ddlSize.SelectedValue, out num))
            {
                return;
            }
            cart.ProdAttrID = num;

            num = 0;
            if (!Int32.TryParse(ddlQuantity.SelectedValue, out num) || num == 0)
            {
                return;
            }
            cart.Quantity = num;



            // the versions list of lists is created each time the product popup is shown, and destroyed each time it is closed
            if (Version != null)
            {
                cart.ProductAttributeVersion = Version;
            }
            else
            {
                throw new ApplicationException("Session is compromised! Cannot proceed.");
            }

            SessionCart sC;

            try
            {
                // already in the cart
                if (CartSession != null && CartSession.Count > 0 && (sC = CartSession.Find(c => c.ProductAttributeId == cart.ProdAttrID)) != null)
                {
                    // sum with old quantity
                    cart.Quantity += sC.Quantity;
                    ApplicationContext.Current.Carts.Update(cart, sC.Quantity);

                    // updating session with last quantity and last prod-attr version
                    sC.Quantity = cart.Quantity;
                    sC.ProductAttributeVersion = cart.ProductAttributeVersion;
                }
                else
                {
                    ApplicationContext.Current.Carts.Insert(cart);
                    sC = new SessionCart(cart);
                    CartSession.Add(sC);
                }
                TotalAmount = ApplicationContext.Current.Carts.GetShoppingCartTotalAmount(CartID);
            }
            catch (Exception ex)
            {
                //TODO log error
                Log(ex, ex.Message, ex.StackTrace, "Product.AddToCart");

                List <int>        qtyList;
                PRODUCT_ATTRIBUTE prodAttr = ApplicationContext.Current.Products.GetProductAvailability(cart.ProdAttrID, out qtyList);

                Version = prodAttr.Version;

                ddlQuantity.DataSource = qtyList;
                ddlQuantity.DataBind();
                if (!qtyList.Contains(cart.Quantity))
                {
                    lblMessage.Text = Resources.Lang.InsufficientAvailabilityMessage;
                }
                if (qtyList.Count == 0)
                {
                    ddlQuantity.Enabled    = false;
                    lnkAddToBasket.Enabled = false;
                    loadProductAttributes();
                }
                //refreshing the size ddl
                loadProductAttributes();
                updPanelDDL.Update();
                return;
            }


            Version = null;
            Response.Redirect("/cart/mycart/");
        }
Esempio n. 20
0
        /// <summary>
        /// Adds a new product to this session cart
        /// </summary>
        /// <param name="CustomerID"></param>
        /// <param name="CampaignID"></param>
        /// <param name="ProductId"></param>
        /// <param name="ProdAttrId"></param>
        /// <param name="Quantity"></param>
        public void AddProductToCart(int CustomerID, int CampaignID, int ProductId, int ProdAttrId, int Quantity, string BrandName)
        {
            if (CartID == null)
            {
                Guid g = Guid.NewGuid();
                UniqueIdGenerator unique = UniqueIdGenerator.GetInstance();
                string            cartId = unique.GetBase32UniqueId(g.ToByteArray(), 20).ToLower();
                CartID = cartId;
            }

            SHOPPING_CART cart = new SHOPPING_CART();

            cart.ID         = CartID;
            cart.FrontEnd   = false;
            cart.CampaignID = CampaignID;
            cart.CustomerID = CustomerID;
            cart.DateAdded  = DateTime.Now;
            cart.ProductID  = ProductId;
            cart.ProdAttrID = ProdAttrId;
            cart.Quantity   = Quantity;
            cart.BrandName  = BrandName;

            // the versions list of lists is created each time the product popup is shown, and destroyed each time it is closed
            if (Versions != null)
            {
                cart.ProductAttributeVersion = Versions.Where(x => x.Key == ProductId).FirstOrDefault().Value.Where(y => y.Key == ProdAttrId).FirstOrDefault().Value;
            }
            else
            {
                throw new ApplicationException("Session is compromised! Cannot proceed.");
            }

            if (CartSession == null)
            {
                CartSession = new List <SHOPPING_CART>();
            }

            List <SHOPPING_CART> carts = CartSession;
            SHOPPING_CART        sc;

            // already in the cart
            if (carts.Count > 0 && (sc = carts.Where(c => c.ID == cart.ID && c.ProdAttrID == cart.ProdAttrID).FirstOrDefault()) != null)
            {
                cart.Quantity += sc.Quantity;
                ApplicationContext.Current.Carts.Update(cart, sc.Quantity);

                // updating session with last quantity and last prod-attr version
                sc.Quantity = cart.Quantity;
                sc.ProductAttributeVersion = cart.ProductAttributeVersion;
                //sc = cart;
            }
            else
            {
                ApplicationContext.Current.Carts.Insert(cart);

                // already has the last version set from the context saving
                CartSession.Add(cart);
            }

            // refreshing session, optional
            //ApplicationContext.Current.Carts.GetShoppingCartItems(CartID);
            DataBind(CartSession);
        }