protected void FetchButton_Click(object sender, EventArgs e)
        {
            MessageUserControl.TryRun(() =>
            {
                int count   = 0;
                int tempint = int.Parse(VendorDDL.SelectedValue);
                if (tempint == 0)
                {
                    //Response.Redirect(Request.RawUrl);
                    throw new Exception("Please select a vendor");
                }
                int employeeID  = int.Parse(EmployeeIDLB.Text);
                VendorIDLB.Text = tempint.ToString();
                int vendorID    = int.Parse(VendorIDLB.Text);
                PurchaseOrderDetailsController sysmgr = new PurchaseOrderDetailsController();
                List <CurrentActiveOrderView> currentOrderListPOCOs = new List <CurrentActiveOrderView>();
                currentOrderListPOCOs = sysmgr.List_OrderDetailPOCO(employeeID, vendorID);
                List <VendorStockItemsView> currentStockItemListPOCOs = sysmgr.List_VendorStockItemsPOCO(vendorID, currentOrderListPOCOs);

                CurrentActiveOrderGDView.DataSource = currentOrderListPOCOs;
                CurrentActiveOrderGDView.DataBind();
                VendorStockItemsGDView.DataSource = currentStockItemListPOCOs;
                VendorStockItemsGDView.DataBind();

                OrderSummaryDisplay(vendorID);
                count = CurrentActiveOrderGDView.Rows.Count;
                MessageUserControl.ShowInfo("Fetched data", "Displaying " + count + " rows");
                //TestLB.Text = "POID " + currentStockItemListPOCO.ToString() + " VID "+ currentPurchaseOrder.VendorID.ToString();
            });
            //MessageUserControl.TryRun(() =>
            //{
            //}, "Fetched data", "Displaying " + count + " rows");
        }
Exemplo n.º 2
0
        public void Get()
        {
            var mockedList = new List <PurchaseOrderDetailDTO>();

            mockedList.Add(new PurchaseOrderDetailDTO
            {
                DueDate = DateTime.Now,
                NumberOfProductUnitsSold = 54000,
                TrafficSum = 25000
            });

            var mockRepository = new Mock <IPurchaseOrderDetailsRepository>();

            mockRepository.Setup(x => x.Get(It.IsAny <DateTime>(), It.IsAny <DateTime>()))
            .Returns(mockedList);

            var controller = new PurchaseOrderDetailsController(mockRepository.Object);

            IHttpActionResult actionResult = controller.Get(DateTime.Now, DateTime.Now);
            var contentResult = actionResult as OkNegotiatedContentResult <IEnumerable <PurchaseOrderDetailDTO> >;

            Assert.IsNotNull(contentResult);
            Assert.IsNotNull(contentResult.Content);
            Assert.AreEqual(mockedList.Count, contentResult.Content.Count());
            Assert.AreEqual(mockedList[0], contentResult.Content.ElementAt(0));
        }
        protected void PlaceButton_Click(object sender, EventArgs e)
        {
            int vendorID = 0;

            MessageUserControl.TryRun(() =>
            {
                PurchaseOrderDetailsController sysmgr = new PurchaseOrderDetailsController();



                vendorID = int.Parse(VendorIDLB.Text);
                List <CurrentActiveOrderView> currentOrderListPOCOs = new List <CurrentActiveOrderView>();
                currentOrderListPOCOs = GetCurrentActiveOrderPOCOList();
                if (currentOrderListPOCOs == null)
                {
                    throw new Exception("Error, no current active order, nothing to place.");
                }

                TestLB.Text           = sysmgr.Place_Order(vendorID, currentOrderListPOCOs).ToString();
                currentOrderListPOCOs = new List <CurrentActiveOrderView>();
                List <VendorStockItemsView> vendorStockItemListPOCOs = sysmgr.List_VendorStockItemsPOCO(vendorID, currentOrderListPOCOs);

                CurrentActiveOrderGDView.DataSource = currentOrderListPOCOs;
                CurrentActiveOrderGDView.DataBind();
                VendorStockItemsGDView.DataSource = vendorStockItemListPOCOs;
                VendorStockItemsGDView.DataBind();
                OrderSummaryDisplay(vendorID);
                VendorDDL.SelectedValue = int.Parse(VendorIDLB.Text).ToString();

                MessageUserControl.ShowInfo("Order Placed", "Order number of " + TestLB.Text + " for Vendor number " + VendorIDLB.Text + " has been placed.");
            });
        }//eom
