public Cancellation(int cancellationId, User user, Article article, int count, DateTime created) { this.cancellationId = cancellationId; this.user = user; this.article = article; this.count = count; this.created = created; }
public void Add(Article article, int count) { if (this.Contains(article)) { foreach (ArticleCount art in container) { if (art.Article.ArticleID == article.ArticleID) art.Count += count; } } else { this.container.Add(new ArticleCount(article, count)); } OnCartChanged(this, new CartChangedEventArgs(article, CartChangedEventArgs.Reason.Add)); }
public CartChangedEventArgs(Article article, Reason action) { this.Article = article; this.Action = action; }
public static string GetArticleButtonDesignXml(Article article) { string definition = ""; try { SqlConnection connection = new SqlConnection(ConnectionString); SqlCommand cmd = new SqlCommand("SELECT Definition FROM ButtonDesign WHERE ArticleID = " + article.ArticleID, connection); connection.Open(); SqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { definition = reader["Definition"].ToString(); } connection.Close(); } catch (Exception ex) { string errmsg = "Fehler beim Abrufen des Buttondesigns des Artikels '" + article.Name + "'.\n\n"; errmsg += "DatabaseHandler.GetArticleButtonDesignXml(article): " + ex.ToString(); throw new Exception(errmsg); } return definition; }
public static void SaveArticle(Article article) { try { string query = "UPDATE [Article] SET "; query += "Name = '" + article.Name + "',"; query += "Price = " + article.Price.ToString().Replace(",", ".") + ","; query += "DoPrint = '" + article.DoPrint.ToString() + "',"; query += "IsEnabled = '" + article.IsEnabled.ToString() + "',"; query += "IsVisible = '" + article.IsVisible.ToString() + "',"; query += "ProfileID = " + article.ProfileID + ","; query += "DepositID = " + (article.Deposit == null ? "-1" : article.Deposit.DepositID.ToString()) + ","; query += "Position = " + article.Position + ","; query += "IsDeleted = '" + article.IsDeleted.ToString() + "' "; query += "WHERE ArticleID = " + article.ArticleID; SqlConnection connection = new SqlConnection(ConnectionString); SqlCommand cmd = new SqlCommand(query, connection); connection.Open(); cmd.ExecuteNonQuery(); connection.Close(); } catch (SqlException ex) { foreach (SqlError err in ex.Errors) { switch (err.Number) { case SqllErrorNumbers.DupKey: throw new Exception("Diese Daten werden bereits verwendet."); } } } catch (Exception ex) { string errmsg = "Fehler beim Speichern des Artikels.\n\n"; errmsg += "DatabaseHandler.SaveArticle(article): " + ex.ToString(); throw new Exception(errmsg); } }
public static Article GetArticle(int articleId) { Article a = null; try { SqlConnection connection = new SqlConnection(ConnectionString); SqlCommand cmd = new SqlCommand("SELECT * FROM Article WHERE ArticleID = " + articleId, connection); connection.Open(); SqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { a = new Article(); a.ArticleID = Convert.ToInt32(reader["ArticleID"]); a.ProfileID = Convert.ToInt32(reader["ProfileID"]); a.Name = reader["Name"].ToString(); a.Price = Convert.ToDouble(reader["Price"]); a.DoPrint = Convert.ToBoolean(reader["DoPrint"]); a.IsEnabled = Convert.ToBoolean(reader["IsEnabled"]); a.IsVisible = Convert.ToBoolean(reader["IsVisible"]); a.Deposit = GetDeposit(GetArticleDepositID(a.ArticleID)); a.Position = Convert.ToInt32(reader["Position"]); a.Created = Convert.ToDateTime(reader["Created"]); } connection.Close(); } catch (Exception ex) { string errmsg = "Fehler beim Abrufen des Artikels.\n\n"; errmsg += "DatabaseHandler.GetArticle(articleId): " + ex.ToString(); throw new Exception(errmsg); } if (a == null) throw new Exception("Es existiert kein Artikel mit den angegebenen Kriterien (" + articleId + ")\n\nDatabaseHandler.GetArticle(profileID, articlename)"); return a; }
private static ObservableCollection<Article> GetArticles(int profileID, bool includeDeleted = false) { ObservableCollection<Article> articles = new ObservableCollection<Article>(); try { SqlConnection connection = new SqlConnection(ConnectionString); SqlCommand cmd = new SqlCommand("SELECT * FROM Article WHERE ProfileID = " + profileID + (includeDeleted ? "" : " AND IsDeleted = 'False'"), connection); connection.Open(); SqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { Article tmp = new Article(); tmp.ArticleID = Convert.ToInt32(reader["ArticleID"]); tmp.ProfileID = Convert.ToInt32(reader["ProfileID"]); tmp.Name = reader["Name"].ToString(); tmp.Price = Convert.ToDouble(reader["Price"]); tmp.DoPrint = Convert.ToBoolean(reader["DoPrint"]); tmp.IsEnabled = Convert.ToBoolean(reader["IsEnabled"]); tmp.IsVisible = Convert.ToBoolean(reader["IsVisible"]); tmp.Deposit = GetDeposit(GetArticleDepositID(tmp.ArticleID)); tmp.Created = Convert.ToDateTime(reader["Created"]); tmp.Position = Convert.ToInt32(reader["Position"]); articles.Add(tmp); } connection.Close(); } catch (Exception ex) { string errmsg = "Fehler beim Abrufen der Artikel.\n\n"; errmsg += "DatabaseHandler.GetArticles(profileID): " + ex.ToString(); throw new Exception(errmsg); } return articles; }
public ArticleCount this[Article article] { get { int counter = 0; foreach (ArticleCount ac in container) { if (article.ArticleID == ac.Article.ArticleID) return ac; counter++; } throw new Exception("Artikel ist nicht enthalten"); } }
public void Add(Article article) { Add(article, 1); }
public void Decrement(Article article) { foreach (ArticleCount a in container) { if (a.Article.ArticleID == article.ArticleID) { a.Count--; OnCartChanged(this, new CartChangedEventArgs(article, CartChangedEventArgs.Reason.Decrement)); return; } } }
public bool Remove(Article article) { foreach (ArticleCount a in container) if (a.Article.ArticleID == article.ArticleID) { container.Remove(a); OnCartChanged(this, new CartChangedEventArgs(article, CartChangedEventArgs.Reason.Remove)); return true; } return false; }
public bool Contains(Article article) { foreach (ArticleCount a in container) if (a.Article.ArticleID == article.ArticleID) { return true; } return false; }
public ArticleCount(Article article, int count) : this(article) { this.Count = count; }
public ArticleCount(Article article) { this.Article = article; this.Count = 1; this.PropertyChanged += ArticleCount_PropertyChanged; }