private void btnAnular_Click(object sender, EventArgs e) { string mensajeCorrecto = "Atención anulada correctamente"; string mensajeError = string.Empty; bool res1 = false, res2 = false; bool necesitaDevolucion = false; try { ATENCION_AGEN atencion = new ATENCION_AGEN(); using (var context = new CMHEntities()) { atencion = context.ATENCION_AGEN.Find(((ComboboxItem)lstAtenciones.SelectedItem).Value); atencion.ESTADO_ATEN = context.ESTADO_ATEN.Find(atencion.ID_ESTADO_ATEN); if (atencion.ESTADO_ATEN.NOM_ESTADO_ATEN.ToUpper() == "PAGADO") { txtRazon.Enabled = true; necesitaDevolucion = true; } else { txtRazon.Enabled = false; } } res1 = at.anularAtencion(atencion); if (atencion.ESTADO_ATEN.NOM_ESTADO_ATEN.ToUpper() == "PAGADO") { res2 = at.devolverPago(pago, txtRazon.Text); } ActualizarLista(); } catch (Exception ex) { mensajeError = "Error al anular atención"; } if (!necesitaDevolucion && res1) { MessageBox.Show(mensajeCorrecto, "Creada", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } else { if (res1 && res2) { MessageBox.Show(mensajeCorrecto, "Creada", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } else { MessageBox.Show(mensajeError, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
private void lstAtenciones_SelectedIndexChanged(object sender, EventArgs e) { lblError.Visible = true; lblError.Text = "Consultando aseguradora..."; lblError.ForeColor = System.Drawing.Color.Violet; mostrarLabelDescuento(); try { ATENCION_AGEN atencion = new ATENCION_AGEN(); PACIENTE paciente = new PACIENTE(); PRESTACION prestacion = new PRESTACION(); ResultadoVerificacionSeguro seguro = new ResultadoVerificacionSeguro(); using (var context = new CMHEntities()) { atencion = context.ATENCION_AGEN.Find(((ComboboxItem)lstAtenciones.SelectedItem).Value); paciente = context.PACIENTE.Find(atencion.ID_PACIENTE); prestacion = context.PRESTACION.Find(atencion.ID_PRESTACION); } seguro = at.verificarSeguro(prestacion, paciente); lblSubtotal.Text = atencion.PRESTACION.PRECIO_PRESTACION.ToString(); lblTotal.Text = seguro.Descuento.ToString(); if (seguro.Aseguradora == "No tiene seguro") { lblTotal.Text = atencion.PRESTACION.PRECIO_PRESTACION.ToString(); lblDescuento.Text = "0"; } else { lblTotal.Text = seguro.Descuento.ToString(); lblDescuento.Text = (int.Parse(lblSubtotal.Text) - int.Parse(lblTotal.Text)).ToString(); } lblAseguradora.Text = seguro.Aseguradora; btnIngresar.Enabled = true; lblError.Visible = false; } catch (Exception ex) { lblError.Visible = true; lblError.Text = "Error al buscar descuento"; lblError.ForeColor = System.Drawing.Color.Red; lblSubtotal.Text = string.Empty; lblTotal.Text = string.Empty; lblDescuento.Text = string.Empty; btnIngresar.Enabled = false; } }
public static PERSONAL verificarUsuario(string usuario, string password) { try { //Verificar si el usuario(email) valido y password es nulo. if (Util.isEmailValido(usuario) != true) { throw new Exception("Formato email no valido"); } else if (password == null || password == "") { throw new Exception("Contraseña vacía"); } //Comprobar de que el usuario y la contraseña sean iguales en la base de datos string passwordHasheada = Util.hashMD5(password); CMHEntities conexionBD = new CMHEntities(); /*string emailBuscado = conexionBD.PERSONAL. * Where(d => d.EMAIL == usuario).FirstOrDefault().EMAIL; * string passBuscada = conexionBD.PERSONAL. * Where(d => d.HASHED_PASS == passwordHasheada).FirstOrDefault().HASHED_PASS;*/ PERSONAL personal = conexionBD.PERSONAL. Where(d => d.EMAIL.ToUpper() == usuario.ToUpper() && d.HASHED_PASS == passwordHasheada).FirstOrDefault(); //Validar usuario(email) if (Util.isObjetoNulo(personal)) { throw new Exception("Usuario y contraseña incorrecto"); } else { return(personal); } } catch (Exception ex) { Console.WriteLine(ex.Message); return(null); } }
private void btnIngresar_Click(object sender, EventArgs e) { string mensajeCorrecto = "Paciente ingresado correctamente"; string mensajeError = string.Empty; bool res1 = false, res2 = false; try { UsuarioLogeado usuario = FrmLogin.usuarioLogeado; ATENCION_AGEN atencion = new ATENCION_AGEN(); PAGO pago = new PAGO(); CAJA caja = new CAJA(); using (var context = new CMHEntities()) { atencion = context.ATENCION_AGEN.Find(((ComboboxItem)lstAtenciones.SelectedItem).Value); } caja = at.buscarCajaAbierta(usuario.Personal.FUNCIONARIO.FirstOrDefault()); pago.ID_ATENCION_AGEN = atencion.ID_ATENCION_AGEN; pago.MONTO_PAGO = int.Parse(lblTotal.Text); pago.ID_CAJA = caja.ID_CAJA; res1 = at.ingresarPaciente(atencion); res2 = at.registrarPago(pago, lblAseguradora.Text, int.Parse(lblDescuento.Text)); ActualizarLista(); } catch (Exception ex) { mensajeError = "Error al ingresar paciente"; } if (res1 && res2) { MessageBox.Show(mensajeCorrecto, "Creada", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } else { MessageBox.Show(mensajeError, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void btnAgendar_Click(object sender, EventArgs e) { string mensajeCorrecto = "Atención agendada correctamente"; string mensajeError = string.Empty; lblError_ACM.Visible = false; try { AccionesTerminal at = new AccionesTerminal(); ATENCION_AGEN atencion = new ATENCION_AGEN(); PACIENTE paciente = new PACIENTE(); PRESTACION prestacion = new PRESTACION(); ESTADO_ATEN estado = new ESTADO_ATEN(); PERS_MEDICO personalMedico = new PERS_MEDICO(); BLOQUE bloque = new BLOQUE(); if (dtFecha_ACM.Value < DateTime.Today) { mensajeError = "La fecha de atención ha expirado"; } else { using (var context = new CMHEntities()) { estado = context.ESTADO_ATEN.Where(d => d.NOM_ESTADO_ATEN.ToUpper() == "VIGENTE").FirstOrDefault(); personalMedico = context.PERS_MEDICO.Find((int)cmbPersonal_ACM.SelectedValue); } if (txtRut_ACM.Text == string.Empty || txtDv_ACM.Text == string.Empty) { mensajeError = "Complete los campos de RUT"; } else { paciente = at.buscarPaciente(int.Parse(txtRut_ACM.Text), txtDv_ACM.Text.ToUpper()); if (!Util.isObjetoNulo(paciente)) { atencion.FECHOR = dtFecha_ACM.Value; atencion.ID_PACIENTE = paciente.ID_PACIENTE; atencion.ID_PRESTACION = (int)cmbPrestacion_ACM.SelectedValue; atencion.ID_ESTADO_ATEN = estado.ID_ESTADO_ATEN; atencion.ID_PERS_ATIENDE = (int)cmbPersonal_ACM.SelectedValue; atencion.ID_BLOQUE = ((ComboboxItem)cmbHora_ACM.SelectedItem).Value; atencion.OBSERVACIONES = rtObservacion.Text; atencion.ID_PERS_SOLICITA = FrmLogin.usuarioLogeado.Personal.ID_PERSONAL; if (!at.agendarAtencion(atencion)) { mensajeError = "Error al agendar atención"; } actualizarBloques(); } else { mensajeError = "Paciente no encontrado"; } } } } catch (Exception ex) { mensajeError = "Error al agendar atención"; } if (mensajeError == string.Empty) { MessageBox.Show(mensajeCorrecto, "Creada", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } else { MessageBox.Show(mensajeError, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void btnRegistrar_MP_Click(object sender, EventArgs e) { try { AccionesTerminal at = new AccionesTerminal(); PERSONAL p1 = new PERSONAL(); if (txtContrasena_MP.Text == null || txtContrasena_MP.Text == "") { throw new Exception(); } //CapturarDatos p1.NOMBRES = txtNombres_MP.Text; p1.APELLIDOS = txtApellidos_MP.Text; p1.EMAIL = txtEmail_MP.Text; p1.HASHED_PASS = Util.hashMD5(txtContrasena_MP.Text); p1.RUT = int.Parse(txtRutPersonalCargado_MP.Text); p1.VERIFICADOR = txtVerificadorCargado_MP.Text; p1.REMUNERACION = int.Parse(txtRemuneracion_MP.Text); p1.PORCENT_DESCUENTO = byte.Parse(txtDescuento_MP.Text); p1.ACTIVO = true; if (!Util.isEmailValido(p1.EMAIL)) { throw new Exception(); } if (!Util.rutValido(p1.RUT, p1.VERIFICADOR)) { throw new Exception(); } int privi = ((ComboboxItem)cbCargo_MP.SelectedItem).Value; if (privi == 0 && (txtCuentaBanc_MP.Text == "" || (txtCuentaBanc_MP.Text == string.Empty))) { throw new Exception(); } p1.ID_PERSONAL = at.nuevoPersonalId(p1); if (p1.ID_PERSONAL == 0) { throw new Exception(); } if (((ComboboxItem)cbCargo_MP.SelectedItem).Text == "Médico") { string cuentaBancaria = txtCuentaBanc_MP.Text; } using (var context = new CMHEntities()) { switch (privi) { case 0: // Médico PERS_MEDICO persMedico = new PERS_MEDICO(); persMedico.ID_ESPECIALIDAD = context.ESPECIALIDAD.Where(d => d.NOM_ESPECIALIDAD.ToUpper() == "MEDICO").FirstOrDefault().ID_ESPECIALIDAD; persMedico.ID_PERSONAL = p1.ID_PERSONAL; persMedico.ID_PERSONAL_MEDICO = at.nuevoPersonalMedicoID(persMedico); at.asignarBloques(persMedico); CUEN_BANCARIA cuentaB = new CUEN_BANCARIA(); cuentaB.ID_PERS_MEDICO = persMedico.ID_PERSONAL_MEDICO; cuentaB.ID_TIPO_C_BANCARIA = ((TIPO_C_BANCARIA)cbTipoCuenta_MP.SelectedItem).ID_TIPO_C_BANCARIA; cuentaB.NUM_C_BANCARIA = txtCuentaBanc_MP.Text; cuentaB.ID_BANCO = ((BANCO)cbBanco_MP.SelectedItem).ID_BANCO; at.crearCuentaBancaria(cuentaB); break; case 1: // Enfermero PERS_MEDICO persEnfermero = new PERS_MEDICO(); persEnfermero.ID_ESPECIALIDAD = context.ESPECIALIDAD.Where(d => d.NOM_ESPECIALIDAD.ToUpper() == "ENFERMERO").FirstOrDefault().ID_ESPECIALIDAD; persEnfermero.ID_PERSONAL = p1.ID_PERSONAL; at.nuevoPersonalMedico(persEnfermero); at.asignarBloques(persEnfermero); break; case 2: // Tecnólogo PERS_MEDICO persTecnologo = new PERS_MEDICO(); persTecnologo.ID_ESPECIALIDAD = context.ESPECIALIDAD.Where(d => d.NOM_ESPECIALIDAD.ToUpper() == "TECNOLOGO").FirstOrDefault().ID_ESPECIALIDAD; persTecnologo.ID_PERSONAL = p1.ID_PERSONAL; at.nuevoPersonalMedico(persTecnologo); at.asignarBloques(persTecnologo); break; case 3: // Operador FUNCIONARIO funcOperador = new FUNCIONARIO(); funcOperador.ID_CARGO_FUNCI = context.CARGO.Where(d => d.NOMBRE_CARGO.ToUpper() == "OPERADOR").FirstOrDefault().ID_CARGO_FUNCI; funcOperador.ID_PERSONAL = p1.ID_PERSONAL; at.nuevoFuncionario(funcOperador); break; case 4: // Jefe de operador FUNCIONARIO funcJefeOperador = new FUNCIONARIO(); funcJefeOperador.ID_CARGO_FUNCI = context.CARGO.Where(d => d.NOMBRE_CARGO.ToUpper() == "JEFE DE OPERADOR").FirstOrDefault().ID_CARGO_FUNCI; funcJefeOperador.ID_PERSONAL = p1.ID_PERSONAL; at.nuevoFuncionario(funcJefeOperador); break; } } MessageBox.Show("¡Personal creado exitosamente!", "Personal", MessageBoxButtons.OK, MessageBoxIcon.None); limpiarCampos_MP(); } catch (Exception ex) { MessageBox.Show("Error al registrar", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void lstAtenciones_SelectedIndexChanged(object sender, EventArgs e) { mostrarLabelDescuento(); try { ATENCION_AGEN atencion = new ATENCION_AGEN(); PACIENTE paciente = new PACIENTE(); PRESTACION prestacion = new PRESTACION(); BONO bono = new BONO(); ASEGURADORA aseguradora = new ASEGURADORA(); ResultadoVerificacionSeguro seguro = new ResultadoVerificacionSeguro(); bool necesitaDevolucion = false; using (var context = new CMHEntities()) { atencion = context.ATENCION_AGEN.Find(((ComboboxItem)lstAtenciones.SelectedItem).Value); atencion.ESTADO_ATEN = context.ESTADO_ATEN.Find(atencion.ID_ESTADO_ATEN); if (atencion.ESTADO_ATEN.NOM_ESTADO_ATEN.ToUpper() == "PAGADO") { necesitaDevolucion = true; } if (necesitaDevolucion) { paciente = context.PACIENTE.Find(atencion.ID_PACIENTE); prestacion = context.PRESTACION.Find(atencion.ID_PRESTACION); pago = context.PAGO.Where(d => d.ID_ATENCION_AGEN == atencion.ID_ATENCION_AGEN).FirstOrDefault(); if (pago.ID_BONO != null) { bono = context.BONO.Find(pago.ID_BONO); aseguradora = context.ASEGURADORA.Find(bono.ID_ASEGURADORA); } } } if (necesitaDevolucion) { lblSubtotal.Text = atencion.PRESTACION.PRECIO_PRESTACION.ToString(); lblTotal.Text = pago.MONTO_PAGO.ToString(); if (pago.ID_BONO != null) { lblDescuento.Text = pago.BONO.CANT_BONO.ToString(); lblAseguradora.Text = aseguradora.NOM_ASEGURADORA; } else { lblDescuento.Text = "0"; lblAseguradora.Text = "No tiene seguro"; } btnAnular.Enabled = true; lblError.Visible = false; txtRazon.Enabled = true; } else { txtRazon.Enabled = false; btnAnular.Enabled = true; } } catch (Exception ex) { lblError.Visible = true; lblError.Text = "Error al buscar pago"; lblError.ForeColor = System.Drawing.Color.Red; lblSubtotal.Text = string.Empty; lblTotal.Text = string.Empty; lblDescuento.Text = string.Empty; btnAnular.Enabled = false; } }