Example #1
0
        public static Cart GetUserCancellationSummary(Profile profile, User user)
        {
            Cart c = new Cart();

            try
            {
                SqlConnection connection = new SqlConnection(ConnectionString);
                SqlCommand cmd = new SqlCommand("SELECT [Artikel],[Anzahl] FROM [KASSE].[dbo].[vCancellationSummaryUserDetailed] WHERE Benutzer = '" + user.Username + "' AND Veranstaltung = '" + profile.Name + "' ORDER BY Summe DESC", connection);
                connection.Open();
                SqlDataReader reader = cmd.ExecuteReader();
                while (reader.Read())
                {
                    ArticleCount ac = new ArticleCount(GetArticle(profile.ProfileID, reader["Artikel"].ToString()), Convert.ToInt32(reader["Anzahl"]));
                    c.Add(ac);
                }
                connection.Close();
            }
            catch (Exception ex)
            {
                LogWriter.Write(ex, LOGFILE_NAME);
                string errmsg = "Fehler beim Abrufen der Benutzerstornos.\n\n";
                errmsg += "DatabaseHandler.GetUserCancellationSummary(profile, user): " + ex.Message;
                throw new Exception(errmsg);
            }

            return c;
        }
Example #2
0
File: Cart.cs Project: fhoner/Kasse
 public void Add(ArticleCount articleCount)
 {
     Add(articleCount.Article, articleCount.Count);
 }
Example #3
0
        private string FormatItem(ArticleCount a)
        {
            int maxCountLength = 3;
            int maxPriceLength = 3;
            int spacesToName = 3;
            string result = "";

            // spaces to count
            for (int i = 0; i < maxCountLength - a.Count.ToString().Length; i++) result += " ";

            // count
            result += a.Count.ToString() + "x";

            // spaces to price
            for (int i = 0; i < maxPriceLength - ((int)a.Article.Price).ToString().Length; i++) result += " ";

            // price
            result += string.Format("{0:0.00}", a.Article.Price);

            // spaces to name
            for (int i = 0; i < spacesToName; i++) result += " ";

            // name
            result += a.Article.Name;

            return result;
        }