Beispiel #1
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="transactionInformation"></param>
 private void OnUpsert(WarehouseOrder transactionInformation)
 {
     if (InvokeRequired)
     {
         BeginInvoke(new WarehouseUpsertHandler(UpsertOrder), transactionInformation);
     }
     else
     {
         UpsertOrder(transactionInformation);
     }
 }
Beispiel #2
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="warehouseOrder"></param>
 public void InsertOrder(WarehouseOrder warehouseOrder)
 {
     try
     {
         WarehouseLogger.LogMessage(Resources.MessagingInsertOrder, warehouseOrder.Identifier, warehouseOrder.Title, warehouseOrder.Timestamp);
         WarehouseServer.InsertOrder(warehouseOrder);
     }
     catch (Exception ex)
     {
         WarehouseLogger.LogException(ex);
     }
 }
Beispiel #3
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="transactionInformation"></param>
 /// <returns></returns>
 private static ListViewItem ParseTransaction(WarehouseOrder transactionInformation)
 {
     return(new ListViewItem(LibrettoCommon.FormatDate(transactionInformation.Timestamp))
     {
         Name = LibrettoCommon.FormatGuid(transactionInformation.Identifier),
         SubItems =
         {
             LibrettoCommon.FormatGuid(transactionInformation.Identifier),
             transactionInformation.Title,
             Convert.ToString(transactionInformation.Quantity),
             LibrettoCommon.FormatCurrency(transactionInformation.Total)
         }
     });
 }
        /// <summary>
        ///
        /// </summary>
        /// <param name="orderInformation"></param>
        /// <returns></returns>
        public Response Insert(Order orderInformation)
        {
            try
            {
                if (orderInformation == null)
                {
                    return(Response.InvalidArguments);
                }

                var bookInformation = LibrettoDatabase.BookIntegration.Lookup(orderInformation.BookId);

                if (bookInformation == null)
                {
                    return(Response.NotFound);
                }

                orderInformation.Timestamp = DateTime.Now;

                if (orderInformation.Quantity > bookInformation.Stock)
                {
                    orderInformation.Status          = Status.Waiting;
                    orderInformation.StatusTimestamp = orderInformation.Timestamp;
                }
                else
                {
                    orderInformation.Status          = Status.Dispatched;
                    orderInformation.StatusTimestamp = DateTime.Now.AddDays(1);
                }

                _context.Orders.Add(orderInformation);
                _context.SaveChanges();

                if (orderInformation.Status == Status.Waiting)
                {
                    LibrettoHost.WarehouseService.InsertOrder(WarehouseOrder.FromOrder(orderInformation));
                }
                else
                {
                    LibrettoDatabase.BookIntegration.UpdateStock(orderInformation.BookId, -orderInformation.Quantity);
                }

                StoreService.NotifyRegisterTransaction(orderInformation);

                return(EmailClient.Instance.NotifyInsert(orderInformation));
            }
            catch
            {
                return(Response.DatabaseError);
            }
        }
        public ActionResult AddOrder(WarehouseOrderJoin warehouseOrderJoin)
        {
            var  OrderId       = Request.Form["OrderID"];
            var  date          = Request.Form["date"];
            var  orderType     = Int32.Parse(Request.Form["OrderType"]);
            var  orderSender   = Request.Form["OrderSender"];
            var  OrderReciever = Request.Form["OrderReciever"];
            bool condition     = false;

            int    NoOfProducts = Int32.Parse(Request.Form["length"]);
            double price        = 0;

            for (int i = 0; i <= NoOfProducts; i++)
            {
                var product     = Request.Form["PID[" + i + "]"];
                var quatity     = Int32.Parse(Request.Form["PQ[" + i + "]"]);
                var stockInDb   = _context.WarehouseStocks.SingleOrDefault(p => p.ProductID == product);
                var productInDb = _context.WarehouseProducts.SingleOrDefault(p => p.PId == product);
                if (stockInDb != null)
                {
                    if (stockInDb.Quantity >= quatity)
                    {
                        condition = true;
                    }
                    else
                    {
                        condition = false;
                        break;
                    }
                }
                else if (productInDb != null)
                {
                    condition = false;
                    break;
                }
                else
                {
                    condition = false;
                    break;
                }
            }

            if (condition == true)
            {
                for (int i = 0; i <= NoOfProducts; i++)
                {
                    var product = Request.Form["PID[" + i + "]"];
                    var quatity = Int32.Parse(Request.Form["PQ[" + i + "]"]);

                    if (product == null || product == "")
                    {
                    }
                    else
                    {
                        var Order       = new WarehouseOrder();
                        var OrderDetail = new WarehouseOrderDetail();
                        var OrderType   = new WarehouseOrderType();
                        var stockInDb   = _context.WarehouseStocks.SingleOrDefault(p => p.ProductID == product);

                        try
                        {
                            //Calculating price for each product w.r.t to quantity
                            var productPrice =
                                _context.WarehouseProducts.SingleOrDefault(p => p.PId == product);
                            var tprice = quatity * productPrice.Price;

                            Order.TotalPrice = tprice;
                        }
                        catch (Exception e)
                        {
                            continue;
                        }


                        //Setting Id to all of them
                        Order.OId           = OrderId;
                        Order.Notification  = 0;
                        OrderDetail.OrderID = OrderId;
                        OrderType.OId       = OrderId;

                        //Setting remaining instances
                        Order.PId            = Request.Form["PID[" + i + "]"];
                        Order.PQuantity      = Int32.Parse(Request.Form["PQ[" + i + "]"]);
                        Order.Date           = DateTime.Parse(date);
                        OrderDetail.Receiver = OrderReciever;
                        OrderDetail.Sender   = orderSender;


                        if (i == 0)
                        {
                            OrderType.type = orderType;
                            _context.WarehouseOrderDetails.Add(OrderDetail);
                            _context.WarehouseOrderTypes.Add(OrderType);
                        }

                        try
                        {
                            _context.WarehouseOrders.Add(Order);
                            _context.SaveChanges();
                        }
                        catch (Exception e)
                        {
                            Debug.WriteLine(e.ToString());
                        }
                    }
                }
            }
            else
            {
                return(Redirect("~/Warehouse/OrderError"));
            }

            return(Redirect("~/Warehouse/Orders"));
        }
