예제 #1
0
        public void AddRemittance(Remittance model)
        {
            Remittances.Add(model);

            string sql = "INSERT INTO Remittance (Id,Date,Deposit,WithDrawal,Type,Summary,AccountId) "
                         + "VALUES(@Id,@Date,@Deposit,@WithDrawal,@Type,@Summary,@AccountId)";
            SQLiteCommand cmd = new SQLiteCommand(sql);

            cmd.Parameters.AddWithValue("@AccountId", model.AccountId.ToString());
            cmd.Parameters.AddWithValue("@Date", model.Date);
            cmd.Parameters.AddWithValue("@Deposit", model.Deposit);
            cmd.Parameters.AddWithValue("@Id", model.Id.ToString());
            cmd.Parameters.AddWithValue("@Summary", model.Summary);
            cmd.Parameters.AddWithValue("@Type", model.Type);
            cmd.Parameters.AddWithValue("@WithDrawal", model.WithDrawal);
            cmds.Add(cmd);
        }
예제 #2
0
        public List <Remittance> GetRemittances()
        {
            List <Remittance> result = new List <Remittance>();
            SQLiteConnection  conn   = null;

            try
            {
                conn = new SQLiteConnection(connectionStr);
                conn.Open();
                string           sql    = string.Format("SELECT * FROM Remittance");
                SQLiteCommand    cmd    = new SQLiteCommand(sql, conn);
                SQLiteDataReader reader = cmd.ExecuteReader();
                while (reader.Read())
                {
                    Remittance model = new Remittance();
                    model.Id         = Guid.Parse(reader.GetString(0));
                    model.Date       = reader.GetDateTime(1);
                    model.Deposit    = reader.GetDecimal(2);
                    model.WithDrawal = reader.GetDecimal(3);
                    model.Type       = reader.GetString(4);
                    model.Summary    = reader.GetString(5);
                    model.AccountId  = Guid.Parse(reader.GetString(6));
                    result.Add(model);
                }
                conn.Close();
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                if (conn != null)
                {
                    conn.Close();
                }
            }
            return(result);
        }