Пример #1
0
        // This method gets called by the runtime. Use this method to add services to the container.
        // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
        public void ConfigureServices(IServiceCollection services)
        {
            string connectionstring = _confString.GetConnectionString("DefaultConnectionString");

            // get connection string "DefaultConnectionString"  from dbsettings.json
            services.AddDbContext <AppDBContext>(options =>
                                                 options.UseSqlServer(connectionstring));

            services.AddTransient <IOrders, OrderRepository>();

            services.AddTransient <IAllCars, CarRepository>();
            services.AddTransient <ICarsCategory, CategoryRepository>();
            services.AddSingleton <IHttpContextAccessor, HttpContextAccessor>();
            services.AddScoped(sp => ShopCart.GetCart(sp));
            services.AddMemoryCache();
            services.AddSession();

            services.AddMvc().AddMvcOptions(ab => ab.EnableEndpointRouting = false);

            /* services.AddTransient<IAllCars, MockCars>();
             * services.AddTransient<ICarsCategory, MockCategory>();*/
            MvcOptions compatibilities = new MvcOptions();

            compatibilities.EnableEndpointRouting = false;
        }
Пример #2
0
        private void MigrateShoppingCart(string UserName)
        {
            var cart = ShopCart.GetCart(this.HttpContext);

            cart.MigrateCart(UserName);
            Session[ShopCart.CartSessionKey] = UserName;
        }
Пример #3
0
        public void inputEnter()
        {
            var input = this.txtBarCode.Text;

            //商品编码固定6位,少于6位,即认为是输入的金额
            if (input.Length < 6)
            {
                this._currentShopCat = this._currentShopCat ?? new ShopCart(ContextService.StoreId, ContextService.PosId, ContextService.CurrentAccount.Id);
                this._currentShopCat.WorkScheduleCode = _currentWork.Code;
                if (this._currentShopCat.OrderAmount > 0)
                {
                    CreateSaleOrder(input);
                }
                else if (this._currentShopCat.OrderAmount < 0)
                {
                    CreateSaleRefund(input);
                }
                else
                {
                    MessageBox.Show("请输入正确的商品条码或金额", "系统消息", MessageBoxButtons.OK, MessageBoxIcon.Information); return;
                }
            }
            else
            {
                InputBarCode(input);
            }
        }
Пример #4
0
        public void SetVipCard(VipCard vip)
        {
            //设置vip对象
            this.VipCustomer = vip;

            //刷新当前购物车折扣
            // var discount = this.VipCustomer == null ? 1 : this.VipCustomer.Discount;
            this._currentShopCat            = this._currentShopCat ?? new ShopCart(ContextService.StoreId, ContextService.PosId, ContextService.CurrentAccount.Id);
            this._currentShopCat.OrderLevel = Domain.ValueObject.SaleOrderLevel.Vip;
            if (this._currentShopCat.Items.Count == 0)
            {
                //如果当前还没刷商品,焦点返回输入框
                this.txtBarCode.Focus();
                return;
            }
            foreach (var item in this._currentShopCat.Items)
            {
                //只取会员商品价,不按折扣计算
                var realPrice  = item.SalePrice;
                var vipProduct = _vipProductService.GetByProductId(item.ProductId);
                realPrice = vipProduct == null ? item.SalePrice : vipProduct.SalePrice;
                item.ChangeRealPrice(realPrice);
            }
            // 重新绑定
            this.ShowOrderInfo();
            if (this.dgvData.CurrentCell != null)
            {
                this.dgvData.CurrentCell.Selected = true;
            }
            this.txtBarCode.Focus();
        }
Пример #5
0
 public AccountSetController(Context context, IGoods goodsRepository, ShopCart shopCart)
 {
     this.context  = context;
     this.shopCart = shopCart;
     MyCabinet     = new UnitOfWork_MyCabinet(context);
     //this.goodsRepository = goodsRepository;
 }
