private bool ExisteEnLaBaseDeDatos() { RepositorioBase <Sugerencias> db = new RepositorioBase <Sugerencias>(); Sugerencias sugerencia = db.Buscar(Convert.ToInt32(SugerenciaIdTextBox.Text)); return(sugerencia != null); }
public IActionResult Sugerencias(Sugerencias sug) { if (ModelState.IsValid) { _context.Sugerencias.Add(sug); _context.SaveChanges(); return(RedirectToAction("validarSugerencias")); } return(View(sug)); }
public Sugerencias LlenaClase() { Sugerencias sugerencia = new Sugerencias(); sugerencia.SugerenciaId = Convert.ToInt32(SugerenciaIdTextBox.Text); sugerencia.Fecha = DateTime.Now; sugerencia.Descripcion = DescripcionTextBox.Text; return(sugerencia); }
public Sugerencias LLenaClase() { Sugerencias sugerencias = new Sugerencias(); sugerencias.SugerenciaId = Utils.ToInt(TextBoxId.Text); sugerencias.Fecha = Utils.ToDateTime(TextBoxFecha.Text); sugerencias.Descripcion = TextBoxDescripcion.Text; return(sugerencias); }
public Sugerencias Llenar() { Sugerencias d = new Sugerencias(); d.SugerenciasId = Utils.ToInt(SugerenciaIdTextBox.Text); d.Fecha = Utils.ToDateTime(FechaTextBox.Text); d.Descripcion = DescripcionTextBox.Text; return(d); }
protected void BuscarButton_Click(object sender, EventArgs e) { RepositorioBase <Sugerencias> repositorio = new RepositorioBase <Sugerencias>(); Sugerencias Sugerencias = repositorio.Buscar(SugerenciasIdTextBox.Text.ToInt()); if (!Sugerencias.EsNulo()) { Limpiar(); LlenaCampo(Sugerencias); } else { Utils.ToastSweet(this, IconType.info, TiposMensajes.RegistroNoEncontrado); } }
protected void buscarButton_Click(object sender, EventArgs e) { RepositorioBase <Sugerencias> Repositorio = new RepositorioBase <Sugerencias>(); Sugerencias Sugerencias = new Sugerencias(); Sugerencias = Repositorio.Buscar(Utils.ToInt(SugerenciaIdTextBox.Text)); if (Sugerencias != null) { RegSugerenciasLlenaCampo(Sugerencias); } else { Utils.ShowToastr(this.Page, "Error no se pudo buscar", "Error", "error"); Limpiar(); } }
protected void BuscarButton_Click(object sender, EventArgs e) { int id; RepositorioBase <Sugerencias> db = new RepositorioBase <Sugerencias>(); Sugerencias sugerencia = new Sugerencias(); int.TryParse(SugerenciaIdTextBox.Text, out id); Limpiar(); sugerencia = db.Buscar(id); if (sugerencia != null) { LlenaCampo(sugerencia); } else { Utilitarios.Utils.ShowToastr(this.Page, "No se encontro ese tipo de analisis", "Error", "error"); } }
private void eliminarSugerencia_Click(object sender, EventArgs e) { try { Sugerencias soliSugerencia = new Sugerencias(); soliSugerencia.IdSugerencia = Convert.ToInt32(txtSugerencia.Text); if (soliSugerencia.eliminar()) { limpiar(); reiniciar(); const string ELIMINADO = "Registro eliminado correctamente"; MessageBox.Show(ELIMINADO, INFORMATION, MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show(soliSugerencia.Error, WARNING, MessageBoxButtons.OK, MessageBoxIcon.Warning); } } catch (Exception ex) { MessageBox.Show(ex.Message, EXCEPTION, MessageBoxButtons.OK, MessageBoxIcon.Error); } }
protected void guardarButton_Click(object sender, EventArgs e) { Sugerencias Sugerencias = new Sugerencias(); RepositorioBase <Sugerencias> Repositorio = new RepositorioBase <Sugerencias>(); bool paso = false; Sugerencias = Llenar(); if (Utils.ToInt(SugerenciaIdTextBox.Text) == 0) { paso = Repositorio.Guardar(Sugerencias); Limpiar(); } else { if (!RegSugerenciasExisteEnLaBaseDeDatos()) { Utils.ShowToastr(this, "No se pudo guardar", "Error", "error"); return; } paso = Repositorio.Modificar(Sugerencias); Limpiar(); } if (paso) { Utils.ShowToastr(this, "Guardado", "Exito", "success"); return; } else { Utils.ShowToastr(this, "No se pudo guardar", "Error", "error"); } Limpiar(); }
protected void GuadarButton_Click(object sender, EventArgs e) { if (!Validar()) { return; } RepositorioBase <Sugerencias> repositorio = new RepositorioBase <Sugerencias>(); Sugerencias sugerencias = LlenaClase(); TipoTitulo tipoTitulo = TipoTitulo.OperacionFallida; TiposMensajes tiposMensajes = TiposMensajes.RegistroNoGuardado; IconType iconType = IconType.error; bool paso = false; if (sugerencias.SugerenciasId == 0) { paso = repositorio.Guardar(sugerencias); } else { if (!ExisteEnLaBaseDeDatos()) { Utils.ToastSweet(this, IconType.info, TiposMensajes.RegistroNoEncontrado); return; } paso = repositorio.Modificar(sugerencias); } if (paso) { Limpiar(); tipoTitulo = TipoTitulo.OperacionExitosa; tiposMensajes = TiposMensajes.RegistroGuardado; iconType = IconType.success; } Utils.Alerta(this, tipoTitulo, tiposMensajes, iconType); }
protected void consultar_Click(object sender, EventArgs e) { try { switch (this.solicitudes.SelectedIndex) { case 0: if (!string.IsNullOrEmpty(this.idPeticion.Text)) { Peticiones soliPeticion = new Peticiones(); soliPeticion.IdPeticion = Convert.ToInt32(this.idPeticion.Text); if (soliPeticion.consultar()) { this.area.Text = soliPeticion.Area.ToString(); this.idCliente.Text = soliPeticion.IdCliente.ToString(); this.fecha.SelectedDate = Convert.ToDateTime(soliPeticion.Fecha); this.servicio.SelectedIndex = soliPeticion.Servicio; this.idPeticion.Text = soliPeticion.IdPeticion.ToString(); this.idSuper.Text = soliPeticion.IdSupervisor.ToString(); soliPeticion = null; this.modificar.Enabled = true; this.eliminar.Enabled = true; this.idSuper.Enabled = true; break; } else { mostrarErr(soliPeticion.Error); soliPeticion = null; break; } } else { const string ERROR_PETICION_ID = "Debe ingresar el id de la petición para consultar"; mostrarErr(ERROR_PETICION_ID); } break; case 1: if (!string.IsNullOrEmpty(this.idQueja.Text)) { Quejas soliQueja = new Quejas(); soliQueja.IdQueja = Convert.ToInt32(this.idQueja.Text); if (soliQueja.consultar()) { this.area.Text = soliQueja.Area.ToString(); this.idCliente.Text = soliQueja.IdCliente.ToString(); this.fecha.SelectedDate = Convert.ToDateTime(soliQueja.Fecha); this.servicio.SelectedIndex = soliQueja.Servicio; this.idQueja.Text = soliQueja.IdQueja.ToString(); this.tipoRemu.SelectedIndex = soliQueja.IdTipoRemuneracion; soliQueja = null; this.modificar.Enabled = true; this.eliminar.Enabled = true; this.tipoRemu.Enabled = true; break; } else { mostrarErr(soliQueja.Error); soliQueja = null; break; } } else { const string ERROR_PETICION_ID = "Debe ingresar el id de la queja para consultar"; mostrarErr(ERROR_PETICION_ID); } break; case 2: if (!string.IsNullOrEmpty(this.idReclamo.Text)) { Reclamos soliReclamo = new Reclamos(); soliReclamo.IdReclamo = Convert.ToInt32(this.idReclamo.Text); if (soliReclamo.consultar()) { this.area.Text = soliReclamo.Area.ToString(); this.idCliente.Text = soliReclamo.IdCliente.ToString(); this.fecha.SelectedDate = Convert.ToDateTime(soliReclamo.Fecha); this.servicio.SelectedIndex = soliReclamo.Servicio; this.idReclamo.Text = soliReclamo.IdReclamo.ToString(); this.tipoRecl.SelectedIndex = soliReclamo.IdTipoReclamo; this.costo.Text = soliReclamo.Costo.ToString(); this.tipoSol.SelectedIndex = soliReclamo.IdSolucion; soliReclamo = null; this.modificar.Enabled = true; this.eliminar.Enabled = true; this.tipoSol.Enabled = true; this.costo.Enabled = true; break; } else { mostrarErr(soliReclamo.Error); soliReclamo = null; break; } } else { const string ERROR_PETICION_ID = "Debe ingresar el id del reclamo para consultar"; mostrarErr(ERROR_PETICION_ID); } break; case 3: if (!string.IsNullOrEmpty(this.idSuge.Text)) { Sugerencias soliSugerencia = new Sugerencias(); soliSugerencia.IdSugerencia = Convert.ToInt32(this.idSuge.Text); if (soliSugerencia.consultar()) { this.area.Text = soliSugerencia.Area.ToString(); this.idCliente.Text = soliSugerencia.IdCliente.ToString(); this.fecha.SelectedDate = Convert.ToDateTime(soliSugerencia.Fecha); this.servicio.SelectedIndex = soliSugerencia.Servicio; this.idSuge.Text = soliSugerencia.IdSugerencia.ToString(); this.sugerencia.Text = soliSugerencia.Sugerencia; soliSugerencia = null; this.modificar.Enabled = true; this.eliminar.Enabled = true; break; } else { mostrarErr(soliSugerencia.Error); soliSugerencia = null; break; } } else { const string ERROR_PETICION_ID = "Debe ingresar el id de la sugerencia para consultar"; mostrarErr(ERROR_PETICION_ID); } break; case 4: if (!string.IsNullOrEmpty(this.idFeli.Text)) { Felicitaciones soliFelicitacion = new Felicitaciones(); soliFelicitacion.IdFelicitacion = Convert.ToInt32(this.idFeli.Text); if (soliFelicitacion.consultar()) { this.area.Text = soliFelicitacion.Area.ToString(); this.idCliente.Text = soliFelicitacion.IdCliente.ToString(); this.fecha.SelectedDate = Convert.ToDateTime(soliFelicitacion.Fecha); this.servicio.SelectedIndex = soliFelicitacion.Servicio; this.idFeli.Text = soliFelicitacion.IdFelicitacion.ToString(); this.felicitacion.Text = soliFelicitacion.Felicitacion; soliFelicitacion = null; this.modificar.Enabled = true; this.eliminar.Enabled = true; break; } else { mostrarErr(soliFelicitacion.Error); soliFelicitacion = null; break; } } else { const string ERROR_PETICION_ID = "Debe ingresar el id de la felicitación para consultar"; mostrarErr(ERROR_PETICION_ID); } break; default: goto case 0; } } catch (Exception ex) { mostrarErr(ex.Message); } }
public void LLenaCampo(Sugerencias sugerencias) { TextBoxId.Text = sugerencias.SugerenciaId.ToString(); TextBoxFecha.Text = sugerencias.Fecha.ToString(); TextBoxDescripcion.Text = sugerencias.Descripcion.ToString(); }
protected void eliminar_Click(object sender, EventArgs e) { try { switch (this.solicitudes.SelectedIndex) { case 0: if (!string.IsNullOrEmpty(this.idPeticion.Text)) { Peticiones soliPeticion = new Peticiones(); soliPeticion.IdPeticion = Convert.ToInt32(this.idPeticion.Text); if (soliPeticion.eliminar()) { reiniElem(); mostrarMensaje(ELIMINADO); soliPeticion = null; break; } mostrarErr(soliPeticion.Error); soliPeticion = null; break; } const string ID_PETICIO_VACIO = "Debe ingresar el id de la petición a eliminar"; mostrarErr(ID_PETICIO_VACIO); break; case 1: if (!string.IsNullOrEmpty(this.idQueja.Text)) { Quejas soliQueja = new Quejas(); soliQueja.IdQueja = Convert.ToInt32(this.idQueja.Text); if (soliQueja.eliminar()) { reiniElem(); mostrarMensaje(ELIMINADO); soliQueja = null; break; } mostrarErr(soliQueja.Error); soliQueja = null; break; } const string ID_QUEJA_VACIO = "Debe ingresar el id de la queja a eliminar"; mostrarErr(ID_QUEJA_VACIO); break; case 2: if (!string.IsNullOrEmpty(this.idReclamo.Text)) { Reclamos soliReclamo = new Reclamos(); soliReclamo.IdReclamo = Convert.ToInt32(this.idReclamo.Text); if (soliReclamo.eliminar()) { reiniElem(); mostrarMensaje(ELIMINADO); soliReclamo = null; break; } mostrarErr(soliReclamo.Error); soliReclamo = null; break; } const string ID_RECLAMO_VACIO = "Debe ingresar el id del reclamo a eliminar"; mostrarErr(ID_RECLAMO_VACIO); break; case 3: if (!string.IsNullOrEmpty(this.idSuge.Text)) { Sugerencias soliSugerencia = new Sugerencias(); soliSugerencia.IdSugerencia = Convert.ToInt32(this.idSuge.Text); if (soliSugerencia.eliminar()) { reiniElem(); mostrarMensaje(ELIMINADO); soliSugerencia = null; break; } mostrarErr(soliSugerencia.Error); soliSugerencia = null; break; } const string ID_SUGERENCIA_VACIO = "Debe ingresar el id de la sugerencia a eliminar"; mostrarErr(ID_SUGERENCIA_VACIO); break; case 4: if (!string.IsNullOrEmpty(this.idFeli.Text)) { Felicitaciones solifelicitacion = new Felicitaciones(); solifelicitacion.IdFelicitacion = Convert.ToInt32(this.idFeli.Text); if (solifelicitacion.eliminar()) { reiniElem(); mostrarMensaje(ELIMINADO); solifelicitacion = null; break; } mostrarErr(solifelicitacion.Error); solifelicitacion = null; break; } const string ID_FELICITACION_VACIO = "Debe ingresar el id de la felicitación a eliminar"; mostrarErr(ID_FELICITACION_VACIO); break; default: goto case 0; } } catch (Exception ex) { mostrarErr(ex.Message); } }
private void LlenaCampo(Sugerencias sugerencia) { SugerenciaIdTextBox.Text = sugerencia.SugerenciaId.ToString(); DescripcionTextBox.Text = sugerencia.Descripcion; FechaTextBox.Text = sugerencia.Fecha.ToString("yyyy-MM-dd"); }
protected void modificar_Click(object sender, EventArgs e) { try { if (!validarCom()) { return; } switch (this.solicitudes.SelectedIndex) { case 0: Peticiones soliPeticion = new Peticiones(); soliPeticion.Area = Convert.ToInt32(this.area.Text); soliPeticion.IdCliente = Convert.ToInt32(this.idCliente.Text); soliPeticion.Servicio = this.servicio.SelectedIndex; soliPeticion.Fecha = this.fecha.SelectedDate.ToString(); soliPeticion.TipoSoli = UNO; soliPeticion.IdSupervisor = Convert.ToInt32(this.idSuper.Text); soliPeticion.IdPeticion = Convert.ToInt32(this.idPeticion.Text); if (soliPeticion.modificar()) { soliPeticion = null; mostrarMensaje(MODIFICADO); break; } mostrarErr(soliPeticion.Error); soliPeticion = null; break; case 1: if (validarQueja()) { Quejas soliQuejas = new Quejas(); soliQuejas.Area = Convert.ToInt32(this.area.Text); soliQuejas.IdCliente = Convert.ToInt32(this.idCliente.Text); soliQuejas.Servicio = this.servicio.SelectedIndex; soliQuejas.Fecha = this.fecha.SelectedDate.ToString(); soliQuejas.TipoSoli = DOS; soliQuejas.IdQueja = Convert.ToInt32(this.idQueja.Text); soliQuejas.IdTipoRemuneracion = this.tipoRemu.SelectedIndex; if (soliQuejas.modificar()) { soliQuejas = null; mostrarMensaje(MODIFICADO); break; } mostrarErr(soliQuejas.Error); soliQuejas = null; } break; case 2: if (validarIngrRecl() && validarModiRecl()) { Reclamos soliReclamo = new Reclamos(); soliReclamo.Area = Convert.ToInt32(this.area.Text); soliReclamo.IdCliente = Convert.ToInt32(this.idCliente.Text); soliReclamo.Servicio = this.servicio.SelectedIndex; soliReclamo.Fecha = this.fecha.SelectedDate.ToString(); soliReclamo.TipoSoli = TRES; soliReclamo.IdTipoReclamo = this.tipoRecl.SelectedIndex; soliReclamo.IdReclamo = Convert.ToInt32(this.idReclamo.Text); soliReclamo.IdSolucion = this.tipoSol.SelectedIndex; soliReclamo.Costo = Convert.ToInt32(this.costo.Text); if (soliReclamo.modificar()) { soliReclamo = null; mostrarMensaje(MODIFICADO); break; } mostrarErr(soliReclamo.Error); soliReclamo = null; } break; case 3: if (validarInreSuge()) { Sugerencias soliSugerencia = new Sugerencias(); soliSugerencia.Area = Convert.ToInt32(this.area.Text); soliSugerencia.IdCliente = Convert.ToInt32(this.idCliente.Text); soliSugerencia.Servicio = this.servicio.SelectedIndex; soliSugerencia.Fecha = this.fecha.SelectedDate.ToString(); soliSugerencia.TipoSoli = CUATRO; soliSugerencia.Sugerencia = this.sugerencia.Text; soliSugerencia.IdSugerencia = Convert.ToInt32(this.idSuge.Text); if (soliSugerencia.modificar()) { soliSugerencia = null; mostrarMensaje(MODIFICADO); break; } mostrarErr(soliSugerencia.Error); soliSugerencia = null; } break; case 4: if (validarIngrFeli()) { Felicitaciones soliFelicitacion = new Felicitaciones(); soliFelicitacion.Area = Convert.ToInt32(this.area.Text); soliFelicitacion.IdCliente = Convert.ToInt32(this.idCliente.Text); soliFelicitacion.Servicio = this.servicio.SelectedIndex; soliFelicitacion.Fecha = this.fecha.SelectedDate.ToString(); soliFelicitacion.TipoSoli = CINCO; soliFelicitacion.Felicitacion = this.felicitacion.Text; soliFelicitacion.IdFelicitacion = Convert.ToInt32(this.idFeli.Text); if (soliFelicitacion.modificar()) { soliFelicitacion = null; mostrarMensaje(MODIFICADO); break; } mostrarErr(soliFelicitacion.Error); soliFelicitacion = null; } break; default: goto case 0; } } catch (Exception ex) { mostrarErr(ex.Message); } }
private void LlenaCampo(Sugerencias sugerencias) { SugerenciasIdTextBox.Text = sugerencias.SugerenciasId.ToString(); FechaTextBox.Text = sugerencias.Fecha.ToFormatDate(); DescripcionTextBox.Text = sugerencias.Descripcion; }