Beispiel #6
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="warehouseOrder"></param>
 public void InvokeUpsert(WarehouseOrder warehouseOrder)
 {
     OnUpsert?.Invoke(warehouseOrder);
 }
Beispiel #7
0
 /// <summary>
 ///
 /// </summary>
 private void UpsertOrder(WarehouseOrder transactionInformation)
 {
     _transactions.Remove(transactionInformation.Identifier);
     _transactions.Add(transactionInformation.Identifier, transactionInformation);
     ResetWindow();
 }
Beispiel #8
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="orderInformation"></param>
 /// <returns></returns>
 private bool FilterOrder(WarehouseOrder orderInformation)
 {
     return((string.IsNullOrEmpty(filterTitle.Text) || filterTitle.Text == orderInformation.Title) &&
            (dateFromPicker.Checked == false || orderInformation.Timestamp > dateFromPicker.Value) &&
            (dateUntilPicker.Checked == false || orderInformation.Timestamp < dateUntilPicker.Value));
 }
Beispiel #9
0
 public void addWareHouseOrder(WarehouseOrder order)
 {
     orders.Add(order.id, order);
     updateGUI();
 }
 /// <summary>
 ///
 /// </summary>
 /// <param name="warehouseOrder"></param>
 public void Insert(WarehouseOrder warehouseOrder)
 {
     Orders.Add(warehouseOrder);
 }
Beispiel #11
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="warehouseOrder"></param>
 public static void InsertOrder(WarehouseOrder warehouseOrder)
 {
     _orders.Insert(warehouseOrder);
     _warehouseRemoting.InvokeUpsert(warehouseOrder);
     SerializeTransactions();
 }