Example #1
0
        private void procurarVendas(int Tipo, DateTime Data1, DateTime Data2, string Produto, string Categoria)
        {
            try
            {
                dalPedido      ped  = new dalPedido();
                dalItensPedido iped = new dalItensPedido();
                dalEstoque     est  = new dalEstoque();
                dalProduto     prod = new dalProduto();
                dalCategoria   cat  = new dalCategoria();

                switch (Tipo)
                {
                case 1:
                    dgvRelatorio.DataSource            = null;
                    dgvRelatorio.DataSource            = ped.TotalPorMes(Data1, Data2);
                    dgvRelatorio.Columns[0].HeaderText = "Mês";
                    dgvRelatorio.Columns[0].DefaultCellStyle.Format = "MM/yyyy";
                    dgvRelatorio.Columns[0].AutoSizeMode            = DataGridViewAutoSizeColumnMode.DisplayedCells;
                    dgvRelatorio.Columns[1].HeaderText = "Valor";
                    dgvRelatorio.Columns[1].DefaultCellStyle.Format = "f";
                    dgvRelatorio.Columns[1].AutoSizeMode            = DataGridViewAutoSizeColumnMode.Fill;
                    TTipo = Tipo;
                    break;

                case 3:
                    dgvRelatorio.DataSource            = null;
                    dgvRelatorio.DataSource            = iped.TotalProdutosPorMes(Data1, Data2, Produto);
                    dgvRelatorio.Columns[0].HeaderText = "Mês";
                    dgvRelatorio.Columns[0].DefaultCellStyle.Format = "MM/yyyy";
                    dgvRelatorio.Columns[0].AutoSizeMode            = DataGridViewAutoSizeColumnMode.DisplayedCells;
                    dgvRelatorio.Columns[1].HeaderText              = "Produto";
                    dgvRelatorio.Columns[1].AutoSizeMode            = DataGridViewAutoSizeColumnMode.Fill;
                    dgvRelatorio.Columns[2].HeaderText              = "Quantidade";
                    dgvRelatorio.Columns[2].DefaultCellStyle.Format = "f";
                    dgvRelatorio.Columns[2].AutoSizeMode            = DataGridViewAutoSizeColumnMode.DisplayedCells;
                    dgvRelatorio.Columns[3].HeaderText              = "Valor";
                    dgvRelatorio.Columns[3].DefaultCellStyle.Format = "f";
                    dgvRelatorio.Columns[3].AutoSizeMode            = DataGridViewAutoSizeColumnMode.DisplayedCells;
                    TTipo = Tipo;
                    break;

                case 4:
                    dgvRelatorio.DataSource            = null;
                    dgvRelatorio.DataSource            = iped.TotalCategoriasPorMes(Data1, Data2, Categoria);
                    dgvRelatorio.Columns[0].HeaderText = "Mês";
                    dgvRelatorio.Columns[0].DefaultCellStyle.Format = "MM/yyyy";
                    dgvRelatorio.Columns[0].AutoSizeMode            = DataGridViewAutoSizeColumnMode.DisplayedCells;
                    dgvRelatorio.Columns[1].HeaderText              = "Categoria";
                    dgvRelatorio.Columns[1].AutoSizeMode            = DataGridViewAutoSizeColumnMode.Fill;
                    dgvRelatorio.Columns[2].HeaderText              = "Quantidade";
                    dgvRelatorio.Columns[2].DefaultCellStyle.Format = "f";
                    dgvRelatorio.Columns[2].AutoSizeMode            = DataGridViewAutoSizeColumnMode.DisplayedCells;
                    dgvRelatorio.Columns[3].HeaderText              = "Valor";
                    dgvRelatorio.Columns[3].DefaultCellStyle.Format = "f";
                    dgvRelatorio.Columns[3].AutoSizeMode            = DataGridViewAutoSizeColumnMode.DisplayedCells;
                    TTipo = Tipo;
                    break;

                case 5:
                    dgvRelatorio.DataSource            = null;
                    dgvRelatorio.DataSource            = ped.VendaPorData(Data1, Data2);
                    dgvRelatorio.Columns[0].HeaderText = "Data";
                    dgvRelatorio.Columns[0].DefaultCellStyle.Format = "dd/MM/yyyy";
                    dgvRelatorio.Columns[0].AutoSizeMode            = DataGridViewAutoSizeColumnMode.DisplayedCells;
                    dgvRelatorio.Columns[1].HeaderText = "Valor";
                    dgvRelatorio.Columns[1].DefaultCellStyle.Format = "f";
                    dgvRelatorio.Columns[1].AutoSizeMode            = DataGridViewAutoSizeColumnMode.Fill;
                    TTipo = Tipo;
                    break;

                case 7:
                    dgvRelatorio.DataSource            = null;
                    dgvRelatorio.DataSource            = iped.ProdutosPorData(Data1, Data2, Produto);
                    dgvRelatorio.Columns[0].HeaderText = "Data";
                    dgvRelatorio.Columns[0].DefaultCellStyle.Format = "dd/MM/yyyy";
                    dgvRelatorio.Columns[0].AutoSizeMode            = DataGridViewAutoSizeColumnMode.DisplayedCells;
                    dgvRelatorio.Columns[1].HeaderText              = "Produto";
                    dgvRelatorio.Columns[1].AutoSizeMode            = DataGridViewAutoSizeColumnMode.Fill;
                    dgvRelatorio.Columns[2].HeaderText              = "Quantidade";
                    dgvRelatorio.Columns[2].DefaultCellStyle.Format = "f";
                    dgvRelatorio.Columns[2].AutoSizeMode            = DataGridViewAutoSizeColumnMode.DisplayedCells;
                    dgvRelatorio.Columns[3].HeaderText              = "Valor";
                    dgvRelatorio.Columns[3].DefaultCellStyle.Format = "f";
                    dgvRelatorio.Columns[3].AutoSizeMode            = DataGridViewAutoSizeColumnMode.DisplayedCells;
                    TTipo = Tipo;
                    break;

                case 8:
                    dgvRelatorio.DataSource            = null;
                    dgvRelatorio.DataSource            = iped.CategoriasPorData(Data1, Data2, Categoria);
                    dgvRelatorio.Columns[0].HeaderText = "Data";
                    dgvRelatorio.Columns[0].DefaultCellStyle.Format = "dd/MM/yyyy";
                    dgvRelatorio.Columns[0].AutoSizeMode            = DataGridViewAutoSizeColumnMode.DisplayedCells;
                    dgvRelatorio.Columns[1].HeaderText              = "Categoria";
                    dgvRelatorio.Columns[1].AutoSizeMode            = DataGridViewAutoSizeColumnMode.Fill;
                    dgvRelatorio.Columns[2].HeaderText              = "Quantidade";
                    dgvRelatorio.Columns[2].DefaultCellStyle.Format = "f";
                    dgvRelatorio.Columns[2].AutoSizeMode            = DataGridViewAutoSizeColumnMode.DisplayedCells;
                    dgvRelatorio.Columns[3].HeaderText              = "Valor";
                    dgvRelatorio.Columns[3].DefaultCellStyle.Format = "f";
                    dgvRelatorio.Columns[3].AutoSizeMode            = DataGridViewAutoSizeColumnMode.DisplayedCells;
                    TTipo = Tipo;
                    break;

                case 9:
                    dgvRelatorio.DataSource                         = null;
                    dgvRelatorio.DataSource                         = est.relEstoqueConfCont(Categoria, cbVendavel.Checked);
                    dgvRelatorio.Columns[0].HeaderText              = "Categoria";
                    dgvRelatorio.Columns[0].AutoSizeMode            = DataGridViewAutoSizeColumnMode.DisplayedCells;
                    dgvRelatorio.Columns[1].HeaderText              = "Produto";
                    dgvRelatorio.Columns[1].AutoSizeMode            = DataGridViewAutoSizeColumnMode.Fill;
                    dgvRelatorio.Columns[2].HeaderText              = "Quantidade";
                    dgvRelatorio.Columns[2].DefaultCellStyle.Format = "f";
                    dgvRelatorio.Columns[2].AutoSizeMode            = DataGridViewAutoSizeColumnMode.DisplayedCells;
                    TTipo = Tipo;
                    break;

                case 10:
                    dgvRelatorio.DataSource                         = null;
                    dgvRelatorio.DataSource                         = est.relEstoqueConfCont(Categoria, cbVendavel.Checked);
                    dgvRelatorio.Columns[0].HeaderText              = "Categoria";
                    dgvRelatorio.Columns[0].AutoSizeMode            = DataGridViewAutoSizeColumnMode.DisplayedCells;
                    dgvRelatorio.Columns[1].HeaderText              = "Produto";
                    dgvRelatorio.Columns[1].AutoSizeMode            = DataGridViewAutoSizeColumnMode.Fill;
                    dgvRelatorio.Columns[2].Visible                 = false;
                    dgvRelatorio.Columns[3].HeaderText              = "Quantidade";
                    dgvRelatorio.Columns[3].DefaultCellStyle.Format = "f";
                    dgvRelatorio.Columns[3].AutoSizeMode            = DataGridViewAutoSizeColumnMode.DisplayedCells;
                    TTipo = Tipo;
                    break;

                case 11:
                    dgvRelatorio.DataSource                         = null;
                    dgvRelatorio.DataSource                         = est.relEstoqueProducao(Categoria, cbVendavel.Checked);
                    dgvRelatorio.Columns[0].HeaderText              = "Categoria";
                    dgvRelatorio.Columns[0].AutoSizeMode            = DataGridViewAutoSizeColumnMode.DisplayedCells;
                    dgvRelatorio.Columns[1].HeaderText              = "Produto";
                    dgvRelatorio.Columns[1].AutoSizeMode            = DataGridViewAutoSizeColumnMode.Fill;
                    dgvRelatorio.Columns[2].HeaderText              = "Ideal";
                    dgvRelatorio.Columns[2].DefaultCellStyle.Format = "f";
                    dgvRelatorio.Columns[2].AutoSizeMode            = DataGridViewAutoSizeColumnMode.DisplayedCells;
                    dgvRelatorio.Columns[3].HeaderText              = "Quantidade";
                    dgvRelatorio.Columns[3].DefaultCellStyle.Format = "f";
                    dgvRelatorio.Columns[3].AutoSizeMode            = DataGridViewAutoSizeColumnMode.DisplayedCells;
                    TTipo = Tipo;
                    break;

                case 12:
                    dgvRelatorio.DataSource                         = null;
                    dgvRelatorio.DataSource                         = est.relEstoqueMin(Categoria, cbVendavel.Checked);
                    dgvRelatorio.Columns[0].HeaderText              = "Categoria";
                    dgvRelatorio.Columns[0].AutoSizeMode            = DataGridViewAutoSizeColumnMode.DisplayedCells;
                    dgvRelatorio.Columns[1].HeaderText              = "Produto";
                    dgvRelatorio.Columns[1].AutoSizeMode            = DataGridViewAutoSizeColumnMode.Fill;
                    dgvRelatorio.Columns[2].HeaderText              = "Mínimo";
                    dgvRelatorio.Columns[2].DefaultCellStyle.Format = "f";
                    dgvRelatorio.Columns[2].AutoSizeMode            = DataGridViewAutoSizeColumnMode.DisplayedCells;
                    dgvRelatorio.Columns[3].HeaderText              = "Quantidade";
                    dgvRelatorio.Columns[3].DefaultCellStyle.Format = "f";
                    dgvRelatorio.Columns[3].AutoSizeMode            = DataGridViewAutoSizeColumnMode.DisplayedCells;
                    TTipo = Tipo;
                    break;

                case 13:
                    dgvRelatorio.DataSource                         = null;
                    dgvRelatorio.DataSource                         = est.relEstoqueIde(Categoria, cbVendavel.Checked);
                    dgvRelatorio.Columns[0].HeaderText              = "Categoria";
                    dgvRelatorio.Columns[0].AutoSizeMode            = DataGridViewAutoSizeColumnMode.DisplayedCells;
                    dgvRelatorio.Columns[1].HeaderText              = "Produto";
                    dgvRelatorio.Columns[1].AutoSizeMode            = DataGridViewAutoSizeColumnMode.Fill;
                    dgvRelatorio.Columns[2].HeaderText              = "Ideal";
                    dgvRelatorio.Columns[2].DefaultCellStyle.Format = "f";
                    dgvRelatorio.Columns[2].AutoSizeMode            = DataGridViewAutoSizeColumnMode.DisplayedCells;
                    dgvRelatorio.Columns[3].HeaderText              = "Quantidade";
                    dgvRelatorio.Columns[3].DefaultCellStyle.Format = "f";
                    dgvRelatorio.Columns[3].AutoSizeMode            = DataGridViewAutoSizeColumnMode.DisplayedCells;
                    TTipo = Tipo;
                    break;

                case 14:
                    dgvRelatorio.DataSource                         = null;
                    dgvRelatorio.DataSource                         = est.relHistoricoEntSai(Data1, Data2, Produto, cbVendavel.Checked);
                    dgvRelatorio.Columns[0].HeaderText              = "Data";
                    dgvRelatorio.Columns[0].AutoSizeMode            = DataGridViewAutoSizeColumnMode.DisplayedCells;
                    dgvRelatorio.Columns[0].DefaultCellStyle.Format = "dd/MM/yyyy";
                    dgvRelatorio.Columns[1].HeaderText              = "Produto";
                    dgvRelatorio.Columns[1].AutoSizeMode            = DataGridViewAutoSizeColumnMode.Fill;
                    dgvRelatorio.Columns[2].HeaderText              = "Entrada";
                    dgvRelatorio.Columns[2].DefaultCellStyle.Format = "f";
                    dgvRelatorio.Columns[2].AutoSizeMode            = DataGridViewAutoSizeColumnMode.DisplayedCells;
                    dgvRelatorio.Columns[3].HeaderText              = "Saida";
                    dgvRelatorio.Columns[3].DefaultCellStyle.Format = "f";
                    dgvRelatorio.Columns[3].AutoSizeMode            = DataGridViewAutoSizeColumnMode.DisplayedCells;
                    TTipo = Tipo;
                    break;

                case 16:
                    dgvRelatorio.DataSource                         = null;
                    dgvRelatorio.DataSource                         = prod.listaProdutos(Categoria, cbVendavel.Checked);
                    dgvRelatorio.Columns[0].HeaderText              = "Categoria";
                    dgvRelatorio.Columns[0].AutoSizeMode            = DataGridViewAutoSizeColumnMode.DisplayedCells;
                    dgvRelatorio.Columns[1].HeaderText              = "Código";
                    dgvRelatorio.Columns[1].AutoSizeMode            = DataGridViewAutoSizeColumnMode.DisplayedCells;
                    dgvRelatorio.Columns[2].HeaderText              = "Produto";
                    dgvRelatorio.Columns[2].AutoSizeMode            = DataGridViewAutoSizeColumnMode.Fill;
                    dgvRelatorio.Columns[3].HeaderText              = "Custo";
                    dgvRelatorio.Columns[3].DefaultCellStyle.Format = "f";
                    dgvRelatorio.Columns[3].AutoSizeMode            = DataGridViewAutoSizeColumnMode.DisplayedCells;
                    dgvRelatorio.Columns[4].HeaderText              = "Preço";
                    dgvRelatorio.Columns[4].DefaultCellStyle.Format = "f";
                    dgvRelatorio.Columns[4].AutoSizeMode            = DataGridViewAutoSizeColumnMode.DisplayedCells;
                    dgvRelatorio.Columns[5].HeaderText              = "% Lucro";
                    dgvRelatorio.Columns[5].DefaultCellStyle.Format = "P2";
                    dgvRelatorio.Columns[5].AutoSizeMode            = DataGridViewAutoSizeColumnMode.DisplayedCells;
                    TTipo = Tipo;
                    break;

                case 17:
                    dgvRelatorio.DataSource              = null;
                    dgvRelatorio.DataSource              = cat.listaCategorias();
                    dgvRelatorio.Columns[0].HeaderText   = "Código";
                    dgvRelatorio.Columns[0].AutoSizeMode = DataGridViewAutoSizeColumnMode.DisplayedCells;
                    dgvRelatorio.Columns[1].HeaderText   = "Categoria";
                    dgvRelatorio.Columns[1].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
                    dgvRelatorio.Columns[2].Visible      = false;
                    TTipo = Tipo;
                    break;

                default:
                    MessageBox.Show("Selecione um tipo de relatório.", "Tipo de relatório", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    break;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "ERRO");
            }
        }