Пример #1
0
        /// <summary>
        /// Busca el registro que contiene el ID pasado por parametro y lo elimina.
        /// </summary>
        /// <param name="_ID_EstadoUsuarioEliminar">Registro que se eliminará.</param>
        /// <param name="_InformacionDelError">Devuelve una cadena de texto con informacion para el usuario en caso de que el
        /// metodo devuelva null (debido a que ocurrio un error).</param>
        public int Borrar(int _ID_EstadoUsuarioEliminar, ref string _InformacionDelError)
        {
            using (BDRestauranteEntities BBDD = new BDRestauranteEntities())
            {
                try
                {
                    EstadoUsuario ObjetoAEliminar = BBDD.EstadoUsuario.SingleOrDefault(Identificador => Identificador.ID_EstadoUsuario == _ID_EstadoUsuarioEliminar);

                    if (ObjetoAEliminar != null)
                    {
                        BBDD.EstadoUsuario.Remove(ObjetoAEliminar);
                        return(BBDD.SaveChanges());
                    }
                    else
                    {
                        return(0);
                    }
                }
                catch (Exception Error)
                {
                    _InformacionDelError = $"OCURRIO UN ERROR INESPERADO AL INTENTAR LISTAR LA INFORMACIÓN: {Error.Message}\r\n\r\n" +
                                           $"ORIGEN DEL ERROR: {Error.StackTrace}\r\n\r\n" +
                                           $"OBJETO QUE GENERÓ EL ERROR: {Error.Data}\r\n\r\n\r\n" +
                                           $"ENVIE AL PROGRAMADOR UNA FOTO DE ESTE MENSAJE CON UNA DESCRIPCION DE LO QUE HIZO ANTES DE QUE SE GENERARÁ " +
                                           $"ESTE ERROR PARA QUE SEA ARREGLADO.";
                    return(0);
                }
            }
        }
Пример #2
0
        public Usuario(String vUser, String vPass)
        {
            // Tenemos que crear el string de conexion primero
            SqlConnectionStringBuilder builder = new SqlConnectionStringBuilder();

            builder.DataSource     = "204.93.168.25";
            builder.InitialCatalog = "impexcom_cotizacion";
            builder.UserID         = "impexcom_sistema";
            builder.Password       = "******";
            StringConexion         = builder.ConnectionString;

            // Ahora veremos si podemos ingresar.
            Conexion vCon = new Conexion(this);

            try
            {
                vCon.IniciarTransaccion();
            }
            catch (Exception ex)
            {
                throw new Exception("No se pudo conectar a la base de datos.<br/>" + ex.Message);
            }
            Dictionary <string, object> vParam = new Dictionary <string, object>();



            vParam.Add("@sUsuario", vUser);
            vParam.Add("@sPass", vPass);
            //vParam.Add("P_NOMBRE_ROL", "");// OUT

            try
            {
                //aca tengo que ver si existe el usuario en BD
                string    vError = "";
                DataTable vResp  = vCon.Ejecutar("sp_existe_usuario", ref vError, vParaMetros: vParam);
                if (vResp.Rows.Count > 0)
                {
                    vEstado             = EstadoUsuario.Logeado;
                    id_usuario          = int.Parse(vResp.Rows[0]["id_usuario"].ToString());
                    id_tipo_usuario     = int.Parse(vResp.Rows[0]["id_tipo_usuario"].ToString());
                    NombreUsuario       = vResp.Rows[0]["nombre"].ToString();
                    cod_usuario         = vResp.Rows[0]["cod_usuario"].ToString();
                    pwd_usuario         = vResp.Rows[0]["pwd_usuario"].ToString();
                    fecha_ingreso       = DateTime.Parse(vResp.Rows[0]["fecha_ingreso"].ToString());
                    activo              = bool.Parse(vResp.Rows[0]["activo"].ToString());
                    fecha_actualizacion = DateTime.Parse(vResp.Rows[0]["fecha_actualizacion"].ToString());
                }
                else
                {
                    vEstado = EstadoUsuario.NoLogeado; //No pudo ingresar
                }


                vCon.Confirmar();
            }
            catch (Exception ex)
            {
                throw new Exception("No se pudo validar el inicio de sesión.<br/>" + ex.Message, ex);
            }
        }
        public async Task <IActionResult> PutEstadoUsuario([FromRoute] int id, [FromBody] EstadoUsuario estadoUsuario)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != estadoUsuario.Id)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
Пример #4
0
        public async Task <IActionResult> Edit(int id, [Bind("IdEstadoUsuario,DescripcionEstadoUsuario")] EstadoUsuario estadoUsuario)
        {
            if (id != estadoUsuario.IdEstadoUsuario)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(estadoUsuario);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!EstadoUsuarioExists(estadoUsuario.IdEstadoUsuario))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(estadoUsuario));
        }
Пример #5
0
 public ActionResult Logear(DetallesUsuario d)
 {
     if (ModelState.IsValid)
     {
         EmpleadoBusinessLayer ebl    = new EmpleadoBusinessLayer();
         EstadoUsuario         estado = ebl.GetUserValidity(d);
         bool esAdmin = false;
         if (estado == EstadoUsuario.AdminAutenticado)
         {
             esAdmin = true;
         }
         else if (estado == EstadoUsuario.UsuarioAutenticado)
         {
             esAdmin = false;
         }
         //if (ebl.UsuarioEsValido(d))
         //{
         //    FormsAuthentication.SetAuthCookie(d.NombreUsuario, false);
         //    return RedirectToAction("Index", "Empleado");
         //}
         else
         {
             ModelState.AddModelError("CredentialError", "Nombre o contraseña inválido");
             return(View("Login"));
         }
         FormsAuthentication.SetAuthCookie(d.NombreUsuario, false);
         Session["EsAdmin"] = esAdmin;
         return(RedirectToAction("Index", "Empleado"));
     }
     else
     {
         return(View("Login"));
     }
 }