Exemplo n.º 4
0
        public void GetReturnsNotFound()
        {
            var mockRepository = new Mock <IPurchaseOrderDetailsRepository>();
            var controller     = new PurchaseOrderDetailsController(mockRepository.Object);

            IHttpActionResult actionResult = controller.Get(DateTime.Now, DateTime.Now);

            Assert.IsInstanceOfType(actionResult, typeof(NotFoundResult));
        }
        protected void CurrentActiveOrderGridView_RowCommand_RemoveItem(object sender, CommandEventArgs e)
        {
            MessageUserControl.TryRun(() =>
            {
                int orderDetailSID = int.Parse(e.CommandArgument.ToString());
                int vendorID       = int.Parse(VendorIDLB.Text);
                int employeeID     = int.Parse(EmployeeIDLB.Text);
                PurchaseOrderDetailsController sysmgr = new PurchaseOrderDetailsController();
                //TestLB.Text = "Stock item number " + sysmgr.RemovingASingleRowFromActiveOrder(vendorID, orderDetailSID) + " was removed from the list, " + (CurrentActiveOrderGDView.Rows.Count-1).ToString() +" items left on view";
                List <CurrentActiveOrderView> currentOrderListPOCOs = new List <CurrentActiveOrderView>();
                currentOrderListPOCOs = GetCurrentActiveOrderPOCOList();
                CurrentActiveOrderView toRemoveItem = currentOrderListPOCOs.Where(x => x.SID.Equals(orderDetailSID)).FirstOrDefault();

                currentOrderListPOCOs.Remove(toRemoveItem);

                currentOrderListPOCOs = sysmgr.RemovingWhileUpdating(employeeID, vendorID, currentOrderListPOCOs);
                int tempCount         = 0;
                if (currentOrderListPOCOs == null)
                {
                    tempCount = 0;
                }
                else
                {
                    tempCount = currentOrderListPOCOs.Count;
                }

                TestLB.Text = "Item " + orderDetailSID + " was removed from the list, " + tempCount.ToString() + " items left on view";
                MessageUserControl.ShowInfo("Item Removed", TestLB.Text);


                List <VendorStockItemsView> vendorStockItemListPOCOs = sysmgr.List_VendorStockItemsPOCO(vendorID, currentOrderListPOCOs);

                //display

                CurrentActiveOrderGDView.DataSource = currentOrderListPOCOs;

                CurrentActiveOrderGDView.DataBind();
                VendorStockItemsGDView.DataSource = vendorStockItemListPOCOs;
                VendorStockItemsGDView.DataBind();

                OrderSummaryDisplay(vendorID);
                VendorDDL.SelectedValue = int.Parse(VendorIDLB.Text).ToString();
            });
        } //eom;
        } //eom;

        protected void CurrentActiveOrderGridView_RowCommand_AddItem(object sender, CommandEventArgs e)
        {
            MessageUserControl.TryRun(() =>
            {
                int orderDetailSID = int.Parse(e.CommandArgument.ToString());
                int employeeID     = int.Parse(EmployeeIDLB.Text);
                List <CurrentActiveOrderView> currentOrderListPOCOs = GetCurrentActiveOrderPOCOList();
                PurchaseOrderDetailsController sysmgr = new PurchaseOrderDetailsController();
                int vendorID = int.Parse(VendorIDLB.Text);
                List <VendorStockItemsView> vendorStockItemListPOCOs = sysmgr.List_VendorStockItemsPOCO(vendorID, currentOrderListPOCOs);

                VendorStockItemsView stockItemToRemove = vendorStockItemListPOCOs.SingleOrDefault(x => x.SID == orderDetailSID);
                if (stockItemToRemove == null)
                {
                    throw new Exception();
                }
                else
                {
                    CurrentActiveOrderView detailItemToAdd = new CurrentActiveOrderView();
                    detailItemToAdd.SID         = stockItemToRemove.SID;
                    detailItemToAdd.Description = stockItemToRemove.ItemDescription;
                    detailItemToAdd.QOH         = stockItemToRemove.QOH;
                    detailItemToAdd.QOO         = stockItemToRemove.QOO;
                    detailItemToAdd.ROL         = stockItemToRemove.ROL;
                    detailItemToAdd.QTO         = 1;
                    detailItemToAdd.Price       = stockItemToRemove.Price;
                    //add the item to top view
                    currentOrderListPOCOs.Add(detailItemToAdd);
                    //pass the top view into the controller for the bottom view, this will remove the stockItemToRemove, because SID exist in the top list.
                    TestLB.Text = "the add stockitem id is " + orderDetailSID.ToString() + sysmgr.AddDBPOPODetails(employeeID, vendorID, currentOrderListPOCOs);
                    vendorStockItemListPOCOs = sysmgr.List_VendorStockItemsPOCO(vendorID, currentOrderListPOCOs);

                    CurrentActiveOrderGDView.DataSource = currentOrderListPOCOs;
                    CurrentActiveOrderGDView.DataBind();
                    VendorStockItemsGDView.DataSource = vendorStockItemListPOCOs;
                    VendorStockItemsGDView.DataBind();
                    //for development, change this part latter!

                    OrderSummaryDisplay(vendorID);
                    VendorDDL.SelectedValue = int.Parse(VendorIDLB.Text).ToString();
                    MessageUserControl.ShowInfo("Item added", TestLB.Text);
                } //endofelse;
            });
        }         //eom;
        }//eom;

        protected void UpdateButton_Click(object sender, EventArgs e)
        {
            MessageUserControl.TryRun(() =>
            {
                PurchaseOrderDetailsController sysmgr = new PurchaseOrderDetailsController();
                List <CurrentActiveOrderView> currentOrderListPOCOs = GetCurrentActiveOrderPOCOList();
                if (currentOrderListPOCOs == null || String.IsNullOrEmpty(VendorIDLB.Text) || VendorIDLB.Text == "0")
                {
                    throw new Exception("empty active order, nothing to update");
                }
                int vendorID = int.Parse(VendorIDLB.Text);
                TestLB.Text  = sysmgr.UpdateDBPOPODetails(vendorID, currentOrderListPOCOs);
                CurrentActiveOrderGDView.DataSource = currentOrderListPOCOs;
                CurrentActiveOrderGDView.DataBind();

                OrderSummaryDisplay(vendorID);
                VendorDDL.SelectedValue = int.Parse(VendorIDLB.Text).ToString();
                MessageUserControl.ShowInfo("Order updated", TestLB.Text);
            });
        }
        protected void DeleteButton_Click(object sender, EventArgs e)
        {
            MessageUserControl.TryRun(() =>
            {
                PurchaseOrderDetailsController sysmgr = new PurchaseOrderDetailsController();
                int vendorID = int.Parse(VendorIDLB.Text);
                TestLB.Text  = sysmgr.DeletePurchaseOrder(vendorID);

                List <CurrentActiveOrderView> currentOrderListPOCOs  = new List <CurrentActiveOrderView>();
                List <VendorStockItemsView> vendorStockItemListPOCOs = sysmgr.List_VendorStockItemsPOCO(vendorID, currentOrderListPOCOs);

                CurrentActiveOrderGDView.DataSource = currentOrderListPOCOs;
                CurrentActiveOrderGDView.DataBind();
                VendorStockItemsGDView.DataSource = vendorStockItemListPOCOs;
                VendorStockItemsGDView.DataBind();
                OrderSummaryDisplay(vendorID);
                VendorDDL.SelectedValue = 0.ToString();
                //Response.Redirect(Request.RawUrl);
                MessageUserControl.ShowInfo("Order deleted", TestLB.Text);
            });
        }
