Пример #1
0
        public static List <MealItemReportItem> GetMenuItemsByDateRange(DateTime startDate, DateTime endDate, Boolean includeAlaCarte = true)
        {
            try
            {
                List <MealItemReportItem> retVals = new List <MealItemReportItem>();

                using (TransactionScope scope = new TransactionScope())
                {
                    using (SqlConnection conn = new SqlConnection(WebConfigurationManager.ConnectionStrings["WebModules"].ConnectionString))
                    {
                        using (SqlCommand cmd = new SqlCommand("hcc_MenuItemsByDateRange", conn))
                        {
                            conn.Open();

                            SqlParameter prm1 = new SqlParameter("@start", SqlDbType.DateTime);
                            prm1.Value = startDate;
                            SqlParameter prm2 = new SqlParameter("@end", SqlDbType.DateTime);
                            prm2.Value = endDate;
                            SqlParameter prm3 = new SqlParameter("@includeAlaCarte", SqlDbType.Bit);
                            prm3.Value      = includeAlaCarte;
                            cmd.CommandType = CommandType.StoredProcedure;
                            cmd.Parameters.Add(prm1);
                            cmd.Parameters.Add(prm2);
                            cmd.Parameters.Add(prm3);

                            SqlDataReader t = cmd.ExecuteReader();

                            if (t != null)
                            {
                                // get from reader
                                retVals = MealItemReportItem.GetFromReader(t);
                            }
                            else
                            {
                                retVals = null;
                            }

                            cmd.Dispose();
                            conn.Close();
                            conn.Dispose();
                        }
                    }
                    scope.Complete();
                }

                if (retVals != null)
                {
                    return(retVals);
                }
                else
                {
                    throw new Exception("GetMenuItemsByDateRange could not be returned.");
                }
            }
            catch
            {
                throw;
            }
        }
Пример #2
0
        public static List <MealItemReportItem> GetMenuItemsByOrderNumber(string orderNumber, DateTime deliveryDate)
        {
            try
            {
                List <MealItemReportItem> retVals = null;

                using (TransactionScope scope = new TransactionScope())
                {
                    using (SqlConnection conn = new SqlConnection(WebConfigurationManager.ConnectionStrings["WebModules"].ConnectionString))
                    {
                        using (SqlCommand cmd = new SqlCommand("hcc_MenuItemsByOrderNumber", conn))
                        {
                            conn.Open();

                            SqlParameter prm1 = new SqlParameter("@orderNumber", SqlDbType.VarChar);
                            prm1.Value = orderNumber;
                            SqlParameter prm2 = new SqlParameter("@deliveryDate", SqlDbType.DateTime);
                            prm2.Value      = deliveryDate;
                            cmd.CommandType = CommandType.StoredProcedure;
                            cmd.Parameters.Add(prm1);
                            cmd.Parameters.Add(prm2);

                            SqlDataReader t = cmd.ExecuteReader();

                            if (t != null)
                            {   // get from reader
                                retVals = MealItemReportItem.GetFromReader(t);
                            }
                            else
                            {
                                retVals = null;
                            }

                            cmd.Dispose();
                            conn.Close();
                            conn.Dispose();
                        }
                    }
                    scope.Complete();
                }

                if (retVals != null)
                {
                    return(retVals);
                }
                else
                {
                    throw new Exception("GetMenuItemsByDateRange could not be returned.");
                }
            }
            catch
            {
                throw;
            }
        }
        private static CustCalDay AgregateByDay(CustCalDay ccd, MealItemReportItem reportItem, bool init)
        {
            switch ((Enums.MealTypes)reportItem.MealTypeId)
            {
            case Enums.MealTypes.BreakfastEntree:
                ccd.Breakfast += AddAsEntree(reportItem);
                break;

            case Enums.MealTypes.BreakfastSide:
                ccd.Breakfast += AddAsSide(reportItem);
                break;

            case Enums.MealTypes.Snack:
                ccd.Snack += AddAsEntree(reportItem);
                break;

            case Enums.MealTypes.Dessert:
                ccd.Dessert += AddAsEntree(reportItem);
                break;

            case Enums.MealTypes.DinnerEntree:
                ccd.Dinner += AddAsEntree(reportItem);
                break;

            case Enums.MealTypes.DinnerSide:
                ccd.Dinner += AddAsSide(reportItem);
                break;

            case Enums.MealTypes.LunchEntree:
                ccd.Lunch += AddAsEntree(reportItem);
                break;

            case Enums.MealTypes.LunchSide:
                ccd.Lunch += AddAsSide(reportItem);
                break;

            case Enums.MealTypes.OtherEntree:
            case Enums.MealTypes.ChildEntree:
            case Enums.MealTypes.Beverage:
            case Enums.MealTypes.Salad:
            case Enums.MealTypes.Soup:
            case Enums.MealTypes.Supplement:
            case Enums.MealTypes.Goods:
            case Enums.MealTypes.Miscellaneous:
                ccd.Other += AddAsEntree(reportItem);
                break;

            case Enums.MealTypes.OtherSide:
            case Enums.MealTypes.ChildSide:
                ccd.Other += AddAsSide(reportItem);
                break;
            }
            return(ccd);
        }
        private static string AddAsSide(MealItemReportItem reportItem)
        {
            var itemName = ServedWith /*link Sides to Entree*/ + reportItem.ItemName;

            if (!string.IsNullOrWhiteSpace(reportItem.Prefs))
            {
                itemName += " - " + reportItem.Prefs;
            }

            return(itemName);
        }
        private static string AddAsEntree(MealItemReportItem reportItem)
        {
            var itemName = MealDelimiter /*support several items per day*/ + reportItem.ItemName;

            if (!string.IsNullOrWhiteSpace(reportItem.Prefs))
            {
                itemName += " - " + reportItem.Prefs;
            }

            return(itemName);
        }
