Пример #1
0
        private LIS_PRODUTOSPEDFESTACollection ProdutoRel(int IDPEDIDOFESTA)
        {
            LIS_PRODUTOSPEDFESTACollection LIS_PRODUTOSPEDFESTAColl2 = new LIS_PRODUTOSPEDFESTACollection();
            LIS_PRODUTOSPEDFESTAProvider   LIS_PRODUTOSPEDFESTAP     = new LIS_PRODUTOSPEDFESTAProvider();

            try
            {
                RowRelatorio.Clear();
                if (Convert.ToInt32(cbProduto.SelectedValue) > 0)
                {
                    RowRelatorio.Add(new RowsFiltro("IDPRODUTO", "System.Int32", "=", Convert.ToInt32(cbProduto.SelectedValue).ToString()));
                }

                RowRelatorio.Add(new RowsFiltro("IDPEDIDOFESTA", "System.Int32", "=", IDPEDIDOFESTA.ToString()));

                LIS_PRODUTOSPEDFESTAColl2 = LIS_PRODUTOSPEDFESTAP.ReadCollectionByParameter(RowRelatorio);

                return(LIS_PRODUTOSPEDFESTAColl2);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Erro técnico: " + ex.Message);
                return(LIS_PRODUTOSPEDFESTAColl2);
            }
        }
Пример #2
0
        private LIS_PRODUTOSPEDFESTACollection ProdutoRel(int idvendedor)
        {
            LIS_PRODUTOSPEDFESTACollection LIS_PRODUTOSPEDFESTAColl = new LIS_PRODUTOSPEDFESTACollection();

            RowRelatorio.Clear();
            RowRelatorio.Add(new RowsFiltro("idvendedor", "System.Int32", "=", idvendedor.ToString()));

            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"));
            }

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

            LIS_PRODUTOSPEDFESTAColl = LIS_PRODUTOSPEDFESTAP.ReadCollectionByParameter(RowRelatorio);

            return(LIS_PRODUTOSPEDFESTAColl);
        }
Пример #3
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);

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

                    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"));
                    }

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

                    LIS_SERVICOPEDIDOFESTAColl = LIS_SERVICOPEDIDOFESTAP.ReadCollectionByParameter(RowRelatorio, "dtemissao DESC");
                    LIS_PRODUTOSPEDFESTAColl   = LIS_PRODUTOSPEDFESTAP.ReadCollectionByParameter(RowRelatorio, "dtemissao DESC");

                    PreencheGrid2();
                    PreencheGrid3();
                }
                catch (Exception EX)
                {
                    MessageBox.Show("Erro na pesquisa!");
                    MessageBox.Show("Erro técnico: " + EX.Message);
                }
            }
        }
Пример #4
0
        private static LIS_PRODUTOSPEDFESTACollection ExecuteReader(ref LIS_PRODUTOSPEDFESTACollection collection, ref FbDataReader dataReader, FbCommand dbCommand)
        {
            using (dataReader = dbCommand.ExecuteReader())
            {
                collection = new LIS_PRODUTOSPEDFESTACollection();

                if (dataReader.HasRows)
                {
                    while (dataReader.Read())
                    {
                        collection.Add(FillEntityObject(ref dataReader));
                    }
                }

                if (!(dataReader.IsClosed))
                {
                    dataReader.Close();
                }
                dataReader.Dispose();
            }

            return(collection);
        }
