public HttpResponseMessage Get(int Id)
        {
            EstructuraModel datos   = new EstructuraModel();
            var             listado = new List <Contacto>();

            try
            {
                var registro = new ContactoLN().ObtenerRegistro(Id);
                if (registro != null)
                {
                    listado.Add(registro);
                    datos.responseData    = listado;
                    datos.responseDetails = Constantes.Respuestas.Correcta;
                    datos.responseStatus  = (int)EnumEstado.Correcto;
                }
                else
                {
                    datos.responseDetails = Constantes.Respuestas.Vacio;
                    datos.responseStatus  = (int)EnumEstado.Vacio;
                }

                return(Request.CreateResponse(HttpStatusCode.OK, datos));
            }
            catch (Exception ex)
            {
                datos.responseDetails = Constantes.Respuestas.Error;
                datos.responseStatus  = (int)EnumEstado.Error;

                return(Request.CreateResponse(HttpStatusCode.InternalServerError, datos));
            }
        }
        public HttpResponseMessage Get()
        {
            EstructuraModel datos = new EstructuraModel();

            try
            {
                var listado = new ContactoLN().Consultar();
                if (listado.Count > 0)
                {
                    datos.responseData    = listado;
                    datos.responseDetails = Constantes.Respuestas.Correcta;
                    datos.responseStatus  = (int)EnumEstado.Correcto;
                }
                else if (listado.Count == 0)
                {
                    datos.responseDetails = Constantes.Respuestas.Vacio;
                    datos.responseStatus  = (int)EnumEstado.Vacio;
                }

                return(Request.CreateResponse(HttpStatusCode.OK, datos));
            }
            catch (Exception ex)
            {
                datos.responseDetails = Constantes.Respuestas.Error;
                datos.responseStatus  = (int)EnumEstado.Error;

                return(Request.CreateResponse(HttpStatusCode.InternalServerError, datos));
            }
        }
