Пример #1
0
        private void ListaEquipamentoServico()
        {
            try
            {
                RowsFiltroCollection RowRelatorio = new RowsFiltroCollection();
                RowRelatorio.Add(new RowsFiltro("DATAEMISSAO", "System.DateTime", ">=", Util.ConverStringDateSearch(maskedtxtData.Text)));
                RowRelatorio.Add(new RowsFiltro("DATAEMISSAO", "System.DateTime", "<=", Util.ConverStringDateSearch(mdkDataFinal.Text)));

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


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

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

                LIS_EQUIPAMENTOOSFECHColl = LIS_EQUIPAMENTOOSFECHP.ReadCollectionByParameter(RowRelatorio);

                PreencheGrid();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Erro técnico: " + ex.Message);
            }
        }
Пример #2
0
        private void ListaHistEquip(int IDEQUIPAMENTO)
        {
            RowRelatorio.Clear();
            RowRelatorio.Add(new RowsFiltro("IDEQUIPAMENTO", "System.Int32", "=", IDEQUIPAMENTO.ToString()));
            LIS_EQUIPAMENTOOSFECHColl = LIS_EQUIPAMENTOOSFECHP.ReadCollectionByParameter(RowRelatorio, "IDORDEMSERVICO DESC");

            //Colocando somatorio no final da lista
            LIS_EQUIPAMENTOOSFECHEntity LIS_EQUIPAMENTOOSFECHTy = new LIS_EQUIPAMENTOOSFECHEntity();

            LIS_EQUIPAMENTOOSFECHTy.VALORTOTAL = SumTotalPesquisa("VALORTOTAL");
            LIS_EQUIPAMENTOOSFECHColl.Add(LIS_EQUIPAMENTOOSFECHTy);

            DSHistorico.AutoGenerateColumns = false;
            DSHistorico.DataSource          = LIS_EQUIPAMENTOOSFECHColl;
        }
Пример #3
0
        private void btnFiltra_Click(object sender, EventArgs e)
        {
            if (Convert.ToInt32(cbEquipamento.SelectedValue) < 1)
            {
                errorProvider1.SetError(cbEquipamento, ConfigMessage.Default.CampoObrigatorio);
                Util.ExibirMSg(ConfigMessage.Default.CampoObrigatorio2, "Red");
            }
            else
            {
                RowRelatorio.Clear();
                if (Convert.ToInt32(cbFuncionario2.SelectedValue) > 0)
                {
                    RowRelatorio.Add(new RowsFiltro("IDFUNCIONARIO", "System.Int32", "=", cbFuncionario2.SelectedValue.ToString()));
                }

                if (maskedtxtData.Text != "  /  /")
                {
                    RowRelatorio.Add(new RowsFiltro("DATAEMISSAO", "System.DateTime", ">=", Util.ConverStringDateSearch(maskedtxtData.Text)));
                }

                if (mdkDataFinal.Text != "  /  /")
                {
                    RowRelatorio.Add(new RowsFiltro("DATAEMISSAO", "System.DateTime", "<=", Util.ConverStringDateSearch(mdkDataFinal.Text)));
                }

                RowRelatorio.Add(new RowsFiltro("IDEQUIPAMENTO", "System.Int32", "=", cbEquipamento.SelectedValue.ToString()));

                LIS_EQUIPAMENTOOSFECHColl = LIS_EQUIPAMENTOOSFECHP.ReadCollectionByParameter(RowRelatorio, "IDORDEMSERVICO DESC");

                //Colocando somatorio no final da lista
                LIS_EQUIPAMENTOOSFECHEntity LIS_EQUIPAMENTOOSFECHTy = new LIS_EQUIPAMENTOOSFECHEntity();
                LIS_EQUIPAMENTOOSFECHTy.VALORTOTAL   = SumTotalPesquisa("VALORTOTAL");
                LIS_EQUIPAMENTOOSFECHTy.QUANTIDADE   = SumTotalPesquisa("QUANTIDADE");
                LIS_EQUIPAMENTOOSFECHTy.QUANTLOCACAO = SumTotalPesquisa("QUANTLOCACAO");

                LIS_EQUIPAMENTOOSFECHColl.Add(LIS_EQUIPAMENTOOSFECHTy);

                DSHistorico.AutoGenerateColumns = false;
                DSHistorico.DataSource          = LIS_EQUIPAMENTOOSFECHColl;
            }
        }
