public async Task <ActionResult <Posto> > PostPosto(Posto posto) { _context.Posto.Add(posto); await _context.SaveChangesAsync(); return(CreatedAtAction("GetPosto", new { id = posto.Id }, posto)); }
public static void AtualizarAdmPosto(Posto posto) { string listaPostos = "UPDATE postos SET admPosto = @adm, " + "cpfAdmPosto = @cpf " + "WHERE cnpj = @cnpj " + "INSERT INTO pacientes(nome, senha,idEndereco, perfil,cpfAdm, cartaoCidadao ) " + "VALUES(@adm, @senha, 1, 'Administrador', @cpf, @cartaoCidadao) "; int atualizado = 0; try { using (IDbConnection conn = new SqlConnection(connectionString)) { atualizado = conn.Execute(listaPostos, new { adm = posto.admPosto, senha = posto.senha, cpf = posto.cpfAdmPosto, cnpj = posto.cnpj, cartaoCidadao = posto.cpfAdmPosto }); } if (atualizado <= 0) { throw new Exception("Posto não atualizado. Houve um erro interno, favor contate o administrador."); } } catch (SqlException ex) { throw new Exception("Houve um erro ao realizar o cadastro do administrador. Contate o suporte."); } }
public async Task <IActionResult> Edit(int id, [Bind("PostoId,Nome")] Posto posto) { if (id != posto.PostoId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(posto); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PostoExists(posto.PostoId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(posto)); }
private void pEditar_Click(object sender, EventArgs e) { Posto posto = (Posto)lista[this.dataGrid.CurrentRowIndex]; GerenciadorDados.Instancia.Set(posto); Program.FormStack.Push(typeof(CadastroPostos)); }
public List <Posto> listar() { List <Posto> lista = new List <Posto>(); Posto posto; MySqlDataReader reader; try { command.Connection.Open(); vsql.Append("SELECT ID,NOME,BAIRRO,CIDADE,UF FROM TB_POSTO "); vsql.Append("SELECT NOME "); command.CommandText = vsql.ToString(); reader = command.ExecuteReader(); while (reader.Read()) { posto = new Posto(); posto.ID = Convert.ToInt32(reader["ID"].ToString()); posto.nome = reader["NOME"].ToString(); posto.bairro = reader["BAIRRO"].ToString(); posto.cidade = reader["CIDADE"].ToString(); posto.uf = reader["UF"].ToString(); lista.Add(posto); } } finally { command.Connection.Close(); } return(lista); }
public async Task <IActionResult> PutPosto(int id, Posto posto) { if (id != posto.Id) { return(BadRequest()); } _context.Entry(posto).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PostoExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public override void TratarDados() { Posto posto = (Posto)GerenciadorDados.Instancia.Get(); if (posto != null) { this.tId.Text = posto.Id.ToString(); // Endereço this.tEnderecoId.Text = posto.Endereco.Id.ToString(); this.tBairro.Text = posto.Endereco.Bairro; this.tCEP.Text = posto.Endereco.CodigoPostal; this.tRua.Text = posto.Endereco.Logradouro; this.tNumero.Text = posto.Endereco.Numero; this.tComplemento.Text = posto.Endereco.Complemento; if (posto.Endereco.Cidade != null) { this.cmbCidade.SelectedItem = posto.Endereco; } // Empresa. this.tCNPJ.Text = posto.PessoaJuridica.CNPJ; this.tPJId.Text = posto.PessoaJuridica.Id.ToString(); // Posto. this.tNome.Text = posto.PessoaJuridica.NomeFantasia; this.tObs.Text = posto.Observacoes; } }
private void pExcluir_Click(object sender, EventArgs e) { Posto posto = (Posto)lista[this.dataGrid.CurrentRowIndex]; VeiculozFachada.Instancia.ExcluirPosto(posto.Id); this.TratarDados(); }
public PostoColecao ConsultarPorId(int IDCADPOSTO) { try { PostoColecao postoColecao = new PostoColecao(); acessoDadosSqlServer.LimparParametros(); acessoDadosSqlServer.AdicionarParametros("@IDCADPOSTO", IDCADPOSTO); DataTable dataTablePosto = acessoDadosSqlServer.ExecutarConsulta(CommandType.StoredProcedure, "uspCADPOSTOConsultarPorID"); foreach (DataRow dataRowLinha in dataTablePosto.Rows) { Posto posto = new Posto(); posto.IDCADPOSTO = Convert.ToInt32(dataRowLinha["IDCADPOSTO"]); posto.CADPOSTO = Convert.ToString(dataRowLinha["CADPOSTO"]); postoColecao.Add(posto); } return(postoColecao); } catch (Exception exception) { throw new Exception("Não foi possível consultar o posto por código. Detalhes: " + exception.Message); } }
//Construtor public FrmPostoCadastrar(AcaoNaTela acaoNaTela, Posto posto) { InitializeComponent(); this.acaoNaTelaSelecionada = acaoNaTela; if (acaoNaTela == AcaoNaTela.Inserir) { this.Text = "Inserir Serviço"; } else if (acaoNaTela == AcaoNaTela.Alterar) { this.Text = "Alterar Serviço"; textBoxCodigo.Text = posto.IDCADPOSTO.ToString(); textBoxPosto.Text = posto.CADPOSTO; } else if (acaoNaTela == AcaoNaTela.Consultar) { this.Text = "Consultar Serviço"; //Carregar campos da tela textBoxCodigo.Text = posto.IDCADPOSTO.ToString(); textBoxPosto.Text = posto.CADPOSTO; //Desabilitar campos da tela textBoxPosto.ReadOnly = true; textBoxPosto.TabStop = false; buttonSalvar.Visible = false; buttonCancelar.Text = "&Fechar"; buttonCancelar.Focus(); } }
public override void Excluir(long id) { Posto posto = (Posto)this.Obter(id); enderecoNegocio.Excluir(posto.Endereco.Id); pessoaJuridicaNegocio.Excluir(posto.PessoaJuridica.Id); base.Excluir(id); }
public override void Salvar(Midas.Nucleo.Objetos.ObjetoNegocio objeto) { Posto posto = (Posto)objeto; pessoaJuridicaNegocio.Salvar(posto.PessoaJuridica); enderecoNegocio.Salvar(posto.Endereco); base.Salvar(posto); }
public ActionResult RemoverPostoAdmin(int id) { Posto posto = db.Postos.Find(id); db.Postos.Remove(posto); db.SaveChanges(); return(RedirectToAction("ListarPostosPendentes")); }
public ActionResult Index() { var bombeiro = _bombeiroStore.GetAll(); var postos = new Posto(); var quarteis = new Quartel(); return(View(bombeiro)); }
private void buttonSalvar_Click(object sender, EventArgs e) { //Verificar se é inserção ou alteração if (acaoNaTelaSelecionada == AcaoNaTela.Inserir) { Posto posto = new Posto(); posto.CADPOSTO = textBoxPosto.Text; PostoNegocios postoNegocios = new PostoNegocios(); string retorno = postoNegocios.Inserir(posto); //Tentar converter para inteiro //Se der tudo certo é porque devolveu o código do cliente //Se der errado tem a mensagem de erro try { int idPosto = Convert.ToInt32(retorno); MessageBox.Show("Serviço inserido com sucesso." + idPosto.ToString()); this.DialogResult = DialogResult.Yes; } catch { MessageBox.Show("Não foi possível inserir. Detalhes: " + retorno, "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error); this.DialogResult = DialogResult.No; } } else if (acaoNaTelaSelecionada == AcaoNaTela.Alterar) { // Crio um cliente Posto posto = new Posto(); //Coloco os campos da tela no objeto clliente, e envio para alterar no banco posto.IDCADPOSTO = Convert.ToInt32(textBoxCodigo.Text); posto.CADPOSTO = textBoxPosto.Text; PostoNegocios postoNegocios = new PostoNegocios(); string retorno = postoNegocios.Alterar(posto); //Tentar converter para inteiro //Se der tudo certo é porque devolveu o código do cliente //Se der errado tem a mensagem de erro try { int idPosto = Convert.ToInt32(retorno); MessageBox.Show("Serviço alterado com sucesso." + idPosto.ToString()); this.DialogResult = DialogResult.Yes; } catch { MessageBox.Show("Não foi possível alterar. Detalhes: " + retorno, "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error); this.DialogResult = DialogResult.No; } } }
public List <Abastecimento> listar(Posto pPosto) { criarLista(); var xmlLista = _xmlDoc.Descendants("abastecimento"). Where(x => x.Element("id_posto").Value == pPosto.ID.ToString()); carregaListaAbastecimento(xmlLista); return(_lista); }
Spettacolo spettacolo; /**< Detailed Spettacolo rappresentato dal Biglietto */ /** Il costruttore. Inizializza gli attributi. */ public Biglietto(Persona cliente, Posto posto,Spettacolo spettacolo) { this.cliente = cliente; nBiglietto++; this.posto = posto; this.spettacolo = spettacolo; }
public bool Posto(Posto Posto, int TipoPesquisa) { try { DataTable table = new DataTable(); MySqlDataAdapter adapter = new MySqlDataAdapter(); MySqlCommand command = new MySqlCommand(); table = Consulta.Posto(Posto, TipoPesquisa); //Verifica se o Posto Ja esta cadastrado. if (table.Rows.Count != 0) { if (!Conexão.Checkconection()) { Conexão.Conectar(); } if (Conexão.Checkconection()) { string AlterPosto = "UPDATE POSTO SET NOME = @NOME, CNPJ = @CNPJ, RAZAO_SOCIAL = @RAZAO_SOCIAL, TELEFONE = @TELEFONE, CELULAR = @CELULAR, SITE = @SITE, ENDERECO = @ENDERECO WHERE ID_POSTO = @ID_POSTO"; command.CommandText = AlterPosto; command.Connection = Conexão.Pega_Conexão(); command.Parameters.Add("@NOME", MySqlDbType.VarChar).Value = Posto.Nome; command.Parameters.Add("@CNPJ", MySqlDbType.VarChar).Value = Posto.CNPJ; command.Parameters.Add("@RAZAO_SOCIAL", MySqlDbType.VarChar).Value = Posto.RazaoSocial; command.Parameters.Add("@TELEFONE", MySqlDbType.Int32).Value = Posto.Telefone; command.Parameters.Add("@CELULAR", MySqlDbType.Int32).Value = Posto.Celular; command.Parameters.Add("@ENDERECO", MySqlDbType.VarChar).Value = Posto.Endereço; command.Parameters.Add("@ID_POSTO", MySqlDbType.Int32).Value = table.Rows[0][0]; int retorno = command.ExecuteNonQuery(); if (retorno > 0) { Posto_Alterado = true; } Conexão.Desconectar(); } else { return(Posto_Alterado); } } else { MessageBox.Show("Posto não pode ser Alterado", "Problemas ao Alterar"); } } catch (MySqlException Exception) { MessageBox.Show(Convert.ToString(Exception), "Estado da Conexão"); } return(Posto_Alterado); }
public ActionResult EditarPosto([Bind(Include = "PostoId,Estado,EstacaoId")] Posto posto) { if (ModelState.IsValid) { db.Entry(posto).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("ListarPostos")); } return(View(posto)); }
public ActionResult NovoPosto([Bind(Include = "EstacaoId")] Posto posto) { if (ModelState.IsValid) { db.Postos.Add(new Posto(false, posto.EstacaoId)); db.SaveChanges(); return(RedirectToAction("ListarPostos")); } return(View(posto)); }
public bool Posto(Posto Posto, int TipoPesquisa) { try { DataTable table = new DataTable(); MySqlDataAdapter adapter = new MySqlDataAdapter(); MySqlCommand command = new MySqlCommand(); table = Consulta.Posto(Posto, TipoPesquisa); //Verifica se o Posto Ja esta cadastrado. if (table.Rows.Count == 0) { if (!Conexão.Checkconection()) { Conexão.Conectar(); } if (Conexão.Checkconection()) { string InsertPosto = "INSERT INTO POSTO(NOME, CNPJ, RAZAO_SOCIAL, TELEFONE, CELULAR, ENDERECO) VALUES (@NOME, @CNPJ, @RAZAO_SOCIAL, @TELEFONE, @CELULAR, @ENDERECO);"; command.CommandText = InsertPosto; command.Connection = Conexão.Pega_Conexão(); command.Parameters.Add("@NOME", MySqlDbType.VarChar).Value = Posto.Nome; command.Parameters.Add("@CNPJ", MySqlDbType.VarChar).Value = Posto.CNPJ; command.Parameters.Add("@RAZAO_SOCIAL", MySqlDbType.VarChar).Value = Posto.RazaoSocial; command.Parameters.Add("@TELEFONE", MySqlDbType.Int32).Value = Posto.Telefone; command.Parameters.Add("@CELULAR", MySqlDbType.Int32).Value = Posto.Celular; command.Parameters.Add("@ENDERECO", MySqlDbType.VarChar).Value = Posto.Endereço; int retorno = command.ExecuteNonQuery(); if (retorno > 0) { Posto_Incluido = true; } Conexão.Desconectar(); } else { return(Posto_Incluido); } } else { MessageBox.Show("Posto já Existe", "Problemas ao inserir"); } } catch (MySqlException Exception) { MessageBox.Show(Convert.ToString(Exception), "Estado da Conexão"); } return(Posto_Incluido); }
public ActionResult AceitarPostoAdmin([Bind(Include = "PostoId,EstacaoId")] Posto posto) { if (ModelState.IsValid) { posto.Estado = true; db.Entry(posto).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("ListarPostosPendentes")); } return(View(posto)); }
public async Task <IActionResult> Create([Bind("PostoId,Nome")] Posto posto) { if (ModelState.IsValid) { _context.Add(posto); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(posto)); }
/// <summary> /// Converter um SqlCeDataReader em um objeto Posto. /// </summary> /// <param name="entrada">SqlCeDataReader</param> /// <returns>Posto</returns> public object Converter(object entrada) { SqlCeDataReader dataReader = (SqlCeDataReader)entrada; Posto posto = new Posto(); posto.Id = dataReader.GetInt32(0); posto.Distribuidora = (Distribuidora)Negocio.NegocioFactory.Instancia.DistribuidoraNegocio.Obter(dataReader.GetInt32(1)); posto.PessoaJuridica = (PessoaJuridica)Midas.Nucleo.Negocio.NegocioFactory.Instancia.PessoaJuridicaNegocio.Obter(dataReader.GetInt32(2)); posto.Endereco = (Endereco)Midas.Nucleo.Negocio.NegocioFactory.Instancia.EnderecoNegocio.Obter(dataReader.GetInt32(3)); posto.Observacoes = dataReader.GetString(4); return(posto); }
public JsonResult Edit(Posto posto) { try { var newPosto = _postoStore.Save(posto); return(Json(new { success = true, message = "Posto guardado com sucesso!" })); } catch (Exception) { return(Json(new { success = false, message = "Erro ao guardar este Posto" })); } }
public bool Posto(Posto Posto, int TipoPesquisa) { try { DataTable table = new DataTable(); MySqlDataAdapter adapter = new MySqlDataAdapter(); MySqlCommand command = new MySqlCommand(); table = Consulta.Posto(Posto, TipoPesquisa); //Verifica se o Posto Ja esta cadastrado. if (table.Rows.Count == 0) { if (!Conexão.Checkconection()) { Conexão.Conectar(); } if (Conexão.Checkconection()) { string ExcludPosto = "DELETE FROM `POSTO` WHERE ID_POSTO = @ID_POSTO;"; command.CommandText = ExcludPosto; command.Connection = Conexão.Pega_Conexão(); command.Parameters.Add("@ID_POSTO", MySqlDbType.Int32).Value = table.Rows[0][0]; int retorno = command.ExecuteNonQuery(); if (retorno > 0) { Posto_Excluido = true; } Conexão.Desconectar(); } else { return(Posto_Excluido); } } else { MessageBox.Show("Posto não pode ser Excluido", "Problemas ao Excluir"); } } catch (MySqlException Exception) { MessageBox.Show(Convert.ToString(Exception), "Estado da Conexão"); } return(Posto_Excluido); }
public string Excluir(Posto posto) { try { acessoDadosSqlServer.LimparParametros(); acessoDadosSqlServer.AdicionarParametros("@IDCADPOSTO", posto.IDCADPOSTO); string IDCADPOSTO = acessoDadosSqlServer.ExecutarManipulacao(CommandType.StoredProcedure, "uspCADPOSTOExcluir").ToString(); return(IDCADPOSTO); } catch (Exception exception) { return(exception.Message); } }
public Posto Save(Posto save) { Posto saved = null; if (_repository.IsExisting(save.Id)) { saved = _repository.Update(save); } else { saved = _repository.Create(save); } return(saved); }
public Posto Update(Posto posto) { if (posto == null) { return(null); } using (var context = new MapaDaForcaDbContext(Options)) { context.Postos.Add(posto); context.Entry(posto).State = EntityState.Modified; return(context.SaveChanges() > 0 ? posto : null); } }
private void pSalvar_Click(object sender, EventArgs e) { Posto posto = new Posto(); if (this.tId.Text != "") { posto.Id = Int32.Parse(this.tId.Text); } PessoaJuridica pj = new PessoaJuridica(); if (this.tPJId.Text != "") { pj.Id = Int32.Parse(this.tPJId.Text); } pj.CNPJ = this.tCNPJ.Text; pj.NomeFantasia = tNome.Text; posto.PessoaJuridica = pj; posto.Observacoes = this.tObs.Text; posto.Distribuidora = (Distribuidora)this.cmbDistribuidora.SelectedItem; Endereco endereco = new Endereco(); if (this.tEnderecoId.Text != "") { endereco.Id = Int32.Parse(this.tEnderecoId.Text); } endereco.Bairro = this.tBairro.Text; endereco.Logradouro = this.tRua.Text; endereco.Complemento = this.tComplemento.Text; endereco.CodigoPostal = this.tCEP.Text; endereco.Numero = this.tNumero.Text; endereco.Cidade = null; endereco.CodigoPostal = tCEP.Text; posto.Endereco = endereco; Validacao v = new Midas.VeiculoZ.Validador.PostoValidador().Validar(posto); if (v.Passou) { VeiculozFachada.Instancia.SalvarPosto(posto); this.tId.Text = posto.Id.ToString(); this.tPJId.Text = posto.PessoaJuridica.Id.ToString(); this.tEnderecoId.Text = posto.Endereco.Id.ToString(); } else { MessageBox.Show(v.Mensagem, "Erro"); } }