Ejemplo n.º 3
0
        private void tsbEliminar_Click(object sender, EventArgs e)
        {
            try
            {
                this.Cursor = Cursors.WaitCursor;

                if (LosDatosIngresadosSonCorrectos())
                {
                    if (txtIdentificador.Text.Length == 0 || txtIdentificador.Text == "0")
                    {
                        MessageBox.Show("No se puede continuar. Ha ocurrido un error y el registro no ha sido cargado correctamente.", OperacionARealizar, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        return;
                    }


                    if (MessageBox.Show("¿Está seguro que desea eliminar el registro?", "Eliminar la Confirmación", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button3) == System.Windows.Forms.DialogResult.No)
                    {
                        return;
                    }

                    ContactoEN oRegistroEN = InformacionDelRegistro();
                    ContactoLN oRegistroLN = new ContactoLN();

                    if (Controles.IsNullOEmptyElControl(txtIdProveedorContacto) == false)
                    {
                        EliminarRegistroDelaVinculacion();
                    }

                    if (oRegistroLN.Eliminar(oRegistroEN, Program.oDatosDeConexion))
                    {
                        EvaluarErrorParaMensajeAPantalla(oRegistroLN.Error, "Eliminar");

                        oRegistroEN = null;
                        oRegistroLN = null;

                        this.Cursor = Cursors.Default;

                        if (CerrarVentana == true)
                        {
                            this.Close();
                        }
                    }
                    else
                    {
                        throw new ArgumentException(oRegistroLN.Error);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Eliminar la información del registro", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                this.Cursor = Cursors.Default;
            }
        }
Ejemplo n.º 4
0
        private void GenerarCodigoDelContacto()
        {
            try
            {
                ContactoEN oRegistroEN = new ContactoEN();
                ContactoLN oRegistroLN = new ContactoLN();

                if (oRegistroLN.GenerarCodigoDelContacto(oRegistroEN, Program.oDatosDeConexion))
                {
                    txtCodigo.Text = oRegistroEN.Codigo;
                }
            }catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Generar codigo Automatico", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
Ejemplo n.º 5
0
        private void LLenarListado()
        {
            try
            {
                this.Cursor = Cursors.WaitCursor;

                ContactoEN oRegistrosEN = new ContactoEN();
                ContactoLN oRegistrosLN = new ContactoLN();

                oRegistrosEN.Where = WhereDinamico();

                if (oRegistrosLN.Listado(oRegistrosEN, Program.oDatosDeConexion))
                {
                    dgvLista.Columns.Clear();

                    if (ActivarFiltros == true)
                    {
                        dgvLista.DataSource = AgregarColumnaSeleccionar(oRegistrosLN.TraerDatos());
                    }
                    else
                    {
                        dgvLista.DataSource = oRegistrosLN.TraerDatos();
                    }

                    FormatearDGV();
                    this.dgvLista.ClearSelection();

                    tsbNoRegistros.Text = "No. Registros: " + oRegistrosLN.TotalRegistros().ToString();
                }
                else
                {
                    throw new ArgumentException(oRegistrosLN.Error);
                }
            }catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Llenar listado de registro en la lista", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                this.Cursor = Cursors.Default;
            }
        }
        public HttpResponseMessage Post([FromBody] Contacto item)
        {
            String         Mensaje   = "";
            ContactoLN     objLogica = new ContactoLN();
            ResultadoModel datos     = new ResultadoModel();

            try
            {
                if (item != null)
                {
                    if (!ModelState.IsValid)
                    {
                        var errors = ModelState.Select(x => x.Value.Errors)
                                     .Where(y => y.Count > 0)
                                     .ToList();

                        datos.responseDetails = Mensaje;
                        datos.responseStatus  = (int)EnumEstado.NoAceptado;
                        return(Request.CreateResponse <ResultadoModel>(HttpStatusCode.NotAcceptable, datos));
                    }

                    if (item != null)
                    {
                        //se realizan validaciones para verificar los datos requeridos

                        if (String.IsNullOrEmpty(item.NOMBRE))
                        {
                            Mensaje = "El nombre es requerido";
                        }
                        if (String.IsNullOrEmpty(item.IDENTIFICACION))
                        {
                            Mensaje = "la identificación es requerido";
                        }
                        if (String.IsNullOrEmpty(item.EMAIL))
                        {
                            Mensaje = "el email es requerido";
                        }
                        if (String.IsNullOrEmpty(item.CELULAR))
                        {
                            Mensaje = "el celular es requerido";
                        }

                        if (!String.IsNullOrEmpty(Mensaje))
                        {
                            datos.responseDetails = Mensaje;
                            datos.responseStatus  = (int)EnumEstado.NoAceptado;
                        }
                        else
                        {
                            var registro = new Contacto
                            {
                                IDENTIFICACION  = item.IDENTIFICACION,
                                NOMBRE          = item.NOMBRE,
                                CELULAR         = item.CELULAR,
                                DESCRIPCION     = item.DESCRIPCION,
                                EMAIL           = item.EMAIL,
                                FECHA_SOLICITUD = DateTime.Now,
                                ID_CONTACTO     = 0
                            };

                            //llama al método agregar de la logica de negocio
                            Int64 Id = objLogica.Agregar(registro);
                            datos.responseDetails = Constantes.Respuestas.Correcta;
                            datos.responseStatus  = (int)EnumEstado.Correcto;
                            datos.Id = Id.ToString();
                        }
                    }
                    else
                    {
                        datos.responseDetails = Constantes.Respuestas.Vacio;
                        datos.responseStatus  = (int)EnumEstado.Vacio;
                    }
                }
                else
                {
                    datos.responseDetails = "El registro no puede ser nulo";
                    datos.responseStatus  = (int)EnumEstado.NoAceptado;
                }

                return(Request.CreateResponse <ResultadoModel>(HttpStatusCode.OK, datos));
            }
            catch (Exception ex)
            {
                datos.responseDetails = Constantes.Respuestas.Error;
                datos.responseStatus  = (int)EnumEstado.Error;
                return(Request.CreateResponse <ResultadoModel>(HttpStatusCode.InternalServerError, datos));
            }
        }
        public HttpResponseMessage Put([FromBody] Contacto item)
        {
            String         Mensaje   = "";
            ContactoLN     objLogica = new ContactoLN();
            Contacto       registro;
            ResultadoModel datos = new ResultadoModel();

            try
            {
                if (item != null)
                {
                    if (!ModelState.IsValid)
                    {
                        var errors = ModelState.Select(x => x.Value.Errors)
                                     .Where(y => y.Count > 0)
                                     .ToList();

                        datos.responseDetails = Mensaje;
                        datos.responseStatus  = (int)EnumEstado.NoAceptado;
                        return(Request.CreateResponse <ResultadoModel>(HttpStatusCode.NotAcceptable, datos));
                    }

                    registro = objLogica.ObtenerRegistro(item.ID_CONTACTO);
                    if (registro != null)
                    {
                        if (item.ID_CONTACTO == 0)
                        {
                            Mensaje = "Id Contacto es requerido";
                        }

                        if (String.IsNullOrEmpty(item.NOMBRE))
                        {
                            Mensaje = "El nombre es requerido";
                        }
                        if (String.IsNullOrEmpty(item.IDENTIFICACION))
                        {
                            Mensaje = "la identificación es requerido";
                        }
                        if (String.IsNullOrEmpty(item.EMAIL))
                        {
                            Mensaje = "el email es requerido";
                        }
                        if (String.IsNullOrEmpty(item.CELULAR))
                        {
                            Mensaje = "el celular es requerido";
                        }

                        if (!String.IsNullOrEmpty(Mensaje))
                        {
                            datos.responseDetails = Mensaje;
                            datos.responseStatus  = (int)EnumEstado.NoAceptado;
                        }
                        else
                        {
                            registro = item;
                            objLogica.Editar(registro);
                            datos.responseDetails = Constantes.Respuestas.Correcta;
                            datos.responseStatus  = (int)EnumEstado.Correcto;
                            datos.Id = item.ID_CONTACTO.ToString();
                        }
                    }
                    else
                    {
                        datos.responseDetails = Constantes.Respuestas.Vacio;
                        datos.responseStatus  = (int)EnumEstado.Vacio;
                    }
                }
                else
                {
                    datos.responseDetails = "El registro no puede ser nulo";
                    datos.responseStatus  = (int)EnumEstado.NoAceptado;
                }

                return(Request.CreateResponse <ResultadoModel>(HttpStatusCode.OK, datos));
            }
            catch (Exception ex)
            {
                datos.responseDetails = Constantes.Respuestas.Error;
                datos.responseStatus  = (int)EnumEstado.Error;
                return(Request.CreateResponse <ResultadoModel>(HttpStatusCode.InternalServerError, datos));
            }
        }
Ejemplo n.º 8
0
        private void tsbActualzar_Click(object sender, EventArgs e)
        {
            try
            {
                this.Cursor = Cursors.WaitCursor;

                if (LosDatosIngresadosSonCorrectos())
                {
                    if (txtIdentificador.Text.Length == 0 || txtIdentificador.Text == "0")
                    {
                        MessageBox.Show("No se puede continuar. Ha ocurrido un error y el registro no ha sido cargado correctamente.", OperacionARealizar, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        return;
                    }


                    if (MessageBox.Show("¿Está seguro que desea aplicar los cambios al registro seleccionado?", "Actualizar la Confirmación", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button3) == System.Windows.Forms.DialogResult.No)
                    {
                        return;
                    }

                    ContactoEN oRegistroEN = InformacionDelRegistro();
                    ContactoLN oRegistroLN = new ContactoLN();

                    /*if (oRegistroLN.ValidarSiElRegistroEstaVinculado(oRegistroEN, Program.oDatosDeConexion, "ACTUALIZAR"))
                     * {
                     *  this.Cursor = Cursors.Default;
                     *  MessageBox.Show(oRegistroLN.Error, this.OperacionARealizar, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                     *  return;
                     * }*/

                    if (oRegistroLN.ValidarRegistroDuplicado(oRegistroEN, Program.oDatosDeConexion, "ACTUALIZAR"))
                    {
                        this.Cursor = Cursors.Default;
                        MessageBox.Show(oRegistroLN.Error, "Actualizar la información", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }

                    if (Controles.IsNullOEmptyElControl(txtCedula) == false)
                    {
                        if (oRegistroLN.ValidarRegistroDuplicadoParaCedula(oRegistroEN, Program.oDatosDeConexion, "ACTUALIZAR"))
                        {
                            MessageBox.Show(oRegistroLN.Error, "Guardar información", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            return;
                        }
                    }

                    if (oRegistroLN.Actualizar(oRegistroEN, Program.oDatosDeConexion))
                    {
                        GuardarActualizarVinculo();

                        EvaluarErrorParaMensajeAPantalla(oRegistroLN.Error, "Actualizar");

                        oRegistroEN = null;
                        oRegistroLN = null;

                        this.Cursor = Cursors.Default;

                        if (CerrarVentana == true)
                        {
                            this.Close();
                        }
                    }
                    else
                    {
                        throw new ArgumentException(oRegistroLN.Error);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Actualizar información del registro", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
Ejemplo n.º 9
0
        private void tsbGuardar_Click(object sender, EventArgs e)
        {
            try
            {
                this.Cursor = Cursors.WaitCursor;

                if (LosDatosIngresadosSonCorrectos())
                {
                    ContactoEN oRegistroEN = InformacionDelRegistro();
                    ContactoLN oRegistroLN = new ContactoLN();

                    if (oRegistroLN.ValidarRegistroDuplicado(oRegistroEN, Program.oDatosDeConexion, "AGREGAR"))
                    {
                        MessageBox.Show(oRegistroLN.Error, "Guardar información", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }

                    if (Controles.IsNullOEmptyElControl(txtCedula) == false)
                    {
                        if (oRegistroLN.ValidarRegistroDuplicadoParaCedula(oRegistroEN, Program.oDatosDeConexion, "AGREGAR"))
                        {
                            MessageBox.Show(oRegistroLN.Error, "Guardar información", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            return;
                        }
                    }

                    EntidadEN oEntidadEN = informacionDeLaEntidad();
                    EntidadLN oEntidadLN = new EntidadLN();

                    if (oEntidadLN.Agregar(oEntidadEN, Program.oDatosDeConexion))
                    {
                        oRegistroEN.idContacto = oEntidadEN.idEntidad;

                        if (oRegistroLN.Agregar(oRegistroEN, Program.oDatosDeConexion))
                        {
                            txtIdentificador.Text     = oRegistroEN.idContacto.ToString();
                            ValorLlavePrimariaEntidad = oRegistroEN.idContacto;
                            txtCodigo.Text            = oRegistroEN.Codigo;

                            GuardarActualizarVinculo();

                            EvaluarErrorParaMensajeAPantalla(oRegistroLN.Error, "Guardar");

                            if (CerrarVentana == true)
                            {
                                this.Cursor = Cursors.Default;
                                this.Close();
                            }
                            else
                            {
                                OperacionARealizar = "Modificar";
                                ObtenerValoresDeConfiguracion();
                                DeshabilitarControlesSegunOperacionesARealizar();
                                EstablecerTituloDeVentana();
                                LlamarMetodoSegunOperacion();
                            }
                        }
                        else
                        {
                            oEntidadLN.Eliminar(oEntidadEN, Program.oDatosDeConexion);
                            string mensaje = string.Format("Se ha encontrado el siguiente error al Guardar la iformación del Contacto: {0} {1} {0} Desea continuar ingresando la información del Contacto", Environment.NewLine, oRegistroLN.Error);
                            throw new ArgumentException(mensaje);
                        }
                    }
                    else
                    {
                        string mensaje = string.Format("Se ha encontrado el siguiente error: {0} {1} {0} Desea continuar ingresando la información", Environment.NewLine, oEntidadLN.Error);
                        throw new ArgumentException(mensaje);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Guardar la información del registro", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally {
                this.Cursor = Cursors.Default;
            }
        }
Ejemplo n.º 10
0
        private void LlenarCamposDesdeBaseDatosSegunID()
        {
            this.Cursor = Cursors.WaitCursor;

            ContactoEN oRegistrosEN = new ContactoEN();
            ContactoLN oRegistrosLN = new ContactoLN();

            oRegistrosEN.idContacto = ValorLlavePrimariaEntidad;

            if (oRegistrosLN.ListadoPorIdentificador(oRegistrosEN, Program.oDatosDeConexion))
            {
                if (oRegistrosLN.TraerDatos().Rows.Count > 0)
                {
                    DataRow Fila = oRegistrosLN.TraerDatos().Rows[0];
                    txtCodigo.Text            = Fila["Codigo"].ToString();
                    txtNombre.Text            = Fila["Nombre"].ToString();
                    txtDireccion.Text         = Fila["Direccion"].ToString();
                    txtTelefono.Text          = Fila["Telefono"].ToString();
                    txtMovil.Text             = Fila["Movil"].ToString();
                    txtObservaciones.Text     = Fila["Observaciones"].ToString();
                    txtCorreo.Text            = Fila["Correo"].ToString();
                    txtFechaDeCumpleanos.Text = Fila["FechaDeCumpleanos"].ToString();
                    txtMessenger.Text         = Fila["Messenger"].ToString();
                    txtSkype.Text             = Fila["Skype"].ToString();
                    txtTwitter.Text           = Fila["Twitter"].ToString();
                    txtFaceBook.Text          = Fila["Facebook"].ToString();
                    cmbEstado.Text            = Fila["Estado"].ToString();
                    txtCedula.Text            = Fila["Cedula"].ToString();

                    if (Controles.IsNullOEmptyElControl(txtFechaDeCumpleanos) == false)
                    {
                        dtpkFecha.Value = Convert.ToDateTime(txtFechaDeCumpleanos.Text);
                    }

                    if (Fila["Foto"] != DBNull.Value)
                    {
                        pbxImagen.Image = Imagenes.ProcesarImagenToBitMap((object)(Fila["Foto"]));
                    }

                    //LLenarCampoDeBaseDeDatosSegundContacto();
                    LLenarListBoxDeBaseDeDatosSegundContacto();

                    oRegistrosEN = null;
                    oRegistrosLN = null;
                }
                else
                {
                    string Mensaje;
                    Mensaje = string.Format("El registro solicitado de {0} no ha sido encontrado."
                                            + "\n\r-----Causas---- "
                                            + "\n\r1. Este registro pudo haber sido eliminado por otro usuario."
                                            + "\n\r2. El listado no está actualizado.", NombreEntidad);

                    MessageBox.Show(Mensaje, "Listado", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);

                    oRegistrosEN = null;
                    oRegistrosLN = null;

                    this.Close();
                }
            }
            else
            {
                this.Cursor = Cursors.Default;
                MessageBox.Show(oRegistrosLN.Error, "Listado", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                oRegistrosEN = null;
                oRegistrosLN = null;
            }

            this.Cursor = Cursors.Default;
        }