コード例 #1
0
        private Abastecimento GerarAbastecimento()
        {
            Abastecimento abastecimento = new Abastecimento();

            abastecimento.NovoEstadoTanque = (EstadosTanqueCombustivel)int.Parse(QuantidadeSlider.Value.ToString("F0"));
            abastecimento.VeiculoId        = SeletorVeiculo.Veiculo.VeiculoId;
            abastecimento.MotoristaId      = MotoristaUC.Motorista.MotoristaId;

            if (AgendarRB.IsChecked == true)
            {
                abastecimento.Estado       = EstadoAbastecimento.AGENDADO;
                abastecimento.DataAgendada = DataAgendamentoUC.Date;
            }
            if (RegistrarRB.IsChecked == true)
            {
                abastecimento.Estado        = EstadoAbastecimento.REALIZADO;
                abastecimento.DataConclusao = DataConclusaoUC.Date;
                abastecimento.Valor         = ValorUC.Valor;
            }

            abastecimento.QuantidadeAbastecida = QuantidadeLitrosUC.Value;


            abastecimento.Local = EnderecoUC.Endereco;

            return(abastecimento);
        }
コード例 #2
0
        public int Atualizar(AbastecimentoDto entity)
        {
            Abastecimento abastecimento = new Abastecimento();

            abastecimento.PrepararDadosParaAtualizar(entity.NCodAbastecimento, entity.NKmAbastecimento, entity.NLitroAbastecimento, entity.VVlrPago, entity.DAbastecimento, entity.NCodPosto, entity.NCodUsuarioInc, entity.NCodTipoCombustivel, entity.NCodTipoVeiculo, entity.NCodVeiculo);
            return(_serviceAbastecimento.Atualizar(abastecimento));
        }
コード例 #3
0
        public IHttpActionResult Post([FromBody] Abastecimento abastecimento)
        {
            if (abastecimento == null)
            {
                return(BadRequest());
            }

            try
            {
                bool result = _abastecimentoService.Cadastrar(abastecimento, abastecimento.Placa, abastecimento.Tipo, abastecimento.Data);
                if (result)
                {
                    return(Ok());
                }
                else
                {
                    return(BadRequest("Houve um erro na operação!"));
                }
            }
            catch (RegistroExisteException e)
            {
                return(BadRequest(e.Message));
            }
            catch (ConcorrenciaBancoException e)
            {
                return(BadRequest(e.Message));
            }
            catch (TipoCombustivelException)
            {
                HttpResponseMessage message = new HttpResponseMessage(HttpStatusCode.NotAcceptable);
                return(ResponseMessage(message));
            }
        }
コード例 #4
0
        public JsonResult Pesquisar(DatatableParm parm, Abastecimento item)
        {
            try
            {
                SalvarPesquisa(item, parm);
                var items = abastecimentoService.GetAllByPage(item, parm);

                return(Json(new
                {
                    ok = true,
                    sEcho = parm.sEcho,
                    iTotalRecords = items.Count(),
                    iTotalDisplayRecords = parm.totalRecords,
                    aaData = items.Select(x => new
                    {
                        IdeAbastecimento = x.IdeAbastecimento,
                        DatAbastecimento = x.DatAbastecimento.ToString("dd/MM/yyyy"),
                        VlrAbastecimento = x.VlrAbastecimento.ToString("C"),
                        Veiculo = new { DscMarcaModelo = x.Veiculo.DscMarcaModelo },
                        PessoaJuridica = new { NomRazaoSocial = x.PessoaJuridica.NomRazaoSocial }
                    })
                }));
            }
            catch (Exception ex)
            {
                return(Json(CreateMessageDatatable(ex)));
            }
        }
