protected void InventoryList_SelectedIndexChanged(object sender, EventArgs e)

        {
            GridView    grd      = (GridView)sender;
            GridViewRow agvrow   = grd.Rows[grd.SelectedIndex];
            int         prodid   = int.Parse((agvrow.FindControl("InvProductID") as Label).Text);
            int         vendorid = int.Parse(VendorList.SelectedValue);

            MessageUserControl.TryRun(() =>
            {
                PurchasingController sysmgr        = new PurchasingController();
                List <PurchaseOrder> purchaseorder = new List <PurchaseOrder>();
                loadPOGridView(purchaseorder);
                PurchaseOrder newitem = sysmgr.InventoryToPO(vendorid, prodid, purchaseorder);
                purchaseorder.Add(newitem);
                if (newitem == null)
                {
                    throw new BusinessRuleException("Input Error", new List <string> {
                        "This item is in the purchase order already. You can modify the Order Qty if you need."
                    });
                }
                PurchaseOrderGV.DataSource = purchaseorder;
                PurchaseOrderGV.DataBind();
                calculatePOValue();
            }, "Item added", "The item has been added to the purchase order.");
            //MessageUserControl.ShowInfo("The Product ID selected",
            //         (agvrow.FindControl("InvProductID") as Label).Text);
        }
 protected void SelectVendor_Click(object sender, EventArgs e)
 {
     if (VendorList.SelectedIndex == 0)
     {
         MessageUserControl.ShowInfo("Select Error", "You must select a vendor.");
         Subtotal.Text = "0.00";
         Tax.Text      = "0.00";
         Total.Text    = "0.00";
         Cancel_Click(sender, e);
     }
     else
     {
         MessageUserControl.TryRun(() =>
         {
             int vendorid = int.Parse(VendorList.SelectedValue);
             PurchasingController sysmgr = new PurchasingController();
             VendorInfo newinfo          = sysmgr.Vendor_Info(vendorid);
             VName.Text    = newinfo.VendorName;
             Contact.Text  = newinfo.Contact;
             Phone.Text    = newinfo.Phone;
             Comments.Text = newinfo.Comments;
             List <PurchaseOrder> order = sysmgr.Purchase_Order(vendorid);
             PurchaseOrderGV.DataSource = order;
             PurchaseOrderGV.DataBind();
             calculatePOValue();
             List <ProdCategoryInfo> inventory = sysmgr.ProdCategory_List(vendorid);
             ProdCatListDTO.DataSource         = inventory;
             ProdCatListDTO.DataBind();
         }, "Purchase Order Info", "Create purchase order for this vendor.");
     }
 }
 protected void DeleteProduct_Click(object sender, EventArgs e)
 {
     MessageUserControl.TryRun(() =>
     {
         int index;
         LinkButton button           = (LinkButton)sender;
         GridViewRow gvr             = (GridViewRow)button.Parent.Parent;
         index                       = gvr.RowIndex;
         List <PurchaseOrder> POList = new List <PurchaseOrder>();
         loadPOGridView(POList);
         POList.RemoveAt(index);
         PurchaseOrderGV.DataSource = POList;
         PurchaseOrderGV.DataBind();
         calculatePOValue();
     }, "Deleted", "The product has been deleted from the purchase order.");
 }
        protected void Cancel_Click(object sender, EventArgs e)
        {
            VendorList.SelectedValue = "0";
            VName.Text              = "";
            Contact.Text            = "";
            Phone.Text              = "";
            Comments.Text           = "";
            UsersList.SelectedValue = "0";

            List <PurchaseOrder> emptypo = null;

            PurchaseOrderGV.DataSource = emptypo;
            PurchaseOrderGV.DataBind();

            List <ProdCategoryInfo> emptyinv = null;

            ProdCatListDTO.DataSource = emptyinv;
            ProdCatListDTO.DataBind();
            calculatePOValue();
        }
 protected void RefreshPrice_Click(object sender, EventArgs e)
 {
     MessageUserControl.TryRun(() =>
     {
         int index;
         LinkButton button                = (LinkButton)sender;
         GridViewRow gvr                  = (GridViewRow)button.Parent.Parent;
         index                            = gvr.RowIndex;
         PurchasingController sysmgr      = new PurchasingController();
         List <PurchaseOrder> refreshlist = new List <PurchaseOrder>();
         loadPOGridView(refreshlist);
         refreshlist[index].PerItemCost  = refreshlist[index].UnitCost / refreshlist[index].UnitSize;
         refreshlist[index].ExtendedCost = refreshlist[index].UnitCost * refreshlist[index].OrderQty;
         int prodid = refreshlist[index].ProductID;
         refreshlist[index].Warning = sysmgr.Warning(prodid, refreshlist);
         PurchaseOrderGV.DataSource = refreshlist;
         PurchaseOrderGV.DataBind();
         calculatePOValue();
     }, "Refresh", "The purchase order is updated.");
 }