コード例 #1
0
        protected void DdlCategoryID_SelectedIndexChanged(object sender, EventArgs e)
        {
            DropDownList ddl = (DropDownList)sender;
            GridViewRow  row = (GridViewRow)ddl.NamingContainer;

            ddl = row.FindControl("DdlCategoryID") as DropDownList;
            Label  LblCatalogueNameAuto = row.FindControl("LblCatalogueNameAuto") as Label;
            string CategoryID           = Convert.ToString(ddl.SelectedItem);

            if (LblCatalogueNameAuto != null)
            {
                LblCatalogueNameAuto.Text = InventoryLogic.GetCatalogueName(CategoryID);
            }
        }
コード例 #2
0
        protected void BindControl(string itemID)
        {
            List <SupplierList> sList = PurchasingLogic.ListSuppliers();

            DdlSupplier1.DataSource = sList;
            DdlSupplier1.DataBind();
            DdlSupplier1.Items.Insert(0, new ListItem(String.Empty, String.Empty));
            DdlSupplier1.SelectedValue = InventoryLogic.GetFirstPrioritySupplierByItemID(itemID);
            DdlSupplier2.DataSource    = sList;
            DdlSupplier2.DataBind();
            DdlSupplier2.Items.Insert(0, new ListItem(String.Empty, String.Empty));
            if (InventoryLogic.GetSecondPrioritySupplierByItemID(itemID) != null)
            {
                DdlSupplier2.SelectedValue = InventoryLogic.GetSecondPrioritySupplierByItemID(itemID);
            }
            else
            {
                DdlSupplier2.SelectedIndex = 0;
            }
            DdlSupplier3.DataSource = sList;
            DdlSupplier3.DataBind();
            DdlSupplier3.Items.Insert(0, new ListItem(String.Empty, String.Empty));
            if (InventoryLogic.GetThirdPrioritySupplierByItemID(itemID) != null)
            {
                DdlSupplier3.SelectedValue = InventoryLogic.GetThirdPrioritySupplierByItemID(itemID);
            }
            else
            {
                DdlSupplier3.SelectedIndex = 0;
            }
            TxtPriceS1.Text         = InventoryLogic.GetFirstPrioritySupplierPriceByItemID(itemID);
            TxtPriceS2.Text         = InventoryLogic.GetSecondPrioritySupplierPriceByItemID(itemID);
            TxtPriceS3.Text         = InventoryLogic.GetThirdPrioritySupplierPriceByItemID(itemID);
            TxtItemID.Text          = itemID;
            TxtItemID.ReadOnly      = true;
            TxtDescription.Text     = InventoryLogic.GetItemDescription(itemID);
            TxtDescription.ReadOnly = true;
            TxtCategory.Text        = InventoryLogic.GetCatalogueName(InventoryLogic.GetInventoryItem(itemID).CategoryID);
            TxtCategory.ReadOnly    = true;
        }
コード例 #3
0
        protected void GridViewCatalogue_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                InventoryCatalogue catalogue = (InventoryCatalogue)e.Row.DataItem;
                string             ItemID    = catalogue.ItemID;

                Label lblCatName = e.Row.FindControl("LblCatalogueName") as Label;
                if (lblCatName != null)
                {
                    lblCatName.Text = InventoryLogic.GetCatalogueName(catalogue.CategoryID);
                }

                DropDownList ddl = e.Row.FindControl("DdlCategoryID") as DropDownList;
                if (ddl != null)
                {
                    ddl.DataSource     = InventoryLogic.CategoryID();
                    ddl.DataTextField  = "CategoryID";
                    ddl.DataValueField = "CategoryID";
                    ddl.DataBind();
                }
            }
        }