コード例 #5
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,PostoId,Odometro,Litros,ValorLitro,TanqueCheio,VeiculoId,Observacao,Data")] Abastecimento abastecimento)
        {
            if (id != abastecimento.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(abastecimento);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!AbastecimentoExists(abastecimento.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["PostoId"]   = new SelectList(_context.PostoCombustivel, "Id", "Nome", abastecimento.PostoId);
            ViewData["VeiculoId"] = new SelectList(_context.Veiculo, "Id", "Modelo", abastecimento.VeiculoId);
            return(View(abastecimento));
        }
コード例 #6
0
        public async Task <IActionResult> PutAbastecimento(int id, Abastecimento abastecimento)
        {
            if (id != abastecimento.Id)
            {
                return(BadRequest());
            }

            _context.Entry(abastecimento).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!AbastecimentoExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
コード例 #7
0
        public async Task <ActionResult <Abastecimento> > PostAbastecimento(Abastecimento abastecimento)
        {
            _context.Abastecimentos.Add(abastecimento);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetAbastecimento", new { id = abastecimento.Id }, abastecimento));
        }
コード例 #8
0
        protected void Page_Load(object sender, EventArgs e)
        {
            /*
             * Op I - É incluir
             * Op A - É alterar
             */

            if (!IsPostBack)
            {
                /***********************************************************/
                abastecimento = new Abastecimento();
                abastecimento.novo();
                setSession();
                /***********************************************************/
                listaCombustivel();
                ddCombustivel.Items.Add(new ListItem("Selecione", "0", true));
                ddCombustivel.Items.FindByValue("0").Selected = true;
                /***********************************************************/
                listaPosto();
                ddPosto.Items.Add(new ListItem("Selecione", "0", true));
                ddPosto.Items.FindByValue("0").Selected = true;
                /***********************************************************/
                if (Request.QueryString["op"] == "A")
                {
                    daoAbastecimento = new DAOAbastecimento(arquivo);
                    abastecimento.ID = Int32.Parse(Request.QueryString["id"]);
                    daoAbastecimento.buscarID(abastecimento);
                    getDados();
                    abastecimento.editar();
                    setSession();
                }
            }
        }
コード例 #9
0
        public static SqlException UpdateAfericao(Abastecimento a)
        {
            SqlException  ex   = null;
            SqlConnection conn = DBAccess.GetConnection();

            try
            {
                string insert = "UPDATE afericao " +
                                "set processado =  @proc " +
                                "WHERE id_abastecimento = @id_abast";
                conn.Open();
                SqlCommand command = new SqlCommand(insert, conn);
                command.Parameters.Add(new SqlParameter("@id_abast", a.Id));
                command.Parameters.Add(new SqlParameter("@proc", true));
                command.ExecuteNonQuery();
            }
            catch (SqlException e)
            {
                Util.WriteLog.Write("" + e, Util.ENUM.LOG_FILENAME_DB);
                ex = e;
            }
            finally
            {
                conn.Close();
            }


            return(ex);
        }
コード例 #10
0
        public static SqlException PersistAfericao(Abastecimento a)
        {
            SqlException  ex   = null;
            SqlConnection conn = DBAccess.GetConnection();

            try
            {
                string insert = "INSERT INTO afericao(id_abastecimento, processado) VALUES(@id_abast, @proc)";
                conn.Open();
                SqlCommand command = new SqlCommand(insert, conn);
                command.Parameters.Add(new SqlParameter("@id_abast", a.Id));
                command.Parameters.Add(new SqlParameter("@proc", false));
                command.ExecuteNonQuery();
            }catch (SqlException e)
            {
                Util.WriteLog.Write("" + e, Util.ENUM.LOG_FILENAME_DB);
                ex = e;
            }
            finally
            {
                conn.Close();
            }


            return(ex);
        }
コード例 #11
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!");
            }
        }
コード例 #12
0
        public int Atualizar(Abastecimento entity)
        {
            using (var connection = _dbConnectionString.Connection())
            {
                connection.Open();

                string sql = @"UPDATE 
                            ger_abastecimento
                            SET
                                n_km_abastecimento =   @NKmAbastecimento,
                                n_litro_abastecimento =   @NLitroAbastecimento,
                                v_vlr_pago =  @VVlrPago,
                                d_abastecimento =   @DAbastecimento,
                                n_cod_posto =  @NCodPosto,
                                n_cod_combustivel = @NCodCombustivel,
                                n_cod_veiculo =  @NCodVeiculo,
                                n_cod_tipo_veiculo =   @NCodTipoVeiculo

                           WHERE n_cod_abastecimento = @NCodAbastecimento; ";

                return(connection.Execute(sql, new
                {
                    NKmAbastecimento = entity.NKmAbastecimento,
                    NLitroAbastecimento = entity.NLitroAbastecimento,
                    VVlrPago = entity.VVlrPago,
                    DAbastecimento = entity.DAbastecimento,
                    NCodPosto = entity.Posto.NCodPosto,
                    NCodCombustivel = entity.TipoCombustivel.NCodCombustivel,
                    NCodVeiculo = entity.Veiculo.NCodVeiculo,
                    NCodTipoVeiculo = entity.TipoVeiculo.NCodTipoVeiculo,
                    NCodAbastecimento = entity.NCodAbastecimento
                }));
            }
        }
コード例 #13
0
        private List <OrdemPagamentoItem> GerarListadeItens(DateTime dataVencimentoOP)
        {
            List <OrdemPagamentoItem>         lstItens             = new List <OrdemPagamentoItem>();
            Abastecimento                     itemAbastecimento    = new Abastecimento();
            DataGridViewSelectedRowCollection lstItensSelecionados = gvAbastecimentos.SelectedRows;

            foreach (DataGridViewRow linhaSelecionada in lstItensSelecionados)
            {
                itemAbastecimento = bizVeiculo.PesquisarAbastecimentos(new Abastecimento()
                {
                    idAbastecimento = int.Parse(linhaSelecionada.Cells[0].Value.ToString())
                })[0];

                lstItens.Add(new OrdemPagamentoItem()
                {
                    idAbastecimento      = itemAbastecimento.idAbastecimento,
                    idObraGastoRealizado = 0,
                    idUEN                = itemAbastecimento.idUEN,
                    idCentroCusto        = itemAbastecimento.idCentroCusto,
                    idDespesa            = itemAbastecimento.idDespesa,
                    descricaoUEN         = itemAbastecimento.descricaoUEN,
                    descricaoCentroCusto = itemAbastecimento.descricaoCentroCusto,
                    descricaoDespesa     = itemAbastecimento.descricaoDespesa,
                    Valor                = itemAbastecimento.valorTotal,
                    dataVencimento       = dataVencimentoOP,
                    numeroParcela        = 1,
                    totalParcelas        = 1
                });
            }

            return(lstItens);
        }
コード例 #14
0
 private void AttachItem(Abastecimento abastecimento, EFContext Context)
 {
     if (!Context.Abastecimentos.Local.Contains(abastecimento))
     {
         Context.Abastecimentos.Attach(abastecimento);
     }
 }
コード例 #15
0
        private Abastecimento PreencherCamposObrigatoriosAbastecimento()
        {
            BIZMotorista   bizMotorista   = new BIZMotorista();
            BIZFornecedor  bizFornecedor  = new BIZFornecedor();
            BIZObra        bizObra        = new BIZObra();
            BIZUEN         bizUEN         = new BIZUEN();
            BIZCentroCusto bizCentroCusto = new BIZCentroCusto();
            BIZDespesa     bizDespesa     = new BIZDespesa();

            Abastecimento abastecimento = new Abastecimento();

            abastecimento.idAbastecimento           = 99;
            abastecimento.numeroAbastecimento       = "0/2019";
            abastecimento.idFornecedor              = bizFornecedor.PesquisarFornecedor(new Fornecedor())[0].idFornecedor;
            abastecimento.idVeiculo                 = bizVeiculo.PesquisarVeiculos(new Veiculo())[0].idVeiculo;;
            abastecimento.idMotorista               = bizMotorista.PesquisarMotorista(new Motorista())[0].idMotorista;;
            abastecimento.idObraEtapa               = bizObra.PesquisarObraEtapa(new ObraEtapa())[0].idObraEtapa;
            abastecimento.idObraEtapaGastoRealizado = bizObra.PesquisarGastosRealizados(new ObraEtapaGastoRealizado())[0].idObraEtapaGastoRealizado;
            abastecimento.idUEN         = bizUEN.PesquisarUEN(new UEN())[0].idUEN;
            abastecimento.idCentroCusto = bizCentroCusto.PesquisarCentroCusto(new CentroCusto())[0].idCentroCusto;
            abastecimento.idDespesa     = bizDespesa.PesquisarDespesa(new Despesa())[0].idDespesa;
            abastecimento.Data          = DateTime.Now;
            abastecimento.Valor         = decimal.Parse("99.99");
            abastecimento.Desconto      = decimal.Parse("77.77");
            abastecimento.idEmissor     = 1;
            abastecimento.Kilometragem  = 999999;
            abastecimento.Litros        = 90;
            abastecimento.UnitTest      = 1;

            return(abastecimento);
        }
コード例 #16
0
ファイル: AbastecimentoDados.cs プロジェクト: branux/veiculoz
        public void Salvar(Midas.Nucleo.Objetos.ObjetoNegocio objeto)
        {
            Abastecimento abastecimento = (Abastecimento)objeto;

            if (abastecimento.Id == 0)
            {
                Comando comando = new Comando(Recursos.ConstantesDados.InserirAbastecimento, Midas.Nucleo.Recursos.ConstantesGerais.BancoVeiculoZ);
                comando.AdicionarParametro("@data", abastecimento.Data);
                comando.AdicionarParametro("@observacoes", abastecimento.Observacoes);
                comando.AdicionarParametro("@idposto", abastecimento.Posto.Id);
                comando.AdicionarParametro("@tanquecheio", abastecimento.TanqueCheio);
                comando.AdicionarParametro("@idtipoabastecimento", abastecimento.TipoCombustivel.Id);
                comando.AdicionarParametro("@valor", abastecimento.Valor);
                comando.AdicionarParametro("@valorlitro", abastecimento.ValorLitro);
                abastecimento.Id = comando.ExecutarInsercao();
            }
            else
            {
                Comando comando = new Comando(Recursos.ConstantesDados.AtualizarAbastecimento, Midas.Nucleo.Recursos.ConstantesGerais.BancoVeiculoZ);
                comando.AdicionarParametro("@data", abastecimento.Data);
                comando.AdicionarParametro("@observacoes", abastecimento.Observacoes);
                comando.AdicionarParametro("@idposto", abastecimento.Posto.Id);
                comando.AdicionarParametro("@tanquecheio", abastecimento.TanqueCheio);
                comando.AdicionarParametro("@idtipoabastecimento", abastecimento.TipoCombustivel.Id);
                comando.AdicionarParametro("@valor", abastecimento.Valor);
                comando.AdicionarParametro("@valorlitro", abastecimento.ValorLitro);
                comando.AdicionarParametro("@id", abastecimento.Id);
                comando.Executar();
            }
        }
コード例 #17
0
        public List <Abastecimento> BuscarTodos(long cnpj)
        {
            List <Abastecimento> abastecimentos = new List <Abastecimento>();
            string query = "SELECT [ABS_ID], [ABS_VCL_PLACA], [ABS_SERVEXT_CNPJ], [ABS_TIPO], [ABS_LITROS], [ABS_VALOR], [ABS_DATA]" +
                           "FROM[TB_ABASTECIMENTO] WHERE [ABS_SERVEXT_CNPJ] = " + cnpj;

            try
            {
                DataTable     dt            = _banco.BuscarRegistro(query);
                Abastecimento abastecimento = null;
                DataRow[]     dataRows      = dt.Select("[ABS_SERVEXT_CNPJ] = " + cnpj);
                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);
                    abastecimentos.Add(abastecimento);
                }
                return(abastecimentos);
            }
            catch (Exception)
            {
                throw new ConcorrenciaBancoException("Erro de concorrência de banco!");
            }
        }
