Пример #1
0
        public void InserePagamento(List <Pagamento> pagamentos)
        {
            conn = Conecta();
            MySqlCommand command = conn.CreateCommand();

            for (int i = 0; i < pagamentos.Count; i++)
            {
                Pagamento pagamento = pagamentos[i];
                try
                {
                    if (conn.State == ConnectionState.Closed)
                    {
                        conn.Open();
                    }

                    command.CommandText = "insert into tb_pagamento(id_venda, valor,forma_pagamento,quantidade_parcelas)" +
                                          " values(@id_venda,@valor,@forma_pagamento,@quantidade_parcelas)";

                    command.Parameters.AddWithValue("@id_venda", pagamento.Id_venda);
                    command.Parameters.AddWithValue("@valor", conversor.toDoubleDB(pagamento.Valor.ToString()));
                    command.Parameters.AddWithValue("@forma_pagamento", pagamento.Forma_pagamento);
                    command.Parameters.AddWithValue("@quantidade_parcelas", pagamento.Quantidade_parcelas);

                    command.ExecuteNonQuery();

                    conn.Close();
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Não foi possivel registrar lancamento, desfazendo alterações" + ex.Message, "Erro");
                }
                finally
                {
                    if (conn.State == ConnectionState.Open)
                    {
                        Desconecta();
                    }
                }
            }
        }
Пример #2
0
 public RegraDeNegocioController(Venda venda, List <ItemVenda> itens, Pagamento pagamento)
 {
     this.venda     = venda;
     this.itens     = itens;
     this.pagamento = pagamento;
 }