Пример #1
0
 public void Initialize()
 {
     using (BombasContext context = new BombasContext())
     {
         int currentVersion = 0;
         if (context.SchemaInfoes.Count() > 0)
         {
             currentVersion = context.SchemaInfoes.Max(x => x.Version);
         }
         BombasContextHelper mmSqliteHelper = new BombasContextHelper();
         while (currentVersion < RequiredDatabaseVersion)
         {
             currentVersion++;
             foreach (string migration in mmSqliteHelper.Migrations[currentVersion])
             {
                 context.Database.ExecuteSqlCommand(migration);
             }
             context.SchemaInfoes.Add(new SchemaInfo()
             {
                 Version = currentVersion
             });
             context.SaveChanges();
         }
     }
 }
Пример #2
0
        private void definePreco_Click(object sender, EventArgs e)
        {
            if (precoGasolina.Text.Length > 0)
            {
                using (var context = new BombasContext())
                {
                    Preco    novoPreco = new Preco();
                    DateTime data      = DateTime.Now;
                    novoPreco.valor = Convert.ToDecimal(precoGasolina.Text);
                    novoPreco.data  = data.ToString();

                    context.Precos.Add(novoPreco);

                    context.SaveChanges();
                }
            }
        }
Пример #3
0
        private void salvaVenda(string valor, int bombaId)
        {
            using (var context = new BombasContext())
            {
                Preco preco = fetchPreco();
                Bomba bomba = context.Bombas.Find(bombaId);

                Venda venda = new Venda();
                venda.bomba  = bomba;
                venda.preco  = preco;
                venda.litros = Convert.ToDecimal(valor) / preco.valor;

                context.Vendas.Add(venda);

                context.SaveChanges();
            }
        }
Пример #4
0
 public void Initialize()
 {
     using (BombasContext context = new BombasContext())
     {
         int currentVersion = 0;
         if (context.SchemaInfoes.Count() > 0)
             currentVersion = context.SchemaInfoes.Max(x => x.Version);
         BombasContextHelper mmSqliteHelper = new BombasContextHelper();
         while (currentVersion < RequiredDatabaseVersion)
         {
             currentVersion++;
             foreach (string migration in mmSqliteHelper.Migrations[currentVersion])
             {
                 context.Database.ExecuteSqlCommand(migration);
             }
             context.SchemaInfoes.Add(new SchemaInfo() { Version = currentVersion });
             context.SaveChanges();
         }
     }
 }
Пример #5
0
        private void salvaVenda(string valor, int bombaId)
        {
            using (var context = new BombasContext())
            {
                Preco preco = fetchPreco();
                Bomba bomba = context.Bombas.Find(bombaId);

                Venda venda = new Venda();
                venda.bomba = bomba;
                venda.preco = preco;
                venda.litros = Convert.ToDecimal(valor) / preco.valor;

                context.Vendas.Add(venda);

                context.SaveChanges();
            }
        }
Пример #6
0
        private void definePreco_Click(object sender, EventArgs e)
        {
            if (precoGasolina.Text.Length > 0)
            {
                using (var context = new BombasContext())
                {
                    Preco novoPreco = new Preco();
                    DateTime data = DateTime.Now;
                    novoPreco.valor = Convert.ToDecimal(precoGasolina.Text);
                    novoPreco.data = data.ToString();

                    context.Precos.Add(novoPreco);

                    context.SaveChanges();
                }

            }
        }