コード例 #18
0
        public override void Salvar(Midas.Nucleo.Objetos.ObjetoNegocio objeto)
        {
            Percurso percurso = (Percurso)objeto;

            Negocio.NegocioFactory.Instancia.AbastecimentoNegocio.Salvar(percurso.AbastecimentoInicial);
            if (percurso.AbastecimentoFinal != null)
            {
                Negocio.NegocioFactory.Instancia.AbastecimentoNegocio.Salvar(percurso.AbastecimentoFinal);
            }

            // TODO Ainda falta checar a invalidez do percurso.
            if (percurso.Id == null || percurso.Id == 0)
            {
                Percurso ultimoPercurso = this.ObterUltimoPercurso();
                if (ultimoPercurso != null)
                {
                    ultimoPercurso.AbastecimentoFinal = percurso.AbastecimentoInicial;
                    base.Salvar(ultimoPercurso);
                }
            }
            else
            {
                PercursoDados dados = (PercursoDados)this.AcessoDados;
                int           id    = dados.ObterIdAbastecimentoFinal(percurso.Id);
                Abastecimento abast = new Abastecimento();
                abast.Id = id;
                percurso.AbastecimentoFinal = abast;
            }

            // Salvar o Percurso.
            base.Salvar(percurso);
        }
コード例 #19
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Km,Litros,Valor,DataAbastecimento,Posto,IdUser,Tipo,VeiculoId")] Abastecimento abastecimento)
        {
            if (id != abastecimento.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(abastecimento);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!AbastecimentoExists(abastecimento.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["VeiculoId"] = new SelectList(_context.Veiculos, "VeiculoId", "Placa", abastecimento.VeiculoId);
            return(View(abastecimento));
        }
コード例 #20
0
        public List <Abastecimento> BuscarTodos(DateTime dtinicio, DateTime dtfim)
        {
            List <Abastecimento> abastecimentos = new List <Abastecimento>();

            string query = "SELECT * FROM [dbo].[TB_ABASTECIMENTO] WHERE" +
                           "((YEAR([ABS_DATAREGISTRO]) >= '" + dtinicio.Year + "' AND YEAR([ABS_DATAREGISTRO]) <= '" + dtfim.Year + "')" +
                           "AND MONTH([ABS_DATAREGISTRO]) >= '" + dtinicio.Month + "' AND MONTH([ABS_DATAREGISTRO]) <= '" + dtfim.Month + "')";

            try
            {
                DataTable     dt            = _banco.BuscarRegistro(query);
                Abastecimento abastecimento = null;
                DataRow[]     dataRows      = dt.Select();
                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);
                    abastecimentos.Add(abastecimento);
                }
                return(abastecimentos);
            }
            catch (Exception)
            {
                throw new ConcorrenciaBancoException("Erro de concorrência de banco!");
            }
        }
