Пример #1
0
    public string Delete(string UserName, string DeliveryRecurrenceDetailID, string MealCount, string DeliveryDay, string ServingDay, string DeliveryRecurrenceDetailLastModifiedDate)
    {
        m_SQL = "DECLARE @NewDeliveryRecurrenceID int EXECUTE spDeliveryRecurrenceDetail '" + UserName + "', " + DeliveryRecurrenceDetailID + ", " + MealCount + ", '" + DeliveryDay + "', '" + ServingDay + "', '" + DeliveryRecurrenceDetailLastModifiedDate + "', @NewDeliveryRecurrenceID = @NewDeliveryRecurrenceID OUTPUT SELECT @NewDeliveryRecurrenceID as 'DeliveryRecurrenceID'";
        DataSet m_DeliveryRecurrenceDetailsDataSet = GCFDGlobals.m_GCFDPlannerDatabaseLibrary.dbSelectDataSet(m_SQL);

        return(GCFDGlobals.dbGetValue(m_DeliveryRecurrenceDetailsDataSet.Tables[0].Rows[0], "DeliveryRecurrenceID"));
    }
Пример #2
0
    private string[] GetDeliverySiteListFromDb()
    {
        DateTime dailyCountSelectedDate = Convert.ToDateTime(DeliveryWeekTextBox.Text);

        while (dailyCountSelectedDate.DayOfWeek.ToString() != "Monday")
        {
            dailyCountSelectedDate = dailyCountSelectedDate.AddDays(-1);
        }

        m_SQL = "SELECT DISTINCT SiteName FROM vwDelivery WHERE DeliveryDate <> '01/01/1900' AND ServingDate BETWEEN '" + dailyCountSelectedDate +
                "' AND '" + dailyCountSelectedDate.AddDays(6) + "' AND MealTypeID = " + DeliveryTypeDropDownList.SelectedItem.Value + " AND DeliveryTypeName <> 'Cancelled'";
        DataSet servingDateDataSet = GCFDGlobals.m_GCFDPlannerDatabaseLibrary.dbSelectDataSet(m_SQL);

        string[] ret = new string[servingDateDataSet.Tables[0].Rows.Count];

        int i = 0;

        foreach (DataRow SiteDataRow in servingDateDataSet.Tables[0].Rows)
        {
            ret[i] = GCFDGlobals.dbGetValue(SiteDataRow, "SiteName");

            i++;
        }

        return(ret);
    }
    protected void RetrieveMealTypeValues(string mealTypeID)
    {
        m_SQL = "SELECT * FROM MealTypeDict WHERE MealTypeID = " + mealTypeID;
        DataSet m_MealTypeDataSet = GCFDGlobals.m_GCFDPlannerDatabaseLibrary.dbSelectDataSet(m_SQL);

        servingDayInternal        = GCFDGlobals.dbGetValue(m_MealTypeDataSet.Tables[0].Rows[0], "ServingDayInterval");
        hasWeekendActivity        = GCFDGlobals.dbGetValue(m_MealTypeDataSet.Tables[0].Rows[0], "HasWeekendActivity");
        prohibitPastModifications = GCFDGlobals.dbGetValue(m_MealTypeDataSet.Tables[0].Rows[0], "ProhibitPastModifications");
        futureActivityInterval    = Convert.ToInt16(GCFDGlobals.dbGetValue(m_MealTypeDataSet.Tables[0].Rows[0], "FutureActivityInterval"));

        if (hasWeekendActivity == "0")
        {
            if (DateTime.Now.DayOfWeek.ToString() == "Friday")
            {
                permittedStartDate = DateTime.Now.AddDays(2 + futureActivityInterval);
            }
            else
            {
                permittedStartDate = DateTime.Now.AddDays(futureActivityInterval);
            }
        }
        else
        {
            permittedStartDate = DateTime.Now.AddDays(futureActivityInterval);
        }
    }
    protected void SaveCookChillYieldDetail_Click(object sender, EventArgs e)
    {
        string conversion     = "";
        string recipeTypeName = YieldDetailRecipeTypeNameHiddenField.Value;

        if (ConversionFactorTextBox.Text == "N/A")
        {
            conversion = "0.00";
        }
        else
        {
            conversion = ConversionFactorTextBox.Text;
        }

        this.dropDownList = this.Master.FindControl("MainContent").FindControl(recipeTypeName + "DropDownList") as DropDownList;

        m_SQL = "DECLARE @NewRecipeDetailID int EXEC spUpdateMealCookChillRecipeYield " + MealIDHiddenTextBox.Value + ", " + ServingSizeTypeIDHiddenField.Value + ", " + this.dropDownList.SelectedItem.Value + ", " + YieldDetailRecipeDetailIDHiddenField.Value + ", " + PackageTypeIDHiddenField.Value + ", " + VolumeServingSizeDropDownList.SelectedItem.Value + ", " + CookChillWeightDropDownList.SelectedItem.Value + ", " + CookChillConversionFactorTextBox.Text + ", " + ServingsPerPackageTextBox.Text + ", " + ServingsPerBatchTextBox.Text + ", " + BatchYieldInPoundsTextBox.Text + ", '" + NotesTextBox.Text + "', @NewRecipeDetailID = @NewRecipeDetailID OUTPUT SELECT @NewRecipeDetailID AS 'NewRecipeDetailID'";
        DataSet regularYieldDataSet = GCFDGlobals.m_GCFDPlannerDatabaseLibrary.dbSelectDataSet(m_SQL);

        this.hiddenField = this.Master.FindControl("MainContent").FindControl(recipeTypeName + "RecipeDetailIDHiddenField") as HiddenField;

        this.hiddenField.Value = GCFDGlobals.dbGetValue(regularYieldDataSet.Tables[0].Rows[0], "NewRecipeDetailID");

        this.label = this.Master.FindControl("MainContent").FindControl(recipeTypeName + "ServingSizeLabel") as Label;

        this.label.Text = VolumeServingSizeDropDownList.SelectedItem.Value;

        this.label = this.Master.FindControl("MainContent").FindControl(recipeTypeName + "ServingSizeTypeLabel") as Label;

        this.label.Text = CookChillServingSizeTypeLabel.Text;

        GetCalendarData();

        ClientScript.RegisterStartupScript(GetType(), "key", "launchMealDetailModal();", true);
    }
    public void DayDetailsGridView_SelectedIndexChanged(object sender, System.EventArgs e)
    {
        Session["DeliveryCalendarMode"] = "";
        Session["DeliveryEventMode"]    = "";

        m_SQL = "SELECT * FROM vwDelivery WHERE DeliveryID = " + DayDetailsGridView.SelectedRow.Cells[0].Text;
        DataSet deliveryException = GCFDGlobals.m_GCFDPlannerDatabaseLibrary.dbSelectDataSet(m_SQL);

        foreach (DataRow deliveryExceptionData in deliveryException.Tables[0].Rows)
        {
            if (!String.IsNullOrEmpty(GCFDGlobals.dbGetValue(deliveryExceptionData, "GroupCancellationID")))
            {
                DeliveryEventIDHiddenTextBox.Value = GCFDGlobals.dbGetValue(deliveryExceptionData, "GroupCancellationID");

                UpdateGroupExceptions(GCFDGlobals.dbGetValue(deliveryExceptionData, "GroupCancellationID"));

                GetCalendarData();
            }
            else
            {
                Session["SiteID"] = GCFDGlobals.dbGetValue(deliveryExceptionData, "SiteID");

                Session["SiteMode"] = "Update";

                Response.Redirect("SiteDetails.aspx", false);

                GetCalendarData();
            }
        }
    }
    protected void AddGroupExceptions()
    {
        string mealType = MealDeliveryTypeDropDownList.SelectedItem.Value;
        string servingDate;
        string listLine;
        string deliveryDate;
        string scheduleType = "";

        if (CACFPCheckbox.Checked)
        {
            scheduleType = "2";
        }

        if (SFSPCheckbox.Checked)
        {
            if (String.IsNullOrEmpty(scheduleType) == true)
            {
                scheduleType = "1";
            }
            else
            {
                scheduleType = scheduleType + ",1";
            }
        }

        if (NACheckbox.Checked)
        {
            if (String.IsNullOrEmpty(scheduleType) == true)
            {
                scheduleType = "3";
            }
            else
            {
                scheduleType = scheduleType + ",3";
            }
        }

        string scheduleTypeName;

        MealDeliveryTypeHiddenTextBox.Value = MealDeliveryTypeDropDownList.SelectedItem.Value;

        m_SQL = "SELECT * FROM vwDelivery WHERE DeliveryDate BETWEEN '" + CancellationRangeStartDateTextBox.Text + "' AND '" + CancellationRangeEndDateTextBox.Text + "' AND DeliveryTypeName NOT IN('Cancelled', 'Rescheduled') AND MealTypeID = " + mealType + " AND ScheduleTypeID IN(" + scheduleType + ")";
        m_DeliveriesDataSet = GCFDGlobals.m_GCFDPlannerDatabaseLibrary.dbSelectDataSet(m_SQL);

        RemovedDeliverySiteList.Items.Clear();
        AddedDeliverySiteList.Items.Clear();

        foreach (DataRow deliveryDataRow in m_DeliveriesDataSet.Tables[0].Rows)
        {
            servingDate      = Convert.ToDateTime(GCFDGlobals.dbGetValue(deliveryDataRow, "ServingDate")).ToString("MM/dd/yyyy");
            deliveryDate     = Convert.ToDateTime(GCFDGlobals.dbGetValue(deliveryDataRow, "DeliveryDate")).ToString("MM/dd/yyyy");
            scheduleTypeName = GCFDGlobals.dbGetValue(deliveryDataRow, "ScheduleTypeName");

            listLine = GCFDGlobals.dbGetValue(deliveryDataRow, "SiteName") + " (" + deliveryDate + " Delivery Date|" + servingDate + " Serving Date|" + scheduleTypeName + ")";

            AddedDeliverySiteList.Items.Add(new ListItem(listLine, GCFDGlobals.dbGetValue(deliveryDataRow, "DeliveryID")));
        }
    }
    protected void SaveMealDetailButton_Click(object sender, EventArgs e)
    {
        string        mealID;
        StringBuilder builder = new StringBuilder();

        if (!String.IsNullOrEmpty(MealIDHiddenTextBox.Value))
        {
            m_SQL = "DELETE FROM Meal WHERE MealID = " + MealIDHiddenTextBox.Value;
            GCFDGlobals.m_GCFDPlannerDatabaseLibrary.dbExecuteSQLCmd(m_SQL);

            m_SQL = "DELETE FROM MealDetail WHERE MealID = " + MealIDHiddenTextBox.Value;
            GCFDGlobals.m_GCFDPlannerDatabaseLibrary.dbExecuteSQLCmd(m_SQL);

            m_SQL = "DELETE FROM MealDelivery WHERE MealID = " + MealIDHiddenTextBox.Value;
            GCFDGlobals.m_GCFDPlannerDatabaseLibrary.dbExecuteSQLCmd(m_SQL);
        }

        m_SQL = "INSERT INTO Meal(Notes) VALUES('" + NotesTextBox.Text + "')";
        GCFDGlobals.m_GCFDPlannerDatabaseLibrary.dbExecuteSQLCmd(m_SQL);

        m_SQL = "SELECT IDENT_CURRENT('Meal') AS 'MealID'";
        DataSet mealIDDataSet = GCFDGlobals.m_GCFDPlannerDatabaseLibrary.dbSelectDataSet(m_SQL);

        mealID = GCFDGlobals.dbGetValue(mealIDDataSet.Tables[0].Rows[0], "MealID");

        m_SQL = "INSERT INTO MealDetail (MealID, RecipeDetailID) VALUES(" + mealID + ", " + VegetableRecipeDetailIDHiddenField.Value + ")";
        GCFDGlobals.m_GCFDPlannerDatabaseLibrary.dbExecuteSQLCmd(m_SQL);

        m_SQL = "INSERT INTO MealDetail (MealID, RecipeDetailID) VALUES(" + mealID + ", " + BreadRecipeDetailIDHiddenField.Value + ")";
        GCFDGlobals.m_GCFDPlannerDatabaseLibrary.dbExecuteSQLCmd(m_SQL);

        m_SQL = "INSERT INTO MealDetail (MealID, RecipeDetailID) VALUES(" + mealID + ", " + Other1RecipeDetailIDHiddenField.Value + ")";
        GCFDGlobals.m_GCFDPlannerDatabaseLibrary.dbExecuteSQLCmd(m_SQL);

        m_SQL = "INSERT INTO MealDetail (MealID, RecipeDetailID) VALUES(" + mealID + ", " + Other2RecipeDetailIDHiddenField.Value + ")";
        GCFDGlobals.m_GCFDPlannerDatabaseLibrary.dbExecuteSQLCmd(m_SQL);

        m_SQL = "INSERT INTO MealDetail (MealID, RecipeDetailID) VALUES(" + mealID + ", " + Other3RecipeDetailIDHiddenField.Value + ")";
        GCFDGlobals.m_GCFDPlannerDatabaseLibrary.dbExecuteSQLCmd(m_SQL);

        m_SQL = "INSERT INTO MealDetail (MealID, RecipeDetailID) VALUES(" + mealID + ", (SELECT rd.RecipeDetailID FROM RecipeDetail rd, Recipe r WHERE r.RecipeName = 'Milk' AND r.RecipeID = rd.RecipeID))";
        GCFDGlobals.m_GCFDPlannerDatabaseLibrary.dbExecuteSQLCmd(m_SQL);

        for (int i = 0; i < lstSelect.Items.Count; i++)
        {
            m_SQL = "INSERT INTO MealDelivery (MealID, DeliveryID) VALUES(" + mealID + ", " + lstSelect.Items[i].Value + ")";
            GCFDGlobals.m_GCFDPlannerDatabaseLibrary.dbExecuteSQLCmd(m_SQL);
        }

        MealIDHiddenTextBox.Value = "";
        VegetableRecipeDetailIDHiddenField.Value = "";
        BreadRecipeDetailIDHiddenField.Value     = "";
        Other1RecipeDetailIDHiddenField.Value    = "";
        Other2RecipeDetailIDHiddenField.Value    = "";
        Other3RecipeDetailIDHiddenField.Value    = "";

        GetCalendarData();
    }
