예제 #1
0
    protected void CreateNewRetrievalButton_Click(object sender, EventArgs e)
    {
        // Create a new Retrieval
        int newRetrievalFormNumber = RetrievalFormController.CreateNewRetrieval();

        displayRetreivalForm(newRetrievalFormNumber);
        updateDropDownList();
    }
예제 #2
0
    protected void ActualTextBoxValidator_ServerValidate(object source, ServerValidateEventArgs args)
    {
        String          departmentCode;
        String          itemNo;
        int             value;
        bool            result = false;
        int             sum;
        CustomValidator customValidator = (CustomValidator)source;
        int             i          = customValidator.Controls.Count - 2;
        String          infoString = customValidator.ErrorMessage;

        if (int.TryParse(args.Value, out value))
        {
            departmentCode = customValidator.ToolTip;
            itemNo         = customValidator.ErrorMessage;

            // Get the Big row that this field belongs to
            foreach (RepeaterItem item in BigRepeater.Items)
            {
                HiddenField bigItemNoHiddenField = (HiddenField)item.FindControl("BigItemNoHiddenField");
                if (bigItemNoHiddenField.Value.Equals(itemNo))
                {
                    // Find the current sum of items retrieved
                    sum = 0;
                    Repeater SmallRepeater = (Repeater)item.FindControl("SmallRepeater");
                    foreach (RepeaterItem smallItem in SmallRepeater.Items)
                    {
                        TextBox inputTextBox = (TextBox)smallItem.FindControl("ActualTextBox");
                        if (int.TryParse(inputTextBox.Text, out value))
                        {
                            sum += value;
                        }
                    }

                    // Check if sum is greater than stock cart value
                    result = RetrievalFormController.IsThereEnoughItemsInStock(sum, itemNo);
                    break;
                }
            }

            // If an invalid sum was found, then display message
            if (!result)
            {
                customValidator.Text = "There are only " + RetrievalFormController.GetQuantityInStock(itemNo) + " in stock";
            }
            else
            {
                customValidator.Text = "";
            }
        }

        customValidator.ErrorMessage = infoString;
        args.IsValid = result;
    }
예제 #3
0
    private void updateDropDownList()
    {
        // Set the dropdown list
        SelectRetrevialDropDownList.DataTextField  = "Text";
        SelectRetrevialDropDownList.DataValueField = "Value";
        var items = RetrievalFormController
                    .GetAllRetrievals()
                    .Select(ret =>
                            new
        {
            Text  = "#" + ret.RetrievalNo + " (" + String.Format("{0:dd/MMM/yyyy}", ret.Date) + ")",
            Value = ret.RetrievalNo
        }).ToList();

        items.Insert(0, new
        {
            Text  = "Select Retrieval",
            Value = -1
        });
        SelectRetrevialDropDownList.DataSource = items;
        SelectRetrevialDropDownList.DataBind();
    }
예제 #4
0
    private void displayRetreivalForm(int retrievalNo)
    {
        // Set Session Value
        Session["RetrievalNo"] = retrievalNo;

        // Set Editable
        Session["Editable"] = RetrievalFormController.IsRetrievalFormEditable(retrievalNo);

        // Get Retreival Details
        var retreivalDetails = RetrievalFormController.GetRetrievalDetailsOf(retrievalNo);

        data.Clear();
        // Create the Big and Small Row Objects to display
        {
            // Get the list of items
            var items = retreivalDetails.Select(retDet => retDet.StationeryCatalogue).Distinct().ToList();

            // To track CSS
            bool isAlternate = false;

            // For each item, create the big row and populate the values using retreival details
            foreach (var item in items)
            {
                BigRow temp = new BigRow()
                {
                    Bin             = item.Bin,
                    ItemCode        = item.ItemNo,
                    Description     = item.Description,
                    Needed          = 0,
                    Backlog         = 0,
                    Reterived       = 0,
                    Maximum         = item.CurrentQty ?? 0,
                    Breakdown       = new List <SmallRow>(),
                    DepartmentCount = 0,
                    CssClass        = isAlternate ? "active" : "default",
                };

                var itemSpecificDetails = retreivalDetails.Where(retDet => retDet.ItemNo.Equals(item.ItemNo)).ToList();
                foreach (var detail in itemSpecificDetails)
                {
                    SmallRow smallTemp = new SmallRow()
                    {
                        Department = detail.DeptCode,
                        Needed     = detail.Needed ?? 0,
                        Backlog    = detail.BackLogQty ?? 0,
                        Actual     = detail.Actual ?? 0,
                        CssClass   = isAlternate ? "active" : "default",
                        ItemNo     = item.ItemNo
                    };

                    temp.Needed  += smallTemp.Needed;
                    temp.Backlog += smallTemp.Backlog;
                    temp.Breakdown.Add(smallTemp);
                }

                isAlternate          = !isAlternate; // Toggle CSS
                temp.DepartmentCount = temp.Breakdown.Count;
                data.Add(temp);
            }
        }

        // Display the Data
        BigRepeater.DataSource = data;
        BigRepeater.DataBind();

        // Save the Data
        Session["DisplayedData"] = data;
    }