Пример #4
0
        private decimal TotalEquipamentoServico(int IDORDEMSERVICO, int IDEQUIPAMENTO)
        {
            decimal Result = 0;

            RowsFiltroCollection RowRelatorio = new RowsFiltroCollection();

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

            if (IDEQUIPAMENTO != -1)
            {
                RowRelatorio.Add(new RowsFiltro("IDEQUIPAMENTO", "System.Int32", "=", IDEQUIPAMENTO.ToString()));
            }

            LIS_EQUIPAMENTOOSFECHColl = LIS_EQUIPAMENTOOSFECHP.ReadCollectionByParameter(RowRelatorio);

            foreach (LIS_EQUIPAMENTOOSFECHEntity item in LIS_EQUIPAMENTOOSFECHColl)
            {
                Result += Convert.ToDecimal(item.VALORTOTAL);
            }

            return(Result);
        }
Пример #5
0
        private static LIS_EQUIPAMENTOOSFECHCollection ExecuteReader(ref LIS_EQUIPAMENTOOSFECHCollection collection, ref FbDataReader dataReader, FbCommand dbCommand)
        {
            using (dataReader = dbCommand.ExecuteReader())
            {
                collection = new LIS_EQUIPAMENTOOSFECHCollection();

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

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

            return(collection);
        }
Пример #6
0
        private void FrmRelatPedidoVendas_Load(object sender, EventArgs e)
        {
            CreaterCursor Cr = new CreaterCursor();

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

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

            EMPRESAColl = EMPRESAP.ReadCollectionByParameter(null);

            //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("IDORDEMSERVICO", "System.Int32", "=", IDORDEMSERVICO.ToString()));
            LIS_ORDEMSERVICOSFECHProvider LIS_ORDEMSERVICOSFECHP = new LIS_ORDEMSERVICOSFECHProvider();

            LIS_ORDEMSERVICOSFECHColl = LIS_ORDEMSERVICOSFECHP.ReadCollectionByParameter(RowRelatorio);

            //Dados do Produto
            RowRelatorio.Clear();
            RowRelatorio.Add(new RowsFiltro("IDORDEMSERVICO", "System.Int32", "=", IDORDEMSERVICO.ToString()));
            LIS_PRODUTOOSFECHProvider LIS_PRODUTOOSFECHP = new LIS_PRODUTOOSFECHProvider();

            LIS_PRODUTOOSFECHColl = LIS_PRODUTOOSFECHP.ReadCollectionByParameter(RowRelatorio);

            //Dados do Produto MTQ
            RowRelatorio.Clear();
            RowRelatorio.Add(new RowsFiltro("IDORDEMSERVICO", "System.Int32", "=", IDORDEMSERVICO.ToString()));
            LIS_PRODUTOSPEDIDOMTQOSProvider LIS_PRODUTOSPEDIDOMTQOSP = new LIS_PRODUTOSPEDIDOMTQOSProvider();

            LIS_PRODUTOSPEDIDOMTQOSColl = LIS_PRODUTOSPEDIDOMTQOSP.ReadCollectionByParameter(RowRelatorio);

            //Dados Servicos
            RowRelatorio.Clear();
            RowRelatorio.Add(new RowsFiltro("IDORDEMSERVICO", "System.Int32", "=", IDORDEMSERVICO.ToString()));
            LIS_SERVICOOSFECHProvider LIS_SERVICOOSFECHP = new LIS_SERVICOOSFECHProvider();

            LIS_SERVICOOSFECHColl = LIS_SERVICOOSFECHP.ReadCollectionByParameter(RowRelatorio);

            //Dados Equipamento
            RowRelatorio.Clear();
            RowRelatorio.Add(new RowsFiltro("IDORDEMSERVICO", "System.Int32", "=", IDORDEMSERVICO.ToString()));
            LIS_EQUIPAMENTOOSFECHProvider   LIS_EQUIPAMENTOOSFECHP    = new LIS_EQUIPAMENTOOSFECHProvider();
            LIS_EQUIPAMENTOOSFECHCollection LIS_EQUIPAMENTOOSFECHColl = new LIS_EQUIPAMENTOOSFECHCollection();

            LIS_EQUIPAMENTOOSFECHColl = LIS_EQUIPAMENTOOSFECHP.ReadCollectionByParameter(RowRelatorio);

            if (LIS_SERVICOOSFECHColl.Count > 0)
            {
                listaservicoSelec = "true";
            }

            string titulo = "Nº O.S " + IDORDEMSERVICO.ToString().PadLeft(6, '0');

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

            decimal totalproduto = 0;

            foreach (LIS_PRODUTOOSFECHEntity item in LIS_PRODUTOOSFECHColl)
            {
                totalproduto      += Convert.ToDecimal(item.VALORTOTAL);
                listaproduto1Selec = "true";
            }

            foreach (LIS_PRODUTOSPEDIDOMTQOSEntity item in LIS_PRODUTOSPEDIDOMTQOSColl)
            {
                totalproduto      += Convert.ToDecimal(item.VALORTOTAL);
                listaproduto2Selec = "true";
            }

            if (LIS_EQUIPAMENTOOSFECHColl.Count > 0)
            {
                ListaEquipamento = "true";
            }

            //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("totalproduto", totalproduto.ToString("N2"));
            p[3] = new Microsoft.Reporting.WinForms.ReportParameter("listaproduto1", listaproduto1Selec);
            p[4] = new Microsoft.Reporting.WinForms.ReportParameter("listaproduto2", listaproduto2Selec);
            p[5] = new Microsoft.Reporting.WinForms.ReportParameter("listaservico", listaservicoSelec);

            reportViewer1.LocalReport.SetParameters(p);

            this.LIS_CLIENTECollectionBindingSource.DataSource             = LIS_CLIENTEColl;
            this.EMPRESACollectionBindingSource.DataSource                 = EMPRESAColl;
            this.LIS_ORDEMSERVICOSFECHCollectionBindingSource.DataSource   = LIS_ORDEMSERVICOSFECHColl;
            this.LIS_PRODUTOOSFECHCollectionBindingSource.DataSource       = LIS_PRODUTOOSFECHColl;
            this.LIS_PRODUTOSPEDIDOMTQOSCollectionBindingSource.DataSource = LIS_PRODUTOSPEDIDOMTQOSColl;
            this.LIS_SERVICOOSFECHCollectionBindingSource.DataSource       = LIS_SERVICOOSFECHColl;
            LIS_EQUIPAMENTOOSFECHCollectionBindingSource.DataSource        = LIS_EQUIPAMENTOOSFECHColl;

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

            this.Cursor = Cursors.Default;
        }
Пример #7
0
        public LIS_EQUIPAMENTOOSFECHCollection ReadCollectionByParameter(List <RowsFiltro> RowsFiltro, string FieldOrder)
        {
            FbDataReader dataReader    = null;
            string       strSqlCommand = String.Empty;
            LIS_EQUIPAMENTOOSFECHCollection collection = null;

            try
            {
                if (RowsFiltro != null)
                {
                    if (RowsFiltro.Count > 0)
                    {
                        strSqlCommand = "SELECT * FROM LIS_EQUIPAMENTOOSFECH 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_EQUIPAMENTOOSFECH  order by  " + FieldOrder;
                    }
                }
                else
                {
                    strSqlCommand = "SELECT * FROM LIS_EQUIPAMENTOOSFECH 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;
            }
        }
Пример #8
0
        public LIS_EQUIPAMENTOOSFECHCollection ReadCollection()
        {
            FbDataReader dataReader = null;

            try
            {
                LIS_EQUIPAMENTOOSFECHCollection 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_EQUIPAMENTOOSFECH", 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_EQUIPAMENTOOSFECH", 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;
            }
        }