Exemplo n.º 1
0
        private void PreencheGrid2()
        {
            //Remove Vendedor Repetido
            LIS_SERVICOOSFECHCollection LIS_SERVICOOSFECHColl2 = new LIS_SERVICOOSFECHCollection();

            foreach (LIS_SERVICOOSFECHEntity item in LIS_SERVICOOSFECHColl)
            {
                if (LIS_SERVICOOSFECHColl2.Find(delegate(LIS_SERVICOOSFECHEntity item2) { return(item2.IDFUNCIONARIO == item.IDFUNCIONARIO && item.IDFUNCIONARIO != null && item.IDFUNCIONARIO > 0); }) == null)
                {
                    LIS_SERVICOOSFECHColl2.Add(item);
                }
            }

            LIS_SERVICOOSFECHColl.Clear();
            LIS_SERVICOOSFECHColl = LIS_SERVICOOSFECHColl2;

            TotalGeralPedido = 0;


            CreaterCursor Cr = new CreaterCursor();

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

            DataGriewDados.Rows.Clear();

            foreach (var LIS_PEDIDOTy in LIS_SERVICOOSFECHColl)
            {
                LIS_SERVICOOSFECHCollection LIS_SERVICOOSFECH2Coll = new LIS_SERVICOOSFECHCollection();

                if (LIS_PEDIDOTy.IDFUNCIONARIO != null && LIS_PEDIDOTy.IDFUNCIONARIO > 0)
                {
                    //Cabeçalho - Nome do Vendedor
                    DataGridViewRow rowCabec = new DataGridViewRow();
                    rowCabec.CreateCells(DataGriewDados, LIS_PEDIDOTy.NOMEFUNCIONARIO);
                    rowCabec.DefaultCellStyle.Font = new Font("Arial", 8, FontStyle.Bold);
                    DataGriewDados.Rows.Add(rowCabec);


                    DataGridViewRow row4_2 = new DataGridViewRow();
                    row4_2.CreateCells(DataGriewDados, "Serviço", "Quant.", "Total");
                    row4_2.DefaultCellStyle.Font = new Font("Arial", 8, FontStyle.Bold);
                    DataGriewDados.Rows.Add(row4_2);

                    LIS_SERVICOOSFECH2Coll = ServicoRel(Convert.ToInt32(LIS_PEDIDOTy.IDFUNCIONARIO));

                    foreach (LIS_SERVICOOSFECHEntity item in LIS_SERVICOOSFECH2Coll)
                    {
                        DataGridViewRow row5 = new DataGridViewRow();
                        row5.CreateCells(DataGriewDados, item.NOMESERVICO, Convert.ToDecimal(item.QUANTIDADE).ToString(), Convert.ToDecimal(item.VALORTOTAL).ToString("n2"));
                        row5.DefaultCellStyle.Font = new Font("Arial", 8);
                        DataGriewDados.Rows.Add(row5);

                        SubGeralPedido += Convert.ToDecimal(item.VALORTOTAL);
                    }

                    TotalGeralPedido += Convert.ToDecimal(SubGeralPedido);

                    DataGridViewRow rowLinhaSubTotal = new DataGridViewRow();
                    rowLinhaSubTotal.CreateCells(DataGriewDados, "", "Sub-Total", SubGeralPedido.ToString("n2"));
                    rowLinhaSubTotal.DefaultCellStyle.Font = new Font("Arial", 8, FontStyle.Bold);
                    DataGriewDados.Rows.Add(rowLinhaSubTotal);

                    DataGridViewRow rowLinha1 = new DataGridViewRow();
                    rowLinha1.CreateCells(DataGriewDados, "______________________________________", "_________", "_________");
                    rowLinha1.DefaultCellStyle.Font = new Font("Arial", 8, FontStyle.Bold);
                    DataGriewDados.Rows.Add(rowLinha1);
                }
            }

            //Total Geral
            DataGridViewRow rowTotalGeral = new DataGridViewRow();

            rowTotalGeral.CreateCells(DataGriewDados, "______________________________________", "_________", TotalGeralPedido.ToString("n2"));
            rowTotalGeral.DefaultCellStyle.Font = new Font("Arial", 8, FontStyle.Bold);
            DataGriewDados.Rows.Add(rowTotalGeral);


            this.Cursor = Cursors.Default;
        }
Exemplo n.º 2
0
        private void btnPesquisa_Click(object sender, EventArgs e)
        {
            if (Validacoes())
            {
                CreaterCursor Cr = new CreaterCursor();
                this.Cursor = Cr.CreateCursor(Cr.btmap, 0, 0);

                try
                {
                    RowRelatorio.Clear();
                    string DataInicial = Util.ConverStringDateSearch(msktDataInicial.Text);
                    string DataFinal   = Util.ConverStringDateSearch(msktDataFinal.Text);

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

                    if (rbOrcamentoPesquisa.Checked)
                    {
                        RowRelatorio.Add(new RowsFiltro("FLAGORCAMENTO", "System.String", "=", "S", "and"));
                    }

                    if (rbVendasPesquisa.Checked)
                    {
                        RowRelatorio.Add(new RowsFiltro("FLAGORCAMENTO", "System.String", "=", "N", "and"));
                    }

                    RowRelatorio.Add(new RowsFiltro("IDFUNCIONARIO", "System.Int32", "=", Convert.ToInt32(cbFuncionario.SelectedValue).ToString(), "and"));

                    DataGriewDados.Rows.Clear();
                    TotalGeral         = 0;
                    TotalGeralComissao = 0;

                    LIS_PRODUTOOSFECHColl.Clear();
                    LIS_SERVICOOSFECHColl.Clear();
                    if (chkProduto.Checked)
                    {
                        LIS_PRODUTOOSFECHColl  = LIS_PRODUTOOSFECHP.ReadCollectionByParameter(RowRelatorio, "IDORDEMSERVICO DESC");
                        lblTotalRegistros.Text = "Total de Registros: " + LIS_PRODUTOOSFECHColl.Count.ToString();
                        PreencheGridProduto();
                    }

                    if (ChkServiço.Checked)
                    {
                        LIS_SERVICOOSFECHColl  = LIS_SERVICOOSFECHP.ReadCollectionByParameter(RowRelatorio, "IDORDEMSERVICO DESC");
                        lblTotalRegistros.Text = "Total de Registros: " + (LIS_SERVICOOSFECHColl.Count + LIS_PRODUTOOSFECHColl.Count).ToString();
                        PreencheGridServico();
                    }

                    DataGriewDados.Sort(DataGriewDados.Columns["ordemservico"], ListSortDirection.Descending);

                    DataGridViewRow row3 = new DataGridViewRow();
                    row3.CreateCells(DataGriewDados, "", "", "Total Geral:", TotalGeral.ToString("n2"), TotalGeralComissao.ToString("n2"));
                    row3.DefaultCellStyle.Font = new Font("Arial", 8, FontStyle.Bold);
                    DataGriewDados.Rows.Add(row3);

                    this.Cursor = Cursors.Default;
                }
                catch (Exception EX)
                {
                    this.Cursor = Cursors.Default;
                    MessageBox.Show("Erro na pesquisa!");
                    MessageBox.Show("Erro técnico: " + EX.Message);
                }
            }
        }