コード例 #21
0
        private void dgVeiculoAbast_DoubleClick(object sender, EventArgs e)
        {
            if (dgVeiculoAbast.DataSource == null)
            {
            }
            else if (dgVeiculoAbast.CurrentRow.Cells[0].Value.ToString() == "")
            {
                MessageBox.Show("Selecione uma linha válida!");
            }
            else
            {
                string   placa = dgVeiculoAbast.CurrentRow.Cells[0].Value.ToString();
                long     cnpj  = long.Parse(dgVeiculoAbast.CurrentRow.Cells[1].Value.ToString());
                DateTime data  = Convert.ToDateTime(dgVeiculoAbast.CurrentRow.Cells[5].Value);

                foreach (Abastecimento abastecimento in ListaAbastecimentos)
                {
                    if (abastecimento.Placa == placa && abastecimento.CNPJ == cnpj && abastecimento.Data == data)
                    {
                        PlacaAntiga = abastecimento.Placa;
                        TipoAntigo  = abastecimento.Tipo.ToString();
                        dataAntiga  = abastecimento.Data;

                        cbTipo.SelectedItem            = abastecimento.Tipo;
                        dtDataAbast.Value              = abastecimento.Data;
                        txtQuantidadeLitros.Text       = abastecimento.Litros.ToString();
                        txtValor.Text                  = abastecimento.Valor.ToString();
                        cbPlaca.SelectedValue          = abastecimento.Placa;
                        cbServicoExterno.SelectedValue = abastecimento.CNPJ;

                        MessageBox.Show("Dados enviados para a Tela de Cadastro.");
                        tbControlAbast.SelectTab("tbPageCadastroAbast");
                        if (tbControlAbast.SelectedTab == tbPageCadastroAbast)
                        {
                            dtDataAbastConsulta.Value = DateTime.Now;
                            Abastecimento             = null;

                            cbTipoAbastConsulta.Text  = "";
                            cbPlacaAbastConsulta.Text = "";
                            dtDataAbastConsulta.Value = DateTime.Now;

                            btnCadastrarAbast.Visible = false;
                            lblCancelar.Visible       = true;
                            btnAlterarAbast.Enabled   = true;

                            if (PerfilAcesso == PerfilAcesso.Atendimento || PerfilAcesso == PerfilAcesso.Operacional)
                            {
                                btnExcluirAbast.Enabled = false;
                            }
                            else
                            {
                                btnExcluirAbast.Enabled = true;
                            }
                        }
                    }
                }
                dgVeiculoAbast.DataSource = null;
            }
        }