Пример #6
0
        // This method gets called by the runtime. Use this method to add services to the container.
        // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940

        public void ConfigureServices(IServiceCollection services)

        {
            /* Service Configuration */
            /* AddTransient leidzia susieti tam tikra interfeisa ir klase kuri realizuoja ji */
            /* ICarRepository realizuojasi klaseje ...... */
            services.AddIdentity <IdentityUser, IdentityRole>(options => {
            }).AddEntityFrameworkStores <AppDBContent>();

            services.AddDbContext <AppDBContent>(options => options.UseSqlServer(_confSting.GetConnectionString("DefaultConnection")));
            services.AddTransient <ICarRepository, CarRepository>();
            services.AddTransient <ICategoryRepository, CategoryRepository>();
            services.AddTransient <IAllOrders, OrdersRepository>();

            //Old Way
            // services.AddMvc();
            // New Ways
            services.AddRazorPages();
            services.AddCors();

            services.AddMemoryCache();
            services.AddSession();                                               /* Servisai nurodantys, kad mes usinam Sesijas ir Cache */

            services.AddSingleton <IHttpContextAccessor, HttpContextAccessor>(); /* Servisas leidziantis dirbti su sesijom */
            services.AddScoped(sp => ShopCart.GetCart(sp));                      /* Jis leis jeigu 2 naudotojai uzeis i krepseli, tai 2 naudotojams bus skirtingas krepselis */
        }
Пример #7
0
        private void BindGrid()
        {
            ShopCart cart = new ShopCart();
            DataTable dtCart = cart.GetCart();
            if(dtCart.Rows.Count > 0)
            {

                this.DgProducts.Visible = true;
                this.btnOrder.Visible = true;
                this.DgProducts.DataSource = dtCart;
                this.DgProducts.DataBind();

                /*for(int i = 0;i < dtCart.Rows.Count;i++)
                {
                    sum = sum + Convert.ToDecimal(dtCart.Rows[i]["Amount"]);
                }
                this.lblTotal.Text = "Total :: Rs." + Decimal.Round(sum,2).ToString();*/
                this.RefreshTotal();
            }
            else
            {
                this.DgProducts.Visible = false;
                this.btnOrder.Visible = false;
                this.lblTotal.Text = "You have 0 items in the basket";
            }
        }
Пример #8
0
    protected void Page_Load(object sender, EventArgs e)
    {
        //instantiate a shopcart object, if it doesn't exist

        if (Session["CustomerCart"] == null)
        {
            Session["CustomerCart"] = new ShopCart();
        }

        //if the shopcart doesn't have any items, hide the checkout button

        ShopCart aCart = Session["CustomerCart"] as ShopCart;

        if (aCart.GetCartItems().Count == 0)
        {
            btnCheckOut.Visible = false;
        }

        //if it is not a postback, call the BindGrid method

        if (!Page.IsPostBack)
        {
            BindGrid();
        }
    }
Пример #9
0
    //购物车动态添加用户控件,展示购物车数据表的内容
    protected void Page_Load(object sender, EventArgs e)
    {
        SqlConnection conn = new SqlConnection(constr);

        conn.Open();
        string         SqlStr1   = $"select * from [WebCart]";
        SqlDataAdapter data1     = new SqlDataAdapter(SqlStr1, conn);
        DataTable      dataTable = new DataTable();

        data1.Fill(dataTable);
        conn.Close();


        for (int i = 0; i < dataTable.Rows.Count; i++)
        {
            string CID         = dataTable.Rows[i]["commID"].ToString();
            string information = dataTable.Rows[i]["comIntroduction"].ToString();
            string imgURL      = dataTable.Rows[i]["imgUrl"].ToString();
            string temp        = $"{dataTable.Rows[i]["comPrice"]:F2}";
            double Cprice      = double.Parse(temp);
            int    splus       = int.Parse(dataTable.Rows[i]["comSurplus"].ToString());

            //ShopCart shopCart = (ShopCart)LoadControl("~/ShopCart.ascx");
            ShopCart shopCart = (ShopCart)this.Page.LoadControl("~/ShopCart.ascx");
            shopCart.ID = "shopCart" + i.ToString();
            shopCart.OnCheckedChanged += ShopCart_OnCheckedChanged;         //自定义的事件
            shopCart.InitShopCart(CID, information, imgURL, Cprice, splus); //自定义用户控件的一个方法
            this.Panel1.Controls.Add(shopCart);
        }
    }