Пример #8
0
    public void BuildDropDownLists()
    {
        NonFoodItemIDHiddenField.Value   = Request.QueryString.Get("NonFoodItemID");
        NonFoodItemModeHiddenField.Value = Request.QueryString.Get("NonFoodItemMode");

        if (NonFoodItemModeHiddenField.Value == "Update")
        {
            m_SQL = "SELECT ItemName, PurchaseUnit, Vendor, CONVERT(varchar, CONVERT(money, LastInvoicedCost), 1) AS LastInvoicedCost, PiecesPerPurchaseUnit, CONVERT(varchar, CONVERT(money, CostPerPiece), 1) AS CostPerPiece, SubCategory, Par, DateLastUpdated, Notes FROM NonFoodItem WHERE NonFoodItemID = " + NonFoodItemIDHiddenField.Value;
            DataSet nonFoodItemDataSet = GCFDGlobals.m_GCFDPlannerDatabaseLibrary.dbSelectDataSet(m_SQL);

            foreach (DataRow nonFoodItemData in nonFoodItemDataSet.Tables[0].Rows)
            {
                ItemNameTextBox.Text = GCFDGlobals.dbGetValue(nonFoodItemData, "ItemName");

                OriginalNonFoodItemNameHiddenField.Value = GCFDGlobals.dbGetValue(nonFoodItemData, "ItemName");

                UnitDropDownList.SelectedIndex =
                    UnitDropDownList.Items.IndexOf(
                        UnitDropDownList.Items.FindByText(GCFDGlobals.dbGetValue(nonFoodItemData,
                                                                                 "PurchaseUnit")));
                VendorDropDownList.SelectedIndex =
                    VendorDropDownList.Items.IndexOf(
                        VendorDropDownList.Items.FindByText(GCFDGlobals.dbGetValue(nonFoodItemData,
                                                                                   "Vendor")));
                SubCategoryListBox.SelectedIndex =
                    SubCategoryListBox.Items.IndexOf(
                        SubCategoryListBox.Items.FindByText(GCFDGlobals.dbGetValue(nonFoodItemData,
                                                                                   "SubCategory")));
                ParTextBox.Text                      = GCFDGlobals.dbGetValue(nonFoodItemData, "Par");
                InvoicedCostTextBox.Text             = GCFDGlobals.dbGetValue(nonFoodItemData, "LastInvoicedCost");
                PiecesPerPurchasedUnitTextBox.Text   = GCFDGlobals.dbGetValue(nonFoodItemData, "PiecesPerPurchaseUnit");
                CostPerPurchaseUnitLabel.Text        = GCFDGlobals.dbGetValue(nonFoodItemData, "CostPerPiece");
                CostPerPurchaseUnitHiddenField.Value = GCFDGlobals.dbGetValue(nonFoodItemData, "CostPerPiece");

                NotesTextBox.Text         = GCFDGlobals.dbGetValue(nonFoodItemData, "Notes");
                DateLastUpdatedLabel.Text = GCFDGlobals.dbGetValue(nonFoodItemData, "DateLastUpdated");

                PiecesPerPurchasedUnitTextBox.Text = GCFDGlobals.dbGetValue(nonFoodItemData, "PurchaseUnit");
            }

            SaveAsNewButton.Enabled = true;

            DeleteItemButton.Enabled = true;
            DeleteItemButton.Attributes.Add("onclick", "return confirm('Are you sure you want to PERMANENTLY DELETE the " + OriginalNonFoodItemNameHiddenField.Value + " non-food inventory item?')");
        }
        else
        {
            SaveAsNewButton.Visible = false;
        }

        if (NonFoodItemModeHiddenField.Value == "New")
        {
            SaveAsNewButton.Enabled = false;

            DeleteItemButton.Enabled = false;
        }
    }
Пример #9
0
    public void BuildDropDownLists()
    {
        MealDeliveryTypeIDHiddenField.Value   = Request.QueryString.Get("MealDeliveryTypeID");
        MealDeliveryTypeModeHiddenField.Value = Request.QueryString.Get("MealDeliveryTypeMode");

        if (MealDeliveryTypeModeHiddenField.Value == "Update")
        {
            m_SQL = "SELECT * FROM MealTypeDict WHERE MealTypeID = " + Request.QueryString.Get("MealDeliveryTypeID");
            DataSet mealDeliveryTypeDataSet = GCFDGlobals.m_GCFDPlannerDatabaseLibrary.dbSelectDataSet(m_SQL);

            foreach (DataRow mealDeliveryTypeData in mealDeliveryTypeDataSet.Tables[0].Rows)
            {
                MealDeliveryTypeNameTextBox.Text = GCFDGlobals.dbGetValue(mealDeliveryTypeData, "MealTypeName");

                OriginalMealDeliveryTypeNameHiddenField.Value = GCFDGlobals.dbGetValue(mealDeliveryTypeData, "MealTypeName");

                ServingDayIntervalDropDownList.SelectedIndex = ServingDayIntervalDropDownList.Items.IndexOf(ServingDayIntervalDropDownList.Items.FindByValue(GCFDGlobals.dbGetValue(mealDeliveryTypeData, "ServingDayInterval")));

                if (GCFDGlobals.dbGetValue(mealDeliveryTypeData, "HasWeekendActivity") == "1")
                {
                    WeekendActivityCheckBox.Checked = true;
                }

                if (GCFDGlobals.dbGetValue(mealDeliveryTypeData, "ProhibitPastModifications") == "1")
                {
                    ProhibitPastActivityCheckBox.Checked = true;
                }

                FutureIntervalTextBox.Text = GCFDGlobals.dbGetValue(mealDeliveryTypeData, "FutureActivityInterval");

                if (ProhibitPastActivityCheckBox.Checked)
                {
                    FutureIntervalTextBox.Enabled = true;

                    FutureActivityIntervalLabel.Enabled = true;

                    FutureActivityIntervalLabel.ForeColor = System.Drawing.Color.White;
                }
            }

            SaveAsNewButton.Visible = true;

            DeleteMealDeliveryTypeButton.Enabled = true;
            DeleteMealDeliveryTypeButton.Attributes.Add("onclick", "return confirm('Are you sure you want to PERMANENTLY DELETE the " + OriginalMealDeliveryTypeNameHiddenField.Value + " meal type?')");
        }
        else if (Request.QueryString.Get("MealDeliveryTypeMode") == "New")
        {
            SaveAsNewButton.Visible = false;

            DeleteMealDeliveryTypeButton.Enabled = false;
        }
    }
    protected void ViewOther3YieldDetailButton_Click(object sender, EventArgs e)
    {
        m_SQL = "SELECT DISTINCT YieldTypeID FROM RecipeDetail WHERE RecipeDetailID = " + Other3RecipeDetailIDHiddenField.Value;
        DataSet recipeDataSet = GCFDGlobals.m_GCFDPlannerDatabaseLibrary.dbSelectDataSet(m_SQL);

        if (GCFDGlobals.dbGetValue(recipeDataSet.Tables[0].Rows[0], "YieldTypeID") == "1")
        {
            RegularYieldDetail(Other3RecipeDetailIDHiddenField.Value, "Other3");
        }
        else
        {
            CookChillYieldDetail(Other3RecipeDetailIDHiddenField.Value, "Other3");
        }
    }
