public void guardarSuceso(object sender,EventArgs e) { sucesoBean suceso = new sucesoBean(); suceso.codigo_usuario_reporta = GlobalSistema.sistema.obtenerDatosUsuario(lblUsuarioReporta.Text,true).getCodigoUsuario(); suceso.codigo_usuario = Int16.Parse(lsBxUsuarios.SelectedValue); suceso.codigoIncidente = txbxCodigoIncidente.Text; UsuarioBean usrTmp = new UsuarioBean(); usrTmp.setCodigoUsuario(0); List<SucesoReporteBean> lsSuceso = GlobalSistema.sistema.obtenerIncidentesReportePorUsuario(txbxCodigoIncidente.Text, usrTmp); if (lsSuceso.Count > 0) { lblMensaje.Text = "Suceso ya registrado "; return; } DateTime fechaRegistro = DateTime.ParseExact("01/01/1900", "MM/dd/yyyy", CultureInfo.CreateSpecificCulture("en-US")); suceso.registroIncidente = DateTime.Now; suceso.reporteIncidente = fechaRegistro; suceso.fechaCierre = fechaRegistro; suceso.primerInteraccion = fechaRegistro; suceso.etiqueta = txbxDescripcion.Text; suceso.pais = ""; suceso.descripcionincidente = ""; suceso.codigoGrupoAsignado = 1; lblMensaje.Text = GlobalSistema.sistema.insertarActualizarSucesoUsuario(suceso); }
public List<UsuarioBean> obtenerUsurioByDocumento(string documento, bool tipoBusqueda) { SqlCommand cmd = null; if (tipoBusqueda) // true es documento { cmd = new SqlCommand("obtener_usuario_sp", conn); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@documento", documento); } else { cmd = new SqlCommand("obtener_usuario_id_sp", conn); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@codigo_usuario", documento); } List<UsuarioBean> usuarios = new List<UsuarioBean>(); try { SqlDataAdapter da = new SqlDataAdapter(cmd); DataTable tb = new DataTable("UsuarioBean"); da.Fill(tb); for (int i = 0; i < tb.Rows.Count; i++) { UsuarioBean usuario = new UsuarioBean(); usuario.setCodigoUsuario(Convert.ToInt16(tb.Rows[i][0].ToString())); usuario.setNumeroDocumento(tb.Rows[i][1].ToString()); usuario.setNombres(tb.Rows[i][2].ToString()); usuario.setApellido(tb.Rows[i][3].ToString()); usuario.setEstadoUsuario(tb.Rows[i][4].ToString()); usuario.setFechaCreacion(DateTime.Parse(tb.Rows[i][5].ToString())); if (!string.IsNullOrEmpty(tb.Rows[i][6].ToString())) usuario.setFechaUltimoAcceso(DateTime.Parse(tb.Rows[i][6].ToString())); usuario.setNivelAcceso(Convert.ToInt16(tb.Rows[i][7].ToString())); usuario.setPassword(tb.Rows[i][8].ToString()); usuario.setCorreo(tb.Rows[i][9].ToString()); usuarios.Add(usuario); } return usuarios; } catch (IndexOutOfRangeException ex) { logs.escritura_archivo_string_ex(ex); throw new ExpObtenerRegistro(ex.Message); } catch (ArgumentNullException ex) { logs.escritura_archivo_string_ex(ex); throw new ExpObtenerRegistro(ex.Message); } catch (Exception ex) { logs.escritura_archivo_string_ex(ex); throw new Exception(ex.Message); } }
public void guardar_suceso_sistema(object sender, EventArgs e) { if (suceso == null) { suceso = new sucesoBean(); } //Buscar si código de suceso fue ingresado anteriormente UsuarioBean usrTmp = new UsuarioBean(); usrTmp.setCodigoUsuario(0); List<SucesoReporteBean> lsSuceso = GlobalSistema.sistema.obtenerIncidentesReportePorUsuario(txbxNumIncidente.Text,usrTmp); //if (lsSuceso.Count > 0 && sesionUsuario.getNivelAcceso() != 0) //{ suceso.codigo_usuario = GlobalSistema.sistema.obtenerDatosUsuario(lblUsuarioRegistra.Text, true).getCodigoUsuario(); // if (!sesionUsuario.getNumeroDocumento().Equals(lsSuceso[0].documento)) // { // lblMensajeError.Text = "Suceso registrado, con usuario " + lsSuceso[0].codigo_usuario + " solo este usuario puede editar"; // return; // } //} //else { suceso.codigo_usuario = sesionUsuario.getCodigoUsuario(); //} //DateTime fechaRegistro = Convert.ToDateTime(this.txbxFechaIncidente.Text); DateTime fechaRegistro = System.DateTime.Now; try { if (txbxFechaIncidente.Text.EndsWith("AM") || txbxFechaIncidente.Text.EndsWith("PM")) { fechaRegistro = DateTime.ParseExact(this.txbxFechaIncidente.Text, GlobalSistema.formatoFecha, CultureInfo.CreateSpecificCulture("en-US")); } else { fechaRegistro = DateTime.ParseExact(this.txbxFechaIncidente.Text, "MM/dd/yyyy HH:mm", CultureInfo.CreateSpecificCulture("en-US")); } suceso.reporteIncidente = fechaRegistro; //DateTime fechaPrimeraInteraccion = Convert.ToDateTime("1900-01-01"); DateTime fechaPrimeraInteraccion = DateTime.ParseExact("01/01/1900", "MM/dd/yyyy", CultureInfo.CreateSpecificCulture("en-US")); //DateTime fechaFin = Convert.ToDateTime("1900-01-01"); DateTime fechaFin = DateTime.ParseExact("01/01/1900", "MM/dd/yyyy", CultureInfo.CreateSpecificCulture("en-US")); if (!string.IsNullOrEmpty(this.txbxFechaInicio.Text)) { //fechaPrimeraInteraccion = Convert.ToDateTime(this.txbxFechaInicio.Text); if (txbxFechaInicio.Text.EndsWith("AM") || txbxFechaInicio.Text.EndsWith("PM")) { fechaPrimeraInteraccion = DateTime.ParseExact(this.txbxFechaInicio.Text, GlobalSistema.formatoFecha, CultureInfo.CreateSpecificCulture("en-US")); } else { fechaPrimeraInteraccion = DateTime.ParseExact(this.txbxFechaInicio.Text, "MM/dd/yyyy HH:mm", CultureInfo.CreateSpecificCulture("en-US")); } if (DateTime.Compare(fechaPrimeraInteraccion, fechaRegistro) < 0) { this.lblMensajeError.Text = "Fecha de Primera Interacción debe ser mayor que la fecha registro"; return; } suceso.primerInteraccion = fechaPrimeraInteraccion; } else { suceso.primerInteraccion = fechaPrimeraInteraccion; } if (!string.IsNullOrEmpty(this.txbxFechaFin.Text)) { //fechaFin = Convert.ToDateTime(this.txbxFechaFin.Text); if (txbxFechaFin.Text.EndsWith("AM") || txbxFechaFin.Text.EndsWith("PM")) { fechaFin = DateTime.ParseExact(this.txbxFechaFin.Text, GlobalSistema.formatoFecha, CultureInfo.CreateSpecificCulture("en-US")); } else { fechaFin = DateTime.ParseExact(this.txbxFechaFin.Text, "MM/dd/yyyy HH:mm", CultureInfo.CreateSpecificCulture("en-US")); } if (DateTime.Compare(fechaPrimeraInteraccion, Convert.ToDateTime("1900-01-01")) == 0) { this.lblMensajeError.Text = "Seleccione una fecha de primera iteracción para cerrar"; return; } if (DateTime.Compare(fechaPrimeraInteraccion, fechaFin) > 0) { this.lblMensajeError.Text = "Fecha de cierre debe ser mayor que la Primera Interacción"; return; } suceso.fechaCierre = fechaFin; } else { suceso.fechaCierre = fechaFin; } suceso.codigoIncidente = this.txbxNumIncidente.Text; suceso.descripcionincidente = this.txbxObservacion.Text; suceso.etiqueta = this.txbxEtiqueta.Text; suceso.pais = this.txbxPais.Text; suceso.codigoDato = Convert.ToInt16(this.lsBxDatoSeleccionado.SelectedValue); suceso.estadoIncidente = Convert.ToInt16(this.lsBxEstadoIncidente.SelectedValue); suceso.codigoGrupoAsignado = Convert.ToInt16(this.lsBxGrupoAsignado.SelectedValue); suceso.codigoSop = Convert.ToInt16(this.lsBxSOP.SelectedValue); suceso.codigoTierUno = Convert.ToInt16(this.lsBxTierUno.SelectedValue); suceso.codigoTierDos = Convert.ToInt16(this.lsBxTierII.SelectedValue); suceso.codigoTierTres = Convert.ToInt16(this.lsBxTierIII.SelectedValue); suceso.codigoTipoSistemas = Convert.ToInt16(this.lsBxTipoSistemas.SelectedValue); suceso.codigo_usuario_reporta = GlobalSistema.sistema.obtenerDatosUsuario(lblUsuarioAsigna.Text, true).getCodigoUsuario(); suceso.enviadoSistmas = chBxEnviado.Checked; suceso.recibidoSistemas = chbxRebido.Checked; suceso.estadistica = chbxEstadistica.Checked; lblMensajeError.Text = GlobalSistema.sistema.insertarActualizarSucesoUsuario(suceso); } catch(FormatException ex) { lblMensajeError.Text = ex.Message; lblMensajeError.Text = "Debe ingresar formato de fecha Remedy"; } }
public string insertarActualizarSucesoUsuario(sucesoBean sucesoUsr) { mibase.abrir_conexion_base(); UsuarioBean usr = new UsuarioBean(); usr.setCodigoUsuario(0); string mensaje = string.Empty; try { List<sucesoBean> sucesos = mibase.obtenerListaSuceso(sucesoUsr.codigoIncidente, usr); if (sucesos.Count > 0) { //actualizamos mensaje = mibase.insertarActulizarSuceso(sucesoUsr, false); } else { // insertamos sucesoUsr.etiqueta = ""; mensaje =mibase.insertarActulizarSuceso(sucesoUsr, true); } //mensaje = "Proceso realizado con éxito"; } catch (ExInsertarRegistro ex) { mensaje = ex.Message; } catch (ExConexionBase ex) { mensaje = ex.Message; } finally { mibase.cerrar_conexion_base(); } return mensaje; }