243 lines
8.5 KiB
C#
243 lines
8.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 BLL;
|
|
using DAL;
|
|
using MLL;
|
|
using Modelo;
|
|
|
|
namespace IBRCAD
|
|
{
|
|
public partial class frm_consultacompra : Form
|
|
{
|
|
public int codigo = 0;
|
|
public frm_consultacompra()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
private void limparCampos()
|
|
{
|
|
this.dgvDados.DataSource = null;
|
|
this.dgv_itens.DataSource = null;
|
|
this.dgv_parcelas.DataSource = null;
|
|
this.txt_fornome.Text = "";
|
|
this.lbl_codfor.Text = "Infome o código do fornecedor";
|
|
this.dtp_final.Value = DateTime.Now;
|
|
this.dtp_inicial.Value = DateTime.Now;
|
|
}//limpar campos
|
|
private void orgcampos(DataGridView dg, int op)
|
|
{
|
|
try
|
|
{
|
|
if (op == 1)
|
|
{
|
|
dg.Columns[0].Width = 60;
|
|
dg.Columns[0].HeaderText = "Código da compra";
|
|
dg.Columns[1].Width = 100;
|
|
dg.Columns[1].HeaderText = "Data da Compra";
|
|
dg.Columns[2].Width = 100;
|
|
dg.Columns[2].HeaderText = "Nota Fiscal";
|
|
dg.Columns[3].Width = 60;
|
|
dg.Columns[3].HeaderText = "Parcelas";
|
|
dg.Columns[4].Width = 60;
|
|
dg.Columns[4].HeaderText = "Total";
|
|
dg.Columns[5].Width = 60;
|
|
dg.Columns[5].HeaderText = "Status";
|
|
dg.Columns[6].Visible = false;
|
|
dg.Columns[7].Visible = false;
|
|
dg.Columns[8].Width = 100;
|
|
dg.Columns[8].HeaderText = "Nome fornecedor";
|
|
|
|
}//organizar fornecedor
|
|
if (op == 2)
|
|
{
|
|
dg.Columns[0].Width = 100;
|
|
dg.Columns[0].HeaderText = "Cód. Itens";
|
|
dg.Columns[1].Width = 100;
|
|
dg.Columns[1].HeaderText = "Quantidade";
|
|
dg.Columns[2].Width = 100;
|
|
dg.Columns[2].HeaderText = "Valor(R$)";
|
|
dg.Columns[3].Visible = false;
|
|
dg.Columns[4].Visible = false;
|
|
dg.Columns[5].Width = 100;
|
|
dg.Columns[5].HeaderText = "Nome do Produto";
|
|
}
|
|
if (op == 3)
|
|
{
|
|
dg.Columns[0].Width = 100;
|
|
dg.Columns[0].HeaderText = "Cód. Parcelas";
|
|
dg.Columns[1].Width = 100;
|
|
dg.Columns[1].HeaderText = "Valor(R$)";
|
|
dg.Columns[2].Width = 100;
|
|
dg.Columns[2].HeaderText = "Data Pagamento";
|
|
dg.Columns[3].Width = 100;
|
|
dg.Columns[3].HeaderText = "Data Vencimento";
|
|
dg.Columns[4].Width = 100;
|
|
dg.Columns[4].HeaderText = "Cód. Compra";
|
|
}
|
|
|
|
}
|
|
catch { }
|
|
|
|
}//organiza campos
|
|
|
|
private void Rb_todasCompras_CheckedChanged(object sender, EventArgs e)
|
|
{
|
|
this.limparCampos();
|
|
if (rb_todasCompras.Checked)
|
|
{
|
|
pn_todasCompras.Visible = true;
|
|
DALLconexao cx = new DALLconexao(DadosDaConexao.StringDeConexao);
|
|
BLLCompra bcompra = new BLLCompra(cx);
|
|
dgvDados.DataSource = bcompra.Localizar();
|
|
this.orgcampos(dgvDados, 1);
|
|
|
|
}
|
|
}//rb todas as compras
|
|
|
|
private void Btn_localizarfornecedor_Click(object sender, EventArgs e)
|
|
{
|
|
frm_consultafornecedor f = new frm_consultafornecedor();
|
|
f.ShowDialog();
|
|
if (f.codigo != 0)
|
|
{
|
|
lbl_codfor.Text = f.codigo.ToString();
|
|
DALLconexao cx = new DALLconexao(DadosDaConexao.StringDeConexao);
|
|
BLLFornecedor bll = new BLLFornecedor(cx);
|
|
BLLCompra bcompra = new BLLCompra(cx);
|
|
ModeloFornecedor modelo = bll.CarregaModeloFornecedor(f.codigo);
|
|
txt_fornome.Text = modelo.ForNome;
|
|
this.dgvDados.DataSource = bcompra.Localizar(f.codigo);
|
|
f.Dispose();
|
|
this.orgcampos(dgvDados, 1);
|
|
this.orgcampos(dgv_itens, 2);
|
|
this.orgcampos(dgv_parcelas, 3);
|
|
}
|
|
else
|
|
{
|
|
lbl_codfor.Text = "Nenhum dado encontrado";
|
|
|
|
}
|
|
}//localizar fornecedor
|
|
|
|
|
|
private void Btn_localizarPorData_Click(object sender, EventArgs e)
|
|
{
|
|
DateTime datainicial, datafinal;
|
|
DALLconexao cx = new DALLconexao(DadosDaConexao.StringDeConexao);
|
|
BLLCompra bcompra = new BLLCompra(cx);
|
|
datainicial = this.dtp_inicial.Value;
|
|
datafinal = this.dtp_final.Value;
|
|
dgvDados.DataSource = bcompra.Localizar(datainicial, datafinal);
|
|
this.orgcampos(dgvDados, 1);
|
|
}//localizar por data
|
|
|
|
private void Btn_buscarParcelasEmAberto_Click(object sender, EventArgs e)
|
|
{
|
|
if (txt_parcelas.Text == "")
|
|
{
|
|
DALLconexao cx = new DALLconexao(DadosDaConexao.StringDeConexao);
|
|
BLLCompra bcompra = new BLLCompra(cx);
|
|
dgvDados.DataSource = bcompra.LocalizarPorParcelasEmAberto();
|
|
this.orgcampos(dgvDados, 1);
|
|
}
|
|
else
|
|
{
|
|
int cod = Convert.ToInt32(txt_parcelas.Text);
|
|
DALLconexao cx = new DALLconexao(DadosDaConexao.StringDeConexao);
|
|
BLLCompra bcompra = new BLLCompra(cx);
|
|
dgvDados.DataSource = bcompra.Localizar(cod);
|
|
this.orgcampos(dgvDados, 1);
|
|
}
|
|
}//localizar parcelas em aberto
|
|
|
|
private void Rb_for_CheckedChanged(object sender, EventArgs e)
|
|
{
|
|
this.limparCampos();
|
|
if (rb_for.Checked)
|
|
{
|
|
this.pn_for.Visible = true;
|
|
this.pn_todasCompras.Visible = false;
|
|
}
|
|
else
|
|
{
|
|
this.pn_for.Visible = false;
|
|
}
|
|
}//rb fornecedor
|
|
|
|
private void Rb_dataVenda_CheckedChanged(object sender, EventArgs e)
|
|
{
|
|
this.limparCampos();
|
|
if (rb_dataVenda.Checked)
|
|
{
|
|
this.pn_data.Visible = true;
|
|
}
|
|
else
|
|
{
|
|
this.pn_data.Visible = false;
|
|
}
|
|
}//rb por data
|
|
|
|
private void DgvDados_CellClick(object sender, DataGridViewCellEventArgs e)
|
|
{
|
|
if (e.RowIndex >= 0)
|
|
{
|
|
int cod = Convert.ToInt32(dgvDados.Rows[e.RowIndex].Cells[0].Value);
|
|
DALLconexao cx = new DALLconexao(DadosDaConexao.StringDeConexao);
|
|
//itens da compra
|
|
BLLitensCompra bitens = new BLLitensCompra(cx);
|
|
dgv_itens.DataSource = bitens.localizar(cod);
|
|
this.orgcampos(dgv_itens, 2);
|
|
//parcelas da compra
|
|
BLLparcelascompra bpc = new BLLparcelascompra(cx);
|
|
dgv_parcelas.DataSource = bpc.localizar(cod);
|
|
this.orgcampos(dgv_parcelas, 3);
|
|
|
|
}
|
|
}//clicando 1 vez
|
|
|
|
private void DgvDados_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
|
|
{
|
|
if (e.RowIndex >= 0)
|
|
{
|
|
this.codigo = Convert.ToInt32(dgvDados.Rows[e.RowIndex].Cells[0].Value);
|
|
this.Close();
|
|
}
|
|
}//clicando 2 vezes
|
|
|
|
private void Frm_consultacompra_Load(object sender, EventArgs e)
|
|
{
|
|
this.pn_for.Visible = false;
|
|
this.pn_data.Visible = false;
|
|
this.pn_parcelas.Visible = false;
|
|
this.Rb_todasCompras_CheckedChanged(sender, e);
|
|
}
|
|
|
|
private void Rb_parcelas_CheckedChanged(object sender, EventArgs e)
|
|
{
|
|
if (rb_parcelas.Checked)
|
|
{
|
|
this.pn_todasCompras.Visible = false;
|
|
this.pn_parcelas.Visible = true;
|
|
|
|
this.Btn_buscarParcelasEmAberto_Click(sender, e);
|
|
}
|
|
else
|
|
{
|
|
this.pn_parcelas.Visible = false;
|
|
}
|
|
}
|
|
|
|
private void pb_exit_Click(object sender, EventArgs e)
|
|
{
|
|
this.Close();
|
|
}
|
|
}
|
|
}
|