protected void btnRestaurar_Click(object sender, EventArgs e)
        {
            try
            {
                var         guid = Guid.NewGuid().ToString().Replace("-", "");
                DtoContacto dto  = new DtoContacto
                {
                    IN_Tipodoc          = Convert.ToInt32(hdnTipoDoc.Value),
                    Numdoc              = txtNumDocContacto.Text.Trim(),
                    Email               = txtCorreoContacto.Text.Trim(),
                    NuevaCredencial     = guid,
                    Numdoc_Paciente     = txtNumdoc.Text.Trim(),
                    IN_Tipodoc_Paciente = Convert.ToInt32(hdnTipoDoc_Paciente.Value),
                };
                ClassResultV cr = new CtrContacto().Usp_Contacto_ForgotCredential(dto);
                if (!cr.HuboError)
                {
                    String HTML = Resource1.htmlCredencial;
                    HTML = HTML.Replace("{titulo}", "Credencial Actualizada");
                    HTML = HTML.Replace("{credencial}", dto.NuevaCredencial);
                    string to = dto.Email;
                    HelpE.SendMail_Gmail(to.Trim(), "Essalud - Crendencial", HTML);

                    ScriptManager.RegisterStartupScript(this, GetType(), "Pop", HelpE.mensajeConfirmacionRedirect("Credencial Actualizada", "Se envio un correo con la nueva credencial de acceso", "success", "/IngresarCredencial"), true);
                }
                else
                {
                    ScriptManager.RegisterStartupScript(this, GetType(), "Pop", HelpE.mensajeConfirmacion("Error!", cr.ErrorMsj, "error"), true);
                }
            }
            catch (Exception ex)
            {
                ScriptManager.RegisterStartupScript(this, GetType(), "Pop", HelpE.mensajeConfirmacion("Error!", "Oops, algo salió mal :(", "error"), true);
            }
        }
        private void CargarMensajes()
        {
            try
            {
                DtoContacto        userContacto  = (DtoContacto)Session["ContactoSession"];
                List <DtoMensajes> ListaMensajes = new List <DtoMensajes>();

                ClassResultV cr = new CtrMensajes().Usp_Mensajes_SelectAll_Contacto(new DtoMensajes
                {
                    IB_Respondido  = Convert.ToBoolean(Convert.ToInt32(ddlEstado.SelectedValue)),
                    Criterio       = txtBuscar.Text.Trim(),
                    IN_TipoMensaje = Convert.ToInt32(ddlTipoMensaje.SelectedValue),
                    ContactoId     = userContacto.IdContacto
                });
                if (!cr.HuboError)
                {
                    ListaMensajes.AddRange(cr.List.Cast <DtoMensajes>());
                    gvMensajes.DataSource = ListaMensajes;
                }
                gvMensajes.DataBind();
            }
            catch (Exception ex)
            {
                ScriptManager.RegisterStartupScript(this, GetType(), "Pop", @"Swal.fire('Error!', '" + "No se pudieron cargar los mensajes." + "', 'error');", true);
            }
        }
        public DtoContacto Usp_Contacto_Insert(DtoB dtoBase)
        {
            DtoContacto dto = (DtoContacto)dtoBase;

            SqlParameter[] pr = new SqlParameter[9];
            try
            {
                pr[0] = new SqlParameter("@IdContacto", SqlDbType.Int)
                {
                    Direction = ParameterDirection.Output
                };
                pr[1] = new SqlParameter("@NombreCompleto", SqlDbType.VarChar, 200)
                {
                    Value = (V_ValidaPrNull(dto.NombreCompleto))
                };
                pr[2] = new SqlParameter("@IN_Tipodoc", SqlDbType.Int)
                {
                    Value = (V_ValidaPrNull(dto.IN_Tipodoc))
                };
                pr[3] = new SqlParameter("@Numdoc", SqlDbType.VarChar, 20)
                {
                    Value = (V_ValidaPrNull(dto.Numdoc))
                };
                pr[4] = new SqlParameter("@Email", SqlDbType.VarChar, 50)
                {
                    Value = (V_ValidaPrNull(dto.Email))
                };
                pr[5] = new SqlParameter("@Telefono", SqlDbType.VarChar, 50)
                {
                    Value = (V_ValidaPrNull(dto.Telefono))
                };
                pr[6] = new SqlParameter("@UsuarioCreacionId", SqlDbType.Int)
                {
                    Value = (V_ValidaPrNull(dto.UsuarioCreacionId))
                };
                pr[7] = new SqlParameter("@PacienteId", SqlDbType.Int)
                {
                    Value = (V_ValidaPrNull(dto.PacienteId))
                };
                pr[8] = new SqlParameter("@msj", SqlDbType.VarChar, 100)
                {
                    Direction = ParameterDirection.Output
                };
                SqlHelper.ExecuteNonQuery(ObjCn, CommandType.StoredProcedure, "Usp_Contacto_Insert", pr);
                dto.IdContacto = Convert.ToInt32(pr[0].Value);
                if (!String.IsNullOrEmpty(Convert.ToString(pr[8].Value)))
                {
                    dto.ErrorMsj   = Convert.ToString(pr[8].Value);
                    dto.LugarError = "Usp_Contacto_Insert";
                }
            }
            catch (Exception ex)
            {
                dto.LugarError = ex.StackTrace;
                dto.ErrorEx    = ex.Message;
                dto.ErrorMsj   = "Error al insertar Contacto";
            }
            ObjCn.Close();
            return(dto);
        }
