protected void ADD(object sender, ListViewCommandEventArgs a)
    {
        ListViewDataItem  row     = a.Item as ListViewDataItem;
        PurchaseOrderList newItem = new PurchaseOrderList();

        newItem.itemid      = int.Parse((row.FindControl("itemid") as Label).Text);
        newItem.Description = (row.FindControl("Description") as Label).Text;
        newItem.QOH         = int.Parse((row.FindControl("QOH") as Label).Text);
        newItem.QOO         = int.Parse((row.FindControl("ROL") as Label).Text);
        newItem.ROL         = int.Parse((row.FindControl("QOO") as Label).Text);
        newItem.Price       = decimal.Parse((row.FindControl("Price") as Label).Text);
        newItem.Quantity    = 0;

        int index = row.DataItemIndex;

        List <PurchaseOrderList> datatoberemoved = Get_listitemdata(0);
        List <PurchaseOrderList> datatobeadded   = Get_listitemdata(1);

        datatoberemoved.RemoveAt(index);
        CurrentInventoryView.DataSource = datatoberemoved;
        CurrentInventoryView.DataBind();

        datatobeadded.Add(newItem);
        PurchaseOrderView.DataSource = datatobeadded;
        PurchaseOrderView.DataBind();

        GenerateAmounts(datatobeadded);
        show_everything();
    }
    protected void SearchEvent_Click(object sender, EventArgs e)
    {
        if (VendorsDisplay.SelectedValue == "0")
        {
            MessageUserControl.ShowInfo("Please select a valid vendor ID");
        }
        else
        {
            show_everything();
            PurchaseOrderController Sysmgr = new PurchaseOrderController();

            List <PurchaseOrderList> newOrder = new List <PurchaseOrderList>();
            newOrder = Sysmgr.Get_Order(int.Parse(VendorsDisplay.SelectedValue));

            PurchaseOrderView.DataSource = newOrder;
            PurchaseOrderView.DataBind();

            List <PurchaseOrderList> inventory = new List <PurchaseOrderList>();
            inventory = Sysmgr.Get_currentInventory(int.Parse(VendorsDisplay.SelectedValue));

            CurrentInventoryView.DataSource = inventory;
            CurrentInventoryView.DataBind();

            GenerateAmounts(newOrder);
        }
    }
    protected void Clear_Click(object sender, EventArgs e)
    {
        PurchaseOrderController sysmgr = new PurchaseOrderController();
        string message = sysmgr.transaction(null, 4, int.Parse(VendorsDisplay.SelectedValue), 0, 0);

        PurchaseOrderView.DataBind();
        CurrentInventoryView.DataBind();
        VendorsDisplay.SelectedIndex = 0;
        hide_everything();
        MessageUserControl.ShowInfo(message);
    }
    protected void Place_Click(object sender, EventArgs e)
    {
        List <PurchaseOrderList> updatefunctions = Get_listitemdata(1);
        PurchaseOrderController  sysmgr          = new PurchaseOrderController();

        if (updatefunctions.Any())
        {
            MessageUserControl.TryRun(() =>
            {
                string message = sysmgr.transaction(updatefunctions, 2, int.Parse(VendorsDisplay.SelectedValue), decimal.Parse(SubTotal.Text), decimal.Parse(Tax.Text));
                show_everything();
                GenerateAmounts(updatefunctions);
                PurchaseOrderView.DataBind();
                CurrentInventoryView.DataBind();
                VendorsDisplay.SelectedIndex = 0;
                hide_everything();
                MessageUserControl.ShowInfo(message);
            });
        }
        else
        {
            MessageUserControl.ShowInfo("No Order to update");
        }
    }