Ejemplo n.º 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {

                updateLinkButton.Visible = false;

                Repositorio repo = new Repositorio();
                string id = Request.QueryString["id"];

                MembershipUser myObject = Membership.GetUser();
                Guid UserID = (Guid)myObject.ProviderUserKey;

                //preguntamos si el caso pertenece a la institucion

                //el caso no pertenece a la institución
                int? pertenece = entidad.sp_PacientePerteneceAInst(UserID, Convert.ToInt32(id)).SingleOrDefault();

                if (pertenece == 0 && (Roles.IsUserInRole("administrador") || Roles.IsUserInRole("admin_minsa") || Roles.IsUserInRole("admin_regional")))
                {
                    editarLinkButton.Visible = false;
                    casoHide1.Visible = false;
                    casoHide2.Visible = false;
                }
                else if (pertenece == 0)
                    Response.Redirect("~/Hospital/Error1.aspx");

                DataSet dset = repo.BuscarPaciente(id);

                //usado por el gridview
                idHiddenField.Value = id;

                if (dset.Tables[0].Rows.Count >= 1)
                {

                    if ((bool)dset.Tables[0].Rows[0].ItemArray[15] == true)
                    {
                        cedulaLabel.Text = "IDENTIFICADOR";
                        identiCheck.Checked = true;
                    }

                    cedulaTextBox.Text = dset.Tables[0].Rows[0].ItemArray[1].ToString();

                    primerNombre.Text = dset.Tables[0].Rows[0].ItemArray[2].ToString();
                    segundoNombre.Text = dset.Tables[0].Rows[0].ItemArray[3].ToString();
                    primerApellido.Text = dset.Tables[0].Rows[0].ItemArray[4].ToString();
                    segundoApellido.Text = dset.Tables[0].Rows[0].ItemArray[5].ToString();

                    fechaNacimientoTextBox.Text = String.Format("{0:dd/MM/yyyy}", dset.Tables[0].Rows[0].ItemArray[6]);

                    sexo.SelectedValue = dset.Tables[0].Rows[0].ItemArray[7].ToString();

                    if (!(dset.Tables[0].Rows[0].ItemArray[8].ToString()==""))
                        razaRadioButton.SelectedValue = dset.Tables[0].Rows[0].ItemArray[8].ToString();

                    numeroTelTextBox.Text = dset.Tables[0].Rows[0].ItemArray[9].ToString();

                    direccionTextBox.Text = dset.Tables[0].Rows[0].ItemArray[11].ToString();

                    provinciaDropDown.SelectedValue = dset.Tables[0].Rows[0].ItemArray[10].ToString().Substring(0, 2);

                    numeroCelTextBox.Text = dset.Tables[0].Rows[0].ItemArray[12].ToString();
                    numeroCel2TextBox.Text = dset.Tables[0].Rows[0].ItemArray[13].ToString();

                    distritoDropDown.DataSource = repo.Distritos_SelectedProvincia(dset.Tables[0].Rows[0].ItemArray[10].ToString().Substring(0, 2));
                    distritoDropDown.DataTextField = "distrito";
                    distritoDropDown.DataValueField = "cod_distrito";
                    distritoDropDown.SelectedValue = dset.Tables[0].Rows[0].ItemArray[10].ToString().Substring(2, 2);
                    distritoDropDown.DataBind();

                    corregimientoDropDown.DataSource = repo.Corregimiento_SelectProvinciaDistrito(dset.Tables[0].Rows[0].ItemArray[10].ToString().Substring(0, 2), dset.Tables[0].Rows[0].ItemArray[10].ToString().Substring(2, 2));
                    corregimientoDropDown.DataTextField = "corregimiento";
                    corregimientoDropDown.DataValueField = "cod_corregimiento";
                    corregimientoDropDown.SelectedValue = dset.Tables[0].Rows[0].ItemArray[10].ToString().Substring(4, 2);
                    corregimientoDropDown.DataBind();

                    this.enableElements(false);

                    CasosGridView.DataBind();

                }

                InfoMultiView.SetActiveView(UsuarioView);
            }
        }