コード例 #22
0
        private void AbastecimentosFinDetailsBtn_Click(object sender, RoutedEventArgs e)
        {
            Abastecimento abastecimento = ServicoDados.ServicoDadosAbastecimento.ObterAbastecimentoPorId((AbastecimentosFinalizadosDataGrid.SelectedItem as Abastecimento).AbastecimentoId);

            FormAlterarDetalhesAbastecimento formAlterarDetalhesAbastecimento = new FormAlterarDetalhesAbastecimento(abastecimento);

            formAlterarDetalhesAbastecimento.Show();
        }
コード例 #23
0
ファイル: Alterar.cs プロジェクト: Caiocesar173/PIM_4_Periodo
        public bool Abastecimento(Abastecimento Abastecimento, int TipoPesquisa)
        {
            try
            {
                DataTable        table   = new DataTable();
                MySqlDataAdapter adapter = new MySqlDataAdapter();
                MySqlCommand     command = new MySqlCommand();

                table = Consulta.Abastecimento(Abastecimento, TipoPesquisa);

                //Verifica se o Abastecimento Ja esta cadastrado.
                if (table.Rows.Count != 0)
                {
                    if (!Conexão.Checkconection())
                    {
                        Conexão.Conectar();
                    }

                    if (Conexão.Checkconection())
                    {
                        string AlterAbastecimento = "UPDATE ABASTECIMENTO SET KM_NO_ABASTECIMENTO = @KM_NO_ABASTECIMENTO, LITROS = @LITROS, VALOR = @VALOR, ID_POSTO = @ID_POSTO, ID_VEICULO = @ID_VEICULO, DATAS = @DATAS WHERE ID_ABASTECIMENTO = @ID_ABASTECIMENTO;";


                        command.CommandText = AlterAbastecimento;
                        command.Connection  = Conexão.Pega_Conexão();
                        command.Parameters.Add("@KM_NO_ABASTECIMENTO", MySqlDbType.VarChar).Value = Abastecimento.Km_No_Abastecimento;
                        command.Parameters.Add("@LITROS", MySqlDbType.VarChar).Value         = Abastecimento.Litros;
                        command.Parameters.Add("@VALOR", MySqlDbType.VarChar).Value          = Abastecimento.Valor;
                        command.Parameters.Add("@ID_POSTO", MySqlDbType.VarChar).Value       = Abastecimento.ID_Posto;
                        command.Parameters.Add("@ID_VEICULO", MySqlDbType.VarChar).Value     = Abastecimento.ID_Veiculo;
                        command.Parameters.Add("@DATAS", MySqlDbType.VarChar).Value          = Abastecimento.Data;
                        command.Parameters.Add("@ID_ABASTECIMENTO", MySqlDbType.Int32).Value = table.Rows[0][0];

                        int retorno = command.ExecuteNonQuery();
                        if (retorno > 0)
                        {
                            Abastecimento_Alterado = true;
                        }
                        Conexão.Desconectar();
                    }
                    else
                    {
                        return(Abastecimento_Alterado);
                    }
                }
                else
                {
                    MessageBox.Show("Atendimento não pode ser Alterado", "Problemas ao Alterar");
                }
            }
            catch (MySqlException Exception)
            {
                MessageBox.Show(Convert.ToString(Exception), "Estado da Conexão");
            }

            return(Abastecimento_Alterado);
        }
