Пример #1
0
        /// <summary>
        /// Delete infomation
        /// </summary>
        /// <param name="inputObject">DataModel</param>
        /// <returns>DataModel</returns>
        private DeleteDataModel DeleteInfo(DeleteDataModel inputObject)
        {
            // Local variable declaration
            DeleteDataModel getResult = null;
            CartCom cartCom = null;

            // Variable initialize
            getResult = new DeleteDataModel();
            cartCom = new CartCom(inputObject.Cart);

            // Delete data
            cartCom.DeleteItem(inputObject.ItemCd);

            // Set value
            getResult.Cart = cartCom.Items;

            // Return value
            return getResult;
        }
Пример #2
0
        /// <summary>
        /// Check processing
        /// </summary>
        /// <param name="inputObject">DataModel</param>
        /// <returns>ResultModel</returns>
        private void Check(UpdateDataModel inputObject)
        {
            // Local variable declaration
            DataCom dataCom = null;
            CartCom cartCom = null;

            // Variable initialize
            dataCom = new DataCom();
            cartCom = new CartCom(inputObject.Cart);

            // Check valid
            foreach (var item in cartCom.Items)
            {
                if (!dataCom.IsExist<Item>(item.ItemCd, false))
                    throw new DataNotExistException(string.Format("Sản phẩm ({0})", item.ItemCd));
                if (DataCheckHelper.IsNull(item.Quantity))
                    throw new ExecuteException("E_MSG_00001", "Số lượng");
                if (item.Quantity <= decimal.Zero)
                    throw new ExecuteException("E_MSG_00011", "Số lượng");
            }
        }
Пример #3
0
        /// <summary>
        /// Add item to cart
        /// </summary>
        /// <param name="inputObject">DataModel</param>
        /// <returns>DataModel</returns>
        private BuyDataModel AddInfo(BuyDataModel inputObject)
        {
            // Local variable declaration
            BuyDataModel getResult = null;
            CartCom cartCom = null;

            // Variable initialize
            getResult = new BuyDataModel();
            cartCom = new CartCom(inputObject.Cart);

            // Get data
            var cartItem = new CartItem();
            cartItem.ItemCd = inputObject.ItemCd;
            cartItem.Quantity = inputObject.ItemQtty.Value;
            cartCom.AddItem(cartItem);

            // Set value
            getResult.Cart = cartCom.Items;

            // Return value
            return getResult;
        }
Пример #4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (IsPostBack)
            {
                return;
            }
            if (Session["Cart"] == null || Session["payMethod"] == null)
            {
                Response.Redirect(Pages.CLIENT_INDEX);
            }
            if (Session["CheckoutRequestModel"] == null || Session["hasCheckout"] == null)
            {
                Response.Redirect(Pages.CLIENT_CHECKOUT);
            }
            if (Session["payMethod"].ToString().Equals("0") && Session["SaveRequestModel"] == null)
            {
                Response.Redirect(Pages.CLIENT_CHECKOUT);
            }
            else
            {
                Session["hasCheckout"] = null;
            }

            //load data
            MCodeCom codeCom = new MCodeCom();
            IList<ComboItem> citylst = MCodeCom.ToComboItems(codeCom.GetListCity(), "294").ListItems;
            DropDownList1.DataSource = citylst;
            DropDownList1.DataBind();
            DropDownList1.SelectedValue = "294";
            DropDownList2.DataSource = citylst;
            DropDownList2.DataBind();
            DropDownList2.SelectedValue = "294";

            if (Session["payMethod"].ToString().Equals("0"))
            {
                SaveRequestModel accCreate = (SaveRequestModel)Session["SaveRequestModel"];
                email.Text = accCreate.Email;
            }
            CheckoutRequestModel checkout = (CheckoutRequestModel)Session["CheckoutRequestModel"];
            Accept accept = checkout.Accept;
            clientName.Text = accept.ClientName;
            clientAddress.Text = accept.ClientAddress;
            clientTell.Text = accept.ClientTel;
            DropDownList1.SelectedValue = accept.ClientCityCd;
            deliveryName.Text = accept.DeliveryName;
            deliveryAddress.Text = accept.DeliveryAddress;
            deliveryTell.Text = accept.DeliveryTel;
            DropDownList2.SelectedValue = accept.DeliveryCityCd;
            note.Text = accept.Notes;
            if (accept.PaymentMethods == "01")
            {
                lblPay.Text = "Thanh toán tiền mặt khi nhận hàng";
            }
            else if (accept.PaymentMethods == "02")
            {
                lblPay.Text = "Thanh toán trực truyến bằng thẻ ATM - Internet Banking";
            }
            IList<CartItem> cart = (IList<CartItem>)Session["Cart"];
            CartCom cartCom = new CartCom(cart);
            decimal amount = cartCom.TotalAmount;
            decimal ship = 0;
            if (Session["GiftPrice"] != null && Session["GiftCd"] != null)
            {
                amount = amount - (decimal)Session["GiftPrice"];

            }
            total = amount;
            if (accept.DeliveryCityCd == "294")
            {
                if (amount < 200000)
                {
                    ship = 20000;
                    total = total + ship;
                }
            }
            else
            {
                if (amount < 1000000)
                {
                    ship = 30000;
                    total = total + ship;
                }
            }
            Label1.Text = DataHelper.ToString(Formats.CURRENCY, amount);
            if (ship != 0)
            {
                Label2.Text = DataHelper.ToString(Formats.CURRENCY, ship);
            }
            Label3.Text = DataHelper.ToString(Formats.CURRENCY, total);
            Session["TotalAmt"] = total;
        }
