134 lines
4.5 KiB
C#
134 lines
4.5 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Drawing;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Forms;
|
|
using DAL;
|
|
using BLL;
|
|
using MLL;
|
|
using Modelo;
|
|
|
|
namespace IBRCAD
|
|
{
|
|
public partial class frm_recebimentovenda : Form
|
|
{
|
|
int pve_cod;
|
|
public frm_recebimentovenda()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
private void limpar()
|
|
{
|
|
dgv_parcelas.DataSource = null;
|
|
this.txtcodvenda.Text = "";
|
|
this.txtcliente.Text = "";
|
|
this.txtValor.Text = "";
|
|
this.dtp_data_venda.Value = DateTime.Now;
|
|
this.dt_recebimento.Value = DateTime.Now;
|
|
this.dtp_data_venda.Enabled = false;
|
|
this.dt_recebimento.Enabled = false;
|
|
this.btn_receber.Enabled = false;
|
|
}
|
|
private void orgcampos(DataGridView dg)
|
|
{
|
|
dg.Columns[0].Width = 80;
|
|
dg.Columns[0].HeaderText = "Cód.Venda";
|
|
dg.Columns[2].Width = 100;
|
|
dg.Columns[2].HeaderText = "Valor (R$)";
|
|
dg.Columns[3].Width = 100;
|
|
dg.Columns[3].HeaderText = "Recebido em :";
|
|
dg.Columns[4].Width = 100;
|
|
dg.Columns[4].HeaderText = "Data Vencimento";
|
|
|
|
|
|
dg.Columns[1].Visible = false;
|
|
}//organizar campos
|
|
|
|
private void frm_recebimentovenda_Load(object sender, EventArgs e)
|
|
{
|
|
this.btn_receber.Enabled = false;
|
|
|
|
}//load
|
|
|
|
private void btn_localizarcompra_Click(object sender, EventArgs e)
|
|
{
|
|
frm_consultavendas fc = new frm_consultavendas();
|
|
fc.ShowDialog();
|
|
if (fc.codigo != 0)
|
|
{
|
|
DALLconexao cx = new DALLconexao(DadosDaConexao.StringDeConexao);
|
|
BLLvenda bvenda = new BLLvenda(cx);
|
|
BLLCliente bcliente = new BLLCliente(cx);
|
|
ModeloVenda mvenda = bvenda.CarregaModeloVenda(fc.codigo);
|
|
txtcodvenda.Text = mvenda.Ven_cod.ToString();
|
|
dtp_data_venda.Value = mvenda.Ven_data;
|
|
txtValor.Text = mvenda.Ven_total.ToString();
|
|
ModeloCliente modeloc = bcliente.CarregaModeloCliente(mvenda.Cli_cod);
|
|
txtcliente.Text = modeloc.CliNome;
|
|
BLLparcelasvenda bparcelas = new BLLparcelasvenda(cx);
|
|
DataTable parcelas = bparcelas.localizar(mvenda.Ven_cod);
|
|
dgv_parcelas.DataSource = bparcelas.localizar(mvenda.Ven_cod);
|
|
this.orgcampos(dgv_parcelas);
|
|
MessageBox.Show("Para realizar o pagamento click 2 vezes na listagem abaixo","Realizando pagamento");
|
|
|
|
}
|
|
|
|
}//btn localizar compras
|
|
|
|
private void dgv_parcelas_CellClick(object sender, DataGridViewCellEventArgs e)
|
|
{
|
|
if (e.RowIndex >= 0 && dgv_parcelas.Rows[e.RowIndex].Cells[3].Value.ToString() == "")
|
|
{
|
|
this.btn_receber.Enabled = true;
|
|
this.pve_cod = Convert.ToInt32(dgv_parcelas.Rows[e.RowIndex].Cells[1].Value);
|
|
}
|
|
else
|
|
{
|
|
this.btn_receber.Enabled = false;
|
|
}
|
|
}//clicando 1 vez
|
|
|
|
private void btn_cancelar_Click(object sender, EventArgs e)
|
|
{
|
|
this.limpar();
|
|
}//cancelar
|
|
|
|
private void btn_receber_Click(object sender, EventArgs e)
|
|
{
|
|
DALLconexao cx = new DALLconexao(DadosDaConexao.StringDeConexao);
|
|
if (this.pve_cod == 0)
|
|
{
|
|
MessageBox.Show("Selecione a parcela a ser paga clicando na mesma na listagem");
|
|
}
|
|
else
|
|
{
|
|
|
|
BLLparcelasvenda bllp = new BLLparcelasvenda(cx);
|
|
int convenda = Convert.ToInt32(txtcodvenda.Text);
|
|
int pcocod = pve_cod;
|
|
DateTime data = dt_recebimento.Value;
|
|
bllp.EfetuaPagamentoParcelas(convenda, pcocod, data);
|
|
this.pve_cod = 0;
|
|
MessageBox.Show("Pagamento Realizado com Sucesso!", "Pagamento efetuado");
|
|
dgv_parcelas.DataSource = bllp.localizar(convenda);
|
|
this.orgcampos(dgv_parcelas);
|
|
//this.limpar();
|
|
}
|
|
}
|
|
|
|
private void btn_imprimir_Click(object sender, EventArgs e)
|
|
{
|
|
//printDGV.Print_DataGridView(dgv_parcelas);
|
|
}
|
|
|
|
private void pb_exit_Click(object sender, EventArgs e)
|
|
{
|
|
this.Close();
|
|
}
|
|
}
|
|
}
|