Exemplo n.º 1
0
        private void btnPesquisa_Click(object sender, EventArgs e)
        {
            if (Validacoes())
            {
                try
                {
                    RowRelatorio.Clear();
                    string DataInicial = Util.ConverStringDateSearch(msktDataInicial.Text);
                    string DataFinal   = Util.ConverStringDateSearch(msktDataFinal.Text);

                    RowRelatorio.Add(new RowsFiltro("DTEMISSAO", "System.DateTime", ">=", DataInicial));
                    RowRelatorio.Add(new RowsFiltro("DTEMISSAO", "System.DateTime", "<=", DataFinal));

                    if (Convert.ToInt32(cbStatus.SelectedValue) > 0)
                    {
                        RowRelatorio.Add(new RowsFiltro("IDSTATUS", "System.Int32", "=", Convert.ToInt32(cbStatus.SelectedValue).ToString()));
                    }

                    if (Convert.ToInt32(cbCentroCusto.SelectedValue) > 0)
                    {
                        RowRelatorio.Add(new RowsFiltro("IDCENTROCUSTOS", "System.Int32", "=", Convert.ToInt32(cbCentroCusto.SelectedValue).ToString()));
                    }

                    if (rdOrcamento.Checked)
                    {
                        RowRelatorio.Add(new RowsFiltro("FLAGORCAMENTO", "System.String", "=", "S"));
                    }
                    else if (rdOrcamento.Checked)
                    {
                        RowRelatorio.Add(new RowsFiltro("FLAGORCAMENTO", "System.String", "=", "N"));
                    }


                    LIS_PEDIDOColl = LIS_PEDIDOP.ReadCollectionByParameter(RowRelatorio, "CENTROCUSTO");

                    //Elimina os centros de custo repetidos
                    LIS_PEDIDOCollection LIS_PEDIDOColl2 = new LIS_PEDIDOCollection();
                    foreach (LIS_PEDIDOEntity item in LIS_PEDIDOColl)
                    {
                        if (LIS_PEDIDOColl2.Find(delegate(LIS_PEDIDOEntity item2) { return(item2.IDCENTROCUSTOS == item.IDCENTROCUSTOS); }) == null)
                        {
                            LIS_PEDIDOColl2.Add(item);
                        }
                    }

                    LIS_PEDIDOColl = LIS_PEDIDOColl2;

                    PreencheGrid();
                }
                catch (Exception EX)
                {
                    MessageBox.Show("Erro na pesquisa!");
                    MessageBox.Show("Erro técnico: " + EX.Message);
                }
            }
        }
Exemplo n.º 2
0
        private void btnPesquisa_Click(object sender, EventArgs e)
        {
            if (Validacoes())
            {
                try
                {
                    RowRelatorio.Clear();

                    string DataInicial = Util.ConverStringDateSearch(msktDataInicial.Text);
                    string DataFinal   = Util.ConverStringDateSearch(msktDataFinal.Text);

                    RowRelatorio.Add(new RowsFiltro("DTEMISSAO", "System.DateTime", ">=", DataInicial));
                    RowRelatorio.Add(new RowsFiltro("DTEMISSAO", "System.DateTime", "<=", DataFinal));

                    if (rdOrcamento.Checked)
                    {
                        RowRelatorio.Add(new RowsFiltro("FLAGORCAMENTO", "System.String", "=", "S"));
                    }
                    else if (rdVenda.Checked)
                    {
                        RowRelatorio.Add(new RowsFiltro("FLAGORCAMENTO", "System.String", "=", "N"));
                    }

                    LIS_PEDIDOColl = LIS_PEDIDOP.ReadCollectionByParameter(RowRelatorio, "NOMEFORMAPAGTO");

                    //Remove ID de forma de pagamento repetido
                    LIS_PEDIDOCollection LIS_PEDIDO2Coll = new LIS_PEDIDOCollection();
                    foreach (LIS_PEDIDOEntity item in LIS_PEDIDOColl)
                    {
                        if (LIS_PEDIDO2Coll.Find(delegate(LIS_PEDIDOEntity item2)
                        {
                            return
                            (item2.IDFORMAPAGAMENTO == item.IDFORMAPAGAMENTO);
                        }) == null)
                        {
                            LIS_PEDIDO2Coll.Add(item);
                        }
                    }

                    LIS_PEDIDOColl.Clear();
                    LIS_PEDIDOColl = LIS_PEDIDO2Coll;

                    PreencheGrid();
                }
                catch (Exception EX)
                {
                    MessageBox.Show("Erro na pesquisa!");
                    MessageBox.Show("Erro técnico: " + EX.Message);
                }
            }
        }
