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);
        }
    }
 public static void Cleanup()
 {
     foreach (PurchaseOrder obj in _objectsToCleanup)
     {
         PurchaseOrderController.Delete(_authToken, obj, false).Wait();
     }
 }
Beispiel #3
0
        protected void PlaceButton_Click(object sender, EventArgs e)
        {
            MessageUserControl.TryRun(() =>
            {
                int vendorid = int.Parse(VendorDDL.SelectedValue);
                List <PurchaseOrderDetail> polist = new List <PurchaseOrderDetail>();

                foreach (ListViewItem item in ItemToOrderListView.Items)
                {
                    Label sid             = item.FindControl("SIDLabel") as Label;
                    TextBox qtoTB         = item.FindControl("qtoTB") as TextBox;
                    TextBox priceTB       = item.FindControl("priceTB") as TextBox;
                    LinkButton podetailid = item.FindControl("RemoveButton") as LinkButton;

                    PurchaseOrderDetail tempPODetail   = new PurchaseOrderDetail();
                    tempPODetail.PurchaseOrderDetailID = int.Parse(podetailid.CommandArgument);
                    tempPODetail.StockItemID           = int.Parse(sid.Text);
                    tempPODetail.Quantity = int.Parse(qtoTB.Text);
                    if (tempPODetail.Quantity == 0)
                    {
                        throw new Exception("Shouldn not have any Items with 0 quantity.");
                    }
                    tempPODetail.PurchasePrice = decimal.Parse(priceTB.Text);
                    polist.Add(tempPODetail);
                }
                PurchaseOrderController sysmgr = new PurchaseOrderController();
                sysmgr.PurchaseOrder_Place(polist);
                VendorDDL.SelectedIndex  = 0;
                ItemToOrderPanel.Visible = false;
            }, "Success", "Purchase Order have been send to the vendor");
        }
        protected void OrderList_ItemCommand(object sender, ListViewCommandEventArgs e)
        {
            MessageUserControl.TryRun(() =>
            {
                // Note: POID is imbedded on each list row (with the CommandArgument parameter)
                int poID = int.Parse(e.CommandArgument.ToString());

                PurchaseOrderController sysmgr = new PurchaseOrderController();
                OpenOrder openOrder            = sysmgr.OpenOrder_FindByID(poID);

                PurchaseOrderID.Text = openOrder.POID.ToString();
                Number.Text          = openOrder.PONumber.ToString();
                Vendor.Text          = openOrder.VendorName;
                Phone.Text           = openOrder.VendorPhone;

                // Need to rebind data source before visibility enabled
                ReturnList.DataBind();

                // Load/Reload page content
                ReloadPageContent(poID);

                // Ensure insert template gets purchase order ID
                HiddenField insertPOID = ReturnList.InsertItem.FindControl("PurchaseOrderIDField") as HiddenField;
                insertPOID.Value       = poID.ToString();

                // Highlight selected row
                OrderList.SelectedIndex = e.Item.DisplayIndex;
            },
                                      "Order Found",
                                      "Order details successfully retrieved");
        }
Beispiel #5
0
        public void GetAll()
        {
            PurchaseOrderController controller = new PurchaseOrderController();
            var poMasters = controller.GetPOMASTERs().ToList();

            Assert.IsTrue(poMasters[0].PONO == "PO01");
            Assert.IsTrue(poMasters[0].PODETAILs.ToList()[0].QTY == 10);
        }
Beispiel #6
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);
                });
            }
        }
Beispiel #7
0
        protected void RemoveButton_Click(object sender, CommandEventArgs e)
        {
            int vendorid = int.Parse(VendorDDL.SelectedValue);
            int podID    = int.Parse((e.CommandArgument).ToString());
            PurchaseOrderController sysmgr = new PurchaseOrderController();

            sysmgr.PurchaseOrderDetail_Remove(podID);
            RefreshLists(vendorid);
        }
        public void GetOrderItemsFromSupplier()
        {
            ApplicationDbContext context    = new ApplicationDbContext();
            IUnitOfWork          unitOfWork = new UnitOfWork(context);
            var controller = new PurchaseOrderController(unitOfWork);
            var result     = controller.GetOrderItemsFromSupplier(1) as ViewResult;

            Assert.AreEqual(expected: "GetOrderItemsFromSupplier", actual: result.ViewName);
        }
        public void Create()
        {
            ApplicationDbContext context    = new ApplicationDbContext();
            IUnitOfWork          unitOfWork = new UnitOfWork(context);
            var controller = new PurchaseOrderController(unitOfWork);
            var result     = controller.Create() as ViewResult;

            Assert.AreEqual(expected: "Create", actual: result.ViewName);
        }
Beispiel #10
0
        protected void AddButton_Command(object sender, CommandEventArgs e)
        {
            int vendorid    = int.Parse(VendorDDL.SelectedValue);
            int stockItemid = int.Parse((e.CommandArgument).ToString());
            PurchaseOrderController sysmgr = new PurchaseOrderController();

            sysmgr.PurchaseOrderDetail_Add(stockItemid, vendorid);
            RefreshLists(vendorid);
        }
