public int DoCreateFoodItemRecord(string transactionId, int custId, int foodId, int orderQuantity) { string checkOutStatus = "N"; OrderItemList newOrderItemList = new OrderItemList(transactionId, custId, foodId, orderQuantity, checkOutStatus); int result = 0; try { using (NpgsqlConnection connection = new NpgsqlConnection()) { connection.ConnectionString = ConfigurationManager.ConnectionStrings["constr"].ToString(); connection.Open(); NpgsqlCommand cmd = new NpgsqlCommand(); cmd.Connection = connection; cmd.CommandText = "Insert into OrderItemList(transactionId, cId, foodId, orderquantity, checkout) values(@transactionId, @cId, @foodId, @orderquantity, @checkout)"; cmd.CommandType = CommandType.Text; cmd.Parameters.Add(new NpgsqlParameter("@transactionId", newOrderItemList.TransactionId)); cmd.Parameters.Add(new NpgsqlParameter("@cId", newOrderItemList.CustId)); cmd.Parameters.Add(new NpgsqlParameter("@foodId", newOrderItemList.FoodId)); cmd.Parameters.Add(new NpgsqlParameter("@orderquantity", newOrderItemList.OrderQuantity)); cmd.Parameters.Add(new NpgsqlParameter("@checkout", newOrderItemList.Checkout)); result = cmd.ExecuteNonQuery(); cmd.Dispose(); connection.Close(); } } catch (Exception ex) { Console.WriteLine(ex); } return(result); }
public bool SaveOrder(OrderItemList OrderBO) { if (OrderBO.TotalAmount <= 500) { DateTime _orderdate = DateTime.Now.Date; CustomerOrder _customerorder = new CustomerOrder() { }; _customerorder.OrderDate = _orderdate; _customerorder.TotalAmount = OrderBO.TotalAmount; _customerorder.CustomerID = OrderBO.CustomerID; foreach (var order in OrderBO.OrderList) { if (order.ProductID != "undefined") { if ((Convert.ToInt32(order.ItemTotal) <= 200) && (Convert.ToInt32(order.Quantity)) <= 10) { var real = new Order { ProductID = Convert.ToInt32(order.ProductID), Quantity = Convert.ToInt32(order.Quantity), ItemTotal = Convert.ToInt32(order.ItemTotal) }; _customerorder.OrderItems.Add(real); } } } _unitOfWork.CustomerOrderRepository.Insert(_customerorder); _unitOfWork.Save(); return(true); } return(false); }
private async void SetCustomerReturnGoodsSeftReject() { List <OrderItemDto> selectOrder = OrderItemList.Where(e => e.IsSelected).ToList(); if (SaleRma == null) { await MvvmUtility.ShowMessageAsync("请选择订单", "提示", MessageBoxButton.OK, MessageBoxImage.Warning); return; } if (selectOrder.Count == 0) { await MvvmUtility.ShowMessageAsync("请选择销售单明细", "提示", MessageBoxButton.OK, MessageBoxImage.Warning); return; } List <KeyValuePair <int, int> > list = selectOrder.Select( e => new KeyValuePair <int, int>(e.Id, e.NeedReturnCount)).ToList <KeyValuePair <int, int> >(); RmaPost.OrderNo = SaleRma.OrderNo; RmaPost.ReturnProducts = list; bool bFlag = AppEx.Container.GetInstance <ICustomerGoodsReturnService>().CustomerReturnGoodsSelfReject(RmaPost); await MvvmUtility.ShowMessageAsync(bFlag? "拒绝退货申请成功" : "拒绝退货申请失败", "提示", MessageBoxButton.OK, bFlag?MessageBoxImage.Information : MessageBoxImage.Error); if (bFlag) { ClearOrInitData(); RmaPost = new RMAPost(); ReturnGoodsSearch(); } }
public int DoUpdateFoodItemListCheckOut(string transactionId) { string checkout = "Y"; OrderItemList orderItemList = new OrderItemList(transactionId, checkout); int result = 0; try { using (NpgsqlConnection connection = new NpgsqlConnection()) { connection.ConnectionString = ConfigurationManager.ConnectionStrings["constr"].ToString(); connection.Open(); NpgsqlCommand cmd = new NpgsqlCommand(); cmd.Connection = connection; cmd.CommandText = "Update OrderItemList Set checkout=@checkout Where transactionId=@transactionId"; cmd.CommandType = CommandType.Text; cmd.Parameters.Add(new NpgsqlParameter("@transactionId", orderItemList.TransactionId)); cmd.Parameters.Add(new NpgsqlParameter("@checkout", orderItemList.Checkout)); result = cmd.ExecuteNonQuery(); cmd.Dispose(); connection.Close(); } } catch (Exception ex) { Console.WriteLine(ex); } return(result); }
public int DoUpdateFoodItemQuantityByIncreaseCount(string transactionId, int custId, int foodId, int orderQuantity) { int newOrderQuantity = orderQuantity + 1; //Increase by One OrderItemList newOrderItemList = new OrderItemList(transactionId, custId, foodId, newOrderQuantity); int result = 0; try { using (NpgsqlConnection connection = new NpgsqlConnection()) { connection.ConnectionString = ConfigurationManager.ConnectionStrings["constr"].ToString(); connection.Open(); NpgsqlCommand cmd = new NpgsqlCommand(); cmd.Connection = connection; cmd.CommandText = "Update OrderItemList Set orderquantity=@orderquantity Where foodId=@foodId And transactionId=@transactionId"; cmd.CommandType = CommandType.Text; cmd.Parameters.Add(new NpgsqlParameter("@foodId", newOrderItemList.FoodId)); cmd.Parameters.Add(new NpgsqlParameter("@transactionId", newOrderItemList.TransactionId)); cmd.Parameters.Add(new NpgsqlParameter("@orderquantity", newOrderItemList.OrderQuantity)); result = cmd.ExecuteNonQuery(); cmd.Dispose(); connection.Close(); } } catch (Exception ex) { Console.WriteLine(ex); } return(result); }
private async void deleteOrderItem() { if (SelectedItem != null) { await ManagementProvider.DeleteOrderItemAsync(SelectedItem.Id.ToString()); OrderItemList.Remove(SelectedItem); calculPrice(); } }
public void LoadTest() { OrderItemList orderItems = new OrderItemList(); orderItems.LoadByOrderId(1); int expected = 3; int actual = orderItems.Count; Assert.AreEqual(expected, actual); }
protected void Page_Load(object sender, EventArgs e) { using (MWSklep.Logic.ShoppingCartActions usersShoppingCart = new MWSklep.Logic.ShoppingCartActions()) { List <CartItem> myOrderList = usersShoppingCart.GetCartItems(); OrderItemList.DataSource = myOrderList; OrderItemList.DataBind(); lblTotal2.Text = String.Format("{0:c}", usersShoppingCart.GetTotal()); } }
public override void GetOrderDetailByOrderNo() { if (SaleRma != null) { OrderItemList.Clear(); IList <OrderItemDto> list = AppEx.Container.GetInstance <ICustomerGoodsReturnService>() .GetOrderDetailByOrderNoWithSelf(SaleRma.OrderNo); OrderItemList = list.ToList(); } MvvmUtility.WarnIfEmpty(OrderItemList, "订单明细"); }
public void DeleteTest() { OrderItemList orderItems = new OrderItemList(); orderItems.LoadByOrderId(-99); //Find the order with the description testingorder OrderItem orderItem = orderItems.FirstOrDefault(f => f.Quantity == -98); //Delete it int result = orderItem.Delete(); Assert.IsTrue(result == 1); }
public void UpdateTest() { OrderItemList orderItems = new OrderItemList(); orderItems.LoadByOrderId(-99); //Find the order with the description testingorder OrderItem orderItem = orderItems.FirstOrDefault(o => o.Quantity == -99); //Update it and insert it orderItem.Quantity = -98; int result = orderItem.Update(); Assert.IsTrue(result == 1); }
/*客服退货*/ private async void CustomerReturnGoodsSave() { List <OrderItemDto> selectOrder = OrderItemList.Where(e => e.IsSelected).ToList(); if (SaleRma == null) { await MvvmUtility.ShowMessageAsync("请选择订单", "提示", MessageBoxButton.OK, MessageBoxImage.Warning); return; } if (selectOrder.Count == 0) { await MvvmUtility.ShowMessageAsync("请选择销售单明细", "提示", MessageBoxButton.OK, MessageBoxImage.Warning); return; } //原因必填 if (string.Empty == RmaPost.Remark || RmaPost.Remark == null || RmaPost.Remark == "") { await MvvmUtility.ShowMessageAsync("退货备注不能为空", "提示", MessageBoxButton.OK, MessageBoxImage.Warning); return; } List <KeyValuePair <int, int> > list = selectOrder.Select( e => new KeyValuePair <int, int>(e.Id, e.NeedReturnCount)).ToList <KeyValuePair <int, int> >(); //退货数量大于0,且已退数量+退货数量<=销售数量 List <OrderItemDto> q = selectOrder.Where(t => (t.ReturnCount + t.NeedReturnCount > t.Quantity) || t.NeedReturnCount < 1).ToList(); if (q.Count > 0) { await MvvmUtility.ShowMessageAsync("选择的订单明细的退货数量必须大于零,且已退货数量加上退货数量要小于等于销售数量", "提示", MessageBoxButton.OK, MessageBoxImage.Warning); return; } RmaPost.OrderNo = SaleRma.OrderNo; RmaPost.ReturnProducts = list; bool bFlag = AppEx.Container.GetInstance <ICustomerGoodsReturnService>().CustomerReturnGoodsSave(RmaPost); await MvvmUtility.ShowMessageAsync(bFlag? "客服退货成功" : "客服退货失败", "提示", MessageBoxButton.OK, bFlag?MessageBoxImage.Information : MessageBoxImage.Error); if (bFlag) { ClearOrInitData(); RmaPost = new RMAPost(); ReturnGoodsSearch(); } }
protected void Page_Load(object sender, EventArgs e) { if (Session["isLogin"] == null) { Response.Redirect("Login.aspx"); } UserAccount user = (UserAccount)Session["UserAccountObj"]; lblUserName.Text = user.Username.ToUpper(); if (Session["generatedId"] == null) { OrderItemListBLL orderItemListBLL = new OrderItemListBLL(); OrderItemList orderItemList = orderItemListBLL.DoRetrieveExisitngCustomerFoodItemListByCustId(user.UserId); if (orderItemList != null) { Session["generatedId"] = orderItemList.TransactionId; } } StatsBLL statsBLL = new StatsBLL(); string recentLocation = statsBLL.DoRetrieveRecentLocation(user.UserId); if (recentLocation == "") { lblRecentLocation.Text = "You have no recent location"; btnClearHistory.Enabled = false; } else { lblRecentLocation.Text = recentLocation; } int ordersMade = statsBLL.DoCountCustomersOrder(user.UserId); lblOrdersMade.Text = ordersMade.ToString(); int reviewMade = statsBLL.DoCountCustomersReviews(user.UserId); lblReviewsMade.Text = reviewMade.ToString(); }
/*退货单查询*/ public virtual void ReturnGoodsSearch() { SaleRmaList.Clear(); if (OrderItemList != null) { OrderItemList.Clear(); } IList <OPC_SaleRMA> list = AppEx.Container.GetInstance <ICustomerGoodsReturnService>().ReturnGoodsSearch(ReturnGoodsGet); if (list == null) { ClearOrInitData(); } else { SaleRmaList = list.ToList(); } }
public OrderItemList DoRetrieveExisitngCustomerFoodItemListByCustId(int custId) { try { using (NpgsqlConnection connection = new NpgsqlConnection()) { connection.ConnectionString = ConfigurationManager.ConnectionStrings["constr"].ToString(); connection.Open(); NpgsqlCommand cmd = new NpgsqlCommand(); cmd.Connection = connection; cmd.CommandText = "Select * from OrderItemList WHERE cId=@cid And checkout='N' "; cmd.CommandType = CommandType.Text; NpgsqlDataAdapter da = new NpgsqlDataAdapter(cmd); da.SelectCommand.Parameters.AddWithValue("@cId", custId); DataTable dt = new DataTable(); da.Fill(dt); cmd.Dispose(); connection.Close(); int lineId = Convert.ToInt32(dt.Rows[0]["lineId"].ToString()); string transactionId = dt.Rows[0]["transactionId"].ToString(); int foodId = Convert.ToInt32(dt.Rows[0]["foodId"].ToString()); int orderQuantity = Convert.ToInt32(dt.Rows[0]["orderquantity"].ToString()); string checkOut = dt.Rows[0]["checkout"].ToString(); OrderItemList orderItemList = new OrderItemList(lineId, transactionId, custId, foodId, orderQuantity, checkOut); return(orderItemList); } } catch (Exception ex) { Console.WriteLine(ex); } return(null); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { var payPalCaller = new NVPAPICaller(); var retMsg = ""; var token = Session["token"].ToString(); var payerId = ""; var decoder = new NVPCodec(); var ret = payPalCaller.GetCheckoutDetails(token, ref payerId, ref decoder, ref retMsg); if (ret) { Session["PayerId"] = payerId; var myOrder = new Order(); myOrder.OrderDate = Convert.ToDateTime(decoder["TIMESTAMP"]); myOrder.Username = User.Identity.Name; myOrder.FirstName = decoder["FIRSTNAME"]; myOrder.LastName = decoder["LASTNAME"]; myOrder.Address = decoder["SHIPTOSTREET"]; myOrder.City = decoder["SHIPTOCITY"]; myOrder.State = decoder["SHIPTOSTATE"]; myOrder.PostalCode = decoder["SHIPTOZIP"]; myOrder.Country = decoder["SHIPTOCOUNTRYCODE"]; myOrder.Email = decoder["EMAIL"]; myOrder.Total = Convert.ToDecimal(decoder["AMT"]); // Verify total payment amount as set on CheckoutStart.aspx try { var paymentAmountOnCheckout = Convert.ToDecimal(Session["payment_amt"].ToString()); var paymentAmountFromPayPal = Convert.ToDecimal(decoder["AMT"]); if (paymentAmountOnCheckout != paymentAmountFromPayPal) { Response.Redirect("/Checkout/CheckoutError.aspx?Desc=Amount%20total%20mismatch."); } } catch (Exception) { Response.Redirect("/Checkout/CheckoutError.aspx?Desc=Amount%20total%20mismatch."); } // Get DB context var _db = new ProductContext(); // Add order to db _db.Orders.Add(myOrder); _db.SaveChanges(); // Get the shopping cart items and process them. using (var usersShoppingCart = new ShoppingCartActions()) { var myOrderList = usersShoppingCart.GetCartItems(); // Add OrderDetail information to the db for each product purchased foreach (var item in myOrderList) { // Create a new OrderDetail object var myOrderDetail = new OrderDetail { OrderId = myOrder.OrderId, Username = User.Identity.Name, ProductId = item.ProductId, Quantity = item.Quantity, UnitPrice = item.Product.UnitPrice }; // Add OrderDetail to db _db.OrderDetails.Add(myOrderDetail); _db.SaveChanges(); } // Set OrderId Session["CurrentOrderId"] = myOrder.OrderId; // Display Order information var orderList = new List <Order>(); orderList.Add(myOrder); ShipInfo.DataSource = orderList; ShipInfo.DataBind(); // Display OrderDetails OrderItemList.DataSource = myOrderList; OrderItemList.DataBind(); } } else { Response.Redirect($"/Checkout/CheckoutError.aspx?{retMsg}"); } } }
private async void OnItemDeleted(object sender, EventArgs e) { await OrderItemList.RefreshAsync(); }
void SubmitButton_Click(object sender, EventArgs e) { if (Page.IsValid) { try { bool testMode = CardNumberTextBox.Text == TEST_CC_NUMBER; OrderItemList<OrderItem> items = new OrderItemList<OrderItem>(); // you cant add the item if it already exists... foreach (OfferItem item in Controller.Offer.Items) { // Override Add for Duplicate Checks if (item.OfferItemType == OfferItemType.Standard || item.OfferItemType == OfferItemType.ForcedUpsell) { items.Add ( new OrderItem ( item.Sku, Controller.Customer.ID, testMode, Controller.LandingPage.ID, Controller.SessionID, item.ProductTypeID ) ); } } // Controller.Order.Save(); // save the order items to the database foreach (OrderItem item in items) { ICreditCard card = new CreditCard(); item.OrderSucceeded += new EventHandler(item_OrderSucceeded); item.OrderFailed += new EventHandler(item_OrderFailed); // new Products.Provider.ProductProcessor(item).Process(); if (item.Passed) { item.IsQueued = false; Controller.Order.Items.Add(item); } else { item.IsQueued = true; Controller.Queue.Items.Add(item); } /* * Lets say we are processing 3 items, 1 standard and 2 forced upsell * if the standard passes, and foced upsells fail, allow order * to continue processing..., but put failed orderitems in queue * * Lets say we are process 3 items, 1 standard and 2 forced.. * and standard fails... do not even attempt to process forced. * * Lets say there are 2 standard.. one failes and one passes * keep processing... and put one in queue */ } Controller.Order.Save(); // save the order items to the database Controller.Queue.Save(); // save the failed item queue to the database // OnOrderCreated(new OrderCreatedEventArgs(new Order(items), testMode)); } catch (WebException ex) { // indicative of a timeout or some sort of http error... OnOrderError(new OrderErrorEventArgs("Http Error", ex)); } catch (SqlException ex) { OnOrderError(new OrderErrorEventArgs("Sql Error", ex)); } catch (Exception ex) { // Log the error... LandingPageErrorEvent evnt = new LandingPageErrorEvent( ex.Message, "Unknown Error : " + ex.Message.ToString(), this, ex); evnt.Raise(); OnOrderError(new OrderErrorEventArgs("Unknown Error", ex)); } } }
public void Unload() { OrderItemList.Unload(); }
public async Task RefreshAsync() { await OrderItemList.RefreshAsync(); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { NVPAPICaller paypalCaller = new NVPAPICaller(); string retMsg = string.Empty; string token = Session["token"].ToString(); string payerId = string.Empty; NVPCodec decoder = new NVPCodec(); bool ret = paypalCaller.GetCheckoutDetails(token, ref payerId, ref decoder, ref retMsg); if (ret) { Session["payerId"] = payerId; var myOrder = new Order() { OrderDate = Convert.ToDateTime(decoder["TIMESTAMP"].ToString()), Username = User.Identity.Name, FirstName = decoder["FIRSTNAME"].ToString(), LastName = decoder["LASTNAME"].ToString(), Address = decoder["SHIPTOSTREET"].ToString(), City = decoder["SHIPTOCITY"].ToString(), State = decoder["SHIPTOSTATE"].ToString(), PostalCode = decoder["SHIPTOZIP"].ToString(), Country = decoder["SHIPTOCOUNTRYCODE"].ToString(), Email = decoder["EMAIL"].ToString(), Total = Convert.ToDecimal(decoder["AMT"].ToString(), CultureInfo.InvariantCulture), }; // Verify total payment amount as set on CheckoutStart.aspx. try { decimal paymentAmountOnCheckout = Convert.ToDecimal(Session["payment_amt"].ToString(), CultureInfo.InvariantCulture); decimal paymentAmoutFromPayPal = Convert.ToDecimal(decoder["AMT"].ToString(), CultureInfo.InvariantCulture); if (paymentAmountOnCheckout != paymentAmoutFromPayPal) { Response.Redirect("CheckoutError.aspx?" + "Desc=Amount%20total%20mismatch."); } } catch (Exception) { Response.Redirect("CheckoutError.aspx?" + "Desc=Amount%20total%20mismatch."); } // Get DB context. ProductContext _db = new ProductContext(); // Add order to DB. _db.Orders.Add(myOrder); _db.SaveChanges(); // Get the shopping cart items and process them. using (ShoppingCartActions usersShoppingCart = new ShoppingCartActions()) { List <CartItem> myOrderList = usersShoppingCart.GetCartItems(); // Add OrderDetail information to the DB for each product purchased. for (int i = 0; i < myOrderList.Count; i++) { // Create a new OrderDetail object. var myOrderDetail = new OrderDetail { OrderId = myOrder.OrderId, Username = User.Identity.Name, ProductId = myOrderList[i].ProductId, Quantity = myOrderList[i].Quantity, UnitPrice = myOrderList[i].Product.UnitPrice }; // Add OrderDetail to DB. _db.OrderDetails.Add(myOrderDetail); _db.SaveChanges(); } // Set OrderId. Session["currentOrderId"] = myOrder.OrderId; // Display Order information. List <Order> orderList = new List <Order> { myOrder }; ShipInfo.DataSource = orderList; ShipInfo.DataBind(); // Display OrderDetails. OrderItemList.DataSource = myOrderList; OrderItemList.DataBind(); } } else { Response.Redirect($"CheckoutError.aspx?{retMsg}"); } } }
public async Task LoadAsync(OrderItemsViewState state) { await OrderItemList.LoadAsync(state); }
public async Task RefreshAsync(bool resetPageIndex = false) { await OrderItemList.RefreshAsync(resetPageIndex); }
public void Unsubscribe() { MessageService.Unsubscribe(this); OrderItemList.Unsubscribe(); OrderItemDetails.Unsubscribe(); }
public void Subscribe() { MessageService.Subscribe <OrderItemListViewModel>(this, OnMessage); OrderItemList.Subscribe(); OrderItemDetails.Subscribe(); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { NVPAPICaller payPalCaller = new NVPAPICaller(); string retMsg = ""; string token = ""; string PayerID = ""; NVPCodec decoder = new NVPCodec(); token = Session["token"].ToString(); bool ret = payPalCaller.GetCheckoutDetails(token, ref PayerID, ref decoder, ref retMsg); if (ret) { Session["payerId"] = PayerID; var myOrder = new Order1(); myOrder.OrderDate = Convert.ToDateTime(decoder["TIMESTAMP"].ToString()); myOrder.Username = User.Identity.Name; myOrder.FirstName = decoder["FIRSTNAME"].ToString(); myOrder.LastName = decoder["LASTNAME"].ToString(); myOrder.Address = decoder["SHIPTOSTREET"].ToString(); myOrder.City = decoder["SHIPTOCITY"].ToString(); myOrder.State = decoder["SHIPTOSTATE"].ToString(); myOrder.PostalCode = decoder["SHIPTOZIP"].ToString(); myOrder.Country = decoder["SHIPTOCOUNTRYCODE"].ToString(); myOrder.Email = decoder["EMAIL"].ToString(); // myOrder.Total = Convert.ToDecimal(decoder["AMT"].ToString()); //myOrder.Total = decimal.Parse(decoder["AMT"].ToString()); var culture = CultureInfo.InvariantCulture; // int total = Convert.ToInt32(decoder["AMT"].ToString()); myOrder.Total = Decimal.Parse(decoder["AMT"].ToString(), culture); // Verify total payment amount as set on CheckoutStart.aspx. try { decimal paymentAmountOnCheckout = Convert.ToDecimal(Session["TotalPrice"].ToString()); // decimal paymentAmoutFromPayPal = Convert.ToDecimal(decoder["AMT"].ToString()); decimal paymentAmountFromPayPal = myOrder.Total; if (paymentAmountOnCheckout != paymentAmountFromPayPal) { Response.Redirect("~/Checkout/CheckoutError.aspx?" + "Desc=Amount%20total%20mismatch."); } } catch (Exception) { Response.Redirect("~/Checkout/CheckoutError.aspx?" + "Desc=Amount%20total%20mismatch."); } //// Calling ShoppingCart object here ShoppingCart k = new ShoppingCart(); //// Save orderDetails and CustomerDetails to the DB. k.SaveOrderDetails(myOrder); k.SaveCustomerDetails(); //Set OrderId. string currentOrderId = ConnectionClass.GetMaxOrderId(); Session["currentOrderId"] = currentOrderId; // Get the Shopping Cart Products DataTable dt = (DataTable)Session["MyCart"]; DataTable myOrderDetail = new DataTable(); myOrderDetail.Columns.Add("ProductID", typeof(string)); myOrderDetail.Columns.Add("ProductName", typeof(string)); myOrderDetail.Columns.Add("ProductPrice", typeof(string)); myOrderDetail.Columns.Add("ProductQuantity", typeof(string)); DataRow dr = myOrderDetail.NewRow(); // Display OrderDetail information to the Review page for each product purchased. for (int i = 0; i < dt.Rows.Count; i++) { dr["ProductID"] = Convert.ToInt32(dt.Rows[i]["ProductID"]); dr["ProductName"] = dt.Rows[i]["Name"].ToString(); dr["ProductPrice"] = dt.Rows[i]["Price"].ToString(); dr["ProductQuantity"] = Convert.ToInt32(dt.Rows[i]["ProductQuantity"]); myOrderDetail.Rows.Add(dr); } // Display OrderDetails. OrderItemList.DataSource = myOrderDetail; OrderItemList.DataBind(); // Add OrderDetail information to the DB for each product purchased. for (int i = 0; i < dt.Rows.Count; i++) { // Create a new OrderDetail object. ShoppingCart orderDetail = new ShoppingCart() { ProductID = Convert.ToInt32(dt.Rows[i]["ProductID"]), ProductName = dt.Rows[i]["Name"].ToString(), ProductPrice = dt.Rows[i]["Price"].ToString(), ProductQuantity = Convert.ToInt32(dt.Rows[i]["ProductQuantity"]) }; orderDetail.AddOrders(); } // Display Order information. List <Order1> orderList = new List <Order1>(); orderList.Add(myOrder); ShipInfo.DataSource = orderList; ShipInfo.DataBind(); } else { Response.Redirect("~/Checkout/CheckoutError.aspx?" + retMsg); } } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { NVPAPICaller payPalCaller = new NVPAPICaller(); string retMsg = ""; string token = ""; string PayerID = ""; NVPCodec decoder = new NVPCodec(); token = Session["token"].ToString(); bool ret = payPalCaller.GetCheckoutDetails(token, ref PayerID, ref decoder, ref retMsg); if (ret) { Session["payerId"] = PayerID; var myOrder = new Order(); myOrder.OrderDate = Convert.ToDateTime(decoder["TIMESTAMP"].ToString()); myOrder.Username = User.Identity.Name; myOrder.FirstName = decoder["FIRSTNAME"].ToString(); myOrder.LastName = decoder["LASTNAME"].ToString(); myOrder.Address = decoder["SHIPTOSTREET"].ToString(); myOrder.City = decoder["SHIPTOCITY"].ToString(); myOrder.State = decoder["SHIPTOSTATE"].ToString(); myOrder.PostalCode = decoder["SHIPTOZIP"].ToString(); myOrder.Country = decoder["SHIPTOCOUNTRYCODE"].ToString(); myOrder.Email = decoder["EMAIL"].ToString(); myOrder.Total = Convert.ToDecimal(decoder["AMT"].ToString()); // Verify total payment amount as set on CheckoutStart.aspx. try { decimal paymentAmountOnCheckout = Convert.ToDecimal(Session["payment_amt"].ToString()); decimal paymentAmoutFromPayPal = Convert.ToDecimal(decoder["AMT"].ToString()); if (paymentAmountOnCheckout != paymentAmoutFromPayPal) { Response.Redirect("CheckoutError.aspx?" + "Desc=Amount%20total%20mismatch."); } } catch (Exception) { Response.Redirect("CheckoutError.aspx?" + "Desc=Amount%20total%20mismatch."); } // Get DB context. CatalogObjectContext _db = new CatalogObjectContext(); // Add order to DB. _db.Orders.Add(myOrder); try { _db.SaveChanges(); } catch (Exception ex) { string s = ex.Message; } // Get the shopping cart items and process them. using (CatalogiaWebForms.Logic.ShoppingCartActions usersShoppingCart = new CatalogiaWebForms.Logic.ShoppingCartActions()) { List <CartItem> orders = usersShoppingCart.GetCartItems(); // Add OrderDetail information to the DB for each catalog item ordered. for (int i = 0; i < orders.Count; i++) { // Create a new OrderDetail object. var currentDetail = new OrderDetail(); currentDetail.OrderId = myOrder.OrderId; currentDetail.Username = User.Identity.Name; currentDetail.ObjectId = orders[i].CatalogObject.ObjectId; currentDetail.Quantity = orders[i].Quantity; currentDetail.UnitPrice = orders[i].CatalogObject.Price; // Add OrderDetail to DB. _db.OrderDetails.Add(currentDetail); _db.SaveChanges(); } // Set OrderId. Session["currentOrderId"] = myOrder.OrderId; // Display Order information. List <Order> orderList = new List <Order>(); orderList.Add(myOrder); ShipInfo.DataSource = orderList; ShipInfo.DataBind(); // Display OrderDetails. OrderItemList.DataSource = orders; OrderItemList.DataBind(); } } else { Response.Redirect("CheckoutError.aspx?" + retMsg); } } }
protected override void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { var pedido = new Pedido(); if (!string.IsNullOrEmpty(Request.QueryString["idPedido"])) { pedido.ID = Convert.ToInt32(Request.QueryString["idPedido"]); } pedido = commands["CONSULTAR"].execute(pedido).Entidades.Cast <Pedido>().ElementAt(0); pedido.EnderecoEntrega = commands["CONSULTAR"].execute(new Endereco() { ID = pedido.EnderecoEntrega.ID }).Entidades.Cast <Endereco>().ElementAt(0); pedido.Detalhes = commands["CONSULTAR"].execute(new PedidoDetalhe() { IdPedido = pedido.ID }).Entidades.Cast <PedidoDetalhe>().ToList(); pedido.CCs = commands["CONSULTAR"].execute(new CartaoCreditoPedido() { IdPedido = pedido.ID }).Entidades.Cast <CartaoCreditoPedido>().ToList(); entidades = new List <EntidadeDominio>(); entidades = commands["CONSULTAR"].execute(new PedidoXCupom() { ID = pedido.ID }).Entidades; if (entidades.Count > 0) { pedido.CupomPromocional = commands["CONSULTAR"].execute(new PedidoXCupom() { ID = pedido.ID }).Entidades.Cast <PedidoXCupom>().ElementAt(0).Cupom; } entidades = new List <EntidadeDominio>(); entidades = commands["CONSULTAR"].execute(new Cupom() { IdPedido = pedido.ID }).Entidades; if (entidades.Count > 0) { pedido.CuponsTroca = commands["CONSULTAR"].execute(new Cupom() { IdPedido = pedido.ID }).Entidades.Cast <Cupom>().ToList(); } // Set OrderId. Session["currentOrderId"] = pedido.ID; // Exibi as informações do Pedido //List<Pedido> listaPedido = new List<Pedido>(); //listaPedido.Add(pedido); //ShipInfo.DataSource = listaPedido; //ShipInfo.DataBind(); TrocaPedidoTodo.HRef = "GerarPedidoTroca.aspx?idPedido=" + pedido.ID; // Mostra os detalhes do pedido OrderItemList.DataSource = pedido.Detalhes; OrderItemList.DataBind(); } else { //Response.Redirect("./CheckoutError.aspx?Desc=ID%20de%20pedido%20incompatível."); } }
public async Task LoadAsync(OrderItemListArgs args) { await OrderItemList.LoadAsync(args); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { NVPAPICaller payPalCaller = new NVPAPICaller(); string retMsg = ""; string token = ""; string PayerID = ""; NVPCodec decoder = new NVPCodec(); token = Session["token"].ToString(); bool ret = payPalCaller.GetCheckoutDetails(token, ref PayerID, ref decoder, ref retMsg); if (ret) { Session["payerId"] = PayerID; var myOrder = new Order(); var myAddress = new Address(); myOrder.OrderDate = Convert.ToDateTime(decoder["TIMESTAMP"].ToString()); myOrder.Username = User.Identity.Name; myAddress.UserName = decoder["EMAIL"].ToString(); // myAddress = ""; myAddress.AddressLine1 = decoder["SHIPTOSTREET"].ToString(); myAddress.City = decoder["SHIPTOCITY"].ToString(); myAddress.State = decoder["SHIPTOSTATE"].ToString(); myAddress.PostalCode = decoder["SHIPTOZIP"].ToString(); myAddress.Country = decoder["SHIPTOCOUNTRYCODE"].ToString(); myOrder.Email = decoder["EMAIL"].ToString(); myOrder.Total = Convert.ToDecimal(decoder["AMT"].ToString()); // Verify total payment amount as set on CheckoutStart.aspx. try { decimal paymentAmountOnCheckout = Convert.ToDecimal(Session["payment_amt"].ToString()); decimal paymentAmoutFromPayPal = Convert.ToDecimal(decoder["AMT"].ToString()); if (paymentAmountOnCheckout != paymentAmoutFromPayPal) { Response.Redirect("CheckoutError.aspx?" + "Desc=Amount%20total%20mismatch."); } } catch (Exception) { Response.Redirect("CheckoutError.aspx?" + "Desc=Amount%20total%20mismatch."); } // Get DB context. ProductContext _db = new ProductContext(); // Add order to DB. _db.Orders.Add(myOrder); _db.Addresses.Add(myAddress); _db.SaveChanges(); // Get the shopping cart items and process them. using (fashionUtilityApplication.Logic.ShoppingCartActions usersShoppingCart = new fashionUtilityApplication.Logic.ShoppingCartActions()) { List <CartItem> myOrderList = usersShoppingCart.GetCartItems(); // Add OrderDetail information to the DB for each product purchased. for (int i = 0; i < myOrderList.Count; i++) { // Create a new OrderDetail object. var myOrderDetail = new OrderDetail(); myOrderDetail.OrderId = myOrder.OrderId; myOrderDetail.Username = User.Identity.Name; myOrderDetail.ProductId = myOrderList[i].ProductId; myOrderDetail.Quantity = myOrderList[i].Quantity; myOrderDetail.ImagePath = myOrderList[i].ImagePath; myOrderDetail.UnitPrice = myOrderList[i].Product.UnitPrice; // Add OrderDetail to DB. _db.OrderDetails.Add(myOrderDetail); _db.SaveChanges(); } // Set OrderId. Session["currentOrderId"] = myOrder.OrderId; // Display Order information. List <Order> orderList = new List <Order>(); orderList.Add(myOrder); orderInfo.DataSource = orderList; orderInfo.DataBind(); List <Address> addressList = new List <Address>(); addressList.Add(myAddress); ShipInfo.DataSource = addressList; ShipInfo.DataBind(); // Display OrderDetails. OrderItemList.DataSource = myOrderList; OrderItemList.DataBind(); } } else { Response.Redirect("CheckoutError.aspx?" + retMsg); } } }
public void Unload() { OrderItemDetails.CancelEdit(); OrderItemList.Unload(); }