Ejemplo n.º 1
0
        public MemberUpdate(int codigo)
        {
            InitializeComponent();
            this.Code   = codigo;
            this.Change = false;

            SqlConnection connection = new SqlConnection(General_Values.str_connection);

            connection.Open();


            string str_consult = "SELECT * FROM miembro WHERE codigo = " + Code + ";";

            SqlCommand    consult = new SqlCommand(str_consult, connection);
            SqlDataReader record  = consult.ExecuteReader();

            while (record.Read())
            {
                TextBoxCodigo.Text  = record["codigo"].ToString();
                TextBoxNombre.Text  = record["nombre"].ToString();
                TextBoxPaterno.Text = record["ap_paterno"].ToString();
                TextBoxMaterno.Text = record["ap_materno"].ToString();
                TextBoxDni.Text     = record["dni"].ToString();

                //  0 = soltero    1 = casado    2 = viudo    3 = divorciado
                int e_civil = int.Parse(record["estado_civil"].ToString());
                if (e_civil == 0)
                {
                    CheckBoxSoltero.Checked = true;
                }
                else if (e_civil == 1)
                {
                    CheckBoxCasado.Checked = true;
                }
                else if (e_civil == 2)
                {
                    CheckBoxViudo.Checked = true;
                }
                else if (e_civil == 3)
                {
                    CheckBoxDivorciado.Checked = true;
                }

                TextBoxProvincia.Text  = record["provincia"].ToString();
                TextBoxDistrito.Text   = record["distrito"].ToString();
                TextBoxDireccion.Text  = record["direccion"].ToString();
                TextBoxReferencia.Text = record["referencia"].ToString();

                // 0 = hombre    1 = mujer
                bool sexo = bool.Parse(record["sexo"].ToString());
                if (sexo == false)
                {
                    CheckBoxMasculino.Checked = true;
                }
                else if (sexo == true)
                {
                    CheckBoxFemenino.Checked = true;
                }

                TextBoxCelular.Text  = record["celular"].ToString();
                TextBoxTelefono.Text = record["telefono"].ToString();
                TextBoxEmail.Text    = record["email"].ToString();
                TextBoxEstudios.Text = record["estudios"].ToString();

                DateTimeNacimiento.Text = record["fch_nacimiento"].ToString();

                DateTimeBautismo.Text = record["fch_bautismo"].ToString();

                bool estado = bool.Parse(record["activo"].ToString());
                if (estado == false)
                {
                    CheckBoxActivo.Checked = false;
                }
                else if (estado == true)
                {
                    CheckBoxActivo.Checked = true;
                }

                try
                {
                    byte[] datos = (byte[])record["foto"];
                    PictureBoxFoto.Image = Photo.Bytes_To_Image(datos);
                }
                catch
                {
                }
            }
            connection.Close();
        }
