protected void ForceCloseButton_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(ReasonTextBox.Text)) { MessageUserControl.ShowInfo("Required Data", "Reason is required to close order."); } else { MessageUserControl.TryRun(() => { int pOrderID = int.Parse(PurchaseOrderIDLabel.Text); string forceCloseReason = ReasonTextBox.Text; purchaseOrderController sysmgr = new purchaseOrderController(); sysmgr.ForceClosePurchaseOrder(pOrderID, forceCloseReason); }, "Force Close Order", "Order successfuly closed."); PurchaseOrderIDLabel.Text = ""; PurchaseOrderNumberLabel.Text = ""; DateLabel.Text = ""; VendorLabel.Text = ""; VendorPhoneLabel.Text = ""; OpenPOListView.DataBind(); OpenPODetailsGridView.DataBind(); ReceiveButton.Visible = false; ForceCloseButton.Visible = false; ReasonLabel.Visible = false; ReasonTextBox.Visible = false; } }
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."); } } }