Exemplo n.º 9
0
        protected void ReceiveButton_Click(object sender, EventArgs e)
        {
            PurchaseOrderDetailsController sysmgr = new PurchaseOrderDetailsController();
            int pOrderID = int.Parse(PurchaseOrderIDLabel.Text);
            List <OpenPurchaseOrderDetails> oPODetails = sysmgr.List_OpenPurchaseOrderDetails(pOrderID);


            //int receivedQty = 0;
            int  returnQtyint          = 0;
            int  receivedQtyint        = 0;
            bool receivedQtyinputfail  = false;
            bool returnedQtyinputfail  = false;
            bool returnReasoninputfail = false;
            int  i = 0;

            foreach (GridViewRow agvrow in OpenPODetailsGridView.Rows)
            {
                string receivedQty = ((agvrow.FindControl("ReceivedQuantity") as TextBox).Text);
                if ((!(int.TryParse(receivedQty, out receivedQtyint))) || receivedQtyint < 0)
                {
                    receivedQtyinputfail = true;
                }
                string returnedQty = ((agvrow.FindControl("ReturnedQuantity") as TextBox).Text);
                if ((!(int.TryParse(returnedQty, out returnQtyint))) || returnQtyint < 0)
                {
                    returnedQtyinputfail = true;
                }
                oPODetails[i].ReceivedQuantity = receivedQtyint;
                oPODetails[i].ReturnedQuantity = returnQtyint;
                string returnReason = (agvrow.FindControl("ReturnReason") as TextBox).Text;
                if (string.IsNullOrEmpty(returnReason) && returnQtyint > 0)
                {
                    returnReasoninputfail = true;
                }
                oPODetails[i].ReturnReason = returnReason;
                i++;
            }
            if (receivedQtyinputfail || returnedQtyinputfail || returnReasoninputfail)
            {
                if (returnReasoninputfail)
                {
                    MessageUserControl.ShowInfo("Receive Order", "Incorrect data. If returning items from the purchase order, must provide a reason.");
                }
                else
                {
                    MessageUserControl.ShowInfo("Receive Order", "Incorrect data. ReceivedQuantity and ReturnedQuantity must be an integer greater than zero.");
                }
            }
            else
            {
                if (oPODetails.Any(x => x.ReceivedQuantity > x.QuantityOutstanding))
                {
                    MessageUserControl.ShowInfo("Receive Order", "Incorrect data. ReceivedQuantity cannot be greater than QuantityOutstanding.");
                }
                else
                {
                    MessageUserControl.TryRun(() =>
                    {
                        ReceiveOrderDetailsController sysmgr2 = new ReceiveOrderDetailsController();
                        sysmgr2.ReceiveOrder(pOrderID, oPODetails);
                        purchaseOrderController sysmgr3 = new purchaseOrderController();
                        PurchaseOrder pOrder            = sysmgr3.PurchaseOrder_Get(pOrderID);
                        if (pOrder.Closed == true)
                        {
                            PurchaseOrderIDLabel.Text     = "";
                            PurchaseOrderNumberLabel.Text = "";
                            DateLabel.Text           = "";
                            VendorLabel.Text         = "";
                            VendorPhoneLabel.Text    = "";
                            ReceiveButton.Visible    = false;
                            ForceCloseButton.Visible = false;
                            ReasonLabel.Visible      = false;
                            ReasonTextBox.Visible    = false;
                        }
                        OpenPOListView.DataBind();
                        OpenPODetailsGridView.DataBind();
                        UnorderedPurchaseItemCartListView.DataBind();
                    }, "Receive Order", "Order successfully received.");
                }
            }
        }