コード例 #1
0
        private void btnBuscarDoctor_Click(object sender, EventArgs e)
        {
            frmBuscarDoctor ofrmBuscarDoctor = new frmBuscarDoctor();

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

            // Si selecciono un registro
            if (cCodigo != "" && cCodigo != null)
            {
                // Mostrar el codigo
                txtCedula.Text = Convert.ToString(cCodigo).Trim();
            }
        }
コード例 #2
0
        private void btnBuscarDoctor_Click(object sender, EventArgs e)
        {
            frmBuscarDoctor ofrmBuscarDoctor = new frmBuscarDoctor();

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

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

            if (txtCedulaDoctor.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 doctores_rango, doctores_especialidad, doctores_nombre, doctores_apellido " +
                                            "FROM doctores WHERE doctores_cedula =" + "'" + txtCedulaDoctor.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())
                        {
                            cmbRangoDoctor.SelectedValue  = MyReader["doctores_rango"].ToString();
                            cmbEspecialidad.SelectedValue = MyReader["doctores_especialidad"].ToString();
                            txtNombreDoctor.Text          = MyReader["doctores_nombre"].ToString();
                            txtApellidoDoctor.Text        = MyReader["doctores_apellido"].ToString();
                        }
                    }
                    else
                    {
                        MessageBox.Show("No se encontraron registros...");
                        this.txtCedulaDoctor.Clear();
                        this.txtNombreDoctor.Clear();
                        this.txtApellidoDoctor.Clear();
                        this.txtCedulaDoctor.Focus();
                    }

                    // Step 6 - Closing all
                    MyReader.Close();
                    MyCommand.Dispose();
                    MyclsConexion.Close();
                }
                catch (Exception myEx)
                {
                    MessageBox.Show(myEx.Message);
                }
            }
        }
コード例 #3
0
        private void btnBuscar_Click(object sender, EventArgs e)
        {
            frmBuscarDoctor ofrmBuscarDoctor = new frmBuscarDoctor();

            ofrmBuscarDoctor.ShowDialog();
            string cCodigo = ofrmBuscarDoctor.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 * from vdoctores WHERE doctores_cedula = '" + txtCedula.Text.Trim() + "'";

                    // 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["doctores_id"].ToString();
                            cmbRango.SelectedValue = MyReader["doctores_rango"].ToString();
                            txtNombre.Text         = MyReader["doctores_nombre"].ToString();
                            txtApellido.Text       = MyReader["doctores_apellido"].ToString();
                            txtEdad.Text           = MyReader["doctores_edad"].ToString();
                            string sexo = MyReader["doctores_sexo"].ToString();

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

                            if (sexo == "M")
                            {
                                rbSexoMasculino.Select();
                            }
                            else
                            {
                                rbSexoFemenino.Select();
                            }
                            txtExequatur.Text             = MyReader["doctores_exequatur"].ToString();
                            cmbEspecialidad.SelectedValue = Convert.ToInt32(MyReader["doctores_especialidad"].ToString());

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

                            /*
                             * 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());
                             * }*/
                        }
                        this.cModo = "Buscar";
                        this.Botones();
                    }
                    else
                    {
                        MessageBox.Show("No se encontraron registros con esta cedula...", "SysHospitalARD v1.0", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        this.txtCedula.Focus();
                        this.cModo = "Inicio";
                        this.Botones();
                        this.Limpiar();
                        this.txtID.Focus();
                    }
                    // Step 6 - Closing all
                    MyReader.Close();
                    MyCommand.Dispose();
                    MyclsConexion.Close();
                }
                catch (Exception MyEx)
                {
                    MessageBox.Show(MyEx.Message);
                }
            }
        }