public void Delete() { QueryLite query = new QueryLite(ConfigurationManager.ConnectionStrings["EbabobaConnectionString"].ConnectionString); query.Add($"Delete from History where HistoryId = @HistoryId"); query.AddParameter("@HistoryId", this.HistoryId); query.Execute(); query.Clear(); }
public void Delete() { QueryLite query = new QueryLite(ConfigurationManager.ConnectionStrings["EbabobaConnectionString"].ConnectionString); query.Add($"Delete from TransactionType where TransactionTypeId = @TransactionTypeId"); query.AddParameter("@TransactionTypeId", this.TransactionTypeId); query.Execute(); query.Clear(); }
public void Delete() { QueryLite query = new QueryLite(ConfigurationManager.ConnectionStrings["EbabobaConnectionString"].ConnectionString); query.Add($"Delete from Schedule where ScheduleId = @ScheduleId"); query.AddParameter("@ScheduleId", this.ScheduleId); query.Execute(); query.Clear(); }
public DataTable SelectAll() { QueryLite query = new QueryLite(ConfigurationManager.ConnectionStrings["EbabobaConnectionString"].ConnectionString); query.Add($"select * from TransactionType"); var returnValue = query.ExecuteAndGet(); query.Clear(); return(returnValue); }
public DataTable SelectAllIncome() { QueryLite query = new QueryLite(ConfigurationManager.ConnectionStrings["EbabobaConnectionString"].ConnectionString); query.Add($"select * from History where IsIncome = 1"); var returnValue = query.ExecuteAndGet(); query.Clear(); return(returnValue); }
public DataTable SelectByCardId(string cardId) { QueryLite query = new QueryLite(ConfigurationManager.ConnectionStrings["EbabobaConnectionString"].ConnectionString); query.Add($"select * from Schedule where CardId = {cardId}"); var returnValue = query.ExecuteAndGet(); query.Clear(); return(returnValue); }
public void Insert() { QueryLite query = new QueryLite(ConfigurationManager.ConnectionStrings["EbabobaConnectionString"].ConnectionString); query.Add("insert into Card"); query.AddInsertValues(new List <string>() { this.Name, this.CardId, this.CurrencyId }); query.Execute(); query.Clear(); }
public int SelectTypesCount() { QueryLite query = new QueryLite(ConfigurationManager.ConnectionStrings["EbabobaConnectionString"].ConnectionString); query.Add($"select Count(TransactionTypeId) from TransactionType"); var returnValue = query.ExecuteAndGet(); query.Clear(); int count = returnValue.Rows.Count; return(count); }
public Currency(string id) { QueryLite query = new QueryLite(ConfigurationManager.ConnectionStrings["EbabobaConnectionString"].ConnectionString); query.Add($"select * from Currency where @CurrencyId = {id}"); query.AddParameter("CurrencyId", id.ToString()); var dt = query.ExecuteAndGet(); this.CurrencyId = id; this.Name = dt.Rows[0]["Name"].ToString(); query.Clear(); }
public void Insert() { QueryLite query = new QueryLite(ConfigurationManager.ConnectionStrings["EbabobaConnectionString"].ConnectionString); query.Add("insert into Schedule"); query.AddInsertValues(new List <string>() { this.CardId, this.Date, this.Frequency, this.Sum, this.TypeId, this.IsIncome }); query.Execute(); query.Clear(); }
public void Insert() { QueryLite query = new QueryLite(ConfigurationManager.ConnectionStrings["EbabobaConnectionString"].ConnectionString); query.Add("insert into TransactionType"); query.AddInsertValues(new List <string>() { this.Name, this.IsIncome }); query.Execute(); query.Clear(); }
public TransactionType(string id) { QueryLite query = new QueryLite(ConfigurationManager.ConnectionStrings["EbabobaConnectionString"].ConnectionString); query.Add($"select * from TransactionType where @TransactionTypeId = {id}"); query.AddParameter("TransactionTypeId", id.ToString()); var dt = query.ExecuteAndGet(); this.TransactionTypeId = id; this.Name = dt.Rows[0]["Name"].ToString(); this.IsIncome = dt.Rows[0]["IsIncome"].ToString(); query.Clear(); }
public void Update() { QueryLite query = new QueryLite(ConfigurationManager.ConnectionStrings["EbabobaConnectionString"].ConnectionString); Dictionary <string, string> updates = new Dictionary <string, string>(); updates.Add("Name", this.Name); query.Add("update cr"); query.AddUpdates(updates); query.Add("from Currency cr where CurrencyId = @CurrencyId"); query.AddParameter("@CurrencyId", this.CurrencyId); query.Execute(); query.Clear(); }
public void Update() { QueryLite query = new QueryLite(ConfigurationManager.ConnectionStrings["EbabobaConnectionString"].ConnectionString); Dictionary <string, string> updates = new Dictionary <string, string>(); updates.Add("Name", this.Name); updates.Add("IsIncome", this.IsIncome); query.Add("update tt"); query.AddUpdates(updates); query.Add("from TransactionType tt where TransactionTypeId = @TransactionTypeId"); query.AddParameter("@TransactionTypeId", this.TransactionTypeId); query.Execute(); query.Clear(); }
public Schedule(string id) { QueryLite query = new QueryLite(ConfigurationManager.ConnectionStrings["EbabobaConnectionString"].ConnectionString); query.Add($"select * from Schedule where ScheduleId = {id}"); query.AddParameter("ScheduleId", id.ToString()); var dt = query.ExecuteAndGet(); this.ScheduleId = id; this.CardId = dt.Rows[0]["CardId"].ToString(); this.Date = dt.Rows[0]["Date"].ToString(); this.Frequency = dt.Rows[0]["Frequency"].ToString(); this.IsIncome = dt.Rows[0]["IsIncome"].ToString(); this.Sum = dt.Rows[0]["Sum"].ToString(); this.TypeId = dt.Rows[0]["TypeId"].ToString(); query.Clear(); }
public History(string id) { QueryLite query = new QueryLite("*Connection string here*"); query.Add($"select * from History where @id = {id}"); query.AddParameter("id", id.ToString()); var dt = query.ExecuteAndGet(); this.HistoryId = id; this.CardId = dt.Rows[0]["CardId"].ToString(); this.Date = dt.Rows[0]["Date"].ToString(); this.IsIncome = dt.Rows[0]["IsIncome"].ToString(); this.Sum = dt.Rows[0]["Sum"].ToString(); this.TypeId = dt.Rows[0]["TypeId"].ToString(); this.CurrencyId = dt.Rows[0]["CurrencyId"].ToString(); query.Clear(); }
public DataTable GetTransactionsInfo(bool outcome, bool income, DateTime?dateBegin, DateTime?dateEnd, object type, object currency) { QueryLite query = new QueryLite(ConfigurationManager.ConnectionStrings["EbabobaConnectionString"].ConnectionString); query.Add($"select tt.Name 'Тип', concat((case h.IsIncome when 1 then '+' else '-' end), h.Sum) 'Cумма', c.Name 'Валюта', h.Date 'Дата' from History h " + $"join Currency c on h.CurrencyId = c.CurrencyId " + $"join TransactionType tt on tt.TransactionTypeId = h.TypeId "); var wheres = new Dictionary <string, string>(); if (type != null) { wheres.Add("h.TypeId", type.ToString()); } if (currency != null) { wheres.Add("h.Currencyid", currency.ToString()); } if (dateEnd != null) { query.Add($" and '{dateEnd.ToString()}' > h.Date"); } if (dateBegin != null) { query.Add($" and '{dateBegin.ToString()}' < h.Date"); } if (outcome && income) { query.Add(" and h.IsIncome in (1, 0)"); } else if (!outcome && income) { query.Add(" and h.IsIncome = 1"); } else if (outcome && !income) { query.Add(" and h.IsIncome = 0"); } query.AddWheres(wheres); var returnValue = query.ExecuteAndGet(); query.Clear(); return(returnValue); }
public Dictionary <string, double> GetHistoryByCard(string cardId, bool isIncome) { Dictionary <string, double> cardHistory = new Dictionary <string, double>(); QueryLite query = new QueryLite(ConfigurationManager.ConnectionStrings["EbabobaConnectionString"].ConnectionString); query.Add($"select Sum(Sum) as Sum, Date from History where CardId = @CardId and IsIncome = @IsIncome group by Date order by Date"); query.AddParameter("@CardId", cardId); query.AddParameter("@isIncome", isIncome ? "1" : "0"); var dt = query.ExecuteAndGet(); foreach (DataRow row in dt.Rows) { cardHistory.Add(Convert.ToDateTime(row["Date"].ToString()).ToShortDateString(), double.Parse(row["Sum"].ToString())); } query.Clear(); return(cardHistory); }
public void Update() { QueryLite query = new QueryLite(ConfigurationManager.ConnectionStrings["EbabobaConnectionString"].ConnectionString); Dictionary <string, string> updates = new Dictionary <string, string>(); updates.Add("CardId", this.CardId); updates.Add("Date", this.Date); updates.Add("IsIncome", this.IsIncome); updates.Add("Sum", this.Sum); updates.Add("TypeId", this.TypeId); updates.Add("CurrencyId", this.CurrencyId); query.Add("update hs"); query.AddUpdates(updates); query.Add("from History hs where HistoryId = @HistoryId"); query.AddParameter("@HistoryId", this.HistoryId); query.Execute(); query.Clear(); }
public void Update() { QueryLite query = new QueryLite(ConfigurationManager.ConnectionStrings["EbabobaConnectionString"].ConnectionString); Dictionary <string, string> updates = new Dictionary <string, string>(); updates.Add("CardId", this.CardId); updates.Add("Date", this.Date); updates.Add("Frequency", this.Frequency); updates.Add("IsIncome", this.IsIncome); updates.Add("Sum", this.Sum); updates.Add("TypeId", this.TypeId); query.Add("update cr"); query.AddUpdates(updates); query.Add("from Schedule cr where ScheduleId = @ScheduleId"); query.AddParameter("@ScheduleId", this.ScheduleId); query.Execute(); query.Clear(); }