Пример #10
0
        protected void shopping_Init(object sender, EventArgs e)
        {
            int group_id = 0;

            this.userModel = this.GetUserInfo();
            if (this.userModel == null)
            {
                if (this.orderConfig.anonymous == 0)
                {
                    HttpContext.Current.Response.Redirect(this.linkurl("login"));
                }
            }
            else
            {
                group_id = this.userModel.group_id;
            }
            if (string.IsNullOrEmpty(this.goodsJsonValue))
            {
                HttpContext.Current.Response.Redirect(this.linkurl("error", (object)("?msg=" + Utils.UrlEncode("对不起,无法获取您要购买的商品!"))));
            }
            else
            {
                try
                {
                    this.goodsList  = ShopCart.ToList(JsonHelper.JSONToObject <List <cart_keys> >(this.goodsJsonValue), group_id);
                    this.goodsTotal = ShopCart.GetTotal(this.goodsList);
                }
                catch
                {
                    HttpContext.Current.Response.Redirect(this.linkurl("error", (object)("?msg=" + Utils.UrlEncode("对不起,商品的传输参数有误!"))));
                }
            }
        }
Пример #11
0
        public void ConfigureServices(IServiceCollection services)
        {
            var connection = Configuration.GetConnectionString("DefaultConnection");

            services.AddDbContext <DBContext>(options => options.UseSqlServer(connection));



            services.AddSingleton <IHttpContextAccessor, HttpContextAccessor>();
            services.AddScoped(sp => ShopCart.GetCart(sp));

            services.AddIdentity <User, IdentityRole>(opts => {
                opts.Password.RequiredLength         = 3;
                opts.Password.RequireNonAlphanumeric = false;
                opts.Password.RequireLowercase       = false;
                opts.Password.RequireUppercase       = false;
                opts.Password.RequireDigit           = false;
            })
            .AddEntityFrameworkStores <DBContext>();

            services.AddSignalR();
            services.AddMvc();
            services.AddMemoryCache();
            services.AddSession();
        }
Пример #12
0
        public IActionResult Join([FromBody] ShopCart model)
        {
            var ifhave    = _context.ShopCarts.FirstOrDefault(s => s.DBPeriodsID == model.DBPeriodsID && s.UserID == CurrentUserID);
            var dbPeriods = _context.DBPeriods.Find(model.DBPeriodsID);

            if (ifhave != null)
            {
                ifhave.Num += model.Num;
                if (dbPeriods.OverplusNum < ifhave.Num)
                {
                    return(new ObjectResult(FormatResult.Failure("超过剩余次数,请到购物车查看!")));
                }
            }
            else
            {
                model.UserID = CurrentUserID;
                if (dbPeriods.OverplusNum < model.Num)
                {
                    return(new ObjectResult(FormatResult.Failure("超过剩余次数,请刷新重试!")));
                }
                _context.ShopCarts.Add(model);
            }

            _context.SaveChanges();
            return(new ObjectResult(FormatResult.Success("添加成功")));
        }
Пример #13
0
        public ActionResult ThemVaoGioHang(int id)
        {
            var P = db.Products.Single(p => p.id == id);

            if (P != null && P.quantity != 0)
            {
                ShopCart objCart = (ShopCart)Session["Cart"];
                if (objCart == null)
                {
                    objCart = new ShopCart();
                }
                ShoppingCartItem item = new ShoppingCartItem()
                {
                    Name     = P.name,
                    Id       = P.id,
                    Quantity = 1,
                    Price    = P.price,
                    Total    = P.price,
                    Image    = P.image
                };
                objCart.AddToCart(item);
                Session["Cart"] = objCart;

                return(RedirectToAction("Index", "Cart"));
            }
            else
            {
                return(RedirectToAction("Index", "Cart"));
            }
        }