コード例 #4
0
        // This will retrieve all the necessary values and use it to generate our report
        protected void BtnGenerate_Click(object sender, EventArgs e)
        {
            // Resets all controls to default first
            LblHeader.Visible   = false;
            LblErrorMsg.Text    = "";
            LblErrorMsg.Visible = false;

            // Declare our attr to perform our validation
            bool anyErrors = false;

            // Retrieve Item id
            string itemID = LblItemID.Text;

            // Retrieve both of our dates
            string   temp1    = DateFrom.Value;
            DateTime dateFrom = DateTime.ParseExact(temp1, "yyyy-MM-dd", System.Globalization.CultureInfo.InvariantCulture);

            string   temp2  = DateTo.Value;
            DateTime dateTo = DateTime.ParseExact(temp2, "yyyy-MM-dd", System.Globalization.CultureInfo.InvariantCulture);


            // Gotta perform our server-side validation here...
            // Ensure that dateFrom is before dateTo
            if (dateTo < dateFrom)
            {
                LblErrorMsg.Visible = true;
                LblErrorMsg.Text    = "Error. Ensure that the date selected is in the right order.";
                anyErrors           = true;
            }
            //Ensure that dateFrom cannot be below Jan 1st 2014 cos no data for it
            if (dateFrom.Year < 2014 && !anyErrors)
            {
                LblErrorMsg.Visible = true;
                LblErrorMsg.Text    = "Error. No data found before 2014.";
                anyErrors           = true;
            }
            // Ensure that dateTo cannot be beyond the latest date in the actual data table
            bool check = ReportLogic.CheckIfBeyondLatestData(dateTo);

            if (!check && !anyErrors)
            {
                LblErrorMsg.Visible = true;
                LblErrorMsg.Text    = "Error. No data beyond the selected date.";
                anyErrors           = true;
            }
            // Ensure that its 6 months apart
            DateTime tempDate = dateFrom.AddMonths(6);

            if (tempDate > dateTo && !anyErrors)
            {
                LblErrorMsg.Visible = true;
                LblErrorMsg.Text    = "Error. Period selected must be at least 6 months apart.";
                anyErrors           = true;
            }


            // If no errors, run our main logic
            if (!String.IsNullOrWhiteSpace(itemID) && !anyErrors)
            {
                // Retrieve our number of periods
                int numPeriods = Convert.ToInt32(DdlNoForeacast.SelectedItem.Value);

                // Retrieve our type of chart to generate
                int typeOfChart = Convert.ToInt32(DdlTypeChart.SelectedItem.Value);

                // Pass our value to the method in the biz logic side
                ReportLogic.GetChart(itemID, dateFrom, dateTo, numPeriods, typeOfChart);


                // Populating our Images
                ImgChart.Visible          = true;
                ImgChart.ImageUrl         = "~/images/Charts/chart1.png" + "?time=" + DateTime.Now.ToString();
                ImgTableResult.Visible    = true;
                ImgTableResult.ImageUrl   = "~/images/Charts/tableResults.png" + "?time=" + DateTime.Now.ToString();
                ImgTableAccuracy.Visible  = true;
                ImgTableAccuracy.ImageUrl = "~/images/Charts/tableAccuracy.png" + "?time=" + DateTime.Now.ToString();
                ImgTableModel.Visible     = true;
                ImgTableModel.ImageUrl    = "~/images/Charts/tableModel.png" + "?time=" + DateTime.Now.ToString();


                // Populating misc controls
                LblHeader.Visible         = true;
                LblChartHeader.Visible    = true;
                LblExpectedDemand.Visible = true;
                var item = InventoryLogic.FindItemByItemID(itemID);
                LblCode.Visible            = true;
                LblItemCode.Visible        = true;
                LblItemCode.Text           = item.ItemID;
                LblDescription.Visible     = true;
                LblItemDescription.Visible = true;
                LblItemDescription.Text    = item.Description;
                LblCategory.Visible        = true;
                LblItemCategory.Visible    = true;
                LblItemCategory.Text       = InventoryLogic.GetCatalogueName(item.CategoryID);
                BtnPrint.Visible           = true;
                LblAccuracy.Visible        = true;
                LblModel.Visible           = true;
            }

            // Updating the UpdatePanel
            UpdatePanelChart.Update();
        }