Пример #5
0
        /// <summary>
        /// Get infomation
        /// </summary>
        /// <param name="inputObject">DataModel</param>
        /// <returns>DataModel</returns>
        private InitDataModel GetInfo(InitDataModel inputObject)
        {
            // Local variable declaration
            InitDataModel getResult = null;
            ClientMasterDao clientMasterDao = null;
            MCodeCom mCodeCom = null;
            MParameterCom mParameterCom = null;
            CartCom cartCom = null;

            // Variable initialize
            getResult = new InitDataModel();
            clientMasterDao = new ClientMasterDao();
            mCodeCom = new MCodeCom();
            mParameterCom = new MParameterCom();
            cartCom = new CartCom(inputObject.Cart);

            // Get data
            var cartCount = cartCom.Count;
            var strEmail = mParameterCom.GetString(Logics.PR_EMAIL_SUPPORT, false);

            var listToys = clientMasterDao.GetListCategories(Logics.CD_CATEGORY_DIV_TOYS);
            var listLearningTools = clientMasterDao.GetListCategories(Logics.CD_CATEGORY_DIV_LEARNING_TOOLS);
            var listBooks = clientMasterDao.GetListCategories(Logics.CD_CATEGORY_DIV_BOOKS);
            var listAge = clientMasterDao.GetListAge();
            var listGender = clientMasterDao.GetListGender();
            var listBrand = clientMasterDao.GetListBrand();
            var listCountry = clientMasterDao.GetListCountry();

            // Set value
            getResult.CartCount = cartCount;
            getResult.Email = strEmail;

            getResult.ListToys = listToys;
            getResult.ListLearningTools = listLearningTools;
            getResult.ListBooks = listBooks;
            getResult.ListAge = listAge;
            getResult.ListGender = listGender;
            getResult.ListBrand = listBrand;
            getResult.ListCountry = listCountry;

            // Return value
            return getResult;
        }
Пример #6
0
        /// <summary>
        /// Update item to cart
        /// </summary>
        /// <param name="inputObject">DataModel</param>
        /// <returns>DataModel</returns>
        private UpdateDataModel UpdateInfo(UpdateDataModel inputObject)
        {
            // Local variable declaration
            UpdateDataModel getResult = null;
            CartCom cartCom = null;

            // Variable initialize
            getResult = new UpdateDataModel();
            cartCom = new CartCom(inputObject.Cart);

            // Get data
            foreach (var obj in inputObject.ListItems)
            {
                if (DataCheckHelper.IsNull(obj.Quantity)
                    || obj.Quantity < decimal.Zero) continue;
                var item = new CartItem();
                item.ItemCd = obj.ItemCd;
                item.Quantity = obj.Quantity.Value;
                cartCom.UpdateItem(item);
            }

            // Set value
            getResult.Cart = cartCom.Items;

            // Return value
            return getResult;
        }