Пример #14
0
 /// <summary>
 /// 清空订单明细
 /// </summary>
 public void ClearItems()
 {
     ShowPreOrderInfo();
     this.dgvData.DataSource = new List <ShopCartItem>();
     this.VipCustomer        = null;
     this._currentShopCat    = null;
 }
Пример #15
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            string connection = Configuration.GetConnectionString("DefaultConnection");

            services.AddDbContext <ApplicationDBContext>(options =>
                                                         options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")));

            services.AddIdentity <User, IdentityRole <int> >()
            .AddEntityFrameworkStores <ApplicationDBContext>();
            services.AddTransient <IAllComputers, ComputerRepository>();
            services.AddTransient <IComputersProducts, ProductRepository>();
            services.AddTransient <IAllOrders, OrdersRepository>();


            services.AddTransient <IAllOrders, OrdersRepository>();

            services.AddSingleton <IHttpContextAccessor, HttpContextAccessor>();
            services.AddScoped(sp => ShopCart.GetCart(sp));


            services.AddMvc();
            services.AddControllersWithViews();
            services.AddMemoryCache();
            services.AddSession();
        }
Пример #16
0
        // xoa gio hang
        public ActionResult DeleteShopCart(int BookID)
        {
            Book book = db.Books.SingleOrDefault(n => n.BookID == BookID);

            if (book == null)
            {
                Response.StatusCode = 404;
                return(null);
            }
            // dung thi lay gio hang ra tu sesstion
            List <ShopCart> listShopCart = GetShopCart();
            // kiem tra sp co ton tai trong gio hang hay khong
            ShopCart SP = listShopCart.Find(n => n.BookID == BookID);

            // neu ma ton tai ta cho sua so luong lai
            if (SP != null)
            {
                listShopCart.RemoveAll(n => n.BookID == BookID);
            }
            if (listShopCart.Count == 0)
            {
                return(RedirectToAction("Home", "Index"));
            }
            return(RedirectToAction("Shopcart"));
        }
Пример #17
0
        // them gio hang
        public ActionResult AddShopCart(int BookID, string strURL)
        {
            Book book = db.Books.SingleOrDefault(n => n.BookID == BookID);

            if (book == null)
            {
                Response.StatusCode = 404;
                return(null);
            }
            // lay ra sesstin gio hang
            List <ShopCart> listShopCart = GetShopCart();
            // kiem tra sach nay da ton tai trong sesstion[] gio hang chua
            ShopCart SP = listShopCart.Find(n => n.BookID == BookID);

            if (SP == null)
            {
                SP = new ShopCart(BookID);
                // add san pham moi them
                listShopCart.Add(SP);
                return(Redirect(strURL));
            }
            else
            {
                SP.Quantity++;
                return(Redirect(strURL));
            }
        }
Пример #18
0
        public ActionResult XoaGioHang()
        {
            ShopCart objCart = (ShopCart)Session["Cart"];

            objCart.DeleteAllItems();
            Session["Cart"] = objCart;
            return(View());
        }
Пример #19
0
        private void MigrateShoppingCart(string UserName)
        {
            // Associate shopping cart items with logged-in user
            var cart = ShopCart.GetCart(this.HttpContext);

            cart.MigrateCart(UserName);
            Session[ShopCart.CartSessionKey] = UserName;
        }
Пример #20
0
        public ActionResult CartSummary()
        {
            var cart = ShopCart.GetCart(this.HttpContext);

            ViewData["CartCount"] = cart.GetCount();

            return(PartialView("CartSummary"));
        }
Пример #21
0
        public ShopCart Get()
        {
            Cart cart = cartAccess.Get();

            ShopCart shopCart = Mapper.Map <ShopCart>(cart);

            return(shopCart);
        }