Пример #11
0
    protected void SaveAsNewButton_Click(object sender, EventArgs e)
    {
        if (Page.IsValid)
        {
            try
            {
                if (CreateItem() == true)
                {
                    int    weekendActivityEnabled = 0;
                    int    prohibitPastActivity   = 0;
                    string servingDayInterval     = ServingDayIntervalDropDownList.SelectedItem.Value;

                    if (WeekendActivityCheckBox.Checked)
                    {
                        weekendActivityEnabled = 1;
                    }

                    if (ProhibitPastActivityCheckBox.Checked)
                    {
                        prohibitPastActivity = 1;
                    }

                    m_SQL = "INSERT INTO MealTypeDict (MealTypeName, ServingDayInterval, HasWeekendActivity, ProhibitPastModifications, FutureActivityInterval, DateCreated) VALUES('" + MealDeliveryTypeNameTextBox.Text + "', " + servingDayInterval + ", " + weekendActivityEnabled + ", " + prohibitPastActivity + ", " + FutureIntervalTextBox.Text + ", GETDATE())";
                    GCFDGlobals.m_GCFDPlannerDatabaseLibrary.dbExecuteSQLCmd(m_SQL);

                    m_SQL = "SELECT SCOPE_IDENTITY() AS MealTypeID";
                    DataSet newMealTypeDataSet = GCFDGlobals.m_GCFDPlannerDatabaseLibrary.dbSelectDataSet(m_SQL);

                    MealDeliveryTypeIDHiddenField.Value = GCFDGlobals.dbGetValue(newMealTypeDataSet.Tables[0].Rows[0], "MealTypeID");

                    OriginalMealDeliveryTypeNameHiddenField.Value = MealDeliveryTypeNameTextBox.Text;

                    m_SQL = "INSERT INTO UserAction (UserName, Action) VALUES('" + User.Identity.Name + "', 'Meal Type Name= " + MealDeliveryTypeNameTextBox.Text + " Has Been Saved With The Following Values;ServingDayInterval=" + servingDayInterval + ", HasWeekendActivity=" + weekendActivityEnabled + ", ProhibitPastModifications = " + prohibitPastActivity + ", FutureActivityInterval = " + FutureIntervalTextBox.Text + "')";
                    GCFDGlobals.m_GCFDPlannerDatabaseLibrary.dbExecuteSQLCmd(m_SQL);

                    MessageBox.Show("The " + MealDeliveryTypeNameTextBox.Text + " Meal Type Has Been Saved");
                }
                else
                {
                    MessageBox.Show("There already is an meal delivery type saved with the same name as the meal delivery type you're attempting to currently save. Change the current meal delivery type's name before attempting to save.");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);

                throw;
            }
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        string createdMeal;
        string reportStartDate = Request.QueryString.Get("ReportStartDate");
        string reportEndDate   = Request.QueryString.Get("ReportEndDate");
        string reportType      = Request.QueryString.Get("ReportType");
        string bagCount        = Request.QueryString.Get("BagCount");
        string sliceCount      = Request.QueryString.Get("SliceCount");
        string loafCount       = Request.QueryString.Get("LoafCount");
        string bunCount        = Request.QueryString.Get("BunCount");

        m_SQL = "DECLARE @CreatedMeal varchar(50) EXEC spInsertWeeklyOrderReportInformation " + sliceCount + ", " + loafCount + ", " + bunCount + ", " + bagCount + ", '" + reportStartDate + "', '" + reportEndDate + "', '" + User.Identity.Name + "', @CreatedMeal = @CreatedMeal OUTPUT SELECT @CreatedMeal as 'CreatedMeal'";
        DataSet dailyCountReportCreation = GCFDGlobals.m_GCFDPlannerDatabaseLibrary.dbSelectDataSet(m_SQL);

        createdMeal = GCFDGlobals.dbGetValue(dailyCountReportCreation.Tables[0].Rows[0], "CreatedMeal");

        if (createdMeal != "-1")
        {
            if (reportType == "Excel")
            {
                ProcessExcelReport report = new ProcessExcelReport();

                report.ReportID  = createdMeal;
                report.StartDate = reportStartDate;
                report.EndDate   = reportEndDate;
                report.Name      = "CACFPWeeklyOrderReport";
                report.Response  = Response;

                report.RenderReport();
            }
            else
            {
                ProcessReport report = new ProcessReport();

                report.ReportID  = createdMeal;
                report.StartDate = reportStartDate;
                report.EndDate   = reportEndDate;
                report.Name      = "CACFPWeeklyOrderReport";
                report.Response  = Response;

                report.RenderReport();
            }
        }
        else
        {
            RegisterClientScriptBlock("",
                                      "<script>{ alert('Error creating CACFP Weekly Order Report.');window.close();}</script>");
        }
    }
Пример #13
0
    protected void SaveAsNewButton_Click(object sender, EventArgs e)
    {
        if (Page.IsValid)
        {
            string lastInvoiceCost = InvoicedCostTextBox.Text;
            string costPerUnit     = CostPerPurchaseUnitHiddenField.Value;

            if (lastInvoiceCost == "")
            {
                lastInvoiceCost = "null";
            }
            if (costPerUnit == "")
            {
                costPerUnit = "null";
            }

            if (CreateItem() == true)
            {
                try
                {
                    m_SQL =
                        "INSERT INTO NonFoodItem (ItemName, PurchaseUnit, Vendor, LastInvoicedCost, PiecesPerPurchaseUnit, CostPerPiece, SubCategory, Par, Notes, Active, DateLastUpdated, DateCreated) VALUES('" +
                        ItemNameTextBox.Text + "', '" + UnitDropDownList.SelectedItem.Value + "', '";
                    m_SQL = m_SQL + VendorDropDownList.SelectedItem.Value + "', " + lastInvoiceCost + ", '" + PiecesPerPurchasedUnitTextBox.Text + "', '" + costPerUnit + "', '" + SubCategoryListBox.SelectedItem.Value + "', " + ParTextBox.Text + ", '" + NotesTextBox.Text + "', 1, GETDATE(), GETDATE())";
                    GCFDGlobals.m_GCFDPlannerDatabaseLibrary.dbExecuteSQLCmd(m_SQL);

                    m_SQL = "SELECT SCOPE_IDENTITY() AS IngredientID";
                    DataSet newIngredientIDDataSet = GCFDGlobals.m_GCFDPlannerDatabaseLibrary.dbSelectDataSet(m_SQL);

                    NonFoodItemIDHiddenField.Value = GCFDGlobals.dbGetValue(newIngredientIDDataSet.Tables[0].Rows[0], "IngredientID");

                    OriginalNonFoodItemNameHiddenField.Value = ItemNameTextBox.Text;

                    MessageBox.Show("The " + ItemNameTextBox.Text + " Non-food Item Has Been Saved.");
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);

                    throw;
                }
            }
            else
            {
                MessageBox.Show("There already is an non-food item within the system with the same name as the non-food item you're attempting to currently save. Change the current non-food item's name before attempting to save.");
            }
        }
    }
    protected void CategoryDropDownList_SelectedIndexChanged(object sender, EventArgs e)
    {
        SubCategoryListBox.Items.Clear();

        m_SQL = "SELECT * FROM vwCategory WHERE CategoryName = '" + CategoryDropDownList.SelectedItem.Value + "'";
        DataSet categoryDataSet = GCFDGlobals.m_GCFDPlannerDatabaseLibrary.dbSelectDataSet(m_SQL);

        SubCategoryListBox.Items.Add(new ListItem("Select A SubCategory", "Select A SubCategory"));

        foreach (DataRow categoryDataRow in categoryDataSet.Tables[0].Rows)
        {
            SubCategoryListBox.Items.Add(new ListItem(GCFDGlobals.dbGetValue(categoryDataRow, "SubCategoryName"), GCFDGlobals.dbGetValue(categoryDataRow, "SubCategoryName")));
        }

        RecipeUnitLabel.Text           = RecipeUnitHiddenField.Value;
        RecipeUnitAfterWasteLabel.Text = RecipeUnitAfterWasteHiddenField.Value;
        CostPerRecipeUnitLabel.Text    = CostPerRecipeUnitHiddenField.Value;
    }
    private string[] GetNorthRouteOrderItemsFromDb()
    {
        string  m_SQL           = "SELECT SiteName, SiteRoute, SiteRouteOrder FROM Site WHERE SiteRoute = 'North' ORDER BY SiteRouteOrder";
        DataSet siteInfoDataSet = GCFDGlobals.m_GCFDPlannerDatabaseLibrary.dbSelectDataSet(m_SQL);

        string[] ret = new string[siteInfoDataSet.Tables[0].Rows.Count];

        int i = 0;

        foreach (DataRow SiteDataRow in siteInfoDataSet.Tables[0].Rows)
        {
            ret[i] = GCFDGlobals.dbGetValue(SiteDataRow, "SiteName");

            i++;
        }

        return(ret);
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        string createdMeal;
        string reportStartDate = Request.QueryString.Get("ReportStartDate");
        string reportType      = Request.QueryString.Get("ReportType");

        m_SQL = "DECLARE @CreatedMeal varchar(50) EXEC spInsertLabelInformationHot '" + reportStartDate + "', @CreatedMeal = @CreatedMeal OUTPUT SELECT @CreatedMeal as 'CreatedMeal'";;
        DataSet LabelCreation = GCFDGlobals.m_GCFDPlannerDatabaseLibrary.dbSelectDataSet(m_SQL);

        createdMeal = GCFDGlobals.dbGetValue(LabelCreation.Tables[0].Rows[0], "CreatedMeal");

        if (createdMeal != "-1")
        {
            if (reportType == "Excel")
            {
                ProcessExcelReport report = new ProcessExcelReport();

                report.ReportID = createdMeal;
                report.Name     = "LabelReport";
                report.Response = Response;

                report.RenderReport();
            }
            else
            {
                ProcessReport report = new ProcessReport();

                report.ReportID = createdMeal;
                report.Name     = "LabelReport";
                report.Response = Response;

                report.RenderReport();
            }
        }
        else
        {
            RegisterClientScriptBlock("",
                                      "<script>{ alert('No Meal Created For This Date. Please Choose Another Date.');window.close();}</script>");
        }
    }
    public void CalendarLinkButton_Click(string arguement)
    {
        string[] linkValue            = arguement.Split(',');
        string   selectedDeliveryDate = linkValue[0];
        string   selectedDeliveryType = linkValue[1];
        string   mealTypeID           = linkValue[2];

        Session["DeliveryCalendarMode"] = "ExceptionView";

        m_SQL = "SELECT * FROM vwDelivery WHERE DeliveryDate = '" + selectedDeliveryDate + "' AND DeliveryTypeName = '" + selectedDeliveryType + "' AND MealTypeID = " + mealTypeID + " ORDER BY SiteName";
        m_DeliveriesDataSet = GCFDGlobals.m_GCFDPlannerDatabaseLibrary.dbSelectDataSet(m_SQL);

        FillSiteDataGridView(m_DeliveriesDataSet, Convert.ToDateTime(selectedDeliveryDate), "ExceptionClick");

        ScheduledDeliveryWeekdayLabel.Text = selectedDeliveryDate;

        DayOfScheduledTaskLabel.Text = "Date of " + selectedDeliveryType + " " + GCFDGlobals.dbGetValue(m_DeliveriesDataSet.Tables[0].Rows[0], "MealTypeName") + " Delivery:";

        GetCalendarData();

        ClientScript.RegisterStartupScript(GetType(), "key", "launchDeliveryDayDetailModal();", true);
    }
    public void MealCountForCurrentMeal()
    {
        int mealCount = 0;

        for (int i = 0; i < lstSelect.Items.Count; i++)
        {
            m_SQL = "SELECT MealCount FROM vwDelivery WHERE DeliveryID = " + lstSelect.Items[i].Value;
            DataSet deliveryDataSet = GCFDGlobals.m_GCFDPlannerDatabaseLibrary.dbSelectDataSet(m_SQL);

            foreach (DataRow deliveryData in deliveryDataSet.Tables[0].Rows)
            {
                mealCount = Convert.ToInt32(GCFDGlobals.dbGetValue(deliveryData, "MealCount")) + mealCount;
            }
        }

        CurrentMealCountLabel.Text = mealCount.ToString();

        GetRoundedMealCount roundedMealCount = new GetRoundedMealCount();

        roundedMealCount.MealCount = mealCount.ToString();

        RoundedCurrentMealCountLabel.Text = roundedMealCount.RoundedMealCountForCurrentMeal();
    }
    protected int TotalMealCount(string mealDate, string DeliveryTypeName)
    {
        try
        {
            int totalMealCount = 0;

            m_SQL = "SELECT SUM(MealCount) AS MealCount FROM vwDelivery WHERE CONVERT(varchar(50), DeliveryDate, 101) = '" + mealDate + "' AND DeliveryTypeName = '" + DeliveryTypeName + "' AND MealTypeID = 3";
            DataSet deliveriesDataSet = GCFDGlobals.m_GCFDPlannerDatabaseLibrary.dbSelectDataSet(m_SQL);

            if (!String.IsNullOrEmpty(GCFDGlobals.dbGetValue(deliveriesDataSet.Tables[0].Rows[0], "MealCount")))
            {
                totalMealCount = Convert.ToInt32(GCFDGlobals.dbGetValue(deliveriesDataSet.Tables[0].Rows[0], "MealCount"));
            }

            return(totalMealCount);
        }
        catch (Exception ex)
        {
            MessageBox.Show("Error retrieving the total regular meal count - " + ex.Message);

            throw;
        }
    }
Пример #20
0
    protected void Page_Load(object sender, EventArgs e)
    {
        string reportID;
        string reportStartDate = Request.QueryString.Get("ReportStartDate");
        string reportEndDate   = Request.QueryString.Get("ReportEndDate");
        string reportType      = Request.QueryString.Get("ReportType");

        m_SQL = "DECLARE @ReportID int EXEC spInsertCCKDistributionByCommunity '" + reportStartDate + "', '" + reportEndDate + "', '" + User.Identity.Name + "', @ReportID = @ReportID OUTPUT SELECT @ReportID AS 'ReportID'";
        DataSet dailyCountReportCreation = GCFDGlobals.m_GCFDPlannerDatabaseLibrary.dbSelectDataSet(m_SQL);

        reportID = GCFDGlobals.dbGetValue(dailyCountReportCreation.Tables[0].Rows[0], "ReportID");

        if (reportType == "Excel")
        {
            ProcessExcelReport report = new ProcessExcelReport();

            report.Name      = "CCKDistributionByCommunityReport";
            report.StartDate = reportStartDate;
            report.EndDate   = reportEndDate;
            report.ReportID  = reportID;
            report.Response  = Response;

            report.RenderReport();
        }
        else
        {
            ProcessReport report = new ProcessReport();

            report.Name      = "CCKDistributionByCommunityReport";
            report.StartDate = reportStartDate;
            report.EndDate   = reportEndDate;
            report.ReportID  = reportID;
            report.Response  = Response;

            report.RenderReport();
        }
    }
