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; } }
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; } }