Пример #22
0
 public void addItem(ShopCart item)
 {
     using (CrazyBuyDbContext dbContext = ContextInit())
     {
         dbContext.ShopCart.Add(item);
         dbContext.SaveChanges();
     }
 }
        public ActionResult SaveField(string name, string value)
        {
            var cart = new ShopCart().InitCart();

            cart.SetField(name, value);
            cart.Reset();
            return(new ContentResult());
        }
Пример #24
0
        public async Task <IActionResult> AddProductCart(int customerId, string productId)
        {
            CacheProductList list = await _YoungoServer.GetCacheProductList();

            if (_YoungoServer.IsExistenceCart(customerId))
            {
                ShopCart cart = _YoungoServer.GetShopCart(customerId);
                if (cart.ProductList.All(a => a.ProductID == productId))
                {
                    ProductList productList = cart.ProductList.Find(a => a.ProductID == productId);
                    cart.ProductList.Remove(productList);
                    productList.Number++;
                    productList.TotalPrice = productList.Number * productList.Product.PurchasePrice;
                    cart.ProductList.Add(productList);
                    if (_YoungoServer.ClearShopCart(customerId))
                    {
                        result.IsSuccessful = _YoungoServer.CreateShopCart(cart);
                        return(View(result));
                    }
                    else
                    {
                        result.ReasonDescription = "清空购物车货失败!";
                        return(View(result));
                    }
                }
                else
                {
                    ProductList  productList = new ProductList();
                    ProductModel product     = list.ProductList.Find(a => a.ProductID == productId);
                    productList.Product    = product;
                    productList.Number     = 1;
                    productList.ProductID  = productId;
                    productList.TotalPrice = product.PurchasePrice;
                    cart.ProductList.Add(productList);
                    result.IsSuccessful = _YoungoServer.ModifyShopCart(cart);
                    return(View(result));
                }
            }
            else
            {
                ShopCart cart = new ShopCart
                {
                    CustomerID = customerId
                };
                ProductList  productList = new ProductList();
                ProductModel product     = list.ProductList.Find(a => a.ProductID == productId);
                productList.Product    = product;
                productList.Number     = 1;
                productList.ProductID  = productId;
                productList.TotalPrice = product.PurchasePrice;
                cart.ProductList       = new List <ProductList>
                {
                    productList
                };
                result.IsSuccessful = _YoungoServer.CreateShopCart(cart);
                return(View(result));
            }
        }
Пример #25
0
 public AccountController(UserManager <UserData> userMgr, SignInManager <UserData> signinMgr,
                          IWebHostEnvironment _hostingEnv, AppDbContext context, ShopCart shopCart)
 {
     userManager      = userMgr;
     signInManager    = signinMgr;
     this._hostingEnv = _hostingEnv;
     this.context     = context;
     _shopCart        = shopCart;
 }
Пример #26
0
        /// <summary>
        /// 上一单面板显示作废信息
        /// </summary>
        public void ShowCancelOrderInfo()
        {
            var model = this._currentShopCat;

            this._preShopCat             = model;
            this.lblPreOrderCode.Text    = "上一单:" + model.OrderCode;
            this.lblPreOrderAmount.Text  = "金额:" + model.OrderAmount.ToString("F2");
            this.lblPreChargeAmount.Text = "找零:0.00";
        }
Пример #27
0
 public ShopCartViewModel(ShopCart sc)
 {
     ShopCartId = sc.ShopCartId;
     BookID     = sc.BookID;
     Title      = sc.Book.Title;
     Seller     = sc.User.UserName;
     Quantity   = sc.Quantity;
     UnitPrice  = sc.Book.Price;
     check      = false;
 }
Пример #28
0
 public void ClearAll()
 {
     this.dgvData.DataSource    = new List <ShopCartItem>();
     this.lblOrderTotal.Text    = "总金额:0.00";
     this.lblQuantityTotal.Text = "总件数:0";
     this.lblOrderCode.Text     = "订单号:";
     this.lblDiscount.Text      = "总优惠:0.00";
     this.VipCustomer           = null;
     this._currentShopCat       = null;
 }
