示例#1
0
        private void buttonAdd_Click(object sender, EventArgs e)
        {
            Order anOrder = new Order();

            anOrder.OrderId = Convert.ToInt32(textBoxOrderID.Text);

            Ordered ordered = new Ordered();

            ordered.ProductId = Convert.ToInt32(textBoxProductID.Text);
            ordered.Quantity  = Convert.ToInt32(textBoxQuantity.Text);

            anOrder.Ordered      = ordered;
            anOrder.OrderDate    = Convert.ToDateTime(dateTimePickerOrderDate.Text);
            anOrder.ShipDate     = Convert.ToDateTime(dateTimePickerShipDate.Text);
            anOrder.SalesClerkId = LoggedIn.EmpId;

            foreach (Book element in (ProductDA.GetBook()))
            {
                if (element.Isbn == anOrder.Ordered.ProductId)
                {
                    if ((element.Qoh - anOrder.Ordered.Quantity) >= 0)
                    {
                        element.Qoh = element.Qoh - anOrder.Ordered.Quantity;
                        ProductDA.UpdateBook(element);
                        OrderDA.SetOrder(anOrder);
                        RefreshList();
                    }
                    else
                    {
                        MessageBox.Show("Not enough stock to complete order.\nAsk Inventory to add more stock before completing order.", "Error!");
                    }
                }
            }
        }
示例#2
0
        public void RefreshList()
        {
            listViewOrder.Items.Clear();
            myOrderList = OrderDA.GetOrder();

            foreach (Order element in myOrderList)
            {
                listViewOrder.Items.Add(OrderDA.ConvertToListViewItemOrder(element));
            }
        }
示例#3
0
        public static void DeleteOrder(Order order)
        {
            List <Order> myOrderList = OrderDA.GetOrder();

            using (StreamWriter sw = new StreamWriter(filePathTemp))
            {
                foreach (Order element in myOrderList)
                {
                    if (element.OrderId != order.OrderId)
                    {
                        sw.WriteLine(element.GetOrderInfo());
                    }
                }
            }
            File.Replace(filePathTemp, filePathOrder, filePathBackup);
        }
示例#4
0
        private void buttonDelete_Click(object sender, EventArgs e)
        {
            Order anOrder = new Order();

            anOrder.OrderId = Convert.ToInt32(textBoxOrderID.Text);

            Ordered ordered = new Ordered();

            ordered.ProductId = Convert.ToInt32(textBoxProductID.Text);
            ordered.Quantity  = Convert.ToInt32(textBoxQuantity.Text);

            anOrder.Ordered      = ordered;
            anOrder.OrderDate    = DateTime.Now;
            anOrder.ShipDate     = Convert.ToDateTime(dateTimePickerShipDate.Text);
            anOrder.SalesClerkId = Convert.ToInt32(textBoxSalesClerk.Text);

            OrderDA.DeleteOrder(anOrder);
            RefreshList();
        }