Esempio n. 4
0
        public Form1()
        {
            InitializeComponent();

            string url        = @"http://localhost:8080/";
            var    connection = new HubConnection(url);

            _hub = connection.CreateHubProxy("TestHub");
            connection.Start().Wait();

            _hub.On("SendInfo", x => {
                DtoContacto contacto = JsonConvert.DeserializeObject <DtoContacto>(x);

                TxtName.Invoke((MethodInvoker) delegate {
                    // Running on the UI thread
                    TxtName.Text = contacto.Nombre;
                });

                TxtLastName.Invoke((MethodInvoker) delegate {
                    // Running on the UI thread
                    TxtLastName.Text = contacto.Apellido;
                });

                TxtPhone.Invoke((MethodInvoker) delegate {
                    // Running on the UI thread
                    TxtPhone.Text = contacto.Telefono;
                });
            });

            _hub.On("SendNotify", x => {
                MessageBox.Show("Nueva orden");
            });
        }
Esempio n. 5
0
 protected void btnRegistrar_Click(object sender, EventArgs e)
 {
     try
     {
         DtoContacto userContacto = (DtoContacto)Session["ContactoSession"];
         DtoPaciente userPaciente = (DtoPaciente)Session["PacienteContacto"];
         DtoMensajes dtoPa        = new CtrMensajes().Usp_Mensajes_Insert(new DtoMensajes
         {
             ContactoId     = userContacto.IdContacto,
             Asunto         = txtAsunto.Text.Trim(),
             Mensaje        = txtMensaje.Text.Trim(),
             IN_TipoMensaje = Convert.ToInt32(ddlTipoMensaje.SelectedValue),
             OrganizacionId = userPaciente.OrganizacionId
         });
         if (dtoPa.HuboError)
         {
             ScriptManager.RegisterStartupScript(this, GetType(), "Pop", HelpE.mensajeConfirmacion("Error", dtoPa.ErrorMsj, "error"), true);
         }
         else
         {
             ScriptManager.RegisterStartupScript(this, GetType(), "Pop", HelpE.mensajeConfirmacionRedirect("Mensaje Enviado Correctamente", "Se envio correctamente el mensaje", "success", "/contacto/mensaje/lista"), true);
         }
     }
     catch (Exception ex)
     {
         ScriptManager.RegisterStartupScript(this, GetType(), "Pop", @"Swal.fire('Error!', '" + "No se pudo enviar el mensaje." + "', 'error');", true);
     }
 }
        public ClassResultV Usp_Contacto_Update_ByPacienteId(DtoB dtoBase)
        {
            DtoContacto  dto = (DtoContacto)dtoBase;
            ClassResultV cr  = new ClassResultV();

            SqlParameter[] pr = new SqlParameter[9];
            try
            {
                pr[0] = new SqlParameter("@NombreCompleto", SqlDbType.VarChar, 200)
                {
                    Value = (V_ValidaPrNull(dto.NombreCompleto))
                };
                pr[1] = new SqlParameter("@IN_Tipodoc", SqlDbType.Int)
                {
                    Value = (V_ValidaPrNull(dto.IN_Tipodoc))
                };
                pr[2] = new SqlParameter("@Numdoc", SqlDbType.VarChar, 20)
                {
                    Value = (V_ValidaPrNull(dto.Numdoc))
                };
                pr[3] = new SqlParameter("@Email", SqlDbType.VarChar, 50)
                {
                    Value = (V_ValidaPrNull(dto.Email))
                };
                pr[4] = new SqlParameter("@Telefono", SqlDbType.VarChar, 50)
                {
                    Value = (V_ValidaPrNull(dto.Telefono))
                };
                pr[5] = new SqlParameter("@PacienteId", SqlDbType.Int)
                {
                    Value = (V_ValidaPrNull(dto.PacienteId))
                };
                pr[6] = new SqlParameter("@UsuarioModificacionId", SqlDbType.Int)
                {
                    Value = (V_ValidaPrNull(dto.UsuarioModificacionId))
                };
                pr[8] = new SqlParameter("@msj", SqlDbType.VarChar, 100)
                {
                    Direction = ParameterDirection.Output
                };
                SqlHelper.ExecuteNonQuery(ObjCn, CommandType.StoredProcedure, "Usp_Contacto_Update_ByPacienteId", pr);
                if (!String.IsNullOrEmpty(Convert.ToString(pr[8].Value)))
                {
                    cr.ErrorMsj   = Convert.ToString(pr[8].Value);
                    cr.LugarError = "Usp_Contacto_Update_ByPacienteId";
                }
            }
            catch (Exception ex)
            {
                cr.LugarError = ex.StackTrace;
                cr.ErrorEx    = ex.Message;
                cr.ErrorMsj   = "Error al actualizar los datos del Contacto";
            }
            ObjCn.Close();
            return(cr);
        }