Пример #29
0
        public ActionResult DeleteFrist()
        {
            //删除单条购物车
            ShopCart sc = new ShopCart()
            {
                ScartId = int.Parse(Request["CartId"]),
            };

            ShopCartService.Remove(sc);
            return(RedirectToAction("Index"));
        }
Пример #30
0
        // This method gets called by the runtime. Use this method to add services to the container.
        // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940

        //services
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddDbContext <AppDBContent>(options => options.UseSqlServer(_confString.GetConnectionString("DefaultConnection")));
            services.AddTransient <IAllCars, CarRepository>();
            services.AddTransient <ICarsCategory, CategoryRepository>();
            services.AddSingleton <IHttpContextAccessor, HttpContextAccessor>();
            services.AddScoped(sp => ShopCart.GetCart(sp));
            services.AddMvc();
            services.AddMemoryCache();
            services.AddSession();
        }
Пример #31
0
        public async Task <IHttpActionResult> GetShopCart(int id)
        {
            ShopCart shopCart = await db.ShopCart.FindAsync(id);

            if (shopCart == null)
            {
                return(NotFound());
            }

            return(Ok(shopCart));
        }
Пример #32
0
        private void btnCheckoutMail_Click(object sender, ImageClickEventArgs e)
        {
            if(TxtName.Text!="" && TxtAddress.Text!="" && TxtPhone.Text!="" && TxtBankName.Text!="" && TxtChequeDate.Text!="" && TxtChequeNumber.Text!="")
            {

                try
                {

                    string strbody="<h3>Product Deleviry</h3>";
                    strbody=strbody+"<h4>Dear Sir New delevery Informataion is given below : </h4>";
                    strbody=strbody+"Sender Name:: " + this.TxtName.Text.Trim() + "<BR>";
                    strbody=strbody+"Sender Address:: " + this.TxtAddress.Text.Trim() +"<BR>";
                    strbody=strbody+"Sender Phone:: " + this.TxtPhone.Text.Trim() +"<BR>";
                    strbody=strbody+"Bank Name:: " + this.TxtBankName.Text.Trim() +"<BR>";
                    strbody=strbody+"Cheque Date:: " + this.TxtChequeDate.Text.Trim() +"<BR>";
                    strbody=strbody+"Cheque Number:: " + this.TxtChequeNumber.Text.Trim() +"<BR>";

                    ShopCart cart = new ShopCart();
                    DataTable dtItem = (DataTable)cart.GetCart();
                    strbody=strbody+"<br><b>Product to be delevired ::</b><br>";

                    //format the product to be delevired.
                    StringBuilder str = new StringBuilder();
                    str.Append("<table border=1 cellpadding=0 cellspacing=0 width=100%>");
                    str.Append("<tr>");
                    //s.no
                    str.Append("<td>");
                    str.Append("S.No");
                    str.Append("</td>");
                    //product name
                    str.Append("<td>");
                    str.Append("Product Name");
                    str.Append("</td>");
                    //size
                    str.Append("<td>");
                    str.Append("Size");
                    str.Append("</td>");
                    //quantity
                    str.Append("<td>");
                    str.Append("Quantity");
                    str.Append("</td>");
                    str.Append("</tr>");
                    for(int i = 0;i < dtItem.Rows.Count;i++)
                    {
                        str.Append("<tr>");
                        //s.no
                        str.Append("<td>");
                        str.Append((i+1).ToString());
                        str.Append("</td>");
                        //product name
                        str.Append("<td>");
                        str.Append(dtItem.Rows[i]["ProductName"].ToString());
                        str.Append("</td>");
                        //size
                        str.Append("<td>");
                        str.Append(dtItem.Rows[i]["Size"].ToString());
                        str.Append("</td>");
                        //quantity
                        str.Append("<td>");
                        str.Append(dtItem.Rows[i]["Quantity"].ToString());
                        str.Append("</td>");
                        str.Append("</tr>");
                        //strbody=strbody+dtItem.Rows[i]["Amount"].ToString();
                    }
                    //get the total amount.
                    str.Append("<tr>");
                    str.Append("<td colspan='4' align='right'>");
                    str.Append("Total Amount :: " + this.lblTotal.Text.Trim());
                    str.Append("</td>");
                    str.Append("</table>");
                    strbody = strbody + str.ToString();
                    strbody=strbody+"Date:: "+ DateTime.Now.ToLongDateString() +"<BR>";
                    strbody=strbody+"Thank you" + "<BR>";
                    strbody=strbody + this.TxtName.Text.Trim() + "<BR>";

                    Mail.sendemail("*****@*****.**","*****@*****.**","*****@*****.**","New Order",strbody,"","","","");
                    //clear controls
                    this.TxtName.Text = string.Empty;
                    this.TxtAddress.Text = string.Empty;
                    this.TxtPhone.Text = string.Empty;
                    this.TxtBankName.Text = string.Empty;
                    this.TxtChequeDate.Text = string.Empty;
                    this.TxtChequeNumber.Text = string.Empty;

                    this.ltError.Visible=true;
                    this.ltError.Text="Your Order has been places successfully.Thank You";
                }
                catch(Exception ex)
                {
                    Response.Write(ex.Message.ToString());
                }
            }
            else
            {
                lblmessage.Text="All field have required!!";
            }
        }