Пример #6
0
        /// <summary>
        /// Actualiza el registro mediente el ID que contiene el objeto proporcionado como parametro.
        /// </summary>
        /// <param name="_EstadoUsuario">Objeto que contiene los datos del registro al que se le van a actualizar los datos.</param>
        ///<param name="_InformacionDelError">Devuelve una cadena de texto con informacion para el usuario en caso de que el
        /// metodo devuelva null (debido a que ocurrio un error).</param>
        public int Actualizar(EstadoUsuario _EstadoUsuario, ref string _InformacionDelError)
        {
            using (BDRestauranteEntities BBDD = new BDRestauranteEntities())
            {
                try
                {
                    EstadoUsuario ObjetoActualizado = BBDD.EstadoUsuario.SingleOrDefault(Identificador => Identificador.ID_EstadoUsuario == _EstadoUsuario.ID_EstadoUsuario);

                    if (ObjetoActualizado != null)
                    {
                        ObjetoActualizado.ID_EstadoUsuario = _EstadoUsuario.ID_EstadoUsuario;
                        //ObjetoActualizado.Nombre = cliente.Nombre;
                        //ObjetoActualizado.Direccion = cliente.Direccion;
                        //ObjetoActualizado.Id_Localidad = cliente.Id_Localidad;
                        return(BBDD.SaveChanges());
                    }
                    else
                    {
                        return(0);
                    }
                }
                catch (Exception Error)
                {
                    _InformacionDelError = $"OCURRIO UN ERROR INESPERADO AL INTENTAR LISTAR LA INFORMACIÓN: {Error.Message}\r\n\r\n" +
                                           $"ORIGEN DEL ERROR: {Error.StackTrace}\r\n\r\n" +
                                           $"OBJETO QUE GENERÓ EL ERROR: {Error.Data}\r\n\r\n\r\n" +
                                           $"ENVIE AL PROGRAMADOR UNA FOTO DE ESTE MENSAJE CON UNA DESCRIPCION DE LO QUE HIZO ANTES DE QUE SE GENERARÁ " +
                                           $"ESTE ERROR PARA QUE SEA ARREGLADO.";
                    return(0);
                }
            }
        }
Пример #7
0
        public IHttpActionResult EstadoUsuario()
        {
            List <EstadoUsuario> temporal = new List <EstadoUsuario>();

            SqlCommand cmd = new SqlCommand("select * from tb_clientes", cn);

            cn.Open();

            SqlDataReader dr = cmd.ExecuteReader();

            while (dr.Read())
            {
                EstadoUsuario reg = new EstadoUsuario()
                {
                    idEstadoUsuario   = dr.GetInt16(0),
                    descripcionEstado = dr.GetString(1)
                };

                temporal.Add(reg);
            }
            dr.Close(); cn.Close();

            if (temporal.Count() == 0)
            {
                return(NotFound());
            }

            return(Ok(temporal));
        }
Пример #8
0
 public void ActualizarEstadoPorID(int idUsuario, EstadoUsuario estado)
 {
     using (ModelFliplloContainer context = new ModelFliplloContainer())
     {
         context.UsuarioSet.Find(idUsuario).Estado = (short)estado;
         context.SaveChanges();
     }
 }
Пример #9
0
        private void ValidateForm()
        {
            bool NombreUsuarioValidate    = NombreUsuario.Validate();
            bool ApellidosUsuarioValidate = ApellidosUsuario.Validate();
            bool EstadoUsuarioValidate    = EstadoUsuario.Validate();

            IsEditEnable = NombreUsuarioValidate && ApellidosUsuarioValidate && EstadoUsuarioValidate;
            ((Command)UpdateUsuarioCommand).ChangeCanExecute();
        }
Пример #10
0
        public EstadoUsuario GetEstadoUsuario(int id)
        {
            //Cogemos una fila con select y LINQ
            DataRow data = (DataRow)(myDataSet.Tables["EstadoUsuario"].Select("id=" + id)).First();

            EstadoUsuario est = new EstadoUsuario((int)data["id"], (string)data["nombre"]);

            return(est);
        }
Пример #11
0
 public Usuarios(int id, string nombreCompleto, string username, string password, EstadoUsuario estado, TipoUsuario tipoUsuario)
 {
     Id             = id;
     NombreCompleto = nombreCompleto;
     Username       = username;
     Password       = password;
     EstadoUsuario  = estado;
     TipoUsuario    = tipoUsuario;
 }
Пример #12
0
        public async Task <IActionResult> Create([Bind("IdEstadoUsuario,DescripcionEstadoUsuario")] EstadoUsuario estadoUsuario)
        {
            if (ModelState.IsValid)
            {
                _context.Add(estadoUsuario);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(estadoUsuario));
        }
        public async Task <IActionResult> PostEstadoUsuario([FromBody] EstadoUsuario estadoUsuario)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.EstadoUsuario.Add(estadoUsuario);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetEstadoUsuario", new { id = estadoUsuario.Id }, estadoUsuario));
        }
