private void btnBuscarMilitar_Click(object sender, EventArgs e)
        {
            frmBuscarPaciente ofrmBuscarPaciente = new frmBuscarPaciente();

            ofrmBuscarPaciente.ShowDialog();
            string cCodigo = ofrmBuscarPaciente.cCodigo;

            // Si selecciono un registro
            if (cCodigo != "" && cCodigo != null)
            {
                // Mostrar el codigo
                txtCedulaMilitar.Text = Convert.ToString(cCodigo).Trim();
            }
        }
Beispiel #2
0
        private void btnBuscarPaciente_Click(object sender, EventArgs e)
        {
            frmBuscarPaciente ofrmBuscarPaciente = new frmBuscarPaciente();

            ofrmBuscarPaciente.ShowDialog();
            string cCodigo = ofrmBuscarPaciente.cCodigo;

            // Si selecciono un registro
            if (cCodigo != "" && cCodigo != null)
            {
                // Mostrar el codigo
                txtCedulaPaciente.Text = Convert.ToString(cCodigo).Trim();
            }

            if (txtCedulaPaciente.Text != "")
            {
                try
                {
                    // Step 1 - clsConexion
                    MySqlConnection MyclsConexion = new MySqlConnection(clsConexion.ConectionString);

                    // Step 2 - creating the command object
                    MySqlCommand MyCommand = MyclsConexion.CreateCommand();

                    // Step 3 - creating the commandtext
                    MyCommand.CommandText = "SELECT rango, nombre, apellido, edad, seccionaval, departamento " +
                                            "FROM paciente WHERE cedula =" + "'" + txtCedulaPaciente.Text + "'" + "";

                    // Step 4 - connection open
                    MyclsConexion.Open();

                    // Step 5 - Creating the DataReader
                    MySqlDataReader MyReader = MyCommand.ExecuteReader();

                    // Step 6 - Verifying if Reader has rows
                    if (MyReader.HasRows)
                    {
                        while (MyReader.Read())
                        {
                            cmbRangoPaciente.SelectedValue = MyReader["rango"].ToString();
                            txtNombrePaciente.Text         = MyReader["nombre"].ToString();
                            txtNombrePaciente.Text        += " ";
                            txtNombrePaciente.Text        += MyReader["apellido"].ToString();
                            cmbDepartamento.SelectedValue  = MyReader["departamento"].ToString();
                            cmbSeccionNaval.SelectedValue  = MyReader["seccionaval"].ToString();
                        }
                    }
                    else
                    {
                        MessageBox.Show("No se encontraron registros...");
                        this.txtCedulaPaciente.Clear();
                        this.txtNombrePaciente.Clear();
                        this.txtCedulaPaciente.Focus();
                    }

                    // Step 6 - Closing all
                    MyReader.Close();
                    MyCommand.Dispose();
                    MyclsConexion.Close();
                }
                catch (Exception myEx)
                {
                    MessageBox.Show(myEx.Message);
                }
            }
        }
        private void btnBuscarEmpleado_Click(object sender, EventArgs e)
        {
            frmBuscarPaciente ofrmBuscarPaciente = new frmBuscarPaciente();

            ofrmBuscarPaciente.ShowDialog();
            string cCodigo = ofrmBuscarPaciente.cCodigo;

            // Si selecciono un registro
            if (cCodigo != "" && cCodigo != null)
            {
                // Mostrar el codigo
                txtCedula.Text = Convert.ToString(cCodigo).Trim();
                try
                {
                    // Step 1 - clsConexion
                    MySqlConnection MyclsConexion = new MySqlConnection(clsConexion.ConectionString);

                    // Step 2 - creating the command object
                    MySqlCommand MyCommand = MyclsConexion.CreateCommand();

                    // Step 3 - creating the commandtext
                    //MyCommand.CommandText = "SELECT *  FROM paciente WHERE cedula = ' " + txtCedula.Text.Trim() + "'  " ;
                    MyCommand.CommandText = "SELECT id_paciente, cedula, rango, nombre, apellido, edad, sexo, dato_nacimiento, " +
                                            "dato_alimentacion, dato_condicionespsicologicas, dato_sexualidad, dato_operaciones, " +
                                            "dato_intoleranciamedicinal, dato_saludpadres, dato_saludhermanos, dato_saludesposahijos, " +
                                            "dato_saludfamiliargeneral, fecharegistro, fechaupdate,rutafoto FROM paciente " +
                                            "WHERE cedula = " + "'" + txtCedula.Text + "'" + "";

                    // Step 4 - connection open
                    MyclsConexion.Open();

                    // Step 5 - Creating the DataReader
                    MySqlDataReader MyReader = MyCommand.ExecuteReader();

                    // Step 6 - Verifying if Reader has rows
                    if (MyReader.HasRows)
                    {
                        while (MyReader.Read())
                        {
                            // txtID.Text = MyReader["id_paciente"].ToString();
                            cmbRangoPaciente.SelectedValue = Convert.ToInt32(MyReader["rango"]);
                            txtNombre.Text   = MyReader["nombre"].ToString();
                            txtApellido.Text = MyReader["apellido"].ToString();

                            /*
                             * if (this.imgFoto.ImageLocation == null || this.imgFoto.ImageLocation == "")
                             * {
                             *  if (File.Exists(@MyReader["rutafoto"].ToString()))
                             *  {
                             *      this.imgFoto.ImageLocation = @MyReader["rutafoto"].ToString();
                             *  }
                             * }
                             * if (this.imgFoto.Image == null)
                             * {
                             *  // valor por defecto
                             *  //this.imgFoto.Image = System.Drawing.Image.FromFile(@this.Icon);
                             *  //  this.imgFoto.Image = System.Drawing.Image.FromFile(@MyReader["rutafoto"].ToString());
                             * }
                             * */
                        }
                    }
                    else
                    {
                        MessageBox.Show("No se encontraron registros con esta cedula...", "SysHospitalARD v1.0", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        this.txtCedula.Focus();
                    }
                    // Step 6 - Closing all
                    MyReader.Close();
                    MyCommand.Dispose();
                    MyclsConexion.Close();
                }
                catch (Exception MyEx)
                {
                    MessageBox.Show(MyEx.Message);
                }
            }
        }
        private void btnBuscar_Click(object sender, EventArgs e)
        {
            frmBuscarPaciente ofrmBuscarPaciente = new frmBuscarPaciente();

            ofrmBuscarPaciente.ShowDialog();
            string cCodigo = ofrmBuscarPaciente.cCodigo;

            // Si selecciono un registro
            if (cCodigo != "" && cCodigo != null)
            {
                // Mostrar el codigo
                txtCedula.Text = Convert.ToString(cCodigo).Trim();
            }

            if (txtCedula.Text == "")
            {
                MessageBox.Show("No se permiten busquedas con el campo cedula vacio...");
                txtCedula.Focus();
            }
            else
            {
                try
                {
                    // Step 1 - clsConexion
                    MySqlConnection MyclsConexion = new MySqlConnection(clsConexion.ConectionString);

                    // Step 2 - creating the command object
                    MySqlCommand MyCommand = MyclsConexion.CreateCommand();

                    // Step 3 - creating the commandtext
                    MyCommand.CommandText = "SELECT id_paciente, cedula, rango, nombre, apellido, edad, sexo, dato_nacimiento, " +
                                            "dato_alimentacion, dato_condicionespsicologicas, dato_sexualidad, dato_operaciones, " +
                                            "dato_intoleranciamedicinal, dato_saludpadres, dato_saludhermanos, dato_saludesposahijos, " +
                                            "dato_saludfamiliargeneral, fecharegistro, fechaupdate, fechanac, seccionaval, departamento, cedulamilitar FROM paciente " +
                                            "WHERE cedula = " + "'" + txtCedula.Text + "'" + "";

                    // Step 4 - connection open
                    MyclsConexion.Open();

                    // Step 5 - Creating the DataReader
                    MySqlDataReader MyReader = MyCommand.ExecuteReader();

                    // Step 6 - Verifying if Reader has rows
                    if (MyReader.HasRows)
                    {
                        while (MyReader.Read())
                        {
                            txtID.Text             = MyReader["id_paciente"].ToString();
                            cmbRango.SelectedValue = MyReader["rango"].ToString();
                            txtNombre.Text         = MyReader["nombre"].ToString().Trim();
                            txtApellido.Text       = MyReader["apellido"].ToString().Trim();
                            string sexo = MyReader["sexo"].ToString();
                            if (sexo == "M")
                            {
                                rbMasculino.Checked = true;
                            }
                            else
                            {
                                rbFemenino.Checked = true;
                            }
                            txtNacimiento.Text              = MyReader["dato_nacimiento"].ToString();
                            txtAlimentacion.Text            = MyReader["dato_alimentacion"].ToString();
                            txtCondicionesPsicologicas.Text = MyReader["dato_condicionespsicologicas"].ToString();
                            txtSexualidad.Text              = MyReader["dato_sexualidad"].ToString();
                            txtOperaciones.Text             = MyReader["dato_operaciones"].ToString();
                            txtIntoleranciaMedicinal.Text   = MyReader["dato_intoleranciamedicinal"].ToString();
                            txtSaludPadres.Text             = MyReader["dato_saludpadres"].ToString();
                            txtSaludHermanos.Text           = MyReader["dato_saludhermanos"].ToString();
                            txtSaludEsposaHijos.Text        = MyReader["dato_saludesposahijos"].ToString();
                            txtSaludFamiliarGeneral.Text    = MyReader["dato_saludfamiliargeneral"].ToString();
                            txtFechaRegistro.Value          = Convert.ToDateTime(MyReader["fecharegistro"]);
                            txtFechaUpdate.Value            = Convert.ToDateTime(MyReader["fechaupdate"]);
                            cmbDepartamento.SelectedValue   = MyReader["departamento"].ToString();
                            cmbSeccionNaval.SelectedValue   = MyReader["seccionaval"].ToString();
                            txtCedulaMilitar.Text           = MyReader["cedulamilitar"].ToString();

                            // Calcula Edad
                            // txtEdad.Text = MyReader["edad"].ToString();
                            txtEdad.Text = clsProcesos.CalculaEdad(Convert.ToDateTime(MyReader["fechanac"])).ToString("N");
                        }

                        this.cModo = "Buscar";
                        this.Botones();
                    }
                    else
                    {
                        MessageBox.Show("No se encontraron registros con esta cedula...");
                        this.cModo = "Nuevo";
                        this.Botones();
                        //this.Limpiar();
                        //this.txtCedula.Focus();
                        txtNombre.Focus();
                    }

                    // Step 6 - Closing all
                    MyReader.Close();
                    MyCommand.Dispose();
                    MyclsConexion.Close();
                }
                catch (Exception MyEx)
                {
                    MessageBox.Show(MyEx.Message);
                }
            }
        }