private void bunifuTileButton_CreateStockOrder_Click(object sender, EventArgs e) { ThreadManager.DisplayLoadingScreen(); StockOrder newStockOrder = new StockOrder(); try { newStockOrder.DateCreated = Convert.ToDateTime(bunifuCustomTextbox_DateCreated.Text); newStockOrder.TotalPayment = double.Parse(bunifuMetroTextbox_GrandTotal.Text); newStockOrder.SetStockOrderDetails((List <Ingredient>)bunifuCustomTextbox__list_selectedItems.Tag); } catch (Exception ex) { ThreadManager.CloseLoadingScreen(); ErrorManager.MessageDisplay(ex.Message, "", "Extract data failed"); return; } string err = newStockOrder.ValidateFields(); if (err != "") { ThreadManager.CloseLoadingScreen(); ErrorManager.MessageDisplay(err, "", "Data format error"); return; } err = manager.AddStockOrder(newStockOrder); ThreadManager.CloseLoadingScreen(); ErrorManager.MessageDisplay(err, "Create stock order successfully", "Create stock order failed"); if (err == "") { this.Close(); } }
public async Task <OrderResponse> Order(StockOrder stockOrder) { var orderResponse = new OrderResponse() { Success = true }; var itemsThatDontPass = new List <string>(); foreach (var orderItem in stockOrder.OrderItems) { var stockItem = await _stockItemRepository.GetByName(orderItem.Name); if (orderItem.Quantity <= stockItem.Quantity) { stockItem.Quantity -= orderItem.Quantity; _stockItemRepository.UpdateDontSave(stockItem); } else { itemsThatDontPass.Add(orderItem.Name); orderResponse.Success = false; } } if (orderResponse.Success) { orderResponse.Message = $"Success Ordered {stockOrder.OrderNumber}"; await _stockItemRepository.SaveChangesAsync(); } else { orderResponse.Message = $"Order {stockOrder.OrderNumber}, can not be placed not enought stock {string.Join(", ", itemsThatDontPass.ToArray())}."; } return(orderResponse); }
public async Task <string> AdvancedSearch([Bind("StockOrderID,SupplierID,TotalPrice")] StockOrder searchStockOrder) { var result = _context.StockOrder.AsQueryable(); if (searchStockOrder != null) { if (searchStockOrder.StockOrderID != null) { result = result.Where(stockOrder => stockOrder.StockOrderID == searchStockOrder.StockOrderID); } if (searchStockOrder.SupplierID != null) { result = result.Where(stockOrder => stockOrder.SupplierID == searchStockOrder.SupplierID); } if (searchStockOrder.TotalPrice != 0) { result = result.Where(stockOrder => stockOrder.TotalPrice == searchStockOrder.TotalPrice); } } var list = await result.ToListAsync(); var listJason = Newtonsoft.Json.JsonConvert.SerializeObject(list); return(listJason); }
public ActionResult RemoveAll(int?id, StockOrder stockorder) { string name = User.Identity.Name; var getAcctId = (from x in db.Accounts where x.UserName == name select x.AccountID).First(); int accid = Convert.ToInt16(getAcctId); var getCustId = (from x in db.Customers where x.AccountID == accid select x.CustomerID).First(); int customerID = Convert.ToInt16(getCustId); stockorder = db.StockOrders.Find(id); var stockQuantity = db.StockOrders.Where(x => x.SOID == id).Select(y => y.Quantity).First(); double qty = Convert.ToDouble(stockQuantity); if (qty >= 0) { StockOrder stockRemove = db.StockOrders.Find(id); db.StockOrders.Remove(stockRemove); db.SaveChanges(); ViewBag.empty = "Cart empty"; } return(RedirectToAction("Cart", "Customers")); }
public int 주식주문이력추가(StockOrder stockOrder) { //string query = Properties.Resources.주식주문이력추가; //query = string.Format(query, stockOrder.inqDate, stockOrder.stockCode, stockOrder.stockName, stockOrder.Qty, stockOrder.Price // , stockOrder.OrderType, stockOrder.Status, stockOrder.APIResult ); //Execute(query); DynamicParameters p = new DynamicParameters(); p.Add("@주문일자", stockOrder.inqDate); p.Add("@종목코드", stockOrder.stockCode); p.Add("@종목명", stockOrder.stockName); p.Add("@주문수량", stockOrder.Qty); p.Add("@주문단가", stockOrder.Price); p.Add("@주문타입", stockOrder.OrderType); p.Add("@주문옵션", stockOrder.OrderOption); p.Add("@주문상태", stockOrder.Status); p.Add("@APIResult", stockOrder.APIResult); p.Add("@원주문번호", stockOrder.orgOrderNo); p.Add("@매수조건", stockOrder.Reason); p.Add("@매수Seq", stockOrder.BuySeq); Execute("SP_주문이력추가", p); return(GetLastOrderSeq()); }
public JsonResult Save(TransferStockArgs model) { long hotelId = UserContext.CurrentUser.HotelId; var apiResult = new APIResult(); try { if (model.Item1.FromWarehourseId == model.Item1.ToWarehourseId) { apiResult.Ret = -1; apiResult.Msg = "调出仓库和调入仓库不能是同一仓库!"; return(Json(apiResult)); } StockOrder stock = model.Item1; stock.DType = DocumentTypeEnum.调拨; stock.StockOrderDetailsList = model.Item2; StockOrderBll.AddOrUpdateTransferStock(stock, UserContext.CurrentUser.Name, hotelId); } catch (Exception ex) { apiResult.Ret = -1; apiResult.Msg = ex.Message; if (!(ex is OperationExceptionFacade)) { LogFactory.GetLogger().Log(LogLevel.Error, ex); } } return(Json(apiResult)); }
public async Task <IActionResult> PutStockOrder(long id, StockOrder stockOrder) { if (id != stockOrder.ID) { return(BadRequest()); } _context.Entry(stockOrder).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!StockOrderExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public void 수익률에따른손절처리() { // tbl_stock_target 에서 조회 List <StockTarget> 매도요청중인종목리스트 = dacStock.종목대상전체조회(inqDate, "매도요청중"); // -5% 밑으로 인 애들 조회해서 현재가로 손절한다. for (int i = 0; i < 매도요청중인종목리스트.Count; i++) { string tmpRate = 매도요청중인종목리스트[i].손익률; if (string.IsNullOrWhiteSpace(tmpRate)) { tmpRate = "0"; } if (float.Parse(tmpRate) <= -1.5) { StockOrder order = dacStock.매도요청중인주문한종목조회(inqDate, 매도요청중인종목리스트[i].stockCode); if (order == null) { continue; } int price = int.Parse(order.Price); int qty = int.Parse(order.Qty); // 0.5% 더 낮은 금액으로 손절요청 //price -= (int)(price * 0.002); 매도정정요청(order.inqDate, order.orderNo, order.stockCode, order.stockName, qty, price); } } }
public JsonResult Save(RefundArgs model) { long hotelId = UserContext.CurrentUser.HotelId; var apiResult = new APIResult(); try { StockOrder stock = model.Item1; stock.DType = Model.Enum.DocumentTypeEnum.退货; stock.StockOrderDetailsList = model.Item2; StockOrderBll.AddOrUpdate(stock, UserContext.CurrentUser.Name, hotelId); ViewData["supplier"] = SupplierBll.GetAllList(hotelId); ViewData["warehourse"] = WarehouseBll.GetAllList(hotelId); } catch (Exception ex) { apiResult.Ret = -1; apiResult.Msg = ex.Message; if (!(ex is OperationExceptionFacade)) { LogFactory.GetLogger().Log(LogLevel.Error, ex); } } return(Json(apiResult)); }
public void OnNewOrder(StockOrder order) { ListViewItem item = new ListViewItem(new string[] { order.Id.ToString(), order.Email, order.Type.ToString(), order.Quantity.ToString(), order.Company, order.RequestDate }); this.pendingList.Items.Add(item); this.onChangedIds.Add(order.Id, proxy.RegisterOnOrderStatusChange(order.Id)); }
public async Task <IActionResult> PostStockOrder([FromBody] StockOrder stockOrder) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } await _stockOrderRepository.CreateAsync(stockOrder); foreach (var medicineStockOrder in stockOrder.MedicineStockOrders) { Medicine medicine = await _medicineRepository.FindAsync(medicineStockOrder.MedicineId); if (medicineStockOrder.Quantity < 0) { medicine.Stock -= (uint)Math.Abs(medicineStockOrder.Quantity); } else { medicine.Stock += (uint)medicineStockOrder.Quantity; } _medicineRepository.Update(medicine); } await _stockOrderRepository.SaveChangesAsync(); return(CreatedAtAction("GetStockOrder", new { id = stockOrder.Id }, stockOrder)); }
public void 매도정정완료처리(string inqDate, StockOrder order) { log.Info("매도정정완료처리 new start"); // tbl_stock_order 업데이트 dacStock.매도정정내역으로주문업데이트(inqDate, order.orderNo, order.stockCode, order.ConfirmQty, order.ConfirmPrice, order.orgOrderNo); log.Info("주식상태대기로변경 stockCode: " + order.stockCode + " confirmQty:" + order.ConfirmQty + " confirmPrice:" + order.ConfirmPrice); // tbl_stock_target 업데이트 dacStock.주식상태대기로변경(inqDate, order.stockCode, order.ConfirmQty, order.ConfirmPrice); int qty = Util.GetInt(order.ConfirmQty); int price = Util.GetInt(order.ConfirmPrice); if (qty * price > 0) { Biz.TotalBalance += qty * price; // 세금제외 Biz.TotalBalance -= (int)(qty * price * 0.0028); } log.Info("매도정정완료처리 new end"); }
public ActionResult ClearCart() { string name = User.Identity.Name; var getAcctId = (from x in db.Accounts where x.UserName == name select x.AccountID).First(); int accid = Convert.ToInt16(getAcctId); var getCustId = (from x in db.Customers where x.AccountID == accid select x.CustomerID).First(); int customerID = Convert.ToInt16(getCustId); var stockCart = (from x in db.StockOrders join y in db.Orders on x.OrderID equals y.OrderID where y.CustomerID == customerID select x.SOID).ToList(); foreach (var item in stockCart) { int id = Convert.ToInt16(item); StockOrder stockRemove = db.StockOrders.Find(id); db.StockOrders.Remove(stockRemove); db.SaveChanges(); } return(RedirectToAction("Cart", "Customers")); }
private static async Task Main(string[] args) { var message = "PetStore OrderItem"; Console.Title = message; Console.WriteLine(message); var stockOrder = new StockOrder() { OrderNumber = "ABC 123", OrderItems = new List <StockItem>() { new StockItem() { Name = "Item A", Quantity = 1 }, new StockItem() { Name = "Item B", Quantity = 1 }, new StockItem() { Name = "Item C", Quantity = 1 } } }; var orderItemClient = new OrderItemClient(); var responce = await orderItemClient.Send(stockOrder); Console.WriteLine(responce.Success); Console.WriteLine(responce.Message); Console.ReadKey(); }
public async Task <IActionResult> Edit(string id, [Bind("StockOrderID,SupplierID,TotalPrice")] StockOrder stockOrder) { if (id != stockOrder.StockOrderID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(stockOrder); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!StockOrderExists(stockOrder.StockOrderID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["SupplierID"] = new SelectList(_context.Set <Supplier>(), "SupplierID", "SupplierID", stockOrder.SupplierID); return(View(stockOrder)); }
public IActionResult DeleteConfirmed(int id) { StockOrder stockOrder = _context.StockOrder.Single(m => m.ID == id); _context.StockOrder.Remove(stockOrder); _context.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult DeleteConfirmed(int id) { StockOrder stockOrder = db.StockOrders.Find(id); db.StockOrders.Remove(stockOrder); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult CreateOrders() { List <StockOrder> orderlist = new List <StockOrder>(); Random rn = new Random(); for (int i = 0; i < 20; i++) { StockOrder order = new StockOrder(); order.UserID = "buyer" + i; order.OrderType = "buying"; order.TargetPrice = rn.Next(95, 105); order.Amount = rn.Next(10, 20); order.OrderTime = DateTime.Now; orderlist.Add(order); } for (int i = 0; i < 20; i++) { StockOrder order = new StockOrder(); order.UserID = "seller" + i; order.OrderType = "selling"; order.TargetPrice = rn.Next(95, 105); order.Amount = rn.Next(10, 20); order.OrderTime = DateTime.Now; orderlist.Add(order); } orderlist.Sort(); var q = orderlist.GroupBy(o => o.TargetPrice).Select(o => new StockOrderVM { TargetPrice = o.Key, BuyAmount = o.Where(od => od.OrderType == "buying").Sum(od => od.Amount), SellAmount = o.Where(od => od.OrderType == "selling").Sum(od => od.Amount) }); int AccBuying = 0; int AccSelling = q.Sum(o => o.SellAmount); var GroupedOrderList = q.ToList(); foreach (var i in GroupedOrderList) { AccBuying += i.BuyAmount; i.AccBuyAmount = AccBuying; i.AccSellAmount = AccSelling; AccSelling -= i.SellAmount; } Session["OrderList"] = GroupedOrderList; return(PartialView(GroupedOrderList)); }
public Task <OrderResponse> Send(StockOrder stockOrder) { var message = stockOrder.Serialize(); var tcs = new TaskCompletionSource <OrderResponse>(); var correlationId = Guid.NewGuid().ToString(); _pendingMessages[correlationId] = tcs; Publish(message, correlationId); return(tcs.Task); }
public IActionResult Edit(StockOrder stockOrder) { if (ModelState.IsValid) { _context.Update(stockOrder); _context.SaveChanges(); return(RedirectToAction("Index")); } ViewData["StockID"] = new SelectList(_context.Stock, "ID", "Stock", stockOrder.StockID); return(View(stockOrder)); }
public ActionResult Edit([Bind(Include = "OrderID,OrderDate,DateCreated,Description,SupplierId")] StockOrder stockOrder) { if (ModelState.IsValid) { db.Entry(stockOrder).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.SupplierId = new SelectList(db.Suppliers, "SupplierId", "FirstName", stockOrder.SupplierId); return(View(stockOrder)); }
public ActionResult Edit([Bind(Include = "id,UserID,StockID,Value")] StockOrder stockOrder) { if (ModelState.IsValid) { db.Entry(stockOrder).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.StockID = new SelectList(db.Stocks, "id", "Name", stockOrder.StockID); return(View(stockOrder)); }
public async Task <IActionResult> Create([Bind("StockOrderID,SupplierID,TotalPrice")] StockOrder stockOrder) { if (ModelState.IsValid) { _context.Add(stockOrder); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["SupplierID"] = new SelectList(_context.Set <Supplier>(), "SupplierID", "SupplierID", stockOrder.SupplierID); return(View(stockOrder)); }
public async Task OrderOkay_OrderAllStock() { //arrange var repository = new Mock <IStockItemRepository>(); repository.Setup(x => x.GetByName("AA")).Returns(Task.FromResult(new StockItem() { Name = "AA", Quantity = 10 })); repository.Setup(x => x.GetByName("BB")).Returns(Task.FromResult(new StockItem() { Name = "BB", Quantity = 10 })); repository.Setup(x => x.GetByName("CC")).Returns(Task.FromResult(new StockItem() { Name = "CC", Quantity = 10 })); var orderItemManager = new OrderItemManager(repository.Object); var stockOrder = new StockOrder() { OrderNumber = "ZXY 789", OrderItems = new List <StockItem>() { new StockItem() { Name = "AA", Quantity = 10 }, new StockItem() { Name = "BB", Quantity = 10 }, new StockItem() { Name = "CC", Quantity = 10 } } }; //act var value = await orderItemManager.Order(stockOrder); //assert Assert.Equal("Success Ordered ZXY 789", value.Message); Assert.True(value.Success); repository.Verify(a => a.UpdateDontSave(It.Is <StockItem>(s => s.Name == "AA" && s.Quantity == 0)), Times.Once); repository.Verify(a => a.UpdateDontSave(It.Is <StockItem>(s => s.Name == "BB" && s.Quantity == 0)), Times.Once); repository.Verify(a => a.UpdateDontSave(It.Is <StockItem>(s => s.Name == "CC" && s.Quantity == 0)), Times.Once); repository.Verify(x => x.UpdateDontSave(It.IsAny <StockItem>()), Times.Exactly(3)); repository.Verify(a => a.SaveChangesAsync(), Times.Once); }
public ActionResult Edit([Bind(Include = "SOID,OrderID,StockID,Quantity,SubPrice")] StockOrder stockOrder) { if (ModelState.IsValid) { db.Entry(stockOrder).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.OrderID = new SelectList(db.Orders, "OrderID", "status", stockOrder.OrderID); ViewBag.StockID = new SelectList(db.Stocks, "StockID", "StockID", stockOrder.StockID); return(View(stockOrder)); }
public void OnOrderStatusChange(StockOrder order) { foreach (ListViewItem item in ((MarketForm)this).pendingList.Items) { if (item.Text.Equals(order.Id.ToString())) { ((MarketForm)this).pendingList.Items.Remove(item); } } ListViewItem newItem = new ListViewItem(new string[] { order.Id.ToString(), order.Email, order.Type.ToString(), order.Quantity.ToString(), order.Company, order.RequestDate, order.ExecutionDate, order.StockValue.ToString(), order.GetTotalValue().ToString() }); ((MarketForm)this).executedList.Items.Add(newItem); }
public ActionResult Create([Bind(Include = "id,UserID,StockID,Value")] StockOrder stockOrder) { if (ModelState.IsValid) { stockOrder.UserID = User.Identity.GetUserId(); db.StockOrders.Add(stockOrder); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.StockID = new SelectList(db.Stocks, "id", "Name", stockOrder.StockID); return(View(stockOrder)); }
public StockOrder AutoTrade(int id) { StockOrder stockOrder = new StockOrder { Id = 1, Stock = new Stock { Id = 100, Liquidity = 1.1, Name = "FakeStock", Price = 10, Price200DayAverage = 1 }, NumberOfStocks = 100 }; return(stockOrder); }
// GET: StockOrders/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } StockOrder stockOrder = db.StockOrders.Find(id); if (stockOrder == null) { return(HttpNotFound()); } return(View(stockOrder)); }
private void 대상종목매도요청(StockTarget 대상종목) { if (!"매도요청중".Equals(대상종목.status) && Util.GetInt(대상종목.보유수) > 0) { StockOrder 매도요청할주문 = new StockOrder(); 매도요청할주문.inqDate = inqDate; 매도요청할주문.stockCode = 대상종목.stockCode; 매도요청할주문.stockName = 대상종목.stockName; 매도요청할주문.Qty = 대상종목.보유수; 매도요청할주문.Price = 대상종목.매입단가; SellStock(매도요청할주문, 1.5); } }