Exemple #1
0
        public Abastecimento BuscarAbastecimento(string placa, AbastecimentoTipo tipo, DateTime data)
        {
            int    tipoAbastecimento = tipo.GetHashCode();
            string query             = "SELECT [ABS_ID], [ABS_VCL_PLACA], [ABS_SERVEXT_CNPJ], [ABS_TIPO], [ABS_LITROS], [ABS_VALOR], [ABS_DATA]" +
                                       "FROM[TB_ABASTECIMENTO] WHERE [ABS_VCL_PLACA] = '" + placa + "' AND [ABS_TIPO] = " + tipoAbastecimento + "  AND [ABS_DATA] = '" + data.ToShortDateString() + "'";

            try
            {
                DataTable     dt            = _banco.BuscarRegistro(query);
                Abastecimento abastecimento = null;
                DataRow[]     dataRows      = dt.Select("[ABS_VCL_PLACA] = '" + placa + "' AND [ABS_TIPO] = " + tipoAbastecimento + "  AND [ABS_DATA] = '" + data.ToShortDateString() + "'");
                foreach (DataRow dr in dataRows)
                {
                    AbastecimentoTipo abastecimentoTipo = (AbastecimentoTipo)Enum.Parse(typeof(AbastecimentoTipo), dr["ABS_TIPO"].ToString());
                    long     cNPJ = long.Parse(dr["ABS_SERVEXT_CNPJ"].ToString());
                    DateTime dataAbastecimento = Convert.ToDateTime(dr["ABS_DATA"].ToString());
                    double   litros            = double.Parse(dr["ABS_LITROS"].ToString());
                    double   valor             = double.Parse(dr["ABS_VALOR"].ToString());

                    abastecimento = new Abastecimento(abastecimentoTipo, valor, litros, dataAbastecimento, dr["ABS_VCL_PLACA"].ToString(), cNPJ);
                }
                return(abastecimento);
            }
            catch (Exception)
            {
                throw new ConcorrenciaBancoException("Erro de concorrência de banco!");
            }
        }
Exemple #2
0
        public bool Deletar(string placa, AbastecimentoTipo tipo, DateTime data) //Modificado
        {
            int    tipoAbastecimento = tipo.GetHashCode();
            string Query             = "DELETE [TB_ABASTECIMENTO] WHERE [ABS_VCL_PLACA] = '" + placa + "' AND [ABS_TIPO] = " + tipoAbastecimento + " AND [ABS_DATA] = '" + data + "'";

            try
            {
                return(_banco.ExecutarInstrucao(Query));
            }
            catch (ConcorrenciaBancoException e)
            {
                throw new ConcorrenciaBancoException(e.Message);
            }
        }
Exemple #3
0
        public bool Alterar(Abastecimento abastecimento, string placa, AbastecimentoTipo tipo, DateTime data) // Modificado
        {
            int    tipoAbastecimento       = abastecimento.Tipo.GetHashCode();
            int    tipoAbastecimentoAntigo = tipo.GetHashCode();
            string Query = "UPDATE TB_ABASTECIMENTO SET [ABS_VCL_PLACA] = '" + abastecimento.Placa + "', [ABS_SERVEXT_CNPJ] = "
                           + abastecimento.CNPJ + " ,[ABS_TIPO] = " + tipoAbastecimento + ",[ABS_LITROS] = " + abastecimento.Litros
                           + ",[ABS_VALOR] = " + abastecimento.Valor + ",[ABS_DATA] = '"
                           + abastecimento.Data + "' WHERE [ABS_VCL_PLACA] = '" + placa + "' AND [ABS_TIPO] = " + tipoAbastecimentoAntigo + " AND [ABS_DATA] = '" + data + "'";

            try
            {
                return(_banco.ExecutarInstrucao(Query));
            }
            catch (ConcorrenciaBancoException e)
            {
                throw new ConcorrenciaBancoException(e.Message);
            }
        }