Пример #14
0
        //-----------------------------------------------------------------
        #region tspUsuario
        //-----------------------------------------------------------------

        // OK 08/06/12
        private void tsbUsuario_Click(object sender, EventArgs e)
        {
            if (this.Usuario == EstadoUsuario.Valido)
            {
                this.Usuario    = EstadoUsuario.Invalido;
                tsbUsuario.Text = oTxt.IniciarSesion;
                this.Text       = this.TituloVentana + oTxt.TituloLogin;
                // Cerrar odas los frm
                this.HabilitarUsuario(false);
                this.oUtil.IdUsuario = 0;
            }
            else
            {
                bool     H      = true;
                frmLogin fLogin = new frmLogin();

                while (H)
                {
                    if (fLogin.ShowDialog() == DialogResult.Yes)
                    {
                        if (oConsulta.ValidarPassword(fLogin.oUsuario))
                        {
                            this.Usuario    = EstadoUsuario.Valido;
                            tsbUsuario.Text = oTxt.CerrarSesion;
                            this.Text       = this.TituloVentana + oTxt.SeparadorTitulo + fLogin.oUsuario.Nombre.ToString();
                            // Abre todas los frm
                            this.HabilitarUsuario(true);
                            this.oUtil.IdUsuario = oConsulta.SelectUsuario(fLogin.oUsuario).IdUsuario;

                            // Ventana por defect al inicio
                            this.frmAlInicio(sender, e);

                            H = false;
                        }
                        else
                        {
                            this.Usuario         = EstadoUsuario.Invalido;
                            tsbUsuario.Text      = oTxt.IniciarSesion;
                            this.Text            = this.TituloVentana + oTxt.TituloLogin;
                            this.oUtil.IdUsuario = 0;
                            MessageBox.Show(oTxt.LoginInvalido);
                        }
                    }
                    else
                    {
                        H = false;
                    }
                }
            }
            tsmiSesion.Text = tsbUsuario.Text;
        }
Пример #15
0
        private int CambiarEstado(EstadoUsuario estadoUsuario)
        {
            switch (estadoUsuario)
            {
            case EstadoUsuario.Activo:
                return(0);

            case EstadoUsuario.Inactivo:
                return(0);

            default:
                return(0);
            }
        }
Пример #16
0
        public Respuesta <Dato> CambiarEstadoUsuario(string usuario, EstadoUsuario estado)
        {
            JObject prms = new JObject();

            prms.Add("usuario", usuario);
            prms.Add("estado", estado.GetStringValue());

            string rsp = base.ProcesarOperacion(TipoOperacion.Servicio.GetStringValue(),
                                                NOMBRE_CAMBIAR_ESTADO_USUARIO,
                                                DOMINIO_OPERACION,
                                                prms.ToString(Formatting.None));
            var entityRsp = JsonConvert.DeserializeObject <YRespuesta <YDato> >(rsp);

            return(EntitiesMapper.GetRespuestaFromEntity <Dato, YDato>(entityRsp, EntitiesMapper.GetModelFromEntity <Dato, YDato>(entityRsp.Datos)));
        }
Пример #17
0
        /// <summary>
        /// Método para activar el usuario
        /// </summary>
        /// <param name="oUsuario"></param>
        /// <returns></returns>
        public Respuesta <DatosUsuario> ActivarUsuario(string correoElectronico, int codigoActivacion)
        {
            Respuesta <DatosUsuario> respuesta   = new Respuesta <DatosUsuario>();
            TransactionScope         transaccion = new TransactionScope();

            try
            {
                var resultado = new EstadoUsuario();
                using (transaccion)
                {
                    string SQL = @"EXEC Pa_ActivarEstadousuario  @CorreoElectronico, @CodigoActvacion ";
                    resultado = _contexto.Set <EstadoUsuario>().
                                FromSql(SQL,
                                        new SqlParameter("@CorreoElectronico", correoElectronico),
                                        new SqlParameter("@CodigoActvacion", codigoActivacion),
                                        _contexto.SaveChanges()).FirstOrDefault();
                    transaccion.Complete();
                    respuesta.HayError = false;
                }

                if (resultado.Resultado.Equals("Usuario activado correctamente"))
                {
                    using (transaccion = new TransactionScope())
                    {
                        string SQL2       = @"EXEC Pa_ConsultarUsuario  @CorreoElectronico ";
                        var    resultado2 = _contexto.Set <DatosUsuario>().
                                            FromSql(SQL2,
                                                    new SqlParameter("@CorreoElectronico", correoElectronico),
                                                    _contexto.SaveChanges()).FirstOrDefault();
                        respuesta.ObjetoRespuesta = resultado2;
                        transaccion.Complete();
                        respuesta.HayError = false;
                    }
                }
                respuesta.Mensaje = resultado.Resultado;
            }
            catch (Exception ex)
            {
                transaccion.Dispose();
                respuesta.HayError     = true;
                respuesta.MensajeError = ex.Message;
            }
            return(respuesta);
        }
Пример #18
0
        public bool ActualizarEstadoUsuario(EstadoUsuario estado)
        {
            try
            {
                HttpResponseMessage response = client.PutAsJsonAsync("api/estadousuarios/" + estado.IdUsuario, estado).Result;

                if (response.IsSuccessStatusCode)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception e)
            {
                throw new ExternalException("Error:" + e);
            }
        }