Esempio n. 7
0
        private void button1_Click(object sender, EventArgs e)
        {
            DtoContacto contacto = new DtoContacto();

            contacto.Nombre   = textBox1.Text;
            contacto.Apellido = textBox2.Text;
            contacto.Telefono = textBox3.Text;

            string output = JsonConvert.SerializeObject(contacto);

            _hub.Invoke("Notify", output).Wait();
        }
        public ClassResultV Usp_Contacto_ForgotCredential(DtoB dtoBase)
        {
            DtoContacto  dto = (DtoContacto)dtoBase;
            ClassResultV cr  = new ClassResultV();

            SqlParameter[] pr = new SqlParameter[7];
            try
            {
                pr[0] = new SqlParameter("@IN_Tipodoc", SqlDbType.Int)
                {
                    Value = V_ValidaPrNull(dto.IN_Tipodoc)
                };
                pr[1] = new SqlParameter("@Numdoc", SqlDbType.VarChar, 20)
                {
                    Value = V_ValidaPrNull(dto.Numdoc)
                };
                pr[2] = new SqlParameter("@Email", SqlDbType.VarChar, 50)
                {
                    Value = V_ValidaPrNull(dto.Email)
                };
                pr[3] = new SqlParameter("@NuevaCredencial", SqlDbType.VarChar, 100)
                {
                    Value = V_ValidaPrNull(dto.NuevaCredencial)
                };
                pr[4] = new SqlParameter("@IN_Tipodoc_Paciente", SqlDbType.Int)
                {
                    Value = V_ValidaPrNull(dto.IN_Tipodoc_Paciente)
                };
                pr[5] = new SqlParameter("@Numdoc_Paciente", SqlDbType.VarChar, 20)
                {
                    Value = V_ValidaPrNull(dto.Numdoc_Paciente)
                };
                pr[6] = new SqlParameter("@msj", SqlDbType.VarChar, 100)
                {
                    Direction = ParameterDirection.Output
                };
                SqlHelper.ExecuteNonQuery(ObjCn, CommandType.StoredProcedure, "Usp_Contacto_ForgotCredential", pr);
                if (!String.IsNullOrEmpty(Convert.ToString(pr[6].Value)))
                {
                    cr.ErrorMsj   = Convert.ToString(pr[6].Value);
                    cr.LugarError = "Usp_Contacto_ForgotCredential";
                }
            }
            catch (Exception ex)
            {
                cr.LugarError = ex.StackTrace;
                cr.ErrorEx    = ex.Message;
                cr.ErrorMsj   = "Error al actualizar la nueva credencial";
            }
            ObjCn.Close();
            return(cr);
        }
        public DtoContacto Usp_Contacto_SelectOne(DtoB dtoBase)
        {
            DtoContacto dto = (DtoContacto)dtoBase;

            SqlParameter[] pr = new SqlParameter[1];

            try
            {
                pr[0] = new SqlParameter("@PacienteId", SqlDbType.Int)
                {
                    Value = (dto.PacienteId)
                };

                SqlDataReader reader = SqlHelper.ExecuteReader(ObjCn, CommandType.StoredProcedure, "Usp_Contacto_SelectOne", pr);

                //cr.List = new List<DtoB>();
                if (reader.Read())
                {
                    dto = new DtoContacto
                    {
                        IdContacto            = GetValue("IdContacto", reader).ValueInt32,
                        NombreCompleto        = GetValue("NombreCompleto", reader).ValueString,
                        IN_Tipodoc            = GetValue("IN_Tipodoc", reader).ValueInt32,
                        Numdoc                = GetValue("Numdoc", reader).ValueString,
                        Email                 = GetValue("Email", reader).ValueString,
                        Telefono              = GetValue("Telefono", reader).ValueString,
                        EnvioCredencial       = GetValue("EnvioCredencial", reader).ValueBool,
                        FechaEnvioCredencial  = GetValue("FechaEnvioCredencial", reader).ValueDateTime,
                        UsuarioCreacionId     = GetValue("UsuarioCreacionId", reader).ValueInt32,
                        FechaCreacion         = GetValue("FechaCreacion", reader).ValueDateTime,
                        UsuarioModificacionId = GetValue("UsuarioModificacionId", reader).ValueInt32,
                        FechaModificacion     = GetValue("FechaModificacion", reader).ValueDateTime,
                        IB_Estado             = GetValue("IB_Estado", reader).ValueBool,
                        PacienteId            = GetValue("PacienteId", reader).ValueInt32
                    };
                }
                reader.Close();
            }
            catch (Exception ex)
            {
                dto.LugarError = ex.StackTrace;
                dto.ErrorEx    = ex.Message;
                dto.ErrorMsj   = "Error en Usp_Contacto_SelectOne";
            }
            ObjCn.Close();
            return(dto);
        }