예제 #1
0
        private void lblBuscarProfesor_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            try
            {
                frmProfesoresA pp = new frmProfesoresA();
                pp.ShowDialog();

                if (pp.pPS != null)
                {
                    pPS = pp.pPS;
                    txtProfesor.Text = pp.pPS.Nombre.ToString() + " " + pp.pPS.Apellido.ToString();
                    cbAula.Focus();
                    p2 = true;
                    if (p1 == true & p2 == true)
                    {
                        btnGuardar.Enabled = true;
                    }
                }
                else
                {
                    MessageBox.Show("Se Produjo un Error, Intentelo Nuevamente", "Registro de Grupos", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
예제 #2
0
 public void Limpiar()
 {
     txtNombre.Clear();
     txtApellido.Clear();
     pPS = null;
     txtNombre.Focus();
 }
예제 #3
0
        public static int ModificarProfesor(Profesores pProfesores)
        {
            int Retorno = 0;

            using (SqlConnection conexion = DBcomun.ObetenerConexion())
            {
                SqlCommand comando = new SqlCommand(string.Format("update Profesores set Nombre = '{0}', Apellido = '{1}' where ID = {2}", pProfesores.Nombre, pProfesores.Apellido, pProfesores.ID), conexion);
                Retorno = comando.ExecuteNonQuery();
                conexion.Close();
            }
            return(Retorno);
        }
예제 #4
0
        public static int AgregarProfesor(Profesores pProfesor)
        {
            int R = 0;

            using (SqlConnection conexion = DBcomun.ObetenerConexion())
            {
                SqlCommand comando = new SqlCommand(string.Format("Insert into Profesores (Nombre, Apellido) values ('{0}', '{1}')", pProfesor.Nombre, pProfesor.Apellido), conexion);

                R = comando.ExecuteNonQuery();
                conexion.Close();
            }
            return(R);
        }
예제 #5
0
 private void btnModificar_Click(object sender, EventArgs e)
 {
     try
     {
         if (txtNombre.Text == string.Empty)
         {
             MessageBox.Show("El Nombre esta vacio, Digite uno Valido", "Registro de Docentes", MessageBoxButtons.OK, MessageBoxIcon.Stop);
             txtNombre.Focus();
         }
         else if (txtApellido.Text == string.Empty)
         {
             MessageBox.Show("El Apellido esta Vacio, Digite uno valido", "Registro de Docentes", MessageBoxButtons.OK, MessageBoxIcon.Stop);
             txtApellido.Focus();
         }
         else
         {
             Profesores pP = new Profesores();
             if (MessageBox.Show("Seguro que deseea Modificar el Docente?", "Registro de Docentes", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes)
             {
                 pP.Nombre   = txtNombre.Text;
                 pP.Apellido = txtApellido.Text;
                 pP.ID       = pPS.ID;
                 int R = ProfesoresDB.ModificarProfesor(pP);
                 if (R > 0)
                 {
                     MessageBox.Show("Docente Modificado Con Exito", "Registro de Docentes", MessageBoxButtons.OK, MessageBoxIcon.Information);
                     Limpiar();
                     dgvProfesores.DataSource = ProfesoresDB.TodosLosProfesores();
                     btnRegsitrar.Enabled     = true;
                     btnEliminar.Enabled      = false;
                     btnModificar.Enabled     = false;
                 }
                 else
                 {
                     MessageBox.Show("No se Pudo Modificar el Docente, Intentelo Nuevamente", "Registro de Docentes", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                 }
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
예제 #6
0
        public static Profesores ObtenerProfesor(Int32 ID)
        {
            Profesores pP = new Profesores();

            using (SqlConnection conexion = DBcomun.ObetenerConexion())
            {
                SqlCommand    comando = new SqlCommand(string.Format("Select * from Profesores where ID = {0}", ID), conexion);
                SqlDataReader reader  = comando.ExecuteReader();

                while (reader.Read())
                {
                    pP.ID       = reader.GetInt32(0);
                    pP.Nombre   = reader.GetString(1);
                    pP.Apellido = reader.GetString(2);
                }
                conexion.Close();
            }
            return(pP);
        }
예제 #7
0
 private void btnSeleccionar_Click(object sender, EventArgs e)
 {
     try
     {
         if (dgvTabla.SelectedRows.Count == 1)
         {
             Int32 ID;
             ID  = Convert.ToInt32(dgvTabla.CurrentRow.Cells[0].Value);
             pPS = ProfesoresDB.ObtenerProfesor(ID);
             this.Close();
         }
         else
         {
             MessageBox.Show("No se ha Seleccionado un Profesor, Elija uno de la Tabla", "Profesores", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
예제 #8
0
        private void btnRegsitrar_Click(object sender, EventArgs e)
        {
            try
            {
                if (txtNombre.Text == string.Empty)
                {
                    MessageBox.Show("El Nombre esta vacio, Digite uno Valido", "Registro de Docentes", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                    txtNombre.Focus();
                }
                else if (txtApellido.Text == string.Empty)
                {
                    MessageBox.Show("El Apellido esta Vacio, Digite uno valido", "Registro de Docentes", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                    txtApellido.Focus();
                }
                else
                {
                    Profesores pP = new Profesores();
                    pP.Nombre   = txtNombre.Text;
                    pP.Apellido = txtApellido.Text;

                    int R = ProfesoresDB.AgregarProfesor(pP);

                    if (R > 0)
                    {
                        MessageBox.Show("Profesor Registrado Con Exito", "Registro de Docentes", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        dgvProfesores.DataSource = ProfesoresDB.TodosLosProfesores();
                        Limpiar();
                    }
                    else
                    {
                        MessageBox.Show("No se Pudo Registrar el Docente, Intentelo Nuevamente", "Registro de Docentes", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
예제 #9
0
        public static List <Profesores> BuscarProfesores(string nombre, string apellido)
        {
            List <Profesores> list = new List <Profesores>();

            using (SqlConnection conexion = DBcomun.ObetenerConexion())
            {
                SqlCommand comando = new SqlCommand(String.Format("Select * from Profesores where Nombre like '{0}%' or Apellido like '{1}%'", nombre, apellido), conexion);

                SqlDataReader reader = comando.ExecuteReader();

                while (reader.Read())
                {
                    Profesores pP = new Profesores();

                    pP.ID       = reader.GetInt32(0);
                    pP.Nombre   = reader.GetString(1);
                    pP.Apellido = reader.GetString(2);

                    list.Add(pP);
                }
                conexion.Close();
            }
            return(list);
        }
예제 #10
0
        public static List <Profesores> TodosLosProfesores()
        {
            List <Profesores> list = new List <Profesores>();

            using (SqlConnection conexion = DBcomun.ObetenerConexion())
            {
                SqlCommand comando = new SqlCommand("Select * from Profesores", conexion);

                SqlDataReader reader = comando.ExecuteReader();

                while (reader.Read())
                {
                    Profesores pP = new Profesores();

                    pP.ID       = reader.GetInt32(0);
                    pP.Nombre   = reader.GetString(1);
                    pP.Apellido = reader.GetString(2);

                    list.Add(pP);
                }
                conexion.Close();
            }
            return(list);
        }