Пример #19
0
 /// <summary>
 /// Crea un nuevo registro a partir de los datos que contiene el objeto pasado por parametro.
 /// </summary>
 /// <param name="_EstadoUsuario">Objeto que contiene los datos del nuevo registro que se creará.</param>
 ///<param name="_InformacionDelError">Devuelve una cadena de texto con informacion para el usuario en caso de que el
 /// metodo devuelva null (debido a que ocurrio un error).</param>
 public int Crear(EstadoUsuario _EstadoUsuario, ref string _InformacionDelError)
 {
     using (BDRestauranteEntities BBDD = new BDRestauranteEntities())
     {
         try
         {
             BBDD.EstadoUsuario.Add(_EstadoUsuario);
             return(BBDD.SaveChanges());
         }
         catch (Exception Error)
         {
             _InformacionDelError = $"OCURRIO UN ERROR INESPERADO AL INTENTAR LISTAR LA INFORMACIÓN: {Error.Message}\r\n\r\n" +
                                    $"ORIGEN DEL ERROR: {Error.StackTrace}\r\n\r\n" +
                                    $"OBJETO QUE GENERÓ EL ERROR: {Error.Data}\r\n\r\n\r\n" +
                                    $"ENVIE AL PROGRAMADOR UNA FOTO DE ESTE MENSAJE CON UNA DESCRIPCION DE LO QUE HIZO ANTES DE QUE SE GENERARÁ " +
                                    $"ESTE ERROR PARA QUE SEA ARREGLADO.";
             return(0);
         }
     }
 }
Пример #20
0
        public EstadoUsuario LeerEstadoUsuario(int id)
        {
            EstadoUsuario estado = new EstadoUsuario();
            string        aux;

            try
            {
                HttpResponseMessage response = client.GetAsync("api/estadousuarios/" + id).Result;
                if (response.IsSuccessStatusCode)
                {
                    aux = response.Content.ReadAsStringAsync().Result;

                    estado = JsonConvert.DeserializeObject <EstadoUsuario>(aux);
                }
            }
            catch (Exception e)
            {
                throw new ExternalException("Error:" + e);
            }

            return(estado);
        }
Пример #21
0
        // Creo un nuevo usuario en la BD
        public bool InsertarEstadoUsuario(int idUsuario, int idConexion, DateTime fechaUltimaRevision)
        {
            try
            {
                EstadoUsuario est = new EstadoUsuario(idUsuario, idConexion, fechaUltimaRevision);

                HttpResponseMessage response = client.PostAsJsonAsync("api/estadousuarios", est).Result;
                //var response = client.PostAsync("api/usuarios", new StringContent(new JavaScriptSerializer().Serialize(usu), Encoding.UTF8, "application/json")).Result;
                if (response.IsSuccessStatusCode)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("Error " + e);
            }

            return(true);
        }
Пример #22
0
 protected void Page_Load(object sender, EventArgs e)
 {
     try
     {
         Response.Buffer = true;
         DataContext dcTemp = new DcGeneralDataContext();
         if (!this.IsPostBack)
         {
             List <EstadoUsuario> estadoUsuarios = dcTemp.GetTable <EstadoUsuario>().ToList();
             EstadoUsuario        estadoTemp     = new EstadoUsuario();
             estadoTemp.id       = -1;
             estadoTemp.strValor = "Todos";
             estadoUsuarios.Insert(0, estadoTemp);
             this.ddlEstado.DataTextField  = "strValor";
             this.ddlEstado.DataValueField = "id";
             this.ddlEstado.DataSource     = estadoUsuarios;
             this.ddlEstado.DataBind();
         }
     }
     catch (Exception _e)
     {
         this.showMessage("Ha ocurrido un problema al cargar la página");
     }
 }
