Example #1
0
        protected void VendorDDL_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (VendorDDL.SelectedIndex == 0)
            {
                MessageUserControl.ShowInfo("Wait", "Please select a vendor to begin");
                VendorNameL.Text         = "";
                VendorAddressL.Text      = "";
                VendorPhoneL.Text        = "";
                ItemToOrderPanel.Visible = false;
            }
            else
            {
                MessageUserControl.TryRun(() =>
                {
                    ItemToOrderPanel.Visible = true;
                    int vendorid             = int.Parse(VendorDDL.SelectedValue);
                    VendorController sysmg   = new VendorController();
                    var theVendor            = sysmg.Vendor_Get(vendorid);
                    VendorNameL.Text         = theVendor.VendorName;
                    VendorAddressL.Text      = theVendor.Address + ", " + theVendor.City + ", " + theVendor.PostalCode;
                    VendorPhoneL.Text        = theVendor.Phone;

                    string username = User.Identity.Name;
                    ApplicationUserManager secmgr = new ApplicationUserManager(new UserStore <ApplicationUser>(new ApplicationDbContext()));
                    EmployeeInfo info             = secmgr.User_GetEmployee(username);
                    int employeeid = info.EmployeeID;

                    // check if active order exist
                    PurchaseOrderController pomgr = new PurchaseOrderController();
                    if (pomgr.ActiveOrderDetails(vendorid) == null)
                    {
                        pomgr.Create_PurchaseOrder(vendorid, employeeid);
                        MessageUserControl.ShowInfo("Success", "A suggested order has been created");
                        // refresh both listviews
                        //List<PODetail> suggestedItems = pomgr.SuggestedOrderDetails(vendorid);
                        //ItemToOrderListView.DataSource = suggestedItems;
                        //ItemToOrderListView.DataBind();

                        //List<PODetail> remainItems = pomgr.ItemsInStock(vendorid);
                        //RemainingStockItemsListView.DataSource = remainItems;
                        //RemainingStockItemsListView.DataBind();
                    }
                    else
                    {
                        MessageUserControl.ShowInfo("Success", "Retrived a Active Order");
                    }

                    List <PODetail> activeItems    = pomgr.ActiveOrderDetails(vendorid);
                    ItemToOrderListView.DataSource = activeItems;
                    ItemToOrderListView.DataBind();

                    List <PODetail> remainItems            = pomgr.ItemsInStock(vendorid);
                    RemainingStockItemsListView.DataSource = remainItems;
                    RemainingStockItemsListView.DataBind();
                    DisplaySubtotal(activeItems);
                });
            }
        }
Example #2
0
        public void RefreshLists(int vendorid)
        {
            PurchaseOrderController sysmgr      = new PurchaseOrderController();
            List <PODetail>         activeItems = sysmgr.ActiveOrderDetails(vendorid);

            ItemToOrderListView.DataSource = activeItems;
            ItemToOrderListView.DataBind();

            List <PODetail> remainItems = sysmgr.ItemsInStock(vendorid);

            RemainingStockItemsListView.DataSource = remainItems;
            RemainingStockItemsListView.DataBind();
            DisplaySubtotal(activeItems);
        }