Пример #33
0
        private void RefreshTotal()
        {
            ShopCart cart = new ShopCart();
            DataTable dtCart = cart.GetCart();
            //calculate the price in RS.
            for(int i = 0;i < dtCart.Rows.Count;i++)
            {
                sum = sum + Convert.ToDecimal(dtCart.Rows[i]["Amount"]);
            }

            //calculate the price in US dollers
            //
            //fetch the us dollers price for 1 rupee
            Data DbConn = Data.CreateConnection();
            DataTable dt = DbConn.ExecuteResultQuery("SELECT * FROM Tbl_Usd_Price",null);
            decimal USDPrice = decimal.Parse(dt.Rows[0]["Fld_Price"].ToString());
            decimal USDSum=0,USDAmount;
            for(int i = 0;i < dtCart.Rows.Count;i++)
            {
                USDAmount = (Convert.ToDecimal(dtCart.Rows[i]["Amount"]) / USDPrice);
                USDSum = USDSum + USDAmount;
                //Response.Write("USDPrice" +USDPrice);
                //Response.Write("USDSum" + USDSum);
                //Response.Write("USDSum" +USDSum);

            }
            this.lblgoforpayment.Text="RS. " + sum.ToString("0.00") + " or USD " + USDSum.ToString("F");

            //this.lblTotal.Text = "RS. " + sum.ToString() + " or USD " + USDSum.ToString("F");
            if(lblgoforpayment.Text!=String.Empty)
            {
                decimal pay=Convert.ToDecimal(sum.ToString());
                if(pay<5000)
                {
                    decimal USDSum1=0,USDAmount1;
                    decimal shipcharge=(pay*3)/100;

                    USDSum1=shipcharge/USDPrice;
                    lblshiping.Text ="RS. "+ shipcharge.ToString("0.00") +" or USD "+ USDSum1.ToString("F");
                    decimal totalpay=pay+shipcharge;
                    USDAmount1=totalpay/USDPrice;
                    this.lblTotal.Text = "Total Payment RS. " + totalpay.ToString("0.00") + " or USD " + USDAmount1.ToString("F");

                }
                else
                {
                    decimal USDSum1=0,USDAmount1;
                    decimal shipcharge=0;
                    USDSum1=shipcharge/USDPrice;

                    lblshiping.Text ="RS. "+ shipcharge.ToString("0.00") +" or USD "+ USDSum1.ToString("F");
                    decimal totalpay=pay+shipcharge;
                    USDAmount1=totalpay/USDPrice;
                    this.lblTotal.Text = "Total Payment RS. " + totalpay.ToString("0.00") + " or USD " + USDAmount1.ToString("F");

                }

            }
        }