Beispiel #11
0
 protected void DeleteButton_Click(object sender, EventArgs e)
 {
     MessageUserControl.TryRun(() =>
     {
         int vendorid = int.Parse(VendorDDL.SelectedValue);
         PurchaseOrderController sysmgr = new PurchaseOrderController();
         sysmgr.PurchaseOrder_Delete(vendorid);
     }, "Success", "Purchase Order Deleted");
 }
Beispiel #12
0
        protected void Page_Load(object sender, EventArgs e)
        {
            System.Web.UI.HtmlControls.HtmlGenericControl li = (System.Web.UI.HtmlControls.HtmlGenericControl) this.Page.Master.FindControl("RaisePurchaseOrder");
            Label lblWelcome = (Label)this.Master.FindControl("lblWelcome");

            if (Session["Role"] != null)
            {
                if (Session["Role"].ToString() == "Employee")
                {
                    Response.Redirect("../DepartmentEmployee/RequestStationery.aspx");
                }
                else if (Session["Role"].ToString() == "DelegateHead")
                {
                    Response.Redirect("../DepartmentEmployee/RequestStationery.aspx");
                }
                else if (Session["Role"].ToString() == "Head")
                {
                    Response.Redirect("../DepartmentHead/PendingRequests.aspx");
                }
                else if (Session["Role"].ToString() == "StoreSupervisor")
                {
                    Response.Redirect("../StoreSupervisor/PendingAdjustment.aspx");
                }
                else if (Session["Role"].ToString() == "StoreManager")
                {
                    Response.Redirect("../StoreSupervisor/PendingAdjustment.aspx");
                }
            }
            else
            {
                Response.Redirect("../Login.aspx");
            }
            lblWelcome.Text = Session["Name"].ToString();//from login username
            li.Attributes.Add("class", "active");
            if (!IsPostBack)
            {
                ArrayList  pur_list = PurchaseOrderController.GetPendingPurchaseOrder();
                string[]   ponumber = (string[])pur_list[0];
                string[]   name     = (string[])pur_list[1];
                DateTime[] date     = (DateTime[])pur_list[2];
                DataTable  dt       = new DataTable();
                dt.Columns.Add("PONumber");
                dt.Columns.Add("Name");
                dt.Columns.Add("Date");
                for (int i = 0; i < ponumber.Count(); i++)
                {
                    dt.Rows.Add();
                    dt.Rows[i]["PONumber"] = ponumber[i].ToString();
                    dt.Rows[i]["Name"]     = name[i].ToString();
                    dt.Rows[i]["Date"]     = date[i].ToShortDateString();
                }

                grdPendingPurchaseOrder.DataSource = dt;
                grdPendingPurchaseOrder.DataBind();
            }
        }
Beispiel #13
0
        public void Get()
        {
            PurchaseOrderController controller = new PurchaseOrderController();
            IHttpActionResult       poMasters  = controller.GetPOMASTER("PO01");

            var content = poMasters as OkNegotiatedContentResult <POMASTER>;

            Assert.IsTrue(content.Content.PONO == "PO01");
            Assert.IsTrue(content.Content.PODETAILs.ToList()[0].QTY == 10);
        }
    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);
    }
Beispiel #15
0
    private void ShowData()
    {
        string orderNumber = Request.QueryString["OrderNumber"];
        Collection <PurchaseOrderHeaderText> texts = PurchaseOrderController.GetPurchaseOrderHeaderText(orderNumber);

        gvData.DataSource = texts;
        gvData.DataBind();
        if (texts.Count == 0)
        {
            lblCount.Text = string.Format("{0} record(s) found. ", texts.Count.ToString());
        }
    }
        public async Task PO05_GetAllPurchaseOrdersTest()
        {
            // Arrange
            List <PurchaseOrder> poList;

            // Act
            poList = await PurchaseOrderController.GetAll(_authToken);

            // Assert
            Assert.IsNotNull(poList, "Expected a List<PurchaseOrder>, got null");
            Assert.IsTrue(poList.Count >= 1, "Expected at least one member of this list, got " + poList.Count);
            Assert.IsTrue(poList.Contains(_purchaseOrder), "List does not contain the test PurchaseOrder");
        }