Ejemplo n.º 2
0
        private void RefreshPersonal()
        {
            SqlConnection connection = new SqlConnection(General_Values.str_connection);

            connection.Open();
            string        str_consult = "SELECT * FROM miembro WHERE codigo = " + code + ";";
            SqlCommand    consult     = new SqlCommand(str_consult, connection);
            SqlDataReader record      = consult.ExecuteReader();

            if (record.Read())
            {
                TextLabelCodigo.Text    = record["codigo"].ToString();
                TextLabelNombres.Text   = record["nombre"].ToString();
                TextLabelApellidos.Text = record["ap_paterno"].ToString() + " " + record["ap_materno"].ToString();
                TextLabelDni.Text       = record["dni"].ToString();

                //  0 = soltero    1 = casado    2 = viudo    3 = divorciado
                int e_civil = int.Parse(record["estado_civil"].ToString());
                if (e_civil == 0)
                {
                    TextLabelEstadoCivil.Text = "Soltero";
                }
                else if (e_civil == 1)
                {
                    TextLabelEstadoCivil.Text = "Casado";
                }
                else if (e_civil == 2)
                {
                    TextLabelEstadoCivil.Text = "Viudo";
                }
                else if (e_civil == 3)
                {
                    TextLabelEstadoCivil.Text = "Divorciado";
                }

                TextLabelProvincia.Text  = record["provincia"].ToString();
                TextLabelDistrito.Text   = record["distrito"].ToString();
                TextLabelDireccion.Text  = record["direccion"].ToString();
                TextLabelReferencia.Text = record["referencia"].ToString();

                // 0 = hombre    1 = mujer
                bool sexo = bool.Parse(record["sexo"].ToString());
                if (sexo == false)
                {
                    TextLabelSexo.Text = "Hombre";
                }
                else if (sexo == true)
                {
                    TextLabelSexo.Text = "Mujer";
                }

                TextLabelCelular.Text  = record["celular"].ToString();
                TextLabelTelefono.Text = record["telefono"].ToString();
                TextLabelEmail.Text    = record["email"].ToString();
                TextLabelEstudios.Text = record["estudios"].ToString();

                DateTimeNacimiento.Text = record["fch_nacimiento"].ToString();

                DateTimeBautismo.Text = record["fch_bautismo"].ToString();

                bool estado = bool.Parse(record["activo"].ToString());
                if (estado == false)
                {
                    LabelEstado.Text = "No Activo";
                }
                else if (estado == true)
                {
                    LabelEstado.Text = "Activo";
                }

                try
                {
                    byte[] datos = (byte[])record["foto"];
                    PictureBoxFoto.Image = Photo.Bytes_To_Image(datos);
                }
                catch
                {
                }
            }
            connection.Close();


            connection.Open();
            string str_consult2 = "SELECT V.vinculo, V.cod_vinculo, M.nombre, M.ap_paterno, M.ap_materno FROM vinculo V " +
                                  "JOIN miembro M ON M.codigo = V.cod_vinculo WHERE V.cod_miembro = " + this.code + ";";
            //string str_consult2 = "SELECT vinculo, cod_vinculo FROM vinculo WHERE cod_miembro = " + this.code + ";";
            SqlCommand    consult2 = new SqlCommand(str_consult2, connection);
            SqlDataReader record2  = consult2.ExecuteReader();

            DataGridViewFamilia.Rows.Clear();
            while (record2.Read())
            {
                int n = DataGridViewFamilia.Rows.Add();
                DataGridViewFamilia.Rows[n].Cells[0].Value = record2["cod_vinculo"];
                int    int_vin = int.Parse(record2["vinculo"].ToString());
                string str_vin = "";
                switch (int_vin)
                {
                case 0:
                    str_vin = "Conyuge";
                    break;

                case 1:
                    str_vin = "Padre";
                    break;

                case 2:
                    str_vin = "Madre";
                    break;

                case 3:
                    str_vin = "Hijo";
                    break;

                case 4:
                    str_vin = "Hija";
                    break;

                case 5:
                    str_vin = "Hermano";
                    break;

                case 6:
                    str_vin = "Hermana";
                    break;

                case 7:
                    str_vin = "Abuelo";
                    break;

                case 8:
                    str_vin = "Abuela";
                    break;

                case 9:
                    str_vin = "Nieto";
                    break;

                case 10:
                    str_vin = "Nieta";
                    break;

                case 11:
                    str_vin = "Tío";
                    break;

                case 12:
                    str_vin = "Tía";
                    break;

                case 13:
                    str_vin = "Sobrino";
                    break;

                case 14:
                    str_vin = "Sobrina";
                    break;

                case 15:
                    str_vin = "Primo";
                    break;

                case 16:
                    str_vin = "Prima";
                    break;

                case 17:
                    str_vin = "Padrastro";
                    break;

                case 18:
                    str_vin = "Madrastra";
                    break;

                case 19:
                    str_vin = "Hijastro";
                    break;

                case 20:
                    str_vin = "Hijastra";
                    break;

                case 21:
                    str_vin = "Hermanastro";
                    break;

                case 22:
                    str_vin = "Hermanastra";
                    break;
                }
                DataGridViewFamilia.Rows[n].Cells[1].Value = str_vin;
                DataGridViewFamilia.Rows[n].Cells[2].Value = record2["nombre"].ToString() + " " + record2["ap_paterno"].ToString() + " " + record2["ap_materno"].ToString();
            }

            connection.Close();
        }