Exemplo n.º 3
0
        private void PreencheGrid()
        {
            TotalGeralPedido      = 0;
            TotalGeralCliente     = 0;
            TotalGeralComissao    = 0;
            TotalSubGeralPedido   = 0;
            TotalSubGeralComissao = 0;

            CreaterCursor Cr = new CreaterCursor();

            this.Cursor = Cr.CreateCursor(Cr.btmap, 0, 0);

            DataGriewDados.Rows.Clear();

            foreach (var LIS_PEDIDOTy in LIS_PEDIDOColl)
            {
                if (LIS_PEDIDOTy.IDCENTROCUSTOS != null && LIS_PEDIDOTy.IDCENTROCUSTOS > 0)
                {
                    DataGridViewRow row2 = new DataGridViewRow();
                    row2.CreateCells(DataGriewDados, "Centro de Custo: " + LIS_PEDIDOTy.CENTROCUSTO, string.Empty, string.Empty, string.Empty, string.Empty);
                    row2.DefaultCellStyle.Font = new Font("Arial", 8, FontStyle.Bold);
                    DataGriewDados.Rows.Add(row2);


                    //Filtra os vendedores do centro de custo
                    LIS_PEDIDOCollection LIS_PEDIDOColl_Vendedor = new BMSworks.Model.LIS_PEDIDOCollection();
                    LIS_PEDIDOColl_Vendedor = VendedorRel(Convert.ToInt32(LIS_PEDIDOTy.IDCENTROCUSTOS));

                    //Elimina os vendedores repetidos
                    LIS_PEDIDOCollection LIS_PEDIDOColl_Vendedor2 = new LIS_PEDIDOCollection();
                    foreach (LIS_PEDIDOEntity item in LIS_PEDIDOColl_Vendedor)
                    {
                        if (LIS_PEDIDOColl_Vendedor2.Find(delegate(LIS_PEDIDOEntity item2) { return(item2.IDVENDEDOR == item.IDVENDEDOR); }) == null)
                        {
                            LIS_PEDIDOColl_Vendedor2.Add(item);
                        }
                    }
                    LIS_PEDIDOColl_Vendedor = LIS_PEDIDOColl_Vendedor2;

                    //Exibi todos os vendedores
                    foreach (LIS_PEDIDOEntity itemVend in LIS_PEDIDOColl_Vendedor)
                    {
                        if (itemVend.IDVENDEDOR != null && itemVend.IDVENDEDOR > 0)
                        {
                            DataGridViewRow row2_2 = new DataGridViewRow();
                            row2_2.CreateCells(DataGriewDados, "Vendedor: " + itemVend.NOMEVENDEDOR, string.Empty);
                            row2_2.DefaultCellStyle.Font = new Font("Arial", 8, FontStyle.Bold);
                            DataGriewDados.Rows.Add(row2_2);

                            //Filtra os Cliente por vendedor
                            LIS_PEDIDOCollection LIS_PEDIDOColl_Cliente = new BMSworks.Model.LIS_PEDIDOCollection();
                            LIS_PEDIDOColl_Cliente = ClienteRel(Convert.ToInt32(itemVend.IDVENDEDOR), Convert.ToInt32(itemVend.IDCENTROCUSTOS));

                            //Elimina os Cliente repetidos
                            LIS_PEDIDOCollection LIS_PEDIDOColl_Cliente2 = new LIS_PEDIDOCollection();
                            foreach (LIS_PEDIDOEntity item_1 in LIS_PEDIDOColl_Cliente)
                            {
                                if (LIS_PEDIDOColl_Cliente2.Find(delegate(LIS_PEDIDOEntity item2_2) { return(item2_2.IDCLIENTE == item_1.IDCLIENTE); }) == null)
                                {
                                    LIS_PEDIDOColl_Cliente2.Add(item_1);
                                }
                            }
                            LIS_PEDIDOColl_Cliente = LIS_PEDIDOColl_Cliente2;

                            //Cabeçalho com o nome do Cliente
                            DataGridViewRow rowTop_3 = new DataGridViewRow();
                            rowTop_3.CreateCells(DataGriewDados, "Cliente", "Total Pedido");
                            rowTop_3.DefaultCellStyle.Font = new Font("Arial", 8, FontStyle.Bold);
                            DataGriewDados.Rows.Add(rowTop_3);
                            foreach (LIS_PEDIDOEntity item_3 in LIS_PEDIDOColl_Cliente)
                            {
                                if (item_3.IDCLIENTE != null && item_3.IDCLIENTE > 0)
                                {
                                    //Total por cliente
                                    TotalGeralCliente  += TotalCliente(Convert.ToInt32(item_3.IDCLIENTE), Convert.ToInt32(item_3.IDVENDEDOR), Convert.ToInt32(item_3.IDCENTROCUSTOS));
                                    TotalGeralComissao += TotalClienteComissao(Convert.ToInt32(item_3.IDCLIENTE), Convert.ToInt32(item_3.IDVENDEDOR), Convert.ToInt32(item_3.IDCENTROCUSTOS));

                                    DataGridViewRow row2_3 = new DataGridViewRow();
                                    row2_3.CreateCells(DataGriewDados, item_3.NOMECLIENTE, TotalGeralCliente.ToString("n2"));
                                    row2_3.DefaultCellStyle.Font = new Font("Arial", 8);
                                    DataGriewDados.Rows.Add(row2_3);
                                }

                                TotalSubGeralPedido   += TotalGeralCliente;
                                TotalSubGeralComissao += TotalGeralComissao;

                                TotalGeralCliente  = 0;
                                TotalGeralComissao = 0;
                            }

                            //SubGeral do PEdido
                            DataGridViewRow row2_4 = new DataGridViewRow();
                            row2_4.CreateCells(DataGriewDados, "Sub Total: ", TotalSubGeralPedido.ToString("n2"));
                            row2_4.DefaultCellStyle.Font = new Font("Arial", 8, FontStyle.Bold);
                            DataGriewDados.Rows.Add(row2_4);

                            TotalGeralPedido     += TotalSubGeralPedido;
                            TotalSubGeralPedido   = 0;
                            TotalSubGeralComissao = 0;


                            //Rodape do Vendedor
                            DataGridViewRow rowRodape_2 = new DataGridViewRow();
                            rowRodape_2.CreateCells(DataGriewDados, "_____________________________________________________________________", "___________");
                            rowRodape_2.DefaultCellStyle.Font = new Font("Arial", 8, FontStyle.Bold);
                            DataGriewDados.Rows.Add(rowRodape_2);
                        }
                    }

                    //Rodape do centro de custo
                    DataGridViewRow rowRodape = new DataGridViewRow();
                    rowRodape.CreateCells(DataGriewDados, "Total Geral: ", TotalGeralPedido.ToString("n2"));
                    rowRodape.DefaultCellStyle.Font = new Font("Arial", 8, FontStyle.Bold);
                    DataGriewDados.Rows.Add(rowRodape);
                }

                //Rodape Final
                DataGridViewRow rowRodape_3 = new DataGridViewRow();
                rowRodape_3.CreateCells(DataGriewDados, "_____________________________________________________________________", "___________");
                rowRodape_3.DefaultCellStyle.Font = new Font("Arial", 8, FontStyle.Bold);
                DataGriewDados.Rows.Add(rowRodape_3);
            }


            this.Cursor = Cursors.Default;
        }