Beispiel #17
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);
        }
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        try
        {
            string strErrorMsg = ValidateInput();

            if (!string.IsNullOrEmpty(strErrorMsg.ToString()))
            {
                plMessage.Visible = true;
                displayCustomMessage(FormatErrorMessage(strErrorMsg.ToString()), lblMessage, SystemMessageType.Error);
                return;
            }

            m_Header.AcknowledgeStatus = POAckStatus.Acknowledged;

            foreach (GridViewRow rowItem in gvItem.Rows)
            {
                Label    lblItemNo  = (Label)rowItem.FindControl("lblItemNo");
                GridView gvSchedule = (GridView)rowItem.FindControl("gvSchedule");
                foreach (GridViewRow rowSchedule in gvSchedule.Rows)
                {
                    Label lblPurchaseOrderScheduleSequence = (Label)rowSchedule.FindControl("lblPurchaseOrderScheduleSequence");
                    UserControls_DatePicker dtpAck         = (UserControls_DatePicker)rowSchedule.FindControl("dtpAck");

                    foreach (PurchaseOrderItemSchedule schedule in m_Schedules)
                    {
                        if (string.Compare(lblItemNo.Text, schedule.PurchaseOrderItemSequence, true) == 0 &&
                            string.Compare(lblPurchaseOrderScheduleSequence.Text, schedule.PurchaseOrderScheduleSequence, true) == 0)
                        {
                            schedule.AcknowledgementDate = GetStoredDateValue(dtpAck.SelectedDate);
                        }
                    }
                }
            }

            PurchaseOrderController.AcknowledgePurchaseOrder(m_Header, m_Schedules);

            btnSubmit.Enabled = false;
            plMessage.Visible = true;
            string sMessage = "Purchase Order has been acknowledged successfully.";
            displayCustomMessage(sMessage, lblMessage, SystemMessageType.Information);
        }
        catch (Exception ex)
        {
            ExceptionLog(ex);
            plMessage.Visible = true;
            string sMessage = ex.Message;
            displayCustomMessage(sMessage, lblMessage, SystemMessageType.Error);
        }
    }
Beispiel #19
0
        public void TestListPurchaseOrders()
        {
            var supplierController = new SupplierController(new LoggerStub <SupplierController>());
            var poController       = new PurchaseOrderController(new LoggerStub <PurchaseOrderController>());

            var suppliers = supplierController.Search("Test").Result as List <Supplier>;

            Assert.IsNotNull(suppliers, "Suppliers are null");
            Assert.IsTrue(suppliers.Count > 0, "No test suppliers in database");
            var supplier = suppliers.FirstOrDefault();
            var poList   = poController.GetSupplierOrders(supplier.Id).Result as List <PurchaseOrderListDTO>;

            Assert.IsTrue(poList.Count > 0, "Test supplier has no purchase orders, please create test data");
        }
Beispiel #20
0
        protected void grdPendingPurchaseOrder_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "Select")
            {
                int command = Convert.ToInt32(e.CommandArgument);

                string po   = grdPendingPurchaseOrder.Rows[command].Cells[0].Text;
                string name = grdPendingPurchaseOrder.Rows[command].Cells[1].Text;
                string date = grdPendingPurchaseOrder.Rows[command].Cells[2].Text;

                List <PurchaseOrderDetail> pod_list = PurchaseOrderController.GetPendingItemsList(Convert.ToInt32(po));
                ExportToPDF(name, po, date, pod_list);
            }
        }
        public async Task PO06_SetPurchaseOrderParentCommitTest()
        {
            // Arrange
            Guid          id     = Guid.NewGuid();
            PurchaseOrder parent = await PurchaseOrderController.Create(_authToken, "TestParentPO" + id.ToString(), "Test ParentPO", "TestParentPO" + id.ToString(), DateTime.Now);

            _objectsToCleanup.Add(parent);
            _purchaseOrder.Parent = parent;

            // Act
            await _purchaseOrder.Commit(_authToken);

            // Assert
            Assert.AreEqual(parent, _purchaseOrder.Parent, "PuchaseOrder.Parent does not match the test data");
        }
        public async Task PO99_DeletePurchaseOrderTest()
        {
            // Arrange

            // Act
            await PurchaseOrderController.Delete(_authToken, _purchaseOrder, false);

            // Assert
            Assert.IsTrue(_purchaseOrder.IsDeleted, "PurchaseOrder.IsDeleted evaluated to false");

            if (_purchaseOrder.IsDeleted)
            {
                _objectsToCleanup.Remove(_purchaseOrder);
            }
        }
        public async Task PO01_CreatePurchaseOrderTest()
        {
            // Arrange
            Guid   id     = Guid.NewGuid();
            string poName = "TestPurchaseOrder" + id.ToString();

            // Act
            _purchaseOrder = await PurchaseOrderController.Create(_authToken, poName, "Test PurchaseOrder", poName, DateTime.Today);

            _objectsToCleanup.Add(_purchaseOrder);

            // Assert
            Assert.IsNotNull(_purchaseOrder, "Failed to create new PurchaseOrder");
            Assert.IsTrue(_purchaseOrder.IsActive, "PurchaseOrder.IsActive evaluated to false");
        }
        public async Task HWA07_SetHardwareAssetPurchaseOrderCommitTest()
        {
            // Arrange
            Guid          testId = Guid.NewGuid();
            PurchaseOrder po     = await PurchaseOrderController.Create(_authToken, testId.ToString(), testId.ToString(), testId.ToString(), DateTime.Now);

            _objectsToCleanup.Add(po);
            _asset.PurchaseOrder = po;

            // Act
            await _asset.Commit(_authToken);

            // Assert
            Assert.AreEqual(po, _asset.PurchaseOrder, "HardwareAsset.PurchaseOrder does not match the test data");
        }
