Ejemplo n.º 1
0
        protected void PurchaseOrderSelectionList_ItemCommand(object sender, ListViewCommandEventArgs e)
        {
            ReceiveButton.Visible    = true;
            ForceCloseButton.Visible = true;
            ReasonLabel.Visible      = true;
            ReasonTextBox.Visible    = true;

            int pOrderID = int.Parse(e.CommandArgument.ToString());

            PurchaseOrderIDLabel.Text = pOrderID.ToString();
            UnorderedPurchaseItemCartListView.DataBind();

            using (var context = new eToolsContext())
            {
                PurchaseOrder pOrder = context.PurchaseOrders.Find(pOrderID);
                PurchaseOrderNumberLabel.Text = "Purchase Order #: " + pOrder.PurchaseOrderNumber.ToString();
                DateLabel.Text        = "Date: " + pOrder.OrderDate == null ? "" : pOrder.OrderDate.Value.ToShortDateString();
                VendorLabel.Text      = pOrder.Vendor.VendorName;
                VendorPhoneLabel.Text = pOrder.Vendor.Phone;
            }
        }
Ejemplo n.º 2
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.");
                }
            }
        }