Exemplo n.º 1
0
        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();
        }
Exemplo n.º 2
0
        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();
        }
Exemplo n.º 3
0
        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();
        }
Exemplo n.º 4
0
        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();
        }
Exemplo n.º 5
0
        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();
        }
Exemplo n.º 6
0
        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);
        }
Exemplo n.º 7
0
        public DataTable SelectAll()
        {
            QueryLite query = new QueryLite(ConfigurationManager.ConnectionStrings["EbabobaConnectionString"].ConnectionString);

            query.Add($"select * from TransactionType");
            var returnValue = query.ExecuteAndGet();

            query.Clear();
            return(returnValue);
        }
Exemplo n.º 8
0
        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);
        }
Exemplo n.º 9
0
        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();
        }
Exemplo n.º 10
0
        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();
        }
Exemplo n.º 11
0
        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();
        }
Exemplo n.º 12
0
        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();
        }
Exemplo n.º 13
0
        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();
        }
Exemplo n.º 14
0
        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);
        }
Exemplo n.º 15
0
        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();
        }
Exemplo n.º 16
0
        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();
        }
Exemplo n.º 17
0
        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();
        }
Exemplo n.º 18
0
        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();
        }
Exemplo n.º 19
0
        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);
        }
Exemplo n.º 20
0
        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);
        }