Beispiel #25
0
        public void TestCreatePurchaseOrder()
        {
            var supplierController = new SupplierController(new LoggerStub <SupplierController>());
            var poController       = new PurchaseOrderController(new LoggerStub <PurchaseOrderController>());

            var suppliers = supplierController.Search("Test").Result as List <Supplier>;

            Assert.IsNotNull(suppliers, "Suppliers are null");
            Assert.IsTrue(suppliers.Count > 0, "No test suppliers in database");
            var supplier = suppliers.FirstOrDefault();
            var poId     = poController.CreatePurchaseOrder(supplier.Id).Result;

            Assert.IsNotNull(poId, "Purchase order controller returned NULL");
            Assert.AreNotEqual(poId, Guid.Empty, "Purchase Order ID is Empty GUID");
        }
        public async Task CreatePurchaseOrder_Returns_CreatedAtRouteResult()
        {
            //Arrange
            _fixture.MockPurchaseOrderRepository.Setup(x => x.CreatePurchaseOrderAsync(It.IsAny <CreatePurchaseOrderDto>()))
            .ReturnsAsync(_fixture.CreatePurchaseOrderDtoResult);

            var controller = new PurchaseOrderController(_fixture.MockPurchaseOrderRepository.Object);

            //Act
            var result = await controller.CreatePurchaseOrder(_fixture.ValidCreatePurchaseOrderDto, _fixture.ApiVersion);

            //Assert
            var objectResult = result.Should().BeOfType <CreatedAtRouteResult>().Subject;

            objectResult.StatusCode.Should().Be(201);
            objectResult.RouteValues !["id"].Should().Be(4);
Beispiel #27
0
    private void GetData()
    {
        string   orderNumber = txtOrderNumber.Text.Trim();
        DateTime startDate   = DateTime.MinValue;
        DateTime endDate     = DateTime.MinValue;

        if (dtpFrom.SelectedDateString != "")
        {
            startDate = dtpFrom.SelectedDate;
        }
        if (dtpTo.SelectedDateString != "")
        {
            endDate = dtpTo.SelectedDate;
        }
        m_Data = PurchaseOrderController.GetPendingAckPOList(orderNumber, startDate, endDate, "");
    }
Beispiel #28
0
        public void Update()
        {
            PurchaseOrderController controller = new PurchaseOrderController();
            PODETAIL podetail = new PODETAIL()
            {
                PONO = "PO01", ITCODE = "IT01", QTY = 10
            };

            controller.PutPOMASTER("PO01", new POMASTER()
            {
                PODATE = DateTime.Now, PONO = "PO01", SUPLNO = "SU01", PODETAILs = new List <PODETAIL>()
                {
                    podetail
                }
            });
            Assert.IsTrue(podetail.QTY == 10);
        }
Beispiel #29
0
        protected void PlaceOrder_Click(object sender, EventArgs e)
        {
            MessageUserControl.Visible = true;
            List <CurrentActiveOrderList> list = new List <CurrentActiveOrderList>();

            if (OrderList.Rows.Count == 0)
            {
                MessageUserControl.ShowInfo("you must first select vendor name to display Current Active Order.");
                VendorStockItemList.DataSource = null;
                VendorStockItemList.DataBind();
            }
            if (int.Parse(VendorDLL.SelectedValue) == 0)
            {
                MessageUserControl.ShowInfo("you must first select vendor name to display Current Active Order.");
            }
            else
            {
                for (int rowindex = 0; rowindex < OrderList.Rows.Count; rowindex++)
                {
                    CurrentActiveOrderList temp = new CurrentActiveOrderList();
                    temp.StockItemID     = int.Parse((OrderList.Rows[rowindex].FindControl("StockItemID") as Label).Text);
                    temp.Description     = (OrderList.Rows[rowindex].FindControl("Description") as Label).Text;
                    temp.QuantityOnHand  = int.Parse((OrderList.Rows[rowindex].FindControl("QuantityOnHand") as Label).Text);
                    temp.QuantityOnOrder = int.Parse((OrderList.Rows[rowindex].FindControl("QuantityOnOrder") as Label).Text);
                    temp.ReOrderLevel    = int.Parse((OrderList.Rows[rowindex].FindControl("ReOrderLevel") as Label).Text);
                    temp.QuantityToOrder = int.Parse((OrderList.Rows[rowindex].FindControl("QuantityToOrder") as TextBox).Text);
                    temp.Price           = decimal.Parse((OrderList.Rows[rowindex].FindControl("Price") as TextBox).Text, NumberStyles.Currency);
                    list.Add(temp);
                }
                MessageUserControl.TryRun(() =>
                {
                    int vendorid = int.Parse(VendorDLL.SelectedValue);
                    PurchaseOrderDetailController sysmgr = new PurchaseOrderDetailController();
                    sysmgr.Place_ToPurchaseOrder(vendorid, list);
                    List <CurrentActiveOrderList> info = sysmgr.list_PlacedCurerentActiveOrder(vendorid);
                    OrderList.DataSource = info;
                    OrderList.DataBind();

                    PurchaseOrderController order = new PurchaseOrderController();
                    PurchaseOrder result2         = order.CompleteOrder_GetByVendor(vendorid);
                    GSTID.Text      = string.Format("{0:C2}", result2.TaxAmount);
                    SubTotalID.Text = string.Format("{0:C2}", result2.SubTotal);
                    TotalID.Text    = string.Format("{0:C2}", result2.Total);
                }, " Placing order", " Order placed sucessfully.");
            }
        }
Beispiel #30
0
        public void Add()
        {
            PurchaseOrderController controller = new PurchaseOrderController();
            PODETAIL podetail = new PODETAIL()
            {
                PONO = "PO01", ITCODE = "IT01", QTY = 5
            };

            controller.PostPOMASTER(new POMASTER()
            {
                PODATE = DateTime.Now, PONO = "PO01", SUPLNO = "SU01", PODETAILs = new List <PODETAIL>()
                {
                    podetail
                }
            });
            Assert.IsTrue(podetail.PONO == "PO01");
        }
        private PdfPTable GetPOAmountData(int purchaseorderId)
        {
            decimal dTotal = 0;
            string szMsg = "";
            string szLogo = "HILTON GARDEN INN.";
            string szImprintColors = "Process blue & ...";
            string szBlindShip = "Blind Ship";
            string szStars = "**************";

            string szFromTitle = "";
            string szFromCompany = "";
            string szFromAddress1 = "";
            string szFromAddress2 = "";
            string szFromCity = "";
            string szFromState = "";
            string szFromZip = "";
            string szFromCountry = "";
            string szFromEmail = "";
            string szFromTel = "";
            string szFromFax = "";
            string szFromName = "";

            string szToTitle = "";
            string szToCompany = "";
            string szToAddress1 = "";
            string szToAddress2 = "";
            string szToCity = "";
            string szToState = "";
            string szToZip = "";
            string szToCountry = "";
            string szToEmail = "";
            string szToTel = "";
            string szToFax = "";
            string szToName = "";

            PurchaseOrders purchaseorder = db.PurchaseOrders.Find(purchaseorderId);
            if (purchaseorder != null)
            {
                szLogo = purchaseorder.Logo;
                szImprintColors = purchaseorder.ImprintColor;

                if (purchaseorder.IsBlindShip)
                {
                    szBlindShip = "Blind Ship";
                }
                else
                {
                    szBlindShip = string.Empty;
                }

                szFromAddress1 = purchaseorder.FromAddress1;
                szFromAddress2 = purchaseorder.FromAddress2;
                szFromCity = purchaseorder.FromCity;
                szFromCompany = purchaseorder.FromCompany;
                szFromCountry = purchaseorder.FromCountry;
                szFromEmail = purchaseorder.FromEmail;
                szFromFax = purchaseorder.FromFax;
                szFromState = purchaseorder.FromState;
                szFromTel = purchaseorder.FromTel;
                szFromTitle = purchaseorder.FromTitle;
                szFromName = purchaseorder.FromName;
                szFromZip = purchaseorder.FromZip;

                szToAddress1 = purchaseorder.ToAddress1;
                szToAddress2 = purchaseorder.ToAddress2;
                szToCity = purchaseorder.ToCity;
                szToCompany = purchaseorder.ToCompany;
                szToCountry = purchaseorder.ToCountry;
                szToEmail = purchaseorder.ToEmail;
                szToFax = purchaseorder.ToFax;
                szToState = purchaseorder.ToState;
                szToTel = purchaseorder.ToTel;
                szToTitle = purchaseorder.ToTitle;
                szToName = purchaseorder.ToName;
                szToZip = purchaseorder.ToZip;

            }

            //The report data
            //Get the total
            TimelyDepotMVC.Controllers.PurchaseOrderController poctrl = new PurchaseOrderController();
            dTotal = poctrl.GetTotalPO(purchaseorderId);

            //The report layout
            Font times01 = FontFactory.GetFont("helvetica-bold", 12, BaseColor.BLACK);
            Font times02 = FontFactory.GetFont("helvetica-bold", 12, Font.ITALIC, BaseColor.BLACK);
            Font times03 = FontFactory.GetFont("helvetica-bold", 12, Font.UNDERLINE, BaseColor.BLACK);
            Font times04 = FontFactory.GetFont("helvetica", 12, BaseColor.BLACK);
            Font times05 = FontFactory.GetFont("helvetica", 12, Font.UNDERLINE, BaseColor.BLACK);
            Font times06 = FontFactory.GetFont("helvetica", 10, BaseColor.BLACK);
            Font times07 = FontFactory.GetFont("helvetica", 12, Font.ITALIC, BaseColor.BLACK);
            Font times08 = FontFactory.GetFont("helvetica-bold", 16, BaseColor.BLACK);

            PdfPCell nestingcell = null;
            PdfPCell hlpCel = null;
            Paragraph title = null;

            PdfPTable infotable = new PdfPTable(numColumns: 1);
            infotable.WidthPercentage = 100;
            infotable.RunDirection = PdfWriter.RUN_DIRECTION_LTR;
            infotable.SpacingBefore = 25;

            szMsg = string.Format("Total {0}", dTotal.ToString("N2"));
            title = new Paragraph(szMsg, times04);
            hlpCel = new PdfPCell(title);
            hlpCel.RunDirection = PdfWriter.RUN_DIRECTION_LTR;
            hlpCel.BorderWidthLeft = 0;
            hlpCel.BorderWidthRight = 0;
            hlpCel.BorderWidthTop = 0;
            hlpCel.BorderWidthBottom = 0;
            hlpCel.PaddingTop = 4;
            hlpCel.PaddingLeft = 0;
            hlpCel.PaddingRight = 0;
            hlpCel.PaddingBottom = 1;
            //BorderColorTop = new BaseColor(System.Drawing.Color.LightGray),
            hlpCel.HorizontalAlignment = Element.ALIGN_RIGHT;
            infotable.AddCell(hlpCel);

            szMsg = string.Format("Logo: {0}", szLogo);
            title = new Paragraph(szMsg, times01);
            hlpCel = new PdfPCell(title);
            hlpCel.RunDirection = PdfWriter.RUN_DIRECTION_LTR;
            hlpCel.BorderWidthLeft = 0;
            hlpCel.BorderWidthRight = 0;
            hlpCel.BorderWidthTop = 0;
            hlpCel.BorderWidthBottom = 0;
            hlpCel.PaddingTop = 4;
            hlpCel.PaddingLeft = 0;
            hlpCel.PaddingRight = 0;
            hlpCel.PaddingBottom = 1;
            //BorderColorTop = new BaseColor(System.Drawing.Color.LightGray),
            hlpCel.HorizontalAlignment = Element.ALIGN_LEFT;
            infotable.AddCell(hlpCel);

            szMsg = string.Format("Imprint colors: {0}", szImprintColors);
            title = new Paragraph(szMsg, times01);
            hlpCel = new PdfPCell(title);
            hlpCel.RunDirection = PdfWriter.RUN_DIRECTION_LTR;
            hlpCel.BorderWidthLeft = 0;
            hlpCel.BorderWidthRight = 0;
            hlpCel.BorderWidthTop = 0;
            hlpCel.BorderWidthBottom = 0;
            hlpCel.PaddingTop = 4;
            hlpCel.PaddingLeft = 0;
            hlpCel.PaddingRight = 0;
            hlpCel.PaddingBottom = 1;
            //BorderColorTop = new BaseColor(System.Drawing.Color.LightGray),
            hlpCel.HorizontalAlignment = Element.ALIGN_LEFT;
            infotable.AddCell(hlpCel);

            szMsg = string.Format("{0}", szBlindShip);
            title = new Paragraph(szMsg, times08);
            hlpCel = new PdfPCell(title);
            hlpCel.RunDirection = PdfWriter.RUN_DIRECTION_LTR;
            hlpCel.BorderWidthLeft = 0;
            hlpCel.BorderWidthRight = 0;
            hlpCel.BorderWidthTop = 0;
            hlpCel.BorderWidthBottom = 0;
            hlpCel.PaddingTop = 10;
            hlpCel.PaddingLeft = 0;
            hlpCel.PaddingRight = 0;
            hlpCel.PaddingBottom = 1;
            //BorderColorTop = new BaseColor(System.Drawing.Color.LightGray),
            hlpCel.HorizontalAlignment = Element.ALIGN_LEFT;
            infotable.AddCell(hlpCel);

            szMsg = string.Format("{0}", szStars);
            title = new Paragraph(szMsg, times08);
            hlpCel = new PdfPCell(title);
            hlpCel.RunDirection = PdfWriter.RUN_DIRECTION_LTR;
            hlpCel.BorderWidthLeft = 0;
            hlpCel.BorderWidthRight = 0;
            hlpCel.BorderWidthTop = 0;
            hlpCel.BorderWidthBottom = 0;
            hlpCel.PaddingTop = 4;
            hlpCel.PaddingLeft = 0;
            hlpCel.PaddingRight = 0;
            hlpCel.PaddingBottom = 1;
            //BorderColorTop = new BaseColor(System.Drawing.Color.LightGray),
            hlpCel.HorizontalAlignment = Element.ALIGN_LEFT;
            infotable.AddCell(hlpCel);

            szMsg = string.Format("From:");
            title = new Paragraph(szMsg, times03);
            hlpCel = new PdfPCell(title);
            hlpCel.RunDirection = PdfWriter.RUN_DIRECTION_LTR;
            hlpCel.BorderWidthLeft = 0;
            hlpCel.BorderWidthRight = 0;
            hlpCel.BorderWidthTop = 0;
            hlpCel.BorderWidthBottom = 0;
            hlpCel.PaddingTop = 4;
            hlpCel.PaddingLeft = 0;
            hlpCel.PaddingRight = 0;
            hlpCel.PaddingBottom = 1;
            //BorderColorTop = new BaseColor(System.Drawing.Color.LightGray),
            hlpCel.HorizontalAlignment = Element.ALIGN_LEFT;
            infotable.AddCell(hlpCel);

            szMsg = string.Format("{0}", szFromCompany);
            title = new Paragraph(szMsg, times01);
            hlpCel = new PdfPCell(title);
            hlpCel.RunDirection = PdfWriter.RUN_DIRECTION_LTR;
            hlpCel.BorderWidthLeft = 0;
            hlpCel.BorderWidthRight = 0;
            hlpCel.BorderWidthTop = 0;
            hlpCel.BorderWidthBottom = 0;
            hlpCel.PaddingTop = 4;
            hlpCel.PaddingLeft = 0;
            hlpCel.PaddingRight = 0;
            hlpCel.PaddingBottom = 1;
            //BorderColorTop = new BaseColor(System.Drawing.Color.LightGray),
            hlpCel.HorizontalAlignment = Element.ALIGN_LEFT;
            infotable.AddCell(hlpCel);

            szMsg = string.Format("{0}", szFromName);
            title = new Paragraph(szMsg, times01);
            hlpCel = new PdfPCell(title);
            hlpCel.RunDirection = PdfWriter.RUN_DIRECTION_LTR;
            hlpCel.BorderWidthLeft = 0;
            hlpCel.BorderWidthRight = 0;
            hlpCel.BorderWidthTop = 0;
            hlpCel.BorderWidthBottom = 0;
            hlpCel.PaddingTop = 4;
            hlpCel.PaddingLeft = 0;
            hlpCel.PaddingRight = 0;
            hlpCel.PaddingBottom = 1;
            //BorderColorTop = new BaseColor(System.Drawing.Color.LightGray),
            hlpCel.HorizontalAlignment = Element.ALIGN_LEFT;
            infotable.AddCell(hlpCel);

            szMsg = string.Format("{0}", szFromAddress1);
            title = new Paragraph(szMsg, times01);
            hlpCel = new PdfPCell(title);
            hlpCel.RunDirection = PdfWriter.RUN_DIRECTION_LTR;
            hlpCel.BorderWidthLeft = 0;
            hlpCel.BorderWidthRight = 0;
            hlpCel.BorderWidthTop = 0;
            hlpCel.BorderWidthBottom = 0;
            hlpCel.PaddingTop = 4;
            hlpCel.PaddingLeft = 0;
            hlpCel.PaddingRight = 0;
            hlpCel.PaddingBottom = 1;
            //BorderColorTop = new BaseColor(System.Drawing.Color.LightGray),
            hlpCel.HorizontalAlignment = Element.ALIGN_LEFT;
            infotable.AddCell(hlpCel);

            szMsg = string.Format("{0}", szFromAddress2);
            title = new Paragraph(szMsg, times01);
            hlpCel = new PdfPCell(title);
            hlpCel.RunDirection = PdfWriter.RUN_DIRECTION_LTR;
            hlpCel.BorderWidthLeft = 0;
            hlpCel.BorderWidthRight = 0;
            hlpCel.BorderWidthTop = 0;
            hlpCel.BorderWidthBottom = 0;
            hlpCel.PaddingTop = 4;
            hlpCel.PaddingLeft = 0;
            hlpCel.PaddingRight = 0;
            hlpCel.PaddingBottom = 1;
            //BorderColorTop = new BaseColor(System.Drawing.Color.LightGray),
            hlpCel.HorizontalAlignment = Element.ALIGN_LEFT;
            infotable.AddCell(hlpCel);

            szMsg = string.Format("{0}, {1} {2}", szFromCity, szFromState, szFromZip);
            title = new Paragraph(szMsg, times01);
            hlpCel = new PdfPCell(title);
            hlpCel.RunDirection = PdfWriter.RUN_DIRECTION_LTR;
            hlpCel.BorderWidthLeft = 0;
            hlpCel.BorderWidthRight = 0;
            hlpCel.BorderWidthTop = 0;
            hlpCel.BorderWidthBottom = 0;
            hlpCel.PaddingTop = 4;
            hlpCel.PaddingLeft = 0;
            hlpCel.PaddingRight = 0;
            hlpCel.PaddingBottom = 1;
            //BorderColorTop = new BaseColor(System.Drawing.Color.LightGray),
            hlpCel.HorizontalAlignment = Element.ALIGN_LEFT;
            infotable.AddCell(hlpCel);

            szMsg = string.Format("Ship to:");
            title = new Paragraph(szMsg, times03);
            hlpCel = new PdfPCell(title);
            hlpCel.RunDirection = PdfWriter.RUN_DIRECTION_LTR;
            hlpCel.BorderWidthLeft = 0;
            hlpCel.BorderWidthRight = 0;
            hlpCel.BorderWidthTop = 0;
            hlpCel.BorderWidthBottom = 0;
            hlpCel.PaddingTop = 20;
            hlpCel.PaddingLeft = 0;
            hlpCel.PaddingRight = 0;
            hlpCel.PaddingBottom = 1;
            //BorderColorTop = new BaseColor(System.Drawing.Color.LightGray),
            hlpCel.HorizontalAlignment = Element.ALIGN_LEFT;
            infotable.AddCell(hlpCel);

            szMsg = string.Format("{0}", szToCompany);
            title = new Paragraph(szMsg, times01);
            hlpCel = new PdfPCell(title);
            hlpCel.RunDirection = PdfWriter.RUN_DIRECTION_LTR;
            hlpCel.BorderWidthLeft = 0;
            hlpCel.BorderWidthRight = 0;
            hlpCel.BorderWidthTop = 0;
            hlpCel.BorderWidthBottom = 0;
            hlpCel.PaddingTop = 4;
            hlpCel.PaddingLeft = 0;
            hlpCel.PaddingRight = 0;
            hlpCel.PaddingBottom = 1;
            //BorderColorTop = new BaseColor(System.Drawing.Color.LightGray),
            hlpCel.HorizontalAlignment = Element.ALIGN_LEFT;
            infotable.AddCell(hlpCel);

            szMsg = string.Format("{0}", szToName);
            title = new Paragraph(szMsg, times01);
            hlpCel = new PdfPCell(title);
            hlpCel.RunDirection = PdfWriter.RUN_DIRECTION_LTR;
            hlpCel.BorderWidthLeft = 0;
            hlpCel.BorderWidthRight = 0;
            hlpCel.BorderWidthTop = 0;
            hlpCel.BorderWidthBottom = 0;
            hlpCel.PaddingTop = 4;
            hlpCel.PaddingLeft = 0;
            hlpCel.PaddingRight = 0;
            hlpCel.PaddingBottom = 1;
            //BorderColorTop = new BaseColor(System.Drawing.Color.LightGray),
            hlpCel.HorizontalAlignment = Element.ALIGN_LEFT;
            infotable.AddCell(hlpCel);

            szMsg = string.Format("{0}", szToAddress1);
            title = new Paragraph(szMsg, times01);
            hlpCel = new PdfPCell(title);
            hlpCel.RunDirection = PdfWriter.RUN_DIRECTION_LTR;
            hlpCel.BorderWidthLeft = 0;
            hlpCel.BorderWidthRight = 0;
            hlpCel.BorderWidthTop = 0;
            hlpCel.BorderWidthBottom = 0;
            hlpCel.PaddingTop = 4;
            hlpCel.PaddingLeft = 0;
            hlpCel.PaddingRight = 0;
            hlpCel.PaddingBottom = 1;
            //BorderColorTop = new BaseColor(System.Drawing.Color.LightGray),
            hlpCel.HorizontalAlignment = Element.ALIGN_LEFT;
            infotable.AddCell(hlpCel);

            szMsg = string.Format("{0}", szToAddress2);
            title = new Paragraph(szMsg, times01);
            hlpCel = new PdfPCell(title);
            hlpCel.RunDirection = PdfWriter.RUN_DIRECTION_LTR;
            hlpCel.BorderWidthLeft = 0;
            hlpCel.BorderWidthRight = 0;
            hlpCel.BorderWidthTop = 0;
            hlpCel.BorderWidthBottom = 0;
            hlpCel.PaddingTop = 4;
            hlpCel.PaddingLeft = 0;
            hlpCel.PaddingRight = 0;
            hlpCel.PaddingBottom = 1;
            //BorderColorTop = new BaseColor(System.Drawing.Color.LightGray),
            hlpCel.HorizontalAlignment = Element.ALIGN_LEFT;
            infotable.AddCell(hlpCel);

            szMsg = string.Format("{0}, {1} {2}", szToCity, szToState, szToZip);
            title = new Paragraph(szMsg, times01);
            hlpCel = new PdfPCell(title);
            hlpCel.RunDirection = PdfWriter.RUN_DIRECTION_LTR;
            hlpCel.BorderWidthLeft = 0;
            hlpCel.BorderWidthRight = 0;
            hlpCel.BorderWidthTop = 0;
            hlpCel.BorderWidthBottom = 0;
            hlpCel.PaddingTop = 4;
            hlpCel.PaddingLeft = 0;
            hlpCel.PaddingRight = 0;
            hlpCel.PaddingBottom = 1;
            //BorderColorTop = new BaseColor(System.Drawing.Color.LightGray),
            hlpCel.HorizontalAlignment = Element.ALIGN_LEFT;
            infotable.AddCell(hlpCel);

            return infotable;
        }