public static void Excluir(int cod)
 {
     using (Context context = new Context())
     {
         Pagamento pag = context.Pagamentos.First(p => p.ID == cod);
         context.Pagamentos.Remove(pag);
         context.SaveChanges();
     }
 }
 public static void Alterar(int cod, string nome)
 {
     using (Context context = new Context())
     {
         Pagamento pag = context.Pagamentos.First(p => p.ID == cod);
         pag.Forma = nome.ToUpper();
         context.SaveChanges();
     }
 }
 public static void Excluir(int cod)
 {
     using (Context context = new Context())
     {
         Cliente cliente = context.Clientes.First(p => p.ID == cod);
         context.Clientes.Remove(cliente);
         context.SaveChanges();
     }
 }
 public static void Excluir(int cod)
 {
     using (Context context = new Context())
     {
         Produtora prod = context.Produtoras.First(p => p.ID == cod);
         context.Produtoras.Remove(prod);
         context.SaveChanges();
     }
 }
 public static void Criar(string nome)
 {
     using (var context = new Context())
     {
         Pagamento pag = new Pagamento();
         pag.Forma = nome.ToUpper();
         context.Pagamentos.Add(pag);
         context.SaveChanges();
     }
 }
 public static void Alterar(int cod, string nome, string pais)
 {
     using (Context context = new Context())
     {
         Produtora prod = context.Produtoras.First(p => p.ID == cod);
         prod.Nome = nome.ToUpper(); ;
         prod.Pais = pais.ToUpper(); ;
         context.SaveChanges();
     }
 }
 public static void Criar(string nome, string pais)
 {
     using (var context = new Context())
     {
         Produtora prod = new Produtora();
         prod.Nome = nome.ToUpper();
         prod.Pais = pais.ToUpper();
         context.Produtoras.Add(prod);
         context.SaveChanges();
     }
 }
예제 #8
0
 public static void AtualizarEstoque(int cod, int qtd)
 {
     int nova_qtd;
     using (Context context = new Context())
     {
         Item itens = context.Itens.First(p => p.Jogo_ID == cod);
         nova_qtd = getQtd(cod) - qtd;
         itens.Qtde = nova_qtd;
         context.SaveChanges();
     }
 }
 public static void Excluir(int cod)
 {
     using (Context context = new Context())
     {
         Jogo jogo = context.Jogos.First(p => p.ID == cod);
         Item item = context.Itens.First(p => p.Jogo_ID == cod);
         context.Itens.Remove(item);
         context.Jogos.Remove(jogo);
         context.SaveChanges();
     }
 }
 public static void Alterar(int cod, string nome, string tel, string end, string cidade, string cep, string rg)
 {
     using (Context context = new Context())
     {
         Cliente cliente = context.Clientes.First(p => p.ID == cod);
         cliente.Nome = nome.ToUpper(); ;
         cliente.RG = rg.ToUpper(); ;
         cliente.Telefone = tel.ToUpper();
         cliente.CEP = cep.ToUpper(); ;
         cliente.Cidade = cidade.ToUpper();
         cliente.Endereco = end.ToUpper();
         context.SaveChanges();
     }
 }
 public static void Alterar(int cod, string nome, int prod, int qtd, double preco, string genero, string plat)
 {
     using (Context context = new Context())
     {
         Jogo jogo = context.Jogos.First(p => p.ID == cod);
         jogo.Nome = nome.ToUpper(); ;
         jogo.Plataforma = plat.ToUpper(); ;
         jogo.Genero = genero.ToUpper();
         jogo.Preco = preco;
         jogo.Produtora_ID = prod;
         Item item = context.Itens.First(i => i.Jogo_ID == cod);
         item.Qtde = qtd;
         context.SaveChanges();
     }
 }
 public static void Criar(string nome, string tel, string end, string cidade, string cep, string rg)
 {
     using (var context = new Context())
     {
         Cliente cli = new Cliente
         {
             Nome = nome.ToUpper(),
             RG = rg.ToUpper(),
             Telefone = tel.ToUpper(),
             Endereco = end.ToUpper(),
             CEP = cep.ToUpper(),
             Cidade = cidade.ToUpper()
         };
         context.Clientes.Add(cli);
         context.SaveChanges();
     }
 }
 public static void Vender(int _cod, int _jogo, int _cliente, int _pagamento, int _qtd, double _total, double _preco)
 {
     using (var context = new Context())
     {
         Venda venda = new Venda
         {
             CodVenda = _cod,
             Jogo_ID = _jogo,
             Cliente_ID = _cliente,
             Pagamento_ID = _pagamento,
             Qtde = _qtd,
             Preco = _preco,
             Total = _total
         };
         context.Vendas.Add(venda);
         context.SaveChanges();
         Estoque.AtualizarEstoque(_jogo,_qtd);
     }
 }
 public static void Criar(string nome, int prod, string plat, string genero, double preco, int qtd)
 {
     using (var context = new Context())
     {
         Jogo jogo = new Jogo
         {
             Nome = nome.ToUpper(),
             Plataforma = plat.ToUpper(),
             Genero = genero.ToUpper(),
             Preco = preco,
             Produtora_ID = prod
         };
         Item item = new Item()
         {
             Jogo_ID = jogo.ID,
             Qtde = qtd
         };
         context.Jogos.Add(jogo);
         context.Itens.Add(item);
         context.SaveChanges();
     }
 }