Exemple #1
0
 public void gravar()
 {
     if (validacao())
     {
         MySqlConnection con = new MySqlConnection(Config.Conexao);
         string          sql = "insert into parcela_pagar(id_conta_pagar,valor,data_vencimento,situacao) values(@a,@b,@c,@d)";
         MySqlCommand    cmd = new MySqlCommand(sql, con);
         cmd.Parameters.AddWithValue("@a", conta.id_conta_pagar);
         cmd.Parameters.AddWithValue("@b", Convert.ToDecimal(txtvalor.Text));
         cmd.Parameters.AddWithValue("@c", txtdata.Value);
         cmd.Parameters.AddWithValue("@d", "ABERTA");
         con.Open();
         cmd.ExecuteNonQuery();
         cmd.Parameters.Clear();
         string sit = "";
         if (!conta.situacao.Equals("CANCELADA"))
         {
             sit = ", situacao='ABERTA'";
         }
         sql             = "update conta_pagar set valor_total=valor_total+" + Convert.ToDecimal(txtvalor.Text) + sit + " where id_conta_pagar =" + conta.id_conta_pagar;
         cmd.CommandText = sql;
         cmd.ExecuteNonQuery();
         form.filtragem();
         MessageBox.Show("Parcela adicionada com sucesso", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
         con.Close();
         this.Close();
     }
 }
Exemple #2
0
 private void button4_Click(object sender, EventArgs e)
 {
     if (gerar)
     {
         DateTime        venc  = DateTime.Parse(tabela.Rows[tabela.RowCount - 1].Cells[2].Value.ToString());
         MySqlConnection con   = new MySqlConnection(Config.Conexao);
         String          query = "insert into conta_pagar(data_emissao,credor,num_dias,valor_total,num_parcelas,entrada,data_vencimento,situacao,documento,id_fornecedor,valor_pago) values(@a,@b,@c,@d,@e,@f,@g,@h,@i,@j,@k)";
         MySqlCommand    cmd   = new MySqlCommand(query, con);
         decimal         total = Convert.ToDecimal(txtvalortotal.Text);
         con.Open();
         cmd.Parameters.AddWithValue("@a", txtdataemissao.Value);
         cmd.Parameters.AddWithValue("@b", txtcredor.Text);
         cmd.Parameters.AddWithValue("@c", Convert.ToInt32(txtnumdias.Text));
         cmd.Parameters.AddWithValue("@d", total);
         cmd.Parameters.AddWithValue("@e", Convert.ToInt32(txtnumparcelas.Value));
         cmd.Parameters.AddWithValue("@f", entrada);
         cmd.Parameters.AddWithValue("@g", venc);
         if (entrada != total)
         {
             cmd.Parameters.AddWithValue("@h", "ABERTA");
         }
         else
         {
             cmd.Parameters.AddWithValue("@h", "QUITADA");
         }
         cmd.Parameters.AddWithValue("@i", txtdocumento.Text);
         int?forn = null;
         if (fornecedor != null)
         {
             forn = fornecedor.id_fornecedor;
         }
         cmd.Parameters.AddWithValue("@j", forn);
         cmd.Parameters.AddWithValue("@k", entrada);
         cmd.ExecuteNonQuery();
         cmd.Parameters.Clear();
         cmd.CommandText = "select max(id_conta_pagar) from conta_pagar";
         int id = Convert.ToInt32(cmd.ExecuteScalar().ToString());
         cmd.CommandText = "insert into parcela_pagar(id_conta_pagar,valor,data_vencimento,situacao) values(@a,@b,@c,@d)";
         for (int i = 0; i < tabela.RowCount; i++)
         {
             cmd.Parameters.AddWithValue("@a", id);
             cmd.Parameters.AddWithValue("@b", Convert.ToDecimal(tabela.Rows[i].Cells[1].Value.ToString()));
             cmd.Parameters.AddWithValue("@c", DateTime.Parse(tabela.Rows[i].Cells[2].Value.ToString()));
             string situacao = tabela.Rows[i].Cells[tabela.ColumnCount - 1].Value.ToString();
             cmd.Parameters.AddWithValue("@d", situacao);
             cmd.ExecuteNonQuery();
             cmd.Parameters.Clear();
         }
         gerar = false;
         tela.filtragem();
         MessageBox.Show("Conta cadastrada com sucesso", "Atenção", MessageBoxButtons.OK, MessageBoxIcon.Information);
         con.Close();
     }
 }
Exemple #3
0
        public void verificar_pagamento()
        {
            bool cond = true;

            for (int i = 0; i < tabela.RowCount; i++)
            {
                string val = tabela.Rows[i].Cells[3].Value.ToString();
                if (!val.Equals("QUITADA"))
                {
                    cond = false;
                }
            }
            if (cond)
            {
                string          sql = "update conta_pagar set situacao='QUITADA' where id_conta_pagar=" + conta.id_conta_pagar;
                MySqlConnection con = new MySqlConnection(Config.Conexao);
                MySqlCommand    cmd = new MySqlCommand(sql, con);
                con.Open();
                cmd.ExecuteNonQuery();
                con.Close();
                form.filtragem();
            }
        }