Пример #6
0
        public static List <MealItemReportItem> GetFromReader(SqlDataReader reader)
        {
            try
            {
                List <MealItemReportItem> retVals = new List <MealItemReportItem>();

                if (reader.HasRows)
                {
                    while (reader.Read())
                    {
                        MealItemReportItem retVal = new MealItemReportItem();

                        retVal.OrderNumber   = reader["OrderNumber"].ToString();
                        retVal.ItemName      = reader["ItemName"].ToString();
                        retVal.MealTypeName  = reader["MealTypeName"].ToString();
                        retVal.MealSizeName  = reader["MealSizeName"].ToString();
                        retVal.Quantity      = int.Parse(reader["Quantity"].ToString());
                        retVal.DayNum        = int.Parse(reader["DayNum"].ToString());
                        retVal.Prefs         = reader["Prefs"].ToString();
                        retVal.ParentType    = reader["ParentType"].ToString();
                        retVal.ParentTypeId  = int.Parse(reader["ParentTypeId"].ToString());
                        retVal.ParentId      = int.Parse(reader["ParentId"].ToString());
                        retVal.MealTypeId    = int.Parse(reader["MealTypeId"].ToString());
                        retVal.MenuItemId    = int.Parse(reader["MenuItemId"].ToString());
                        retVal.MealSizeId    = int.Parse(reader["MealSizeId"].ToString());
                        retVal.DeliveryDate  = DateTime.Parse(reader["DeliveryDate"].ToString());
                        retVal.CartItemId    = int.Parse(reader["CartItemId"].ToString());
                        retVal.UserProfileId = int.Parse(reader["UserProfileId"].ToString());
                        retVal.PlanId        = int.Parse(reader["PlanId"].ToString());
                        retVal.PlanName      = reader["PlanName"].ToString();
                        retVal.RowId         = int.Parse(reader["RowId"].ToString());

                        retVal.CartId = int.Parse(reader["CartId"].ToString());
                        if (reader["IsFamilyStyle"].ToString() != "")
                        {
                            retVal.IsFamilyStyle = Convert.ToBoolean(reader["IsFamilyStyle"].ToString());
                        }
                        else
                        {
                            retVal.IsFamilyStyle = false;
                        }
                        retVals.Add(retVal);
                    }

                    reader.Close();
                }

                return(retVals);
            }
            catch (Exception)
            {
                throw;
            }
        }