コード例 #24
0
 public Abastecimentos()
 {
     InitializeComponent();
     _abastecimentoController = InstanciarCamadas();
     Abastecimento            = null;
     PlacaAntiga = "";
     TipoAntigo  = "";
     dataAntiga  = new DateTime(2000, 01, 01);
 }
コード例 #25
0
        public void RemoverAbastecimentoPorId(long?id)
        {
            using EFContext Context = new EFContext();
            Abastecimento abastecimento = ObterAbastecimentoPorId(id);

            AttachItem(abastecimento, Context);
            Context.Abastecimentos.Remove(abastecimento);
            Context.SaveChanges();
        }
コード例 #26
0
 public void Insert(Abastecimento info)
 {
     using (var context = new Context())
     {
         info.Veiculo = context.Veiculos.Find(info.Veiculo.Placa);
         context.Abastecimentos.Add(info);
         context.SaveChanges();
     }
 }
コード例 #27
0
 public IActionResult EditAbastecimento(int id, Abastecimento abastecimento)
 {
     if (id != abastecimento.Id)
     {
         return(BadRequest());
     }
     _abastecimentoService.Update(abastecimento);
     return(RedirectToAction(nameof(Index)));
 }
コード例 #28
0
        public bool Abastecimento(Abastecimento Abastecimento, int TipoPesquisa)
        {
            try
            {
                DataTable        table   = new DataTable();
                MySqlDataAdapter adapter = new MySqlDataAdapter();
                MySqlCommand     command = new MySqlCommand();

                table = Consulta.Abastecimento(Abastecimento, TipoPesquisa);

                //Verifica se o Abastecimento Ja esta cadastrado.
                if (table.Rows.Count == 0)
                {
                    if (!Conexão.Checkconection())
                    {
                        Conexão.Conectar();
                    }

                    if (Conexão.Checkconection())
                    {
                        string InsertAbastecimento = "INSERT INTO ABASTECIMENTO(KM_NO_ABASTECIMENTO, LITROS, VALOR, ID_POSTO, ID_VEICULO, DATAS) VALUES (@KM_NO_ABASTECIMENTO, @LITROS, @VALOR, @ID_POSTO, @ID_VEICULO, @DATAS);";


                        command.CommandText = InsertAbastecimento;
                        command.Connection  = Conexão.Pega_Conexão();
                        command.Parameters.Add("@KM_NO_ABASTECIMENTO", MySqlDbType.VarChar).Value = Abastecimento.Km_No_Abastecimento;
                        command.Parameters.Add("@LITROS", MySqlDbType.VarChar).Value     = Abastecimento.Litros;
                        command.Parameters.Add("@VALOR", MySqlDbType.VarChar).Value      = Abastecimento.Valor;
                        command.Parameters.Add("@ID_POSTO", MySqlDbType.VarChar).Value   = Abastecimento.ID_Posto;
                        command.Parameters.Add("@ID_VEICULO", MySqlDbType.VarChar).Value = Abastecimento.ID_Veiculo;
                        command.Parameters.Add("@DATAS", MySqlDbType.VarChar).Value      = Abastecimento.Data;

                        int retorno = command.ExecuteNonQuery();
                        if (retorno > 0)
                        {
                            Abastecimento_Incluido = true;
                        }
                        Conexão.Desconectar();
                    }
                    else
                    {
                        return(Abastecimento_Incluido);
                    }
                }
                else
                {
                    MessageBox.Show("Abastecimento já Existe", "Problemas ao inserir");
                }
            }
            catch (MySqlException Exception)
            {
                MessageBox.Show(Convert.ToString(Exception), "Estado da Conexão");
            }

            return(Abastecimento_Incluido);
        }
コード例 #29
0
        public IActionResult ExcluirAbastecimento(int id)
        {
            int ret = new Abastecimento().Excluir(id);

            if (ret > 0)
            {
                return(Ok("Excluido com sucesso!"));
            }
            return(BadRequest());
        }
コード例 #30
0
        public ActionResult BuscarAbastecimento()
        {
            List <Abastecimento> abastecimento = new Abastecimento().Buscar();

            if (abastecimento == null)
            {
                return(NotFound());
            }
            return(Json(abastecimento));
        }