// METÓDO PARA ALTERAR MANUTENÇÃO
        public void Alterar(clsAdicionarManutencaoDto Manutencao)
        {
            try
            {
                _conexao                = Conexao.ObterConexao();
                _comandoSql             = new SqlCommand();
                _comandoSql.Connection  = _conexao;
                _comandoSql.CommandText =
                    "UPDATE tblmanutencao " +
                    " SET idpeca = " + Manutencao.idPeca + ", " +
                    " placa = '" + Manutencao.Placa + "', " +
                    " problemas = '" + Manutencao.Problemas + "', " +
                    " datamanu = " + Manutencao.DatadeManu + ", " +
                    " tipodemanu = " + Manutencao.TipoManutencao + ", " +
                    "WHERE odsmanutencao = " + Manutencao.ODS;

                _comandoSql.ExecuteNonQuery();
                Conexao.fecharConexao(_conexao);
            }

            catch (Exception)
            {
                throw;
            }
        }
        public List <clsAdicionarManutencaoDto> obterdadosCombo()
        {
            List <clsAdicionarManutencaoDto> manuntencaoDts = new List <clsAdicionarManutencaoDto>();

            _conexao               = Conexao.ObterConexao();
            _comandoSql            = new SqlCommand();
            _comandoSql.Connection = _conexao;

            _comandoSql.CommandText = ("select odsmanutencao, idpeca, placa, problemas, datamanu, tipodemanu " +
                                       " from tblmanutencao ");


            _readersql = _comandoSql.ExecuteReader();
            while (_readersql.Read())
            {
                clsAdicionarManutencaoDto manutencaoDto = new clsAdicionarManutencaoDto();


                manutencaoDto.ODS            = Convert.ToInt32(_readersql["odsmanutencao"].ToString());
                manutencaoDto.idPeca         = Convert.ToInt32(_readersql["idpeca"].ToString());
                manutencaoDto.Placa          = (_readersql["placa"].ToString());
                manutencaoDto.Problemas      = (_readersql["problemas"].ToString());
                manutencaoDto.DatadeManu     = Convert.ToDateTime(_readersql["datamanu"].ToString());
                manutencaoDto.TipoManutencao = (_readersql["tipodemanu"].ToString());

                manuntencaoDts.Add(manutencaoDto);
            }
            _readersql.Close();

            Conexao.fecharConexao(_conexao);
            return(manuntencaoDts);
        }
        public Adcionar_Manutenção()
        {
            InitializeComponent();

            /* Instanciação dos
             * objetos privados */
            _manutencaoDto = new clsAdicionarManutencaoDto();
            _manutencaoBll = new clsAdicionarManutencaBll();
        }
        public List <clsAdicionarManutencaoDto> obterDados(int tipo, String filtro)
        {
            List <clsAdicionarManutencaoDto> manuntencaoDts = new List <clsAdicionarManutencaoDto>();


            try
            {
                _conexao               = Conexao.ObterConexao();
                _comandoSql            = new SqlCommand();
                _comandoSql.Connection = _conexao;

                if (tipo == 0)
                {
                    _comandoSql.CommandText = ("select odsmanutencao, idpeca, placa, problemas, datamanu, tipodemanu " +
                                               " from tblmanutencao ");
                }
                else if (tipo == 1)
                {
                    _comandoSql.CommandText = ("select odsmanutencao, idpeca, placa, problemas, datamanu, tipodemanu " +
                                               " from tblmanutencao " +
                                               " where odsmanutencao like '%" + filtro + "%'");
                }


                _readersql = _comandoSql.ExecuteReader();
                while (_readersql.Read())
                {
                    clsAdicionarManutencaoDto manutencaoDto = new clsAdicionarManutencaoDto();


                    manutencaoDto.ODS            = Convert.ToInt32(_readersql["odsmanutencao"].ToString());
                    manutencaoDto.idPeca         = Convert.ToInt32(_readersql["idpeca"].ToString());
                    manutencaoDto.Placa          = (_readersql["placa"].ToString());
                    manutencaoDto.Problemas      = (_readersql["problemas"].ToString());
                    manutencaoDto.DatadeManu     = Convert.ToDateTime(_readersql["datamanu"].ToString());
                    manutencaoDto.TipoManutencao = (_readersql["tipodemanu"].ToString());

                    manuntencaoDts.Add(manutencaoDto);
                }
                _readersql.Close();

                Conexao.fecharConexao(_conexao);
                return(manuntencaoDts);
            }
            catch (Exception)
            {
                return(null);

                throw;
            }
        }
Ejemplo n.º 5
0
        public void Alterar(clsAdicionarManutencaoDto Manutencao)
        {
            _manutencaoDal = new clsAdicionarManutencaoDal();
            try
            {
                if (Manutencao.idPeca.ToString() != "" || Manutencao.Placa.ToString() != "" || Manutencao.Problemas.ToUpper() != "" || Manutencao.DatadeManu.ToString() != "" || Manutencao.TipoManutencao.ToUpper() != "")

                {
                    _manutencaoDal.Alterar(Manutencao);
                }
                else
                {
                    throw new Exception("PREENCHIMENTO INCORRETO");
                }
            }

            catch (Exception)
            {
                throw;
            }
        }
        // METÓDO PARA INSERIR MANUTENÇÃO
        public void Inserir(clsAdicionarManutencaoDto manutencaoDto)
        {
            try
            {
                manutencaoDto.ODS = obterProximocodigo();
                _conexao          = Conexao.ObterConexao();

                _comandoSql            = new SqlCommand();
                _comandoSql.Connection = _conexao;

                _comandoSql.CommandText = "INSERT INTO tblmanutencao (odsmanutencao, idpeca, placa, problemas, datamanu, tipodemanu) " +
                                          "VALUES " +
                                          "(" + manutencaoDto.ODS + "," + manutencaoDto.idPeca + ",'" + manutencaoDto.Placa + "','" + manutencaoDto.Problemas + "','" + manutencaoDto.DatadeManu + "','" + manutencaoDto.TipoManutencao + "')";

                _comandoSql.ExecuteNonQuery();
                Conexao.fecharConexao(_conexao);
            }

            catch (Exception)
            {
                throw;
            }
        }