Пример #23
0
        private Boolean modificarPaciente()
        {
            String numPaciente;

            if (validador.validarNumeroPaciente(txtNumeroPaciente, "Ingrese el número de paciente", "Atención"))
            {
                numPaciente = txtNumeroPaciente.Text.Trim();
            }
            else
            {
                return(false);
            }

            DateTime fechaAlta       = dtpFechaAlta.Value.Date;
            DateTime fechaNacimiento = dtpFechaNacimiento.Value.Date;

            String nombre;

            if (validador.validarString(txtNombre, "Ingrese el nombre del paciente", "Atención"))
            {
                nombre = txtNombre.Text.Trim();
            }
            else
            {
                return(false);
            }

            String apellido;

            if (validador.validarString(txtApellido, "Ingrese el apellido del paciente", "Atención"))
            {
                apellido = txtApellido.Text.Trim();
            }
            else
            {
                return(false);
            }

            String numeroDocumento;

            if (validador.validarString(txtNumDocumento, "Ingrese el número de documento", "Atención"))
            {
                numeroDocumento = txtNumDocumento.Text.Trim();
            }
            else
            {
                return(false);
            }

            //Tipo de documento
            int           idTipoDoc     = Convert.ToInt32(cmbTipoDocumento.SelectedValue);
            String        nombreTipoDoc = cmbTipoDocumento.Text;
            TipoDocumento tipoDocumento = new TipoDocumento(idTipoDoc, nombreTipoDoc);

            //Sexo
            int    idSexo     = Convert.ToInt32(cmbSexo.SelectedValue);
            String nombreSexo = cmbSexo.Text;
            Sexo   sexo       = new Sexo(idSexo, nombreSexo);

            //Barrio
            int    idBarrio     = Convert.ToInt32(cmbBarrios.SelectedValue);
            String nombreBarrio = cmbBarrios.Text;
            Barrio barrio       = new Barrio(idBarrio, nombreBarrio);

            //Domicilio
            String calle;

            if (validador.validarString(txtCalle, "Ingrese el nombre de la calle", "Atencion"))
            {
                calle = txtCalle.Text.ToString();
            }
            else
            {
                return(false);
            }

            String numeroCalle;

            if (validador.validarString(txtNumeroCalle, "Ingrese número de la calle", "Atencion"))
            {
                numeroCalle = txtNumeroCalle.Text.Trim();
            }
            else
            {
                return(false);
            }

            String    piso      = txtPiso.Text.Trim();
            String    depto     = txtDepto.Text.Trim();
            String    torre     = txtTorre.Text.Trim();
            Domicilio domicilio = new Domicilio(calle, numeroCalle, depto, piso, torre, barrio);

            String comentario = txtComentario.Text.Trim();

            List <Correo> correos = new List <Correo>();

            foreach (Correo correo in lstCorreosElectronicos.Items)
            {
                correos.Add(correo);
            }

            List <Telefono> telefonos = new List <Telefono>();

            foreach (Telefono telefono in lstTelefonos.Items)
            {
                telefonos.Add(telefono);
            }

            List <Afiliacion> afiliaciones = new List <Afiliacion>();

            foreach (Afiliacion afiliacion in lstAfiliaciones.Items)
            {
                afiliaciones.Add(afiliacion);
            }

            //usuario.
            Cuenta cuenta = new Cuenta();

            cuenta = (Cuenta)cmbCuenta.SelectedItem;

            EstadoUsuario estadoUsuario = new EstadoUsuario();

            estadoUsuario = (EstadoUsuario)cmbEstado.SelectedItem;

            String contrasenia;

            if (validador.validarString(txtContrasenia, "Ingrese la contraseña", "Atención"))
            {
                contrasenia = txtContrasenia.Text.Trim();
            }
            else
            {
                return(false);
            }

            int     idPer             = idPersonaGrilla;
            int     idPac             = idPacientegrilla;
            String  nombreUsuario     = cmbNombreUsuario.Text;
            String  comentarioUsuario = txtComentarioUsuario.Text.Trim();
            Usuario usuario           = new Usuario(nombreUsuario, contrasenia, cuenta, comentarioUsuario, estadoUsuario);

            Paciente paciente = new Paciente(idPer, nombre, apellido, fechaAlta, numeroDocumento, tipoDocumento, fechaNacimiento, telefonos,
                                             correos, domicilio, usuario, comentario, sexo, numPaciente, afiliaciones, idPac);

            GestorDePersonas gestorPersonas = new GestorDePersonas();
            string           mensaje        = gestorPersonas.tomarModificacionPaciente(paciente, numeroPacViejo, tipoDniViejo, nroDniViejo);

            if (mensaje.Equals("Se modifico"))
            {
                MessageBox.Show("Paciente modificado", "Atención", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return(true);
            }
            else
            {
                if (mensaje.Equals("No se pudo modificar"))
                {
                    MessageBox.Show("El Paciente no se pudo modificar", "Atención", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return(false);
                }
                else
                {
                    if (mensaje.Equals("error de tipo y nro de DNI"))
                    {
                        MessageBox.Show("La combinacion de tipo de DNI y numero de DNI ya existe", "Atención", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        txtNumDocumento.Focus();
                        return(false);
                    }
                    else
                    {
                        if (mensaje.Equals("error de Numero de Paciente"))
                        {
                            MessageBox.Show("El Numero del paciente ya existe", "Atención", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            txtNumeroPaciente.Focus();
                            return(false);
                        }
                        else
                        {
                            MessageBox.Show("El Numero del Paciente y la combinacion de tipo y numero de DNI ya existe", "Atención", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            txtNumeroPaciente.Focus();
                            return(false);
                        }
                    }
                }
            }
        }
Пример #24
0
        private Boolean modificarEmpleado()
        {
            String legajoEmp;

            if (validador.validarNumeroPaciente(txtLegajoEmpleado, "Ingrese el número de empleado", "Atención"))
            {
                legajoEmp = txtLegajoEmpleado.Text.Trim();
            }
            else
            {
                return(false);
            }

            DateTime fechaAltaEmp       = dtpFechaAltaEmpleado.Value.Date;
            DateTime fechaNacimientoEmp = dtpFechaNacEmpleado.Value.Date;

            String nombreEmp;

            if (validador.validarString(txtNombreEmpleado, "Ingrese el nombre del empleado", "Atención"))
            {
                nombreEmp = txtNombreEmpleado.Text.Trim();
            }
            else
            {
                return(false);
            }

            String apellidoEmp;

            if (validador.validarString(txtApellidoEmpleado, "Ingrese el apellido del empleado", "Atención"))
            {
                apellidoEmp = txtApellidoEmpleado.Text.Trim();
            }
            else
            {
                return(false);
            }
            String numeroDocumentoEmp;

            if (validador.validarString(txtNroDocumentoEmpleado, "Ingrese el número de documento", "Atención"))
            {
                numeroDocumentoEmp = txtNroDocumentoEmpleado.Text.Trim();
            }
            else
            {
                return(false);
            }

            int           idTipoDocEmp     = Convert.ToInt32(cmbTipoDocumentoEmpleado.SelectedValue);
            String        nombreTipoDocEmp = cmbTipoDocumentoEmpleado.Text;
            TipoDocumento tipoDocumentoEmp = new TipoDocumento(idTipoDocEmp, nombreTipoDocEmp);



            String nombreSexoEmp = cmbSexoEmpleado.Text;
            int    idSexoEmp     = (int)cmbSexoEmpleado.SelectedValue;
            Sexo   sexoEmp       = new Sexo(idSexoEmp, nombreSexoEmp);


            int    idBarrioEmp     = Convert.ToInt32(cmbBarrioEmpleado.SelectedValue);
            String nombreBarrioEmp = cmbBarrioEmpleado.Text;
            Barrio barrioEmp       = new Barrio(idBarrioEmp, nombreBarrioEmp);


            String calleEmp;

            if (validador.validarString(txtCalleEmpleado, "Ingrese el nombre de la calle", "Atencion"))
            {
                calleEmp = txtCalleEmpleado.Text.ToString().Trim();
            }
            else
            {
                return(false);
            }

            String numeroCalleEmp;

            if (validador.validarString(txtNumero, "Ingrese número de la calle", "Atencion"))
            {
                numeroCalleEmp = txtNumero.Text.Trim();
            }
            else
            {
                return(false);
            }

            String    pisoEmp      = txtPiso.Text.Trim();
            String    deptoEmp     = txtDpto.Text.Trim();
            String    torreEmp     = txtTorreEmpleado.Text.Trim();
            Domicilio domicilioEmp = new Domicilio(calleEmp, numeroCalleEmp, deptoEmp, pisoEmp, torreEmp, barrioEmp);

            List <Correo> correosEmp = new List <Correo>();

            foreach (Correo correo in lstEmail.Items)
            {
                correosEmp.Add(correo);
            }

            List <Telefono> telefonosEmp = new List <Telefono>();

            foreach (Telefono telefono in lstTelefonos.Items)
            {
                telefonosEmp.Add(telefono);
            }


            String nombreCuentaEmp = cmbCuentaEmpleado.SelectedItem.ToString();
            int    idCuentaEmp     = (int)cmbCuentaEmpleado.SelectedValue;
            Cuenta cuentaEmp       = new Cuenta(idCuentaEmp, nombreCuentaEmp);

            String        nombreEstadoEmp  = cmbCuentaEmpleado.SelectedItem.ToString();
            int           idEstadoEmp      = (int)cmbEstadoEmpleado.SelectedValue;
            EstadoUsuario estadoUsuarioEmp = new EstadoUsuario(idEstadoEmp, nombreEstadoEmp);

            String nombreUsuarioEmp;

            if (validador.validarString(txtNombreUsuarioEmpleado, "Ingrese el nombre de Usuario", "Atención"))
            {
                nombreUsuarioEmp = txtNombreUsuarioEmpleado.Text.Trim();
            }
            else
            {
                return(false);
            }

            String contraseniaEmp;

            if (validador.validarString(txtContraseniaEmpleado, "Ingrese la contraseña", "Atención"))
            {
                contraseniaEmp = txtContraseniaEmpleado.Text.Trim();
            }
            else
            {
                return(false);
            }

            int    idEmpleadoSel        = idEmpleadoSeleccionado;
            int    idPersona            = idPersonaSeleccionado;
            String comentarioUsuarioEmp = txtComentarioUsuarioEmpleado.Text.Trim();

            Usuario usuarioEmp = new Usuario(nombreUsuarioEmp, contraseniaEmp, cuentaEmp, comentarioUsuarioEmp, estadoUsuarioEmp);

            Empleado e = new Empleado(nombreEmp, apellidoEmp, fechaAltaEmp, numeroDocumentoEmp, tipoDocumentoEmp, fechaNacimientoEmp, telefonosEmp, correosEmp, domicilioEmp, usuarioEmp, comentarioUsuarioEmp, sexoEmp, legajoEmp, idEmpleadoSeleccionado, idPersonaSeleccionado);

            GestorDePersonas gestorPersonas = new GestorDePersonas();
            string           mensaje        = gestorPersonas.tomarModificacionEmpleado(e, legajoViejo, tipoDniViejo, nroDniViejo);

            if (mensaje.Equals("Se modifico"))
            {
                MessageBox.Show("Empleado modificado", "Atención", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return(true);
            }
            else
            {
                if (mensaje.Equals("No se pudo modificar"))
                {
                    MessageBox.Show("El Empleado no se pudo modificar", "Atención", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return(false);
                }
                else
                {
                    if (mensaje.Equals("error de tipo y nro de DNI"))
                    {
                        MessageBox.Show("La combinacion de tipo de DNI y numero de DNI ya existe", "Atención", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        txtNroDocumentoEmpleado.Focus();
                        return(false);
                    }
                    else
                    {
                        if (mensaje.Equals("error de Legajo"))
                        {
                            MessageBox.Show("El Legajo del empleado ya existe", "Atención", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            txtLegajoEmpleado.Focus();
                            return(false);
                        }
                        else
                        {
                            MessageBox.Show("El Legajo del empleado y la combinacion de tipo y numero de DNI ya existe", "Atención", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            txtLegajoEmpleado.Focus();
                            return(false);
                        }
                    }
                }
            }
        }
Пример #25
0
        private Boolean modificarProfesional()
        {
            string matricula;

            if (validador.validarString(txtmatricula, "Ingrese el matricula del profesional", "Atención"))
            {
                matricula = txtmatricula.Text.Trim();
            }
            else
            {
                return(false);
            }
            String nombreprof;

            if (validador.validarString(txtnombre, "Ingrese el nombre del profesional", "Atención"))
            {
                nombreprof = txtnombre.Text.Trim();
            }
            else
            {
                return(false);
            }


            String apellidoprof;

            if (validador.validarString(txtapellido, "Ingrese el apellido del profesional", "Atención"))
            {
                apellidoprof = txtapellido.Text.Trim();
            }
            else
            {
                return(false);
            }

            String nrodoc;

            if (validador.validarString(txtnrodoc, "Ingrese el numero de documento del profesional", "Atención"))
            {
                nrodoc = txtnrodoc.Text.Trim();
            }
            else
            {
                return(false);
            }

            String calleProf;

            if (validador.validarString(txtcalle, "Ingrese el nombre de la calle del profesional", "Atención"))
            {
                calleProf = txtcalle.Text.Trim();
            }
            else
            {
                return(false);
            }

            String numeroCalleProf;

            if (validador.validarString(txtnumero, "Ingrese el numero de la calle del profesional", "Atención"))
            {
                numeroCalleProf = txtnumero.Text.Trim();
            }
            else
            {
                return(false);
            }

            DateTime fechaAlta         = dtpFechaAlta.Value.Date;
            DateTime fechanac          = dtpfechanac.Value.Date;
            int      numeroProfesional = Convert.ToInt32(txtnroProfesional.Text.ToString());



            int           idTipoDocProf     = Convert.ToInt32(cmbTipoDocumento.SelectedValue);
            String        nombretipoDocProf = cmbTipoDocumento.Text;
            TipoDocumento tipoDocumentoProf = new TipoDocumento(idTipoDocProf, nombretipoDocProf);


            int    idBarrioProf     = Convert.ToInt32(cmbBarrios.SelectedValue);
            String nombreBarrioProf = cmbBarrios.Text;
            Barrio barrioProf       = new Barrio(idBarrioProf, nombreBarrioProf);

            String    pisoProf      = txtpiso.Text.Trim();
            String    deptoProf     = txtdpto.Text.Trim();
            String    torreProf     = txttorre.Text.Trim();
            Domicilio domicilioProf = new Domicilio(calleProf, numeroCalleProf, pisoProf, deptoProf, torreProf, barrioProf);

            List <Correo> correosProf = new List <Correo>();

            foreach (Correo correo in lstCorreosElectronicos.Items)
            {
                correosProf.Add(correo);
            }

            List <Telefono> telefonosProf = new List <Telefono>();

            foreach (Telefono telefono in lstTelefonos.Items)
            {
                telefonosProf.Add(telefono);
            }

            int    idSexoProf     = Convert.ToInt32(cmbSexo.SelectedValue);
            String nombreSexoProf = cmbSexo.Text;
            Sexo   sexoProf       = new Sexo(idSexoProf, nombreSexoProf);


            String nombreCuentaProf = cmbCuenta.SelectedItem.ToString();
            int    idCuentaProf     = (int)cmbCuenta.SelectedValue;
            Cuenta cuentaProf       = new Cuenta(idCuentaProf, nombreCuentaProf);

            String        nombreEstadoProf  = cmbEstado.SelectedItem.ToString();
            int           idEstadoProf      = (int)cmbEstado.SelectedValue;
            EstadoUsuario estadoUsuarioProf = new EstadoUsuario(idEstadoProf, nombreEstadoProf);

            String nombreUsuarioProf     = txtusuario.Text.Trim();
            String contraseniaProf       = txtcontraseña.Text.Trim();
            String comentarioUsuarioProf = txtcomentario.Text.Trim();

            Usuario usuarioProf      = new Usuario(nombreUsuarioProf, contraseniaProf, cuentaProf, comentarioUsuarioProf, estadoUsuarioProf);
            int     idProfesionalMod = idProfesionalSel;
            int     idPersonaMod     = idPersonaSel;

            //     Profesional prof = new Profesional(nombreprof, apellidoprof, fechaAlta, numeroProfesional, tipoDocumentoProf, fechanac, telefonosProf, correosProf, domicilioProf, usuarioProf, comentarioUsuarioProf, sexoProf, null, matriculaVieja, idProfesionalMod, idPersonaSel);
            Profesional prof = new Profesional(nombreprof, apellidoprof, fechaAlta, nrodoc, tipoDocumentoProf, fechanac, telefonosProf, correosProf, domicilioProf, usuarioProf, comentarioUsuarioProf, sexoProf, "", matricula, idProfesionalMod, idPersonaMod);

            GestorDePersonas gestorPersonas = new GestorDePersonas();

            List <Especialidad> lstespecialidades = new List <Especialidad>();

            for (int i = 0; i < grillaespecialidades.Rows.Count; i++)
            {
                int          id          = Convert.ToInt32(grillaespecialidades["idespecialidad", i].Value.ToString());
                string       nombre      = grillaespecialidades["nombre", i].Value.ToString();
                string       descripcion = grillaespecialidades["descripcion", i].Value.ToString();
                Especialidad esp         = new Especialidad(id, nombre, descripcion);
                lstespecialidades.Add(esp);
            }
            string mensaje = gestorPersonas.tomarModificacionProfesional(prof, matriculaVieja, tipoDniViejo, nroDniViejo, lstespecialidades);

            if (mensaje.Equals("Se modifico"))
            {
                MessageBox.Show("Profesional modificado", "Atención", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return(true);
            }
            else
            {
                if (mensaje.Equals("No se pudo modificar"))
                {
                    MessageBox.Show("El Profesional no se pudo modificar", "Atención", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return(false);
                }
                else
                {
                    if (mensaje.Equals("error de tipo y nro de DNI"))
                    {
                        MessageBox.Show("La combinacion de tipo de DNI y numero de DNI ya existe", "Atención", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        txtnrodoc.Focus();
                        return(false);
                    }
                    else
                    {
                        if (mensaje.Equals("error de Matricula"))
                        {
                            MessageBox.Show("La matricula del profesional ya existe", "Atención", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            txtmatricula.Focus();
                            return(false);
                        }
                        else
                        {
                            MessageBox.Show("La matricula del profesional y la combinacion de tipo y numero de DNI ya existe", "Atención", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            txtmatricula.Focus();
                            return(false);
                        }
                    }
                }
            }
        }
Пример #26
0
        private Boolean guardarProfesional()
        {
            string matricula;

            if (validador.validarString(txtmatricula, "Ingrese el matricula del profesional", "Atención"))
            {
                matricula = txtmatricula.Text.Trim();
            }
            else
            {
                return(false);
            }
            String nombreprof;

            if (validador.validarString(txtnombre, "Ingrese el nombre del profesional", "Atención"))
            {
                nombreprof = txtnombre.Text.Trim();
            }
            else
            {
                return(false);
            }


            String apellidoprof;

            if (validador.validarString(txtapellido, "Ingrese el apellido del profesional", "Atención"))
            {
                apellidoprof = txtapellido.Text.Trim();
            }
            else
            {
                return(false);
            }

            String nrodoc;

            if (validador.validarString(txtnrodoc, "Ingrese el numero de documento del profesional", "Atención"))
            {
                nrodoc = txtnrodoc.Text.Trim();
            }
            else
            {
                return(false);
            }

            String calleProf;

            if (validador.validarString(txtcalle, "Ingrese el nombre de la calle del profesional", "Atención"))
            {
                calleProf = txtcalle.Text.Trim();
            }
            else
            {
                return(false);
            }

            String numeroCalleProf;

            if (validador.validarString(txtnumero, "Ingrese el numero de la calle del profesional", "Atención"))
            {
                numeroCalleProf = txtnumero.Text.Trim();
            }
            else
            {
                return(false);
            }

            DateTime fechaAlta = dtpFechaAlta.Value.Date;
            DateTime fechanac  = dtpfechanac.Value.Date;

            int           idTipoDocProf     = Convert.ToInt32(cmbTipoDocumento.SelectedValue);
            String        nombretipoDocProf = cmbTipoDocumento.Text;
            TipoDocumento tipoDocumentoProf = new TipoDocumento(idTipoDocProf, nombretipoDocProf);

            int    idBarrioProf     = Convert.ToInt32(cmbBarrios.SelectedValue);
            String nombreBarrioProf = cmbBarrios.Text;
            Barrio barrioProf       = new Barrio(idBarrioProf, nombreBarrioProf);

            String    pisoProf      = txtpiso.Text.Trim();
            String    deptoProf     = txtdpto.Text.Trim();
            String    torreProf     = txttorre.Text.Trim();
            Domicilio domicilioProf = new Domicilio(calleProf, numeroCalleProf, pisoProf, deptoProf, torreProf, barrioProf);

            List <Correo> correosProf = new List <Correo>();

            foreach (Correo correo in lstCorreosElectronicos.Items)
            {
                correosProf.Add(correo);
            }

            List <Telefono> telefonosProf = new List <Telefono>();

            foreach (Telefono telefono in lstTelefonos.Items)
            {
                telefonosProf.Add(telefono);
            }

            int    idSexoProf     = Convert.ToInt32(cmbSexo.SelectedValue);
            String nombreSexoProf = cmbSexo.Text;
            Sexo   sexoProf       = new Sexo(idSexoProf, nombreSexoProf);


            String nombreCuentaProf = cmbCuenta.SelectedItem.ToString();
            int    idCuentaProf     = (int)cmbCuenta.SelectedValue;
            Cuenta cuentaProf       = new Cuenta(idCuentaProf, nombreCuentaProf);

            String        nombreEstadoProf  = cmbEstado.SelectedItem.ToString();
            int           idEstadoProf      = (int)cmbEstado.SelectedValue;
            EstadoUsuario estadoUsuarioProf = new EstadoUsuario(idEstadoProf, nombreEstadoProf);

            String nombreUsuarioProf     = txtusuario.Text.Trim();
            String contraseniaProf       = txtcontraseña.Text.Trim();
            String comentarioUsuarioProf = txtcomentario.Text.Trim();

            Usuario usuarioProf = new Usuario(nombreUsuarioProf, contraseniaProf, cuentaProf, comentarioUsuarioProf, estadoUsuarioProf);

            List <Especialidad> lstespecialidades = new List <Especialidad>();

            for (int i = 0; i < grillaespecialidades.Rows.Count; i++)
            {
                int          id          = Convert.ToInt32(grillaespecialidades["idespecialidad", i].Value.ToString());
                string       nombre      = grillaespecialidades["nombre", i].Value.ToString();
                string       descripcion = grillaespecialidades["descripcion", i].Value.ToString();
                Especialidad esp         = new Especialidad(id, nombre, descripcion);
                lstespecialidades.Add(esp);
            }
            Profesional prof = new Profesional(nombreprof, apellidoprof, fechaAlta, nrodoc, tipoDocumentoProf, fechanac, telefonosProf, correosProf, domicilioProf, usuarioProf, comentarioUsuarioProf, sexoProf, "", matricula);

            GestorDePersonas gestorPersonas = new GestorDePersonas();


            if (gestorPersonas.tomarProfesional(prof, lstespecialidades))
            {
                Validador val = new Validador();
                val.limpiarTexBox(this);
                grillaespecialidades.DataSource = gestorPersonas.limpiarGrilla();
                deshabilitarcampos();
                //btnGrabar.Enabled = false;
                btnAgregarProf.Enabled = true;
                //btncancelar.Enabled = false;
                //btneliminar.Enabled = false;
                //btneditar.Enabled = false;
                grbProfesionales.Enabled     = true;
                txtbuscarprofesional.Enabled = true;
                btnBuscarProfesional.Enabled = true;
                btnsalir.Enabled             = true;

                MessageBox.Show("Profesional guardado", "Atención", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return(true);
            }
            else
            {
                MessageBox.Show("El profesional ya se encuentra registrado", "Atención", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return(false);
            }
        }