Пример #34
0
        private void Page_Load(object sender, System.EventArgs e)
        {
            if(!Page.IsPostBack)
            {
                ShopCart cart = new ShopCart();
                if(Request.QueryString["Pid"] != null && Request.QueryString["SId"] != null)
                {
                    DataTable dtItem = cart.GetCart();
                    System.Web.HttpContext context = System.Web.HttpContext.Current;
                    cart.FillItems(context.Session.SessionID,Request.QueryString["Pid"],Request.QueryString["SId"],"1");
                }
                this.BindGrid();
                this.aContinue.HRef="./SeeAllCategories.aspx?Action=All";//this.Request.UrlReferrer.AbsoluteUri;

            }
            this.Load_Control("Basket");
            //this.RefreshTotal();
        }
Пример #35
0
        void CheckOut(ShopCart cart)
        {
            String cartBusiness ="*****@*****.**";
            String cartProduct;
            int cartQuantity;
            int cartItemNumber;
            Decimal cartCost=0;
            Decimal INRcartCost;
            Decimal USDPrice;
            int itemNumber = 1;

            cartBusiness = Server.UrlEncode(cartBusiness);

            String strPaypal = "https://www.paypal.com/cgi-bin/webscr" +
                "?cmd=_cart&upload=1&business=" + cartBusiness;

            //fetch the us dollers price for 1 rupee
            Data DbConn = Data.CreateConnection();
            DataTable dt = DbConn.ExecuteResultQuery("SELECT * FROM Tbl_Usd_Price",null);
            USDPrice = decimal.Parse(dt.Rows[0]["Fld_Price"].ToString());

            DataTable objCartDT = cart.GetCart();
            foreach (DataRow objDR in objCartDT.Rows)
            {

                cartProduct = Server.UrlEncode((String)objDR["ProductName"]);

                cartQuantity = int.Parse(objDR["Quantity"].ToString());
                cartItemNumber = int.Parse(objDR["ProductId"].ToString());

                //calculate the price in US dollers

            //cartCost = (Decimal.Parse(objDR["Price"].ToString()) / USDPrice);
                INRcartCost = (Decimal.Parse(objDR["Price"].ToString()));

                if(INRcartCost<5000)
                {
                    Decimal percentage=(INRcartCost*3)/100;
                    Decimal TotalPay=INRcartCost-percentage;

                    cartCost = TotalPay / USDPrice;

                }
                else
                {
            //					Decimal percentage=(INRcartCost*0)/100;
            //					Decimal TotalPay=INRcartCost-percentage;
            //
            //					cartCost = TotalPay / USDPrice;
                    cartCost = (Decimal.Parse(objDR["Price"].ToString()) / USDPrice);

                }

            //				int iFinalCost = cartQuantity * cartCost;
            //				string fCost = iFinalCost.ToString("f");

                strPaypal += "&item_name_" + itemNumber + "=" + cartProduct;
                strPaypal += "&item_number_" + itemNumber + "=" + cartItemNumber;
                strPaypal += "&quantity_" + itemNumber + "=" + cartQuantity;
            //				strPaypal += "&amount_" + itemNumber + "=" + decimal.Round((cartQuantity * cartCost),2);
                strPaypal += "&amount_" + itemNumber + "=" + decimal.Round(cartCost,2);
                //added to change the currency.
                //strPaypal += "&cy_code" + "currencyCode" + "=" + "GBP";
                //add cancel return url also.
                //strPaypal += "&currency_code" + "=" + "INR";

                itemNumber++;
            }

            //				strPaypal += "&Shipping_charge_" + decimal.Round(Ship,2);
            strPaypal += "&add_" + "=" + 1;
            Response.Write(strPaypal);
            Response.Redirect(strPaypal);
        }
Пример #36
0
 private void btnOrder_Click(object sender, ImageClickEventArgs e)
 {
     ShopCart cart = new ShopCart();
     if(cart.GetCart().Rows.Count > 0)
         this.CheckOut(cart);
     else
         this.ltError.Text = "You have 0 items in the basket. Checkout process cannot continue.";
     cart.ClearCache();
 }