Пример #5
0
        private void PreencheGrid3()
        {
            //Remove Vendedor Repetido
            LIS_PRODUTOSPEDFESTACollection LIS_PRODUTOSPEDFESTAColl2 = new LIS_PRODUTOSPEDFESTACollection();

            foreach (LIS_PRODUTOSPEDFESTAEntity item in LIS_PRODUTOSPEDFESTAColl)
            {
                if (LIS_PRODUTOSPEDFESTAColl2.Find(delegate(LIS_PRODUTOSPEDFESTAEntity item2) { return(item2.IDVENDEDOR == item.IDVENDEDOR && item.IDVENDEDOR != null && item.IDVENDEDOR > 0); }) == null)
                {
                    LIS_PRODUTOSPEDFESTAColl2.Add(item);
                }
            }

            LIS_PRODUTOSPEDFESTAColl.Clear();
            LIS_PRODUTOSPEDFESTAColl = LIS_PRODUTOSPEDFESTAColl2;

            TotalGeralPedido = 0;


            CreaterCursor Cr = new CreaterCursor();

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

            dataGridView1.Rows.Clear();
            //LIS_PRODUTOOSFECHColl2.Clear();
            foreach (var LIS_PRODUTOSPEDFESTATy in LIS_PRODUTOSPEDFESTAColl)
            {
                if (LIS_PRODUTOSPEDFESTATy.IDVENDEDOR != null && LIS_PRODUTOSPEDFESTATy.IDVENDEDOR > 0)
                {
                    //Cabeçalho - Nome do Vendedor
                    DataGridViewRow     rowCabec     = new DataGridViewRow();
                    FUNCIONARIOProvider FUNCIONARIOP = new FUNCIONARIOProvider();
                    string NOMEFUNCIONARIO           = FUNCIONARIOP.Read(Convert.ToInt32(LIS_PRODUTOSPEDFESTATy.IDVENDEDOR)).NOME;
                    rowCabec.CreateCells(dataGridView1, NOMEFUNCIONARIO);
                    rowCabec.DefaultCellStyle.Font = new Font("Arial", 8, FontStyle.Bold);
                    dataGridView1.Rows.Add(rowCabec);


                    DataGridViewRow row4_2 = new DataGridViewRow();
                    row4_2.CreateCells(dataGridView1, "Produto", "Quant.", "Total");
                    row4_2.DefaultCellStyle.Font = new Font("Arial", 8, FontStyle.Bold);
                    dataGridView1.Rows.Add(row4_2);

                    LIS_PRODUTOSPEDFESTACollection LIS_PRODUTOSPEDFESTAColl3 = new LIS_PRODUTOSPEDFESTACollection();
                    LIS_PRODUTOSPEDFESTAColl3 = ProdutoRel(Convert.ToInt32(LIS_PRODUTOSPEDFESTATy.IDVENDEDOR));

                    foreach (LIS_PRODUTOSPEDFESTAEntity item in LIS_PRODUTOSPEDFESTAColl3)
                    {
                        DataGridViewRow row5 = new DataGridViewRow();
                        row5.CreateCells(dataGridView1, item.NOMEPRODUTO, Convert.ToDecimal(item.QUANTIDADE).ToString(), Convert.ToDecimal(item.VALORTOTAL).ToString("n2"));
                        row5.DefaultCellStyle.Font = new Font("Arial", 8);
                        dataGridView1.Rows.Add(row5);

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

                    TotalGeralPedido += Convert.ToDecimal(SubGeralPedido);

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

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

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

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


            this.Cursor = Cursors.Default;
        }
Пример #6
0
        private void FrmRelatorioPedidoFesta_Load(object sender, EventArgs e)
        {
            this.MinimizeBox     = false;
            this.FormBorderStyle = FormBorderStyle.FixedDialog;
            this.reportViewer1.RefreshReport();


            EMPRESAProvider   EMPRESAP    = new EMPRESAProvider();
            EMPRESACollection EMPRESAColl = new EMPRESACollection();

            EMPRESAColl = EMPRESAP.ReadCollectionByParameter(null);

            NomeEmpresa = EMPRESAColl[0].NOMEFANTASIA;

            //Logomarca
            CONFISISTEMAProvider CONFISISTEMAP  = new CONFISISTEMAProvider();
            CONFISISTEMAEntity   CONFISISTEMAty = CONFISISTEMAP.Read(1);

            if (CONFISISTEMAty.FLAGLOGORELATORIO == "S")
            {
                if (CONFISISTEMAty.IDARQUIVOBINARIO1 != null)
                {
                    ARQUIVOBINARIOProvider   ARQUIVOBINARIOP    = new ARQUIVOBINARIOProvider();
                    ARQUIVOBINARIOCollection ARQUIVOBINARIOColl = new ARQUIVOBINARIOCollection();
                    RowRelatorio.Clear();
                    RowRelatorio.Add(new RowsFiltro("IDARQUIVOBINARIO", "System.Int32", "=", CONFISISTEMAty.IDARQUIVOBINARIO1.ToString()));
                    ARQUIVOBINARIOColl = ARQUIVOBINARIOP.ReadCollectionByParameter(RowRelatorio);
                    this.ARQUIVOBINARIOCollectionBindingSource.DataSource = ARQUIVOBINARIOColl;
                }
            }


            //Dados do Cliente
            RowRelatorio.Clear();
            RowRelatorio.Add(new RowsFiltro("IDCLIENTE", "System.Int32", "=", IDCLIENTE.ToString()));
            LIS_CLIENTEProvider LIS_CLIENTEP = new LIS_CLIENTEProvider();

            LIS_CLIENTEColl = LIS_CLIENTEP.ReadCollectionByParameter(RowRelatorio);
            string cpfcnpjPar = (LIS_CLIENTEColl[0].CNPJ == "  .   .   /    -" || LIS_CLIENTEColl[0].CNPJ == string.Empty) ? LIS_CLIENTEColl[0].CPF : LIS_CLIENTEColl[0].CNPJ;


            //Dados do Pedido
            RowRelatorio.Clear();
            RowRelatorio.Add(new RowsFiltro("IDPEDIDOFESTA", "System.Int32", "=", IDPEDIDOFESTA.ToString()));
            LIS_PEDIDOFESTAProvider LIS_PEDIDOFESTAP = new LIS_PEDIDOFESTAProvider();

            LIS_PEDIDOFESTAColl = LIS_PEDIDOFESTAP.ReadCollectionByParameter(RowRelatorio);

            //Dados do Produto
            RowRelatorio.Clear();
            RowRelatorio.Add(new RowsFiltro("IDPEDIDOFESTA", "System.Int32", "=", IDPEDIDOFESTA.ToString()));
            LIS_PRODUTOSPEDFESTAProvider   LIS_PRODUTOSPEDFESTAP    = new LIS_PRODUTOSPEDFESTAProvider();
            LIS_PRODUTOSPEDFESTACollection LIS_PRODUTOSPEDFESTAColl = new LIS_PRODUTOSPEDFESTACollection();

            LIS_PRODUTOSPEDFESTAColl = LIS_PRODUTOSPEDFESTAP.ReadCollectionByParameter(RowRelatorio);

            ///Dados do Servico
            RowRelatorio.Clear();
            RowRelatorio.Add(new RowsFiltro("IDPEDIDOFESTA", "System.Int32", "=", IDPEDIDOFESTA.ToString()));
            LIS_SERVICOPEDIDOFESTAProvider   LIS_SERVICOPEDIDOFESTAP    = new LIS_SERVICOPEDIDOFESTAProvider();
            LIS_SERVICOPEDIDOFESTACollection LIS_SERVICOPEDIDOFESTAColl = new LIS_SERVICOPEDIDOFESTACollection();

            LIS_SERVICOPEDIDOFESTAColl = LIS_SERVICOPEDIDOFESTAP.ReadCollectionByParameter(RowRelatorio);

            foreach (var item in LIS_SERVICOPEDIDOFESTAColl)
            {
                VisualizaServico      = "true";
                TotalServicoProdutos += Convert.ToDecimal(item.VALORTOTAL);
            }

            foreach (var item in LIS_PRODUTOSPEDFESTAColl)
            {
                VisualizaProduto      = "true";
                TotalServicoProdutos += Convert.ToDecimal(item.VALORTOTAL);
            }



            string titulo = "Nº PEDIDO " + IDPEDIDOFESTA.ToString().PadLeft(6, '0');

            if (LIS_PEDIDOFESTAColl[0].FLAGORCAMENTO.TrimEnd() == "S")
            {
                titulo = "Nº ORÇAMENTO " + IDPEDIDOFESTA.ToString().PadLeft(6, '0');
            }

            //setando os parametro
            Microsoft.Reporting.WinForms.ReportParameter[] p = new Microsoft.Reporting.WinForms.ReportParameter[6];
            p[0] = new Microsoft.Reporting.WinForms.ReportParameter("CPFCNPJ", cpfcnpjPar);
            p[1] = new Microsoft.Reporting.WinForms.ReportParameter("titulo", titulo.ToString().PadLeft(6, '0'));
            p[2] = new Microsoft.Reporting.WinForms.ReportParameter("nomeempresa", NomeEmpresa);
            p[3] = new Microsoft.Reporting.WinForms.ReportParameter("VisualizaProduto", VisualizaProduto);
            p[4] = new Microsoft.Reporting.WinForms.ReportParameter("TotalServicoProdutos", TotalServicoProdutos.ToString("n2"));
            p[5] = new Microsoft.Reporting.WinForms.ReportParameter("VisualizaServico", VisualizaServico);
            reportViewer1.LocalReport.SetParameters(p);


            this.LIS_CLIENTECollectionBindingSource.DataSource            = LIS_CLIENTEColl;
            this.EMPRESACollectionBindingSource.DataSource                = EMPRESAColl;
            this.LIS_PEDIDOFESTAEntityBindingSource.DataSource            = LIS_PEDIDOFESTAColl;
            this.LIS_PRODUTOSPEDFESTACollectionBindingSource.DataSource   = LIS_PRODUTOSPEDFESTAColl;
            this.LIS_SERVICOPEDIDOFESTACollectionBindingSource.DataSource = LIS_SERVICOPEDIDOFESTAColl;


            this.reportViewer1.SetDisplayMode(DisplayMode.PrintLayout);
            this.reportViewer1.ZoomMode = ZoomMode.Percent;
            this.reportViewer1.RefreshReport();


            this.reportViewer1.RefreshReport();
            this.reportViewer1.RefreshReport();
        }
Пример #7
0
        private void PreencheGrid()
        {
            CreaterCursor Cr = new CreaterCursor();

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

            try
            {
                DataGriewDados.Rows.Clear();
                DataGridViewRow rowTop = new DataGridViewRow();
                rowTop.CreateCells(DataGriewDados, "_________", "__________", "____________________________________________", "____________________________", "____________________________", "__________");
                rowTop.DefaultCellStyle.Font = new Font("Arial", 8, FontStyle.Bold);
                DataGriewDados.Rows.Add(rowTop);

                decimal TotalGeralOS      = 0;
                Decimal TotalGeralServico = 0;
                Decimal TotalGeralProduto = 0;

                foreach (var LIS_PEDIDOFESTATy in LIS_PEDIDOFESTAColl)
                {
                    string DataEmissao = string.Empty;
                    if (LIS_PEDIDOFESTATy.IDPEDIDOFESTA != null)
                    {
                        DataEmissao = Convert.ToDateTime(LIS_PEDIDOFESTATy.DTEMISSAO).ToString("dd/MM/yyyy");
                    }

                    string TotalOS = Convert.ToDecimal(LIS_PEDIDOFESTATy.TOTALPEDIDO).ToString("n2");
                    TotalGeralOS += Convert.ToDecimal(LIS_PEDIDOFESTATy.TOTALPEDIDO);

                    //Cabeçalho principal
                    if (LIS_PEDIDOFESTATy.IDPEDIDOFESTA != null)
                    {
                        DataGridViewRow row1 = new DataGridViewRow();
                        row1.CreateCells(DataGriewDados, "PEDIDO", "EMISSÃO", "CLIENTE", "STATUS", "FUNCIONÁRIO", "TOTAL");
                        row1.DefaultCellStyle.Font = new Font("Arial", 8, FontStyle.Bold);
                        DataGriewDados.Rows.Add(row1);
                    }

                    DataGridViewRow row2 = new DataGridViewRow();
                    row2.CreateCells(DataGriewDados, LIS_PEDIDOFESTATy.IDPEDIDOFESTA.ToString().PadLeft(6, '0'), DataEmissao, LIS_PEDIDOFESTATy.NOMECLIENTE, LIS_PEDIDOFESTATy.NOMESTATUS, LIS_PEDIDOFESTATy.NOMEVENDEDOR, TotalOS);
                    row2.DefaultCellStyle.Font = new Font("Arial", 8);
                    DataGriewDados.Rows.Add(row2);


                    if (LIS_PEDIDOFESTATy.IDPEDIDOFESTA != null)
                    {
                        //Dados do produto
                        LIS_PRODUTOSPEDFESTACollection LIS_PRODUTOSPEDFESTAColl = new LIS_PRODUTOSPEDFESTACollection();

                        LIS_PRODUTOSPEDFESTAColl = ProdutoRel(Convert.ToInt32(LIS_PEDIDOFESTATy.IDPEDIDOFESTA));
                        if (LIS_PRODUTOSPEDFESTAColl.Count > 0 && chkExibirProdutos.Checked)
                        {
                            DataGridViewRow row3 = new DataGridViewRow();
                            row3.CreateCells(DataGriewDados, "PRODUTOS");
                            row3.DefaultCellStyle.Font = new Font("Arial", 8, FontStyle.Bold);
                            DataGriewDados.Rows.Add(row3);

                            //Cabeçalho do produto
                            DataGridViewRow row4 = new DataGridViewRow();
                            row4.CreateCells(DataGriewDados, "Quant.", "Total", "Produtos");
                            row4.DefaultCellStyle.Font = new Font("Arial", 8, FontStyle.Bold);
                            DataGriewDados.Rows.Add(row4);

                            Decimal TotalProduto = 0;

                            foreach (LIS_PRODUTOSPEDFESTAEntity item in LIS_PRODUTOSPEDFESTAColl)
                            {
                                DataGridViewRow row5 = new DataGridViewRow();
                                row5.CreateCells(DataGriewDados, Convert.ToDecimal(item.QUANTIDADE).ToString("n2"), Convert.ToDecimal(item.VALORTOTAL).ToString("n2"), item.NOMEPRODUTO);
                                row5.DefaultCellStyle.Font = new Font("Arial", 8);
                                DataGriewDados.Rows.Add(row5);
                                TotalProduto += Convert.ToDecimal(item.VALORTOTAL);
                            }

                            TotalGeralProduto += TotalProduto;

                            //Total de Produto
                            DataGridViewRow row5_2 = new DataGridViewRow();
                            row5_2.CreateCells(DataGriewDados, "Total: ", TotalProduto.ToString("n2"), string.Empty);
                            row5_2.DefaultCellStyle.Font = new Font("Arial", 8, FontStyle.Bold);
                            DataGriewDados.Rows.Add(row5_2);
                        }


                        //Dados do Serviço
                        LIS_SERVICOPEDIDOFESTACollection LIS_SERVICOPEDIDOFESTAColl = new LIS_SERVICOPEDIDOFESTACollection();
                        LIS_SERVICOPEDIDOFESTAColl = ServicoRel(Convert.ToInt32(LIS_PEDIDOFESTATy.IDPEDIDOFESTA));

                        if (LIS_SERVICOPEDIDOFESTAColl.Count > 0 && chkExibirServico.Checked)
                        {
                            DataGridViewRow row6 = new DataGridViewRow();
                            row6.CreateCells(DataGriewDados, "SERVIÇOS");
                            row6.DefaultCellStyle.Font = new Font("Arial", 8, FontStyle.Bold);
                            DataGriewDados.Rows.Add(row6);
                            Decimal TotalServico = 0;

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

                            foreach (LIS_SERVICOPEDIDOFESTAEntity item in LIS_SERVICOPEDIDOFESTAColl)
                            {
                                DataGridViewRow row8 = new DataGridViewRow();
                                row8.CreateCells(DataGriewDados, Convert.ToDecimal(item.QUANTIDADE).ToString("n2"), Convert.ToDecimal(item.VALORTOTAL).ToString("n2"), item.NOMESERVICO);
                                row8.DefaultCellStyle.Font = new Font("Arial", 8);
                                DataGriewDados.Rows.Add(row8);
                                TotalServico += Convert.ToDecimal(item.VALORTOTAL);
                            }

                            TotalGeralServico += TotalServico;
                            //Total de Serviço
                            DataGridViewRow row8_2 = new DataGridViewRow();
                            row8_2.CreateCells(DataGriewDados, "Total: ", TotalServico.ToString("n2"), string.Empty);
                            row8_2.DefaultCellStyle.Font = new Font("Arial", 8, FontStyle.Bold);
                            DataGriewDados.Rows.Add(row8_2);
                        }
                    }


                    DataGridViewRow rowLinha = new DataGridViewRow();
                    rowLinha.CreateCells(DataGriewDados, "_________", "__________", "____________________________________________", "____________________________", "____________________________", "__________");
                    rowLinha.DefaultCellStyle.Font = new Font("Arial", 8, FontStyle.Bold);
                    DataGriewDados.Rows.Add(rowLinha);

                    this.Cursor = Cursors.Default;
                }

                if (chkExibirServico.Checked)
                {
                    //Total Geral de Servico
                    DataGridViewRow rowTotalGeralServico = new DataGridViewRow();
                    rowTotalGeralServico.CreateCells(DataGriewDados, "", "", "Total Geral de Serviço: " + TotalGeralServico.ToString("n2"));
                    rowTotalGeralServico.DefaultCellStyle.Font = new Font("Arial", 8, FontStyle.Bold);
                    DataGriewDados.Rows.Add(rowTotalGeralServico);
                }

                if (chkExibirProdutos.Checked)
                {
                    //Total Geral de Produto
                    DataGridViewRow rowTotalGeralProduto = new DataGridViewRow();
                    rowTotalGeralProduto.CreateCells(DataGriewDados, "", "", "Total Geral de Produtos: " + TotalGeralProduto.ToString("n2"));
                    rowTotalGeralProduto.DefaultCellStyle.Font = new Font("Arial", 8, FontStyle.Bold);
                    DataGriewDados.Rows.Add(rowTotalGeralProduto);
                }

                //Total Geral de OS
                DataGridViewRow rowTotalOS = new DataGridViewRow();
                rowTotalOS.CreateCells(DataGriewDados, "_________", "__________", "____________________________________________", "____________________________", "Total Geral:", TotalGeralOS.ToString("n2"));
                rowTotalOS.DefaultCellStyle.Font = new Font("Arial", 8, FontStyle.Bold);
                DataGriewDados.Rows.Add(rowTotalOS);

                this.Cursor = Cursors.Default;
            }
            catch (Exception ex)
            {
                this.Cursor = Cursors.Default;
                MessageBox.Show("Erro técnico: " + ex.Message);
            }
        }
Пример #8
0
        public LIS_PRODUTOSPEDFESTACollection ReadCollectionByParameter(List <RowsFiltro> RowsFiltro, string FieldOrder)
        {
            FbDataReader dataReader    = null;
            string       strSqlCommand = String.Empty;
            LIS_PRODUTOSPEDFESTACollection collection = null;

            try
            {
                if (RowsFiltro != null)
                {
                    if (RowsFiltro.Count > 0)
                    {
                        strSqlCommand = "SELECT * FROM LIS_PRODUTOSPEDFESTA WHERE (";

                        ArrayList _rowsFiltro = new ArrayList();
                        RowsFiltro.ForEach(delegate(RowsFiltro i)
                        {
                            string[] item = { i.Condicao.ToString(), i.Campo.ToString(), i.Tipo.ToString(), i.Operador.ToString(), i.Valor.ToString() };
                            _rowsFiltro.Add(item);
                        });

                        int _count = 1;
                        foreach (string[] item in _rowsFiltro)
                        {
                            strSqlCommand += "(" + item[1] + " " + item[3];
                            switch (item[2])
                            {
                            case ("System.String"):
                                if (item[3].ToUpper() != "LIKE")
                                {
                                    strSqlCommand += " '" + item[4] + "')";
                                }
                                else
                                {
                                    strSqlCommand += " '%" + item[4] + "%')";
                                }
                                break;

                            case ("System.Int16"):
                                if (item[3].ToUpper() != "LIKE")
                                {
                                    strSqlCommand += " " + item[4] + ")";
                                }
                                else
                                {
                                    strSqlCommand += " '%" + item[4] + "%')";
                                }
                                break;

                            case ("System.Int32"):
                                if (item[3].ToUpper() != "LIKE")
                                {
                                    strSqlCommand += " " + item[4] + ")";
                                }
                                else
                                {
                                    strSqlCommand += " '%" + item[4] + "%')";
                                }
                                break;

                            case ("System.Int64"):
                                if (item[3].ToUpper() != "LIKE")
                                {
                                    strSqlCommand += " " + item[4] + ")";
                                }
                                else
                                {
                                    strSqlCommand += " '%" + item[4] + "%')";
                                }
                                break;

                            case ("System.Double"):
                                if (item[3].ToUpper() != "LIKE")
                                {
                                    strSqlCommand += " " + item[4] + ")";
                                }
                                else
                                {
                                    strSqlCommand += " '%" + item[4] + "%')";
                                }
                                break;

                            case ("System.Decimal"):
                                if (item[3].ToUpper() != "LIKE")
                                {
                                    strSqlCommand += " " + item[4] + ")";
                                }
                                else
                                {
                                    strSqlCommand += " '%" + item[4] + "%')";
                                }
                                break;

                            case ("System.Float"):
                                if (item[3].ToUpper() != "LIKE")
                                {
                                    strSqlCommand += " " + item[4] + ")";
                                }
                                else
                                {
                                    strSqlCommand += " '%" + item[4] + "%')";
                                }
                                break;

                            case ("System.Byte"):
                                strSqlCommand += " " + item[4] + ")";
                                break;

                            case ("System.SByte"):
                                strSqlCommand += " " + item[4] + ")";
                                break;

                            case ("System.Char"):
                                if (item[3].ToUpper() != "LIKE")
                                {
                                    strSqlCommand += " '" + item[4] + "')";
                                }
                                else
                                {
                                    strSqlCommand += " '%" + item[4] + "%')";
                                }
                                break;

                            case ("System.DateTime"):
                                if (item[3].ToUpper() != "LIKE")
                                {
                                    strSqlCommand += " '" + item[4] + "')";
                                }
                                else
                                {
                                    strSqlCommand += " '%" + item[4] + "%')";
                                }
                                break;

                            case ("System.Guid"):
                                if (item[3].ToUpper() != "LIKE")
                                {
                                    strSqlCommand += " '" + item[4] + "')";
                                }
                                else
                                {
                                    strSqlCommand += " '%" + item[4] + "%')";
                                }
                                break;

                            case ("System.Boolean"):
                                strSqlCommand += " " + item[4] + ")";
                                break;
                            }
                            if (_rowsFiltro.Count > 1)
                            {
                                if (_count < _rowsFiltro.Count)
                                {
                                    strSqlCommand += " " + item[0] + " ";
                                }
                                _count++;
                            }
                        }
                        strSqlCommand += ") order by  " + FieldOrder;
                    }
                    else
                    {
                        strSqlCommand = "SELECT * FROM LIS_PRODUTOSPEDFESTA  order by  " + FieldOrder;
                    }
                }
                else
                {
                    strSqlCommand = "SELECT * FROM LIS_PRODUTOSPEDFESTA order by  " + FieldOrder;
                }

                //Verificando a existência de um transação aberta
                if (dbTransaction != null)
                {
                    if (dbCnn.State == ConnectionState.Closed)
                    {
                        dbCnn.Open();
                    }

                    dbCommand             = new FbCommand(strSqlCommand, dbCnn);
                    dbCommand.CommandType = CommandType.Text;
                    dbCommand.Transaction = ((FbTransaction)(dbTransaction));
                }
                else
                {
                    if (dbCnn == null)
                    {
                        dbCnn = new FbConnection(connectionString);
                    }

                    if (dbCnn.State == ConnectionState.Closed)
                    {
                        dbCnn.Open();
                    }

                    dbCommand             = new FbCommand(strSqlCommand, dbCnn);
                    dbCommand.CommandType = CommandType.Text;
                    dbCommand.Transaction = dbCnn.BeginTransaction(IsolationLevel.ReadCommitted);
                }


                collection = ExecuteReader(ref collection, ref dataReader, dbCommand);

                if (dataReader != null)
                {
                    dataReader.Close();
                    dataReader.Dispose();
                }

                if (dbTransaction == null)
                {
                    dbCommand.Transaction.Commit();
                    dbCnn.Close();
                }

                return(collection);
            }
            catch (Exception ex)
            {
                // Deleta reader
                if (dataReader != null)
                {
                    dataReader.Close();
                    dataReader.Dispose();
                }

                if (dbTransaction != null)
                {
                    this.RollbackTransaction();
                }
                else
                {
                    if (dbCommand.Transaction != null)
                    {
                        dbCommand.Transaction.Rollback();
                    }
                    if (dbCnn.State == ConnectionState.Open)
                    {
                        dbCnn.Close();
                    }
                }

                throw ex;
            }
        }
Пример #9
0
        public LIS_PRODUTOSPEDFESTACollection ReadCollection()
        {
            FbDataReader dataReader = null;

            try
            {
                LIS_PRODUTOSPEDFESTACollection collection = null;

                //Verificando a existência de um transação aberta
                if (dbTransaction != null)
                {
                    if (dbCnn.State == ConnectionState.Closed)
                    {
                        dbCnn.Open();
                    }

                    dbCommand             = new FbCommand("SELECT * FROM LIS_PRODUTOSPEDFESTA", dbCnn);
                    dbCommand.Transaction = ((FbTransaction)(dbTransaction));
                }
                else
                {
                    if (dbCnn == null)
                    {
                        dbCnn = ((FbConnection)GetConnectionDB());
                    }

                    if (dbCnn.State == ConnectionState.Closed)
                    {
                        dbCnn.Open();
                    }

                    dbCommand             = new FbCommand("SELECT * FROM LIS_PRODUTOSPEDFESTA", dbCnn);
                    dbCommand.Transaction = dbCnn.BeginTransaction(IsolationLevel.ReadCommitted);
                }

                // Tipo do comando de banco Procedure ou SQL
                dbCommand.CommandType = CommandType.Text;

                collection = ExecuteReader(ref collection, ref dataReader, dbCommand);

                if (dataReader != null)
                {
                    dataReader.Close();
                    dataReader.Dispose();
                }

                if (dbTransaction == null)
                {
                    dbCommand.Transaction.Commit();
                    dbCnn.Close();
                }

                return(collection);
            }
            catch (Exception ex)
            {
                // Deleta reader
                if (dataReader != null)
                {
                    dataReader.Close();
                    dataReader.Dispose();
                }

                if (dbTransaction != null)
                {
                    this.RollbackTransaction();
                }
                else
                {
                    if (dbCommand.Transaction != null)
                    {
                        dbCommand.Transaction.Rollback();
                    }
                    if (dbCnn.State == ConnectionState.Open)
                    {
                        dbCnn.Close();
                    }
                }

                throw ex;
            }
        }