Пример #21
0
    public void GetDefaultRecipeDetail()
    {
        sql = "SELECT DISTINCT RecipeID, IsDefault, ServingSize, ServingSizeTypeID, ServingSizeTypeName, VolumeWeight, Conversion, NumberOfServings, YieldInPounds, PackageTypeID, PackageTypeName, PackagesPerBatch, ServingsPerPackage, ServingsPerBatch, Notes FROM vwRecipeDetail WHERE RecipeID = " + recipeID + " AND IsDefault = 'true'";
        DataSet recipeYieldDataSet = GCFDGlobals.m_GCFDPlannerDatabaseLibrary.dbSelectDataSet(sql);

        foreach (DataRow recipeYieldDataRow in recipeYieldDataSet.Tables[0].Rows)
        {
            recipeID            = GCFDGlobals.dbGetValue(recipeYieldDataRow, "RecipeID");
            isDefault           = GCFDGlobals.dbGetValue(recipeYieldDataRow, "IsDefault");
            servingSize         = GCFDGlobals.dbGetValue(recipeYieldDataRow, "ServingSize");
            servingSizeTypeID   = GCFDGlobals.dbGetValue(recipeYieldDataRow, "ServingSizeTypeID");
            servingSizeTypeName = GCFDGlobals.dbGetValue(recipeYieldDataRow, "ServingSizeTypeName");
            volumeWeight        = GCFDGlobals.dbGetValue(recipeYieldDataRow, "VolumeWeight");
            conversion          = GCFDGlobals.dbGetValue(recipeYieldDataRow, "Conversion");
            numberOfServings    = GCFDGlobals.dbGetValue(recipeYieldDataRow, "NumberOfServings");
            yieldInPounds       = GCFDGlobals.dbGetValue(recipeYieldDataRow, "YieldInPounds");
            packageTypeID       = GCFDGlobals.dbGetValue(recipeYieldDataRow, "PackageTypeID");
            packageTypeName     = GCFDGlobals.dbGetValue(recipeYieldDataRow, "PackageTypeName");
            packagesPerBatch    = GCFDGlobals.dbGetValue(recipeYieldDataRow, "PackagesPerBatch");
            servingsPerPackage  = GCFDGlobals.dbGetValue(recipeYieldDataRow, "ServingsPerPackage");
            servingsPerBatch    = GCFDGlobals.dbGetValue(recipeYieldDataRow, "ServingsPerBatch");
            notes = GCFDGlobals.dbGetValue(recipeYieldDataRow, "Notes");
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        string deliverySiteName;
        string m_SQL;
        string reportStartDate = Request.QueryString.Get("ReportStartDate");
        string reportType      = Request.QueryString.Get("ReportType");

        m_SQL = "DELETE FROM DailyCountReport";
        GCFDGlobals.m_GCFDPlannerDatabaseLibrary.dbExecuteSQLCmd(m_SQL);

        m_SQL = "SELECT DISTINCT SiteName FROM vwDelivery WHERE ServingDate BETWEEN '" + reportStartDate + "' AND DATEADD(d, 6, '" + reportStartDate + "') AND DeliveryTypeID IN (1,2) AND DeliveryDate <> '01/01/1900' AND MealTypeID = 2";
        DataSet deliveryDataSet = GCFDGlobals.m_GCFDPlannerDatabaseLibrary.dbSelectDataSet(m_SQL);

        m_SQL =
            "DECLARE @FirstDay smalldatetime, @NumberOfMonths int SELECT @FirstDay = '" + Convert.ToDateTime(reportStartDate).ToString("yyyyMMdd") + "';WITH Days AS (SELECT @FirstDay as CalendarDay UNION ALL SELECT DATEADD(d, 1, CalendarDay) as CalendarDay FROM Days WHERE DATEADD(d, 1, CalendarDay) < DATEADD(d, 6, '" + reportStartDate + "')) SELECT CONVERT(varchar(10), CalendarDay, 101) AS WeekdayDate FROM Days";
        DataSet daysOfTheWeekDataSet = GCFDGlobals.m_GCFDPlannerDatabaseLibrary.dbSelectDataSet(m_SQL);

        foreach (DataRow deliveryDataRow in deliveryDataSet.Tables[0].Rows)
        {
            deliverySiteName = GCFDGlobals.dbGetValue(deliveryDataRow, "SiteName");

            foreach (DataRow weekdayDataRow in daysOfTheWeekDataSet.Tables[0].Rows)
            {
                m_SQL = "SELECT DISTINCT SiteName, LAHSiteCode, ServingDate, DATENAME(dw, ServingDate) AS WeekdayName, MealCount, MealTypeName FROM vwDelivery WHERE MealTypeID = 2 AND ((DeliveryTypeName = 'Scheduled') OR (DeliveryTypeName='Rescheduled' AND CONVERT(varchar(10), DeliveryDate, 101) <> '01/01/1900')) AND ServingDate = '" + GCFDGlobals.dbGetValue(weekdayDataRow, "WeekdayDate") + "' AND SiteName = '" + deliverySiteName + "'";
                DataSet dailyCountDataSet = GCFDGlobals.m_GCFDPlannerDatabaseLibrary.dbSelectDataSet(m_SQL);

                if (dailyCountDataSet.Tables[0].Rows.Count > 0)
                {
                    m_SQL =
                        "INSERT INTO DailyCountReport(ServingDate, SiteName, Sent, MealTypeName) VALUES('" +
                        Convert.ToDateTime(GCFDGlobals.dbGetValue(weekdayDataRow, "WeekdayDate")).ToString("MM/dd/yyyy") + "', '" + deliverySiteName + "', " +
                        GCFDGlobals.dbGetValue(dailyCountDataSet.Tables[0].Rows[0], "MealCount") + ", '" + GCFDGlobals.dbGetValue(dailyCountDataSet.Tables[0].Rows[0], "MealTypeName") + "')";
                    GCFDGlobals.m_GCFDPlannerDatabaseLibrary.dbExecuteSQLCmd(m_SQL);
                }
                else
                {
                    m_SQL =
                        "INSERT INTO DailyCountReport(ServingDate, SiteName, Sent, MealTypeName) VALUES('" +
                        Convert.ToDateTime(GCFDGlobals.dbGetValue(weekdayDataRow, "WeekdayDate")).ToString("MM/dd/yyyy") + "', '" + deliverySiteName + "', 0, 'Cold')";
                    GCFDGlobals.m_GCFDPlannerDatabaseLibrary.dbExecuteSQLCmd(m_SQL);
                }
            }
        }

        m_SQL           = "SELECT DISTINCT SiteName FROM vwDelivery WHERE ServingDate BETWEEN '" + reportStartDate + "' AND DATEADD(d, 6, '" + reportStartDate + "') AND DeliveryTypeID IN (1,2) AND DeliveryDate <> '01/01/1900' AND MealTypeID = 8";
        deliveryDataSet = GCFDGlobals.m_GCFDPlannerDatabaseLibrary.dbSelectDataSet(m_SQL);

        m_SQL =
            "DECLARE @FirstDay smalldatetime, @NumberOfMonths int SELECT @FirstDay = '" + Convert.ToDateTime(reportStartDate).ToString("yyyyMMdd") + "';WITH Days AS (SELECT @FirstDay as CalendarDay UNION ALL SELECT DATEADD(d, 1, CalendarDay) as CalendarDay FROM Days WHERE DATEADD(d, 1, CalendarDay) < DATEADD(d, 6, '" + reportStartDate + "')) SELECT CONVERT(varchar(10), CalendarDay, 101) AS WeekdayDate FROM Days";
        daysOfTheWeekDataSet = GCFDGlobals.m_GCFDPlannerDatabaseLibrary.dbSelectDataSet(m_SQL);

        foreach (DataRow deliveryDataRow in deliveryDataSet.Tables[0].Rows)
        {
            deliverySiteName = GCFDGlobals.dbGetValue(deliveryDataRow, "SiteName");

            foreach (DataRow weekdayDataRow in daysOfTheWeekDataSet.Tables[0].Rows)
            {
                m_SQL = "SELECT DISTINCT SiteName, LAHSiteCode, ServingDate, DATENAME(dw, ServingDate) AS WeekdayName, MealCount, MealTypeName FROM vwDelivery WHERE MealTypeID = 8 AND ((DeliveryTypeName = 'Scheduled') OR (DeliveryTypeName='Rescheduled' AND CONVERT(varchar(10), DeliveryDate, 101) <> '01/01/1900')) AND ServingDate = '" + GCFDGlobals.dbGetValue(weekdayDataRow, "WeekdayDate") + "' AND SiteName = '" + deliverySiteName + "'";
                DataSet dailyCountDataSet = GCFDGlobals.m_GCFDPlannerDatabaseLibrary.dbSelectDataSet(m_SQL);

                if (dailyCountDataSet.Tables[0].Rows.Count > 0)
                {
                    m_SQL =
                        "INSERT INTO DailyCountReport(ServingDate, SiteName, Sent, MealTypeName) VALUES('" +
                        Convert.ToDateTime(GCFDGlobals.dbGetValue(weekdayDataRow, "WeekdayDate")).ToString("MM/dd/yyyy") + "', '" + deliverySiteName + "', " +
                        GCFDGlobals.dbGetValue(dailyCountDataSet.Tables[0].Rows[0], "MealCount") + ", '" + GCFDGlobals.dbGetValue(dailyCountDataSet.Tables[0].Rows[0], "MealTypeName") + "')";
                    GCFDGlobals.m_GCFDPlannerDatabaseLibrary.dbExecuteSQLCmd(m_SQL);
                }
                else
                {
                    m_SQL =
                        "INSERT INTO DailyCountReport(ServingDate, SiteName, Sent, MealTypeName) VALUES('" +
                        Convert.ToDateTime(GCFDGlobals.dbGetValue(weekdayDataRow, "WeekdayDate")).ToString("MM/dd/yyyy") + "', '" + deliverySiteName + "', 0, 'Cold Breakfast (LAH)')";
                    GCFDGlobals.m_GCFDPlannerDatabaseLibrary.dbExecuteSQLCmd(m_SQL);
                }
            }
        }

        if (reportType == "Excel")
        {
            ProcessExcelReport report = new ProcessExcelReport();

            report.StartDate = reportStartDate;
            report.Name      = "ColdMealScheduleReport";
            report.Response  = Response;

            report.RenderReport();
        }
        else
        {
            ProcessReport report = new ProcessReport();

            report.StartDate = reportStartDate;
            report.Name      = "ColdMealScheduleReport";
            report.Response  = Response;

            report.RenderReport();
        }
    }
    protected void UpdateGroupExceptions(string groupExceptionID)
    {
        string mealType     = "";
        string mealTypeName = "";
        string servingDate;
        string rangeStartDate = "";
        string rangeEndDate   = "";
        string listLine;
        string deliveryDate;
        string rescheduledDate  = "";
        string scheduleTypeText = "";
        string scheduleType     = "";

        m_SQL = "SELECT DISTINCT * FROM vwDelivery WHERE GroupCancellationID = " + groupExceptionID + " AND DeliveryTypeName = 'Cancelled'";
        DataSet m_GroupExceptionDataSet = GCFDGlobals.m_GCFDPlannerDatabaseLibrary.dbSelectDataSet(m_SQL);

        mealType         = GCFDGlobals.dbGetValue(m_GroupExceptionDataSet.Tables[0].Rows[0], "MealTypeID");
        rangeStartDate   = Convert.ToDateTime(GCFDGlobals.dbGetValue(m_GroupExceptionDataSet.Tables[0].Rows[0], "CancellationStartDate")).ToString("MM/dd/yyyy");
        rangeEndDate     = Convert.ToDateTime(GCFDGlobals.dbGetValue(m_GroupExceptionDataSet.Tables[0].Rows[0], "CancellationEndDate")).ToString("MM/dd/yyyy");
        rescheduledDate  = Convert.ToDateTime(GCFDGlobals.dbGetValue(m_GroupExceptionDataSet.Tables[0].Rows[0], "RescheduledDate")).ToString("MM/dd/yyyy");
        mealTypeName     = GCFDGlobals.dbGetValue(m_GroupExceptionDataSet.Tables[0].Rows[0], "MealTypeName");
        scheduleTypeText = GCFDGlobals.dbGetValue(m_GroupExceptionDataSet.Tables[0].Rows[0], "ScheduleTypeText");

        GroupCancellationRescheduledDateHiddenTextBox.Value = rescheduledDate;

        if (rescheduledDate == "01/01/1900")
        {
            RescheduleDateTextBox.Text = "Delivery Not Rescheduled";
        }
        else
        {
            RescheduleDateTextBox.Text = rescheduledDate;
        }

        MealDeliveryTypeHiddenTextBox.Value = mealType;

        RemovedDeliverySiteList.Items.Clear();
        AddedDeliverySiteList.Items.Clear();

        RetrieveMealTypeValues(mealType);

        foreach (DataRow groupExceptionData in m_GroupExceptionDataSet.Tables[0].Rows)
        {
            servingDate  = Convert.ToDateTime(GCFDGlobals.dbGetValue(groupExceptionData, "ServingDate")).ToString("MM/dd/yyyy");
            deliveryDate = Convert.ToDateTime(GCFDGlobals.dbGetValue(groupExceptionData, "DeliveryDate")).ToString("MM/dd/yyyy");
            scheduleType = GCFDGlobals.dbGetValue(groupExceptionData, "ScheduleTypeName");

            listLine = GCFDGlobals.dbGetValue(groupExceptionData, "SiteName") + " (" + deliveryDate + " Delivery Date|" + servingDate + " Serving Date|" + scheduleType + ")";

            AddedDeliverySiteList.Items.Add(new ListItem(listLine, GCFDGlobals.dbGetValue(groupExceptionData, "DeliveryID")));

            if (prohibitPastModifications == "1" && Convert.ToInt32(Convert.ToDateTime(deliveryDate).ToString("yyyyMMdd")) < Convert.ToInt32(System.DateTime.Now.ToString("yyyyMMdd")))
            {
                ListItem i = AddedDeliverySiteList.Items.FindByValue(GCFDGlobals.dbGetValue(groupExceptionData, "DeliveryID"));

                i.Attributes.Add("style", "color:gray;");
                i.Attributes.Add("disabled", "true");
            }
        }

        m_SQL = "SELECT * FROM vwDelivery WHERE DeliveryDate BETWEEN '" + rangeStartDate + "' AND '" + rangeEndDate + "' AND MealTypeName = '" + mealTypeName + "' AND DeliveryTypeName = 'Scheduled'";
        m_DeliveriesDataSet = GCFDGlobals.m_GCFDPlannerDatabaseLibrary.dbSelectDataSet(m_SQL);

        foreach (DataRow deliveryDataRow in m_DeliveriesDataSet.Tables[0].Rows)
        {
            servingDate  = Convert.ToDateTime(GCFDGlobals.dbGetValue(deliveryDataRow, "ServingDate")).ToString("MM/dd/yyyy");
            deliveryDate = Convert.ToDateTime(GCFDGlobals.dbGetValue(deliveryDataRow, "DeliveryDate")).ToString("MM/dd/yyyy");
            scheduleType = GCFDGlobals.dbGetValue(deliveryDataRow, "ScheduleTypeName");

            listLine = GCFDGlobals.dbGetValue(deliveryDataRow, "SiteName") + " (" + deliveryDate + " Delivery Date|" + servingDate + " Serving Date|" + scheduleType + ")";

            RemovedDeliverySiteList.Items.Add(new ListItem(listLine, GCFDGlobals.dbGetValue(deliveryDataRow, "DeliveryID")));

            if (prohibitPastModifications == "1" && Convert.ToInt32(Convert.ToDateTime(deliveryDate).ToString("yyyyMMdd")) < Convert.ToInt32(System.DateTime.Now.ToString("yyyyMMdd")))
            {
                ListItem i = RemovedDeliverySiteList.Items.FindByValue(GCFDGlobals.dbGetValue(deliveryDataRow, "DeliveryID"));

                i.Attributes.Add("style", "color:gray;");
                i.Attributes.Add("disabled", "true");
            }
        }

        AddedDeliverySiteList.Rows   = AddedDeliverySiteList.Items.Count;
        RemovedDeliverySiteList.Rows = AddedDeliverySiteList.Items.Count;

        RemovedDeliverySiteList.Width = AddedDeliverySiteList.Width;

        CancellationRangeStartDateLabel.Text = rangeStartDate;
        CancellationRangeEndDateLabel.Text   = rangeEndDate;
        CancellationMealTypeLabel.Text       = mealTypeName;
        CancellationScheduleTypeLabel.Text   = scheduleTypeText;

        GetCalendarData();

        ClientScript.RegisterStartupScript(GetType(), "key", "launchGroupCancellationModal();", true);
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        string reportID;
        string reportStartDate = Request.QueryString.Get("ReportStartDate");
        string reportEndDate   = Request.QueryString.Get("ReportEndDate");
        string communityArea   = Request.QueryString.Get("CommunityArea");
        string siteName        = Request.QueryString.Get("SiteName");
        string reportType      = Request.QueryString.Get("ReportType");

        m_SQL = "DECLARE @ReportID int EXEC spInsertSiteCountMealTotalReportByRange '" + communityArea + "', '" + siteName + "', '" + reportStartDate + "', '" + reportEndDate + "', '" + User.Identity.Name + "', @ReportID = @ReportID OUTPUT SELECT @ReportID AS 'ReportID'";
        DataSet dailyCountReportCreation = GCFDGlobals.m_GCFDPlannerDatabaseLibrary.dbSelectDataSet(m_SQL);

        reportID = GCFDGlobals.dbGetValue(dailyCountReportCreation.Tables[0].Rows[0], "ReportID");

        if (siteName == "-1" && communityArea == "-1")
        {
            if (reportType == "Excel")
            {
                ProcessExcelReport report = new ProcessExcelReport();

                report.Name      = "SiteCountMealTotalReportByRange";
                report.StartDate = reportStartDate;
                report.EndDate   = reportEndDate;
                report.ReportID  = reportID;
                report.Response  = Response;

                report.RenderReport();
            }
            else
            {
                ProcessReport report = new ProcessReport();

                report.Name      = "SiteCountMealTotalReportByRange";
                report.StartDate = reportStartDate;
                report.EndDate   = reportEndDate;
                report.ReportID  = reportID;
                report.Response  = Response;

                report.RenderReport();
            }
        }
        else if (siteName != "-1")
        {
            if (reportType == "Excel")
            {
                ProcessExcelReport report = new ProcessExcelReport();

                report.Name      = "SiteCountMealTotalReportByRange_BySite";
                report.SiteName  = siteName;
                report.StartDate = reportStartDate;
                report.EndDate   = reportEndDate;
                report.ReportID  = reportID;
                report.Response  = Response;

                report.RenderReport();
            }
            else
            {
                ProcessReport report = new ProcessReport();

                report.Name      = "SiteCountMealTotalReportByRange_BySite";
                report.SiteName  = siteName;
                report.StartDate = reportStartDate;
                report.EndDate   = reportEndDate;
                report.ReportID  = reportID;
                report.Response  = Response;

                report.RenderReport();
            }
        }
        else if (communityArea != "-1")
        {
            if (reportType == "Excel")
            {
                ProcessExcelReport report = new ProcessExcelReport();

                report.Name          = "SiteCountMealTotalReportByRange_ByCommunity";
                report.CommunityArea = communityArea;
                report.StartDate     = reportStartDate;
                report.EndDate       = reportEndDate;
                report.ReportID      = reportID;
                report.Response      = Response;

                report.RenderReport();
            }
            else
            {
                ProcessReport report = new ProcessReport();

                report.Name          = "SiteCountMealTotalReportByRange_ByCommunity";
                report.CommunityArea = communityArea;
                report.StartDate     = reportStartDate;
                report.EndDate       = reportEndDate;
                report.ReportID      = reportID;
                report.Response      = Response;

                report.RenderReport();
            }
        }
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        string mealType = MealDeliveryTypeHiddenTextBox.Value;

        for (int i = 0; i < RemovedDeliverySiteList.Items.Count; i++)
        {
            if (RemovedDeliverySiteList.Items[i].Selected)
            {
                string s = RemovedDeliverySiteList.SelectedItem.Value;
                string t = RemovedDeliverySiteList.SelectedItem.Text;

                AddedDeliverySiteList.Items.Add(new ListItem(t, s));

                RemovedDeliverySiteList.Items.Remove(new ListItem(t, s));

                i--;
            }

            m_SQL = "SELECT DeliveryDate FROM vwDelivery WHERE DeliveryID = " + RemovedDeliverySiteList.Items[i].Value;
            m_DeliveriesDataSet = GCFDGlobals.m_GCFDPlannerDatabaseLibrary.dbSelectDataSet(m_SQL);

            RetrieveMealTypeValues(mealType);

            if (prohibitPastModifications == "1" && Convert.ToInt32(Convert.ToDateTime(GCFDGlobals.dbGetValue(m_DeliveriesDataSet.Tables[0].Rows[0], "DeliveryDate")).ToString("yyyyMMdd")) < Convert.ToInt32(System.DateTime.Now.ToString("yyyyMMdd")))
            {
                ListItem li = RemovedDeliverySiteList.Items.FindByValue(RemovedDeliverySiteList.Items[i].Value);

                li.Attributes.Add("style", "color:gray;");
                li.Attributes.Add("disabled", "true");
            }

            UpdateListBoxHeightWidth();
        }

        for (int i = 0; i < AddedDeliverySiteList.Items.Count; i++)
        {
            m_SQL = "SELECT DeliveryDate FROM vwDelivery WHERE DeliveryID = " + AddedDeliverySiteList.Items[i].Value;
            m_DeliveriesDataSet = GCFDGlobals.m_GCFDPlannerDatabaseLibrary.dbSelectDataSet(m_SQL);

            RetrieveMealTypeValues(mealType);

            if (prohibitPastModifications == "1" && Convert.ToInt32(Convert.ToDateTime(GCFDGlobals.dbGetValue(m_DeliveriesDataSet.Tables[0].Rows[0], "DeliveryDate")).ToString("yyyyMMdd")) < Convert.ToInt32(System.DateTime.Now.ToString("yyyyMMdd")))
            {
                ListItem li = AddedDeliverySiteList.Items.FindByValue(AddedDeliverySiteList.Items[i].Value);

                li.Attributes.Add("style", "color:gray;");
                li.Attributes.Add("disabled", "true");
            }
        }

        GetCalendarData();

        ClientScript.RegisterStartupScript(GetType(), "key", "launchGroupCancellationModal();", true);
    }
    protected void SaveAsNewButton_Click(object sender, EventArgs e)
    {
        if (Page.IsValid)
        {
            string lastInvoiceCost   = InvoicedCostTextBox.Text;
            string recipeUnitsInUnit = RecipeUnitInUnitTextBox.Text;
            string costPerUnit       = CostPerRecipeUnitLabel.Text;
            double yield;
            string recipeUnitWaste = RecipeUnitAfterWasteLabel.Text;

            if (String.IsNullOrEmpty(YieldTextBox.Text))
            {
                yield = 0;
            }
            else
            {
                yield = Convert.ToInt16(YieldTextBox.Text) / 100;
            }

            if (lastInvoiceCost == "")
            {
                lastInvoiceCost = "null";
            }

            if (recipeUnitsInUnit == "")
            {
                recipeUnitsInUnit = "null";
            }

            if (costPerUnit == "")
            {
                costPerUnit = "null";
            }

            if (recipeUnitWaste == "")
            {
                recipeUnitWaste = "null";
            }

            if (CreateItem() == true)
            {
                try
                {
                    m_SQL = "INSERT INTO Ingredient (IngredientName, RecipeUnit, Vendor, LastInvoicedCost, PurchaseUnit, RecipeUnitsInPurchaseUnit, RecipeUnitAfterWaste, CostPerRecipeUnit, Yield, Par, Notes, Active, DateLastUpdated, Category, SubCategory, DateCreated) VALUES('" +
                            IngredientNameTextBox.Text + "', '" + UnitDropDownList.SelectedItem.Value + "', '";
                    m_SQL = m_SQL + VendorDropDownList.SelectedItem.Value + "', " + lastInvoiceCost + ", '" + PurchasedUnitTextBox.Text + "', " + recipeUnitsInUnit + ", " + recipeUnitWaste + ", " + costPerUnit + ", " + yield + ", " + ParTextBox.Text + ", '" + NotesTextBox.Text + "', 1, GETDATE(), '" + CategoryDropDownList.SelectedItem.Value + "', '" + SubCategoryListBox.SelectedItem.Value + "', GETDATE())";
                    GCFDGlobals.m_GCFDPlannerDatabaseLibrary.dbExecuteSQLCmd(m_SQL);

                    m_SQL = "SELECT SCOPE_IDENTITY() AS IngredientID";
                    DataSet newIngredientIDDataSet = GCFDGlobals.m_GCFDPlannerDatabaseLibrary.dbSelectDataSet(m_SQL);

                    IngredientIDHiddenField.Value = GCFDGlobals.dbGetValue(newIngredientIDDataSet.Tables[0].Rows[0], "IngredientID");

                    OriginalIngredientNameHiddenField.Value = IngredientNameTextBox.Text;

                    MessageBox.Show("The " + IngredientNameTextBox.Text + " Ingredient Has Been Saved.");
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);

                    throw;
                }
            }
            else
            {
                MessageBox.Show("There already is an ingredient/food item saved with the same name as the ingredient/food item you're attempting to currently save. Change the current ingredient/food item's name before attempting to save.");
            }
        }
    }
    public void BuildDropDownLists()
    {
        IngredientIDHiddenField.Value   = Request.QueryString.Get("IngredientID");
        IngredientModeHiddenField.Value = Request.QueryString.Get("IngredientMode");

        if (IngredientModeHiddenField.Value == "Update")
        {
            m_SQL = "SELECT IngredientName, RecipeUnit, Vendor, CONVERT(varchar, CONVERT(money, LastInvoicedCost), 1) AS LastInvoicedCost, PurchaseUnit, RecipeUnitsInPurchaseUnit, RecipeUnitAfterWaste, CONVERT(varchar, CONVERT(money, CostPerRecipeUnit), 1) AS CostPerRecipeUnit, Yield, DateLastUpdated, Notes, Par, SubCategory, Category FROM Ingredient WHERE IngredientID = " + IngredientIDHiddenField.Value;
            DataSet ingredientDataSet = GCFDGlobals.m_GCFDPlannerDatabaseLibrary.dbSelectDataSet(m_SQL);

            foreach (DataRow ingredientData in ingredientDataSet.Tables[0].Rows)
            {
                IngredientNameTextBox.Text = GCFDGlobals.dbGetValue(ingredientData, "IngredientName");
                OriginalIngredientNameHiddenField.Value = GCFDGlobals.dbGetValue(ingredientData, "IngredientName");

                UnitDropDownList.SelectedIndex =
                    UnitDropDownList.Items.IndexOf(
                        UnitDropDownList.Items.FindByText(GCFDGlobals.dbGetValue(ingredientData,
                                                                                 "RecipeUnit")));
                VendorDropDownList.SelectedIndex =
                    VendorDropDownList.Items.IndexOf(
                        VendorDropDownList.Items.FindByText(GCFDGlobals.dbGetValue(ingredientData,
                                                                                   "Vendor")));

                CategoryDropDownList.SelectedIndex =
                    CategoryDropDownList.Items.IndexOf(
                        CategoryDropDownList.Items.FindByText(GCFDGlobals.dbGetValue(ingredientData,
                                                                                     "Category")));

                InvoicedCostTextBox.Text       = GCFDGlobals.dbGetValue(ingredientData, "LastInvoicedCost");
                PurchasedUnitTextBox.Text      = GCFDGlobals.dbGetValue(ingredientData, "PurchaseUnit");
                RecipeUnitInUnitTextBox.Text   = GCFDGlobals.dbGetValue(ingredientData, "RecipeUnitsInPurchaseUnit");
                RecipeUnitAfterWasteLabel.Text = GCFDGlobals.dbGetValue(ingredientData, "RecipeUnitAfterWaste");
                CostPerRecipeUnitLabel.Text    = "$" + GCFDGlobals.dbGetValue(ingredientData, "CostPerRecipeUnit");
                ParTextBox.Text      = GCFDGlobals.dbGetValue(ingredientData, "Par");
                RecipeUnitLabel.Text = GCFDGlobals.dbGetValue(ingredientData, "RecipeUnit");

                RecipeUnitHiddenField.Value           = GCFDGlobals.dbGetValue(ingredientData, "RecipeUnit");
                RecipeUnitAfterWasteHiddenField.Value = GCFDGlobals.dbGetValue(ingredientData, "RecipeUnitAfterWaste");
                CostPerRecipeUnitHiddenField.Value    = GCFDGlobals.dbGetValue(ingredientData, "CostPerRecipeUnit");

                if (String.IsNullOrEmpty(GCFDGlobals.dbGetValue(ingredientData, "Yield")))
                {
                    YieldTextBox.Text = "0";
                }
                else
                {
                    double yield          = Convert.ToDouble(GCFDGlobals.dbGetValue(ingredientData, "Yield"));
                    int    convertedYield = Convert.ToInt16(yield * 100);

                    YieldTextBox.Text = convertedYield.ToString();
                }

                NotesTextBox.Text         = GCFDGlobals.dbGetValue(ingredientData, "Notes");
                DateLastUpdatedLabel.Text = GCFDGlobals.dbGetValue(ingredientData, "DateLastUpdated");

                SubCategoryListBox.Items.Clear();

                m_SQL = "SELECT * FROM vwCategory WHERE CategoryName = '" + CategoryDropDownList.SelectedItem.Value + "'";
                DataSet categoryDataSet = GCFDGlobals.m_GCFDPlannerDatabaseLibrary.dbSelectDataSet(m_SQL);

                SubCategoryListBox.Items.Add(new ListItem("Select A SubCategory", "Select A SubCategory"));

                foreach (DataRow categoryDataRow in categoryDataSet.Tables[0].Rows)
                {
                    SubCategoryListBox.Items.Add(new ListItem(GCFDGlobals.dbGetValue(categoryDataRow, "SubCategoryName"), GCFDGlobals.dbGetValue(categoryDataRow, "SubCategoryName")));
                }

                SubCategoryListBox.SelectedIndex =
                    SubCategoryListBox.Items.IndexOf(
                        SubCategoryListBox.Items.FindByText(GCFDGlobals.dbGetValue(ingredientData,
                                                                                   "SubCategory")));
            }

            SaveAsNewButton.Enabled = true;

            DeleteIngredientButton.Enabled = true;
            DeleteIngredientButton.Attributes.Add("onclick", "return confirm('Are you sure you want to PERMANENTLY DELETE the " + OriginalIngredientNameHiddenField.Value + " food inventory item?')");
        }
        else if (IngredientModeHiddenField.Value == "New")
        {
            SaveAsNewButton.Visible = false;

            DeleteIngredientButton.Enabled = false;
        }
    }
Пример #28
0
    public Table ExtraMealTable()
    {
        Table     m_ExtraMealTable        = new Table();
        TableCell extraTotalTableCell     = new TableCell();
        TableRow  totalTableRow           = new TableRow();
        TableCell extraTableCell          = new TableCell();
        TableRow  extraTableRow           = new TableRow();
        TableRow  spaceTableRow           = new TableRow();
        TableCell spaceTableCell          = new TableCell();
        TableCell extraMealTotalTableCell = new TableCell();
        TableRow  extraMealTotalTableRow  = new TableRow();

        string totalExtraMealCount = "0";
        string mealID      = "";
        int    buttonCount = 1;

        m_ExtraMealTable.CellPadding     = 0;
        m_ExtraMealTable.CellSpacing     = 0;
        m_ExtraMealTable.Width           = Unit.Percentage(100);
        m_ExtraMealTable.HorizontalAlign = HorizontalAlign.Left;

        DataRow[] drFiltered = RescheduledTotalMealCountDataSet.Tables[0].Select("DeliveryDate = #" + mealDate.ToString("MM/dd/yyyy") + "#");

        if (drFiltered.Length != 0)
        {
            totalExtraMealCount = GCFDGlobals.dbGetValue(drFiltered[0], "MealCount");
        }

        LinkButton totalMealCountLabel = new LinkButton();

        totalMealCountLabel.Text           = totalExtraMealCount;
        totalMealCountLabel.Font.Name      = "Arial";
        totalMealCountLabel.Font.Bold      = true;
        totalMealCountLabel.Font.Underline = true;
        totalMealCountLabel.Font.Size      = FontUnit.Parse("8");
        totalMealCountLabel.ID             = "TotalExtaMealCountButton" + mealDate;
        totalMealCountLabel.ForeColor      = System.Drawing.Color.Black;
        totalMealCountLabel.Attributes.Add("href", "javascript:__doPostBack('CalendarLinkButton','ExtraMealCount" + mealDate.ToString("MM/dd/yyyy") + "')");
        extraMealTotalTableCell.Width = Unit.Percentage(100);

        if (totalMealCountLabel.Text != "0")
        {
            extraMealTotalTableCell.BackColor = System.Drawing.Color.Yellow;
        }

        extraMealTotalTableCell.HorizontalAlign = HorizontalAlign.Right;
        extraMealTotalTableCell.Controls.Add(totalMealCountLabel);
        extraMealTotalTableRow.Controls.Add(extraMealTotalTableCell);
        extraMealTotalTableRow.Width = Unit.Percentage(100);

        m_ExtraMealTable.Controls.Add(extraMealTotalTableRow);

        DataRow[] drMealDataFiltered = CalendarRescheduledDataSet.Tables[0].Select("DeliveryDate = #" + mealDate.ToString("MM/dd/yyyy") + "#");

        for (int i = 0; i < drMealDataFiltered.Length; i++)
        {
            extraTotalTableCell = new TableCell();
            totalTableRow       = new TableRow();
            extraTableCell      = new TableCell();
            extraTableRow       = new TableRow();
            spaceTableRow       = new TableRow();
            spaceTableCell      = new TableCell();

            if (GCFDGlobals.dbGetValue(drMealDataFiltered[i], "MealID") != mealID)
            {
                mealID = GCFDGlobals.dbGetValue(drMealDataFiltered[i], "MealID");

                LinkButton mealCountLabel = new LinkButton();
                mealCountLabel.Style.Add("text-decoration", "none");
                mealCountLabel.Text      = GCFDGlobals.dbGetValue(drMealDataFiltered[i], "MealCount");
                mealCountLabel.Font.Name = "Arial";
                mealCountLabel.Font.Bold = false;
                mealCountLabel.Font.Size = FontUnit.Parse("8");
                mealCountLabel.ForeColor = System.Drawing.Color.Black;
                mealCountLabel.ID        = "MealCountButton" + mealID;
                mealCountLabel.Attributes.Add("href", "javascript:__doPostBack('CalendarLinkButton','" + mealID + "')");
                extraTotalTableCell.Width           = Unit.Percentage(100);
                extraTotalTableCell.HorizontalAlign = HorizontalAlign.Right;
                extraTotalTableCell.Controls.Add(mealCountLabel);
                totalTableRow.Controls.Add(extraTotalTableCell);

                m_ExtraMealTable.Controls.Add(totalTableRow);
            }

            LinkButton mealDetailLabel = new LinkButton();
            mealDetailLabel.Text      = GCFDGlobals.dbGetValue(drMealDataFiltered[i], "RecipeName");
            mealDetailLabel.Font.Name = "Arial";
            mealDetailLabel.Font.Bold = false;
            mealDetailLabel.Font.Size = FontUnit.Parse("8");

            switch (GCFDGlobals.dbGetValue(drMealDataFiltered[i], "RecipeTypeID"))
            {
            case ("1"):
                mealDetailLabel.ForeColor = System.Drawing.Color.Black;

                break;

            case ("2"):
                mealDetailLabel.ForeColor = System.Drawing.Color.DarkGreen;

                break;

            case ("3"):
                mealDetailLabel.ForeColor = System.Drawing.Color.DarkRed;

                break;

            case ("4"):
                mealDetailLabel.ForeColor = System.Drawing.Color.DarkCyan;

                break;

            case ("5"):
                mealDetailLabel.ForeColor = System.Drawing.Color.SteelBlue;

                break;

            case ("6"):
                mealDetailLabel.ForeColor = System.Drawing.Color.DarkSeaGreen;

                break;
            }

            mealDetailLabel.ID = buttonCount + "LinkButton" + mealID;
            mealDetailLabel.Style.Add("text-decoration", "none");
            mealDetailLabel.Attributes.Add("href", "javascript:__doPostBack('CalendarLinkButton','" + mealID + "')");
            extraTableCell.Width           = Unit.Percentage(100);
            extraTableCell.HorizontalAlign = HorizontalAlign.Right;

            extraTableCell.Controls.Add(mealDetailLabel);
            extraTableRow.Controls.Add(extraTableCell);
            extraTableRow.Width = Unit.Percentage(100);

            m_ExtraMealTable.Controls.Add(extraTableRow);

            buttonCount = buttonCount + 1;

            m_ExtraMealTable.Controls.Add(spaceTableRow);
        }

        return(m_ExtraMealTable);
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        string createdMeal;
        string reportStartDate = Request.QueryString.Get("ReportStartDate");
        string reportEndDate   = Request.QueryString.Get("ReportEndDate");
        string mealType        = Request.QueryString.Get("MealType");
        string scheduleType    = Request.QueryString.Get("ScheduleType");
        string communityArea   = Request.QueryString.Get("CommunityArea");
        string siteName        = Request.QueryString.Get("SiteName");
        string reportType      = Request.QueryString.Get("ReportType");

        m_SQL = "DECLARE @CreatedMeal varchar(50) EXEC spInsertDailyCountReportInformation '" + reportStartDate + "', '" + reportEndDate + "', " + mealType + ", " + scheduleType + ",'" + communityArea + "', '" + siteName + "', '" + User.Identity.Name + "', @CreatedMeal = @CreatedMeal OUTPUT SELECT @CreatedMeal as 'CreatedMeal'";
        DataSet dailyCountReportCreation = GCFDGlobals.m_GCFDPlannerDatabaseLibrary.dbSelectDataSet(m_SQL);

        createdMeal = GCFDGlobals.dbGetValue(dailyCountReportCreation.Tables[0].Rows[0], "CreatedMeal");

        if (createdMeal != "-1")
        {
            if (siteName == "-1" && mealType != "-1" && communityArea == "-1" && scheduleType == "-1")
            {
                m_SQL = "SELECT MealTypeName FROM MealTypeDict WHERE MealTypeID = " + mealType;
                DataSet MealTypeIDDataSet = GCFDGlobals.m_GCFDPlannerDatabaseLibrary.dbSelectDataSet(m_SQL);

                //m_SQL = "SELECT ScheduleTypeName FROM ScheduleTypeDict WHERE ScheduleTypeID = " + scheduleType;
                //DataSet ScheduleTypeIDDataSet = GCFDGlobals.m_GCFDPlannerDatabaseLibrary.dbSelectDataSet(m_SQL);

                if (reportType == "Excel")
                {
                    ProcessExcelReport report = new ProcessExcelReport();

                    report.MealType = GCFDGlobals.dbGetValue(MealTypeIDDataSet.Tables[0].Rows[0], "MealTypeName");
                    //report.ScheduleType = GCFDGlobals.dbGetValue(ScheduleTypeIDDataSet.Tables[0].Rows[0], "ScheduleTypeName");
                    report.ReportID  = createdMeal;
                    report.StartDate = reportStartDate;
                    report.EndDate   = reportEndDate;
                    report.Name      = "NewDailyCountReport";
                    report.Response  = Response;
                    report.RenderReport();
                }
                else
                {
                    ProcessReport report = new ProcessReport();

                    report.MealType = GCFDGlobals.dbGetValue(MealTypeIDDataSet.Tables[0].Rows[0], "MealTypeName");
                    //report.ScheduleType = GCFDGlobals.dbGetValue(ScheduleTypeIDDataSet.Tables[0].Rows[0], "ScheduleTypeName");
                    report.ReportID  = createdMeal;
                    report.StartDate = reportStartDate;
                    report.EndDate   = reportEndDate;
                    report.Name      = "NewDailyCountReport";
                    report.Response  = Response;
                    report.RenderReport();
                }
            }
            else if (siteName == "-1" && mealType != "-1" && communityArea == "-1" && scheduleType != "-1")
            {
                m_SQL = "SELECT MealTypeName FROM MealTypeDict WHERE MealTypeID = " + mealType;
                DataSet MealTypeIDDataSet = GCFDGlobals.m_GCFDPlannerDatabaseLibrary.dbSelectDataSet(m_SQL);

                m_SQL = "SELECT ScheduleTypeName FROM ScheduleTypeDict WHERE ScheduleTypeID = " + scheduleType;
                DataSet ScheduleTypeIDDataSet = GCFDGlobals.m_GCFDPlannerDatabaseLibrary.dbSelectDataSet(m_SQL);

                if (reportType == "Excel")
                {
                    ProcessExcelReport report = new ProcessExcelReport();

                    report.MealType     = GCFDGlobals.dbGetValue(MealTypeIDDataSet.Tables[0].Rows[0], "MealTypeName");
                    report.ScheduleType = GCFDGlobals.dbGetValue(ScheduleTypeIDDataSet.Tables[0].Rows[0], "ScheduleTypeName");
                    report.ReportID     = createdMeal;
                    report.StartDate    = reportStartDate;
                    report.EndDate      = reportEndDate;
                    report.Name         = "NewDailyCountReportByScheduleType";
                    report.Response     = Response;
                    report.RenderReport();
                }
                else
                {
                    ProcessReport report = new ProcessReport();

                    report.MealType     = GCFDGlobals.dbGetValue(MealTypeIDDataSet.Tables[0].Rows[0], "MealTypeName");
                    report.ScheduleType = GCFDGlobals.dbGetValue(ScheduleTypeIDDataSet.Tables[0].Rows[0], "ScheduleTypeName");
                    report.ReportID     = createdMeal;
                    report.StartDate    = reportStartDate;
                    report.EndDate      = reportEndDate;
                    report.Name         = "NewDailyCountReportByScheduleType";
                    report.Response     = Response;
                    report.RenderReport();
                }
            }
            else if (siteName == "-1" && mealType != "-1" && communityArea != "-1" && scheduleType == "-1")
            {
                m_SQL = "SELECT MealTypeName FROM MealTypeDict WHERE MealTypeID = " + mealType;
                DataSet MealTypeIDDataSet = GCFDGlobals.m_GCFDPlannerDatabaseLibrary.dbSelectDataSet(m_SQL);

                if (reportType == "Excel")
                {
                    ProcessExcelReport report = new ProcessExcelReport();

                    report.MealType      = GCFDGlobals.dbGetValue(MealTypeIDDataSet.Tables[0].Rows[0], "MealTypeName");
                    report.CommunityArea = communityArea;
                    report.ReportID      = createdMeal;
                    report.StartDate     = reportStartDate;
                    report.EndDate       = reportEndDate;
                    report.Name          = "NewDailyCountReportByCommunityAreaMealType";
                    report.Response      = Response;
                    report.RenderReport();
                }
                else
                {
                    ProcessReport report = new ProcessReport();

                    report.MealType      = GCFDGlobals.dbGetValue(MealTypeIDDataSet.Tables[0].Rows[0], "MealTypeName");
                    report.CommunityArea = communityArea;
                    report.ReportID      = createdMeal;
                    report.StartDate     = reportStartDate;
                    report.EndDate       = reportEndDate;
                    report.Name          = "NewDailyCountReportByCommunityAreaMealType";
                    report.Response      = Response;
                    report.RenderReport();
                }
            }
            else if (siteName == "-1" && mealType != "-1" && communityArea != "-1" && scheduleType != "-1")
            {
                m_SQL = "SELECT MealTypeName FROM MealTypeDict WHERE MealTypeID = " + mealType;
                DataSet MealTypeIDDataSet = GCFDGlobals.m_GCFDPlannerDatabaseLibrary.dbSelectDataSet(m_SQL);

                m_SQL = "SELECT ScheduleTypeName FROM ScheduleTypeDict WHERE ScheduleTypeID = " + scheduleType;
                DataSet ScheduleTypeIDDataSet = GCFDGlobals.m_GCFDPlannerDatabaseLibrary.dbSelectDataSet(m_SQL);

                if (reportType == "Excel")
                {
                    ProcessExcelReport report = new ProcessExcelReport();

                    report.MealType      = GCFDGlobals.dbGetValue(MealTypeIDDataSet.Tables[0].Rows[0], "MealTypeName");
                    report.ScheduleType  = GCFDGlobals.dbGetValue(ScheduleTypeIDDataSet.Tables[0].Rows[0], "ScheduleTypeName");
                    report.CommunityArea = communityArea;
                    report.ReportID      = createdMeal;
                    report.StartDate     = reportStartDate;
                    report.EndDate       = reportEndDate;
                    report.Name          = "NewDailyCountReportByCommunityAreaMealTypeScheduleType";
                    report.Response      = Response;
                    report.RenderReport();
                }
                else
                {
                    ProcessReport report = new ProcessReport();

                    report.MealType      = GCFDGlobals.dbGetValue(MealTypeIDDataSet.Tables[0].Rows[0], "MealTypeName");
                    report.ScheduleType  = GCFDGlobals.dbGetValue(ScheduleTypeIDDataSet.Tables[0].Rows[0], "ScheduleTypeName");
                    report.CommunityArea = communityArea;
                    report.ReportID      = createdMeal;
                    report.StartDate     = reportStartDate;
                    report.EndDate       = reportEndDate;
                    report.Name          = "NewDailyCountReportByCommunityAreaMealTypeScheduleType";
                    report.Response      = Response;
                    report.RenderReport();
                }
            }
            else if (siteName == "-1" && mealType == "-1" && communityArea == "-1" && scheduleType == "-1")
            {
                if (reportType == "Excel")
                {
                    ProcessExcelReport report = new ProcessExcelReport();

                    report.ReportID  = createdMeal;
                    report.StartDate = reportStartDate;
                    report.EndDate   = reportEndDate;
                    report.Name      = "NewDailyCountReportOrderedBySite";
                    report.Response  = Response;
                    report.RenderReport();
                }
                else
                {
                    ProcessReport report = new ProcessReport();

                    report.ReportID  = createdMeal;
                    report.StartDate = reportStartDate;
                    report.EndDate   = reportEndDate;
                    report.Name      = "NewDailyCountReportOrderedBySite";
                    report.Response  = Response;
                    report.RenderReport();
                }
            }
            else if (siteName == "-1" && mealType == "-1" && communityArea == "-1" && scheduleType != "-1")
            {
                m_SQL = "SELECT ScheduleTypeName FROM ScheduleTypeDict WHERE ScheduleTypeID = " + scheduleType;
                DataSet ScheduleTypeIDDataSet = GCFDGlobals.m_GCFDPlannerDatabaseLibrary.dbSelectDataSet(m_SQL);

                if (reportType == "Excel")
                {
                    ProcessExcelReport report = new ProcessExcelReport();

                    report.ReportID     = createdMeal;
                    report.StartDate    = reportStartDate;
                    report.ScheduleType = GCFDGlobals.dbGetValue(ScheduleTypeIDDataSet.Tables[0].Rows[0], "ScheduleTypeName");
                    report.EndDate      = reportEndDate;
                    report.Name         = "NewDailyCountReportOrderedBySiteScheduleType";
                    report.Response     = Response;
                    report.RenderReport();
                }
                else
                {
                    ProcessReport report = new ProcessReport();

                    report.ReportID     = createdMeal;
                    report.StartDate    = reportStartDate;
                    report.ScheduleType = GCFDGlobals.dbGetValue(ScheduleTypeIDDataSet.Tables[0].Rows[0], "ScheduleTypeName");
                    report.EndDate      = reportEndDate;
                    report.Name         = "NewDailyCountReportOrderedBySiteScheduleType";
                    report.Response     = Response;
                    report.RenderReport();
                }
            }
            else if (siteName != "-1" && mealType == "-1" && communityArea == "-1" && scheduleType == "-1")
            {
                if (reportType == "Excel")
                {
                    ProcessExcelReport report = new ProcessExcelReport();

                    report.ReportID  = createdMeal;
                    report.SiteName  = siteName;
                    report.StartDate = reportStartDate;
                    report.EndDate   = reportEndDate;
                    report.Name      = "NewDailyCountReportBySite";
                    report.Response  = Response;
                    report.RenderReport();
                }
                else
                {
                    ProcessReport report = new ProcessReport();

                    report.ReportID  = createdMeal;
                    report.SiteName  = siteName;
                    report.StartDate = reportStartDate;
                    report.EndDate   = reportEndDate;
                    report.Name      = "NewDailyCountReportBySite";
                    report.Response  = Response;
                    report.RenderReport();
                }
            }
            else if (siteName != "-1" && mealType == "-1" && communityArea == "-1" && scheduleType != "-1")
            {
                m_SQL = "SELECT ScheduleTypeName FROM ScheduleTypeDict WHERE ScheduleTypeID = " + scheduleType;
                DataSet ScheduleTypeIDDataSet = GCFDGlobals.m_GCFDPlannerDatabaseLibrary.dbSelectDataSet(m_SQL);

                if (reportType == "Excel")
                {
                    ProcessExcelReport report = new ProcessExcelReport();

                    report.ReportID     = createdMeal;
                    report.ScheduleType = GCFDGlobals.dbGetValue(ScheduleTypeIDDataSet.Tables[0].Rows[0], "ScheduleTypeName");
                    report.SiteName     = siteName;
                    report.StartDate    = reportStartDate;
                    report.EndDate      = reportEndDate;
                    report.Name         = "NewDailyCountReportBySite";
                    report.Response     = Response;
                    report.RenderReport();
                }
                else
                {
                    ProcessReport report = new ProcessReport();

                    report.ReportID     = createdMeal;
                    report.ScheduleType = GCFDGlobals.dbGetValue(ScheduleTypeIDDataSet.Tables[0].Rows[0], "ScheduleTypeName");
                    report.SiteName     = siteName;
                    report.StartDate    = reportStartDate;
                    report.EndDate      = reportEndDate;
                    report.Name         = "NewDailyCountReportBySite";
                    report.Response     = Response;
                    report.RenderReport();
                }
            }
            else if (siteName == "-1" && mealType == "-1" && communityArea != "-1" && scheduleType == "-1")
            {
                if (reportType == "Excel")
                {
                    ProcessExcelReport report = new ProcessExcelReport();

                    report.ReportID      = createdMeal;
                    report.CommunityArea = communityArea;
                    report.StartDate     = reportStartDate;
                    report.EndDate       = reportEndDate;
                    report.Name          = "NewDailyCountReportByCommunityArea";
                    report.Response      = Response;

                    report.RenderReport();
                }
                else
                {
                    ProcessReport report = new ProcessReport();

                    report.ReportID      = createdMeal;
                    report.CommunityArea = communityArea;
                    report.StartDate     = reportStartDate;
                    report.EndDate       = reportEndDate;
                    report.Name          = "NewDailyCountReportByCommunityArea";
                    report.Response      = Response;

                    report.RenderReport();
                }
            }
            else if (siteName == "-1" && mealType == "-1" && communityArea != "-1" && scheduleType != "-1")
            {
                m_SQL = "SELECT ScheduleTypeName FROM ScheduleTypeDict WHERE ScheduleTypeID = " + scheduleType;
                DataSet ScheduleTypeIDDataSet = GCFDGlobals.m_GCFDPlannerDatabaseLibrary.dbSelectDataSet(m_SQL);

                if (reportType == "Excel")
                {
                    ProcessExcelReport report = new ProcessExcelReport();

                    report.ReportID      = createdMeal;
                    report.ScheduleType  = GCFDGlobals.dbGetValue(ScheduleTypeIDDataSet.Tables[0].Rows[0], "ScheduleTypeName");
                    report.CommunityArea = communityArea;
                    report.StartDate     = reportStartDate;
                    report.EndDate       = reportEndDate;
                    report.Name          = "NewDailyCountReportByCommunityArea";
                    report.Response      = Response;

                    report.RenderReport();
                }
                else
                {
                    ProcessReport report = new ProcessReport();

                    report.ReportID      = createdMeal;
                    report.ScheduleType  = GCFDGlobals.dbGetValue(ScheduleTypeIDDataSet.Tables[0].Rows[0], "ScheduleTypeName");
                    report.CommunityArea = communityArea;
                    report.StartDate     = reportStartDate;
                    report.EndDate       = reportEndDate;
                    report.Name          = "NewDailyCountReportByCommunityArea";
                    report.Response      = Response;

                    report.RenderReport();
                }
            }
        }
        else
        {
            RegisterClientScriptBlock("",
                                      "<script>{ alert('Error creating Daily Count Report.');window.close();}</script>");
        }
    }
    protected void UpdateWhiteMilkCounts()
    {
        labelCounter         = 1;
        milkCount            = 0;
        daysTotalMilkCrates  = 0;
        totalCrates          = 0;
        totalWeeksMilkCrates = 0;

        string  m_SQL = "SELECT DISTINCT SiteName, SiteRoute, DeliveryDate, dbo.udf_DeliveryReportByRangeMealCount(DeliveryDate, SiteID, 3, 1) + dbo.udf_DeliveryReportByRangeMealCount(DeliveryDate, SiteID, 3, 2) AS MilkCrateCount FROM vwDelivery WHERE DeliveryDate >= '" + DateTextBox.Text + "' AND DeliveryDate <= '" + Date5Label.Text + "' AND MealTypeName = 'Breakfast' AND DeliveryTypeName <> 'Cancelled' GROUP BY DeliveryDate, SiteRoute, SiteName, SiteID ORDER BY DeliveryDate, siteroute, SiteName";
        DataSet m_MilkCrateDataSet = GCFDGlobals.m_GCFDPlannerDatabaseLibrary.dbSelectDataSet(m_SQL);

        if (m_MilkCrateDataSet.Tables[0].Rows.Count > 0)
        {
            string previousDeliveryDate = Convert.ToDateTime(GCFDGlobals.dbGetValue(m_MilkCrateDataSet.Tables[0].Rows[0], "DeliveryDate")).ToString("MM/dd/yyyy");
            string previousSiteRoute    = GCFDGlobals.dbGetValue(m_MilkCrateDataSet.Tables[0].Rows[0], "SiteRoute");

            foreach (DataRow milkCrateDataRow in m_MilkCrateDataSet.Tables[0].Rows)
            {
                if (previousDeliveryDate != Convert.ToDateTime(GCFDGlobals.dbGetValue(milkCrateDataRow, "DeliveryDate")).ToString("MM/dd/yyyy"))
                {
                    while (labelCounter < 8)
                    {
                        labelName = "Date" + labelCounter + "Label";

                        this.label = this.Master.FindControl("MainContent").FindControl(labelName) as Label;

                        if (this.label.Text != previousDeliveryDate)
                        {
                            labelCounter = labelCounter + 1;
                        }
                        else
                        {
                            break;
                        }
                    }

                    previousDeliveryDate = Convert.ToDateTime(GCFDGlobals.dbGetValue(milkCrateDataRow, "DeliveryDate")).ToString("MM/dd/yyyy");

                    totalCrates = Math.Ceiling(Convert.ToDecimal(milkCount) / 50);

                    daysTotalMilkCrates = daysTotalMilkCrates + Convert.ToInt32(totalCrates);

                    totalWeeksMilkCrates = totalWeeksMilkCrates + daysTotalMilkCrates;

                    labelName = "WhiteMilkCrateCountDate" + labelCounter + "Label";

                    this.label = this.Master.FindControl("MainContent").FindControl(labelName) as Label;

                    this.label.Text = daysTotalMilkCrates.ToString();

                    labelCounter = labelCounter + 1;

                    daysTotalMilkCrates = 0;

                    milkCount = Convert.ToInt32(GCFDGlobals.dbGetValue(milkCrateDataRow, "MilkCrateCount"));

                    previousSiteRoute = GCFDGlobals.dbGetValue(milkCrateDataRow, "SiteRoute");
                }
                else if (previousSiteRoute != GCFDGlobals.dbGetValue(milkCrateDataRow, "SiteRoute"))
                {
                    totalCrates = Math.Ceiling(Convert.ToDecimal(milkCount) / 50);

                    daysTotalMilkCrates = daysTotalMilkCrates + Convert.ToInt32(totalCrates);

                    milkCount = Convert.ToInt32(GCFDGlobals.dbGetValue(milkCrateDataRow, "MilkCrateCount"));

                    previousSiteRoute = GCFDGlobals.dbGetValue(milkCrateDataRow, "SiteRoute");
                }
                else
                {
                    milkCount = milkCount + Convert.ToInt32(GCFDGlobals.dbGetValue(milkCrateDataRow, "MilkCrateCount"));
                }
            }

            totalCrates = Math.Ceiling(Convert.ToDecimal(milkCount) / 50);

            daysTotalMilkCrates = daysTotalMilkCrates + Convert.ToInt32(totalCrates);

            totalWeeksMilkCrates = totalWeeksMilkCrates + daysTotalMilkCrates;

            while (labelCounter < 8)
            {
                labelName = "Date" + labelCounter + "Label";

                this.label = this.Master.FindControl("MainContent").FindControl(labelName) as Label;

                if (this.label.Text != previousDeliveryDate)
                {
                    labelCounter = labelCounter + 1;
                }
                else
                {
                    break;
                }
            }

            labelName = "WhiteMilkCrateCountDate" + labelCounter + "Label";

            this.label = this.Master.FindControl("MainContent").FindControl(labelName) as Label;

            this.label.Text = daysTotalMilkCrates.ToString();

            WhiteMilkCrateCountTotalNeededLabel.Text = totalWeeksMilkCrates.ToString();

            startDate = Convert.ToDateTime(DateTextBox.Text);

            DateTime twoWeekdaysBefore = startDate.AddDays(-2);
            DateTime oneWeekdayBefore;

            if (twoWeekdaysBefore.DayOfWeek.ToString() == "Saturday")
            {
                twoWeekdaysBefore = startDate.AddDays(-4);

                oneWeekdayBefore = startDate.AddDays(-3);
            }
            else if (twoWeekdaysBefore.DayOfWeek.ToString() == "Sunday")
            {
                twoWeekdaysBefore = startDate.AddDays(-4);
                oneWeekdayBefore  = startDate.AddDays(-1);
            }
            else
            {
                twoWeekdaysBefore = startDate.AddDays(-2);
                oneWeekdayBefore  = startDate.AddDays(-1);
            }

            m_SQL = "SELECT DISTINCT SiteName, SiteRoute, DeliveryDate, dbo.udf_DeliveryReportByRangeMealCount(DeliveryDate, SiteID, 3, 1) + dbo.udf_DeliveryReportByRangeMealCount(DeliveryDate, SiteID, 3, 2) AS MilkCrateCount FROM vwDelivery WHERE DeliveryDate = '" + twoWeekdaysBefore + "' OR  DeliveryDate = '" + oneWeekdayBefore + "' AND MealTypeName = 'Breakfast' AND DeliveryTypeName <> 'Cancelled' GROUP BY DeliveryDate, SiteRoute, SiteName, SiteID ORDER BY DeliveryDate, siteroute, SiteName";
            m_MilkCrateDataSet = GCFDGlobals.m_GCFDPlannerDatabaseLibrary.dbSelectDataSet(m_SQL);

            milkCount            = 0;
            daysTotalMilkCrates  = 0;
            totalCrates          = 0;
            totalWeeksMilkCrates = 0;

            foreach (DataRow milkCrateDataRow in m_MilkCrateDataSet.Tables[0].Rows)
            {
                if (previousDeliveryDate != GCFDGlobals.dbGetValue(milkCrateDataRow, "DeliveryDate"))
                {
                    previousDeliveryDate = GCFDGlobals.dbGetValue(milkCrateDataRow, "DeliveryDate");

                    totalCrates = Math.Ceiling(Convert.ToDecimal(milkCount) / 50);

                    daysTotalMilkCrates = daysTotalMilkCrates + Convert.ToInt32(totalCrates);

                    totalWeeksMilkCrates = totalWeeksMilkCrates + daysTotalMilkCrates;

                    labelCounter = labelCounter + 1;

                    daysTotalMilkCrates = 0;

                    milkCount = Convert.ToInt32(GCFDGlobals.dbGetValue(milkCrateDataRow, "MilkCrateCount"));

                    previousSiteRoute = GCFDGlobals.dbGetValue(milkCrateDataRow, "SiteRoute");
                }
                else if (previousSiteRoute != GCFDGlobals.dbGetValue(milkCrateDataRow, "SiteRoute"))
                {
                    totalCrates = Math.Ceiling(Convert.ToDecimal(milkCount) / 50);

                    daysTotalMilkCrates = daysTotalMilkCrates + Convert.ToInt32(totalCrates);

                    milkCount = Convert.ToInt32(GCFDGlobals.dbGetValue(milkCrateDataRow, "MilkCrateCount"));

                    previousSiteRoute = GCFDGlobals.dbGetValue(milkCrateDataRow, "SiteRoute");
                }
                else
                {
                    milkCount = milkCount + Convert.ToInt32(GCFDGlobals.dbGetValue(milkCrateDataRow, "MilkCrateCount"));
                }
            }

            totalCrates = Math.Ceiling(Convert.ToDecimal(milkCount) / 50);

            daysTotalMilkCrates = daysTotalMilkCrates + Convert.ToInt32(totalCrates);

            totalWeeksMilkCrates = totalWeeksMilkCrates + daysTotalMilkCrates;

            WhiteNeededForWeekdaysBeforeLabel.Text = totalWeeksMilkCrates.ToString();
        }
    }