Beispiel #1
0
        private void btnProfesor_Click(object sender, EventArgs e)
        {
            if (profesor == null)
            {
                profesor = new Eprofesores();
            }

            profesor.a      = "Buscar";
            profesor.cedula = txtProfesor.Text;


            if (Accceso_Profesores.BuscarProfesores(profesor))
            {
                gvDatosProfesor.DataSource = Accceso_Profesores.datos;

                id_profesor      = int.Parse(gvDatosProfesor.CurrentRow.Cells["id_profesor"].Value.ToString());
                txtNombre.Text   = gvDatosProfesor.CurrentRow.Cells["nombre"].Value.ToString();
                txtApellido.Text = gvDatosProfesor.CurrentRow.Cells["apellido"].Value.ToString();
                txtCedula.Text   = gvDatosProfesor.CurrentRow.Cells["cedula"].Value.ToString();
                txtTel.Text      = gvDatosProfesor.CurrentRow.Cells["telefono"].Value.ToString();
                txtDire.Text     = gvDatosProfesor.CurrentRow.Cells["direccion"].Value.ToString();
            }
            else
            {
                MessageBox.Show("ESTE PROFESOR NO EXISTE", "PARA CONTINUAR:", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
 public void InsertarProfesores(Eprofesores profesor)
 {
     try {
         con.ConnectionString = Conexion.cadenaConexion;
         comando             = new SqlCommand("Sp_profesores", con);
         comando.CommandType = CommandType.StoredProcedure;
         comando.Parameters.AddWithValue("@a", "Insertar");
         comando.Parameters.AddWithValue("@nombre", profesor.nombre);
         comando.Parameters.AddWithValue("@apellido", profesor.apellido);
         comando.Parameters.AddWithValue("@cedula", profesor.cedula);
         comando.Parameters.AddWithValue("@telefono", profesor.telefono);
         comando.Parameters.AddWithValue("@direccion", profesor.direccion);
         comando.Parameters.AddWithValue("@fecha", profesor.fecha);
         con.Open();
         comando.ExecuteNonQuery();
     }
     catch (Exception ex)
     {
         throw ex;
     }
     finally
     {
         con.Close();
     }
 }
Beispiel #3
0
        private void Guardar()
        {
            try
            {
                if (profesor == null)
                {
                    profesor = new Eprofesores();
                }

                profesor.nombre    = txtNombre.Text;
                profesor.apellido  = txtApellido.Text;
                profesor.cedula    = txtCedula.Text;
                profesor.telefono  = txtTel.Text;
                profesor.direccion = txtDire.Text;
                profesor.fecha     = txtFecha.Text;

                acceso_profesor.InsertarProfesores(profesor);

                if (acceso_profesor.stringBuilder.Length != 0)
                {
                    MessageBox.Show(acceso_profesor.stringBuilder.ToString(), "Para continuar:", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                else
                {
                    MessageBox.Show("CLIENTE REGISTRADO CORRECTAMENTE", "CLIENTE REGISTRADO", MessageBoxButtons.OK, MessageBoxIcon.None);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(string.Format("Error: {0}", ex.Message), "Error inesperado", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Beispiel #4
0
 public void InsertarProfesores(Eprofesores profesor)
 {
     if (ValidarProfesor(profesor))
     {
         acceso_datos.InsertarProfesores(profesor);
     }
 }
Beispiel #5
0
        private bool ValidarProfesor(Eprofesores profesor)
        {
            stringBuilder.Clear();

            if (string.IsNullOrEmpty(profesor.nombre))
            {
                stringBuilder.Append("El campo NOMBRE es obligatorio");
            }
            if (string.IsNullOrEmpty(profesor.apellido))
            {
                stringBuilder.Append(Environment.NewLine + "El campo APELLIDO es obligatorio");
            }
            if (string.IsNullOrEmpty(profesor.cedula))
            {
                stringBuilder.Append(Environment.NewLine + "El campo CEDULA es obligatorio");
            }
            if (string.IsNullOrEmpty(profesor.telefono))
            {
                stringBuilder.Append(Environment.NewLine + "El campo TELEFONO es obligatorio");
            }
            if (string.IsNullOrEmpty(profesor.direccion))
            {
                stringBuilder.Append(Environment.NewLine + "El campo DIRECCION es obligatorio");
            }
            if (string.IsNullOrEmpty(profesor.fecha))
            {
                stringBuilder.Append(Environment.NewLine + "El campo FECHA_NACIMIENTO es obligatorio");
            }
            return(stringBuilder.Length == 0);
        }
Beispiel #6
0
 public static bool BuscarProfesores(Eprofesores profesor)
 {
     datos = acceso_datos.BuscarProfesores(profesor);
     if (datos.Rows.Count > 0)
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
        //______________________PROFESORES_______________________________
        #region datos profesores
        public DataTable BuscarProfesores(Eprofesores profesor)
        {
            con.ConnectionString = Conexion.cadenaConexion;
            comando             = new SqlCommand("Sp_profesores", con);
            comando.CommandType = CommandType.StoredProcedure;
            comando.Parameters.AddWithValue("@a", profesor.a);
            comando.Parameters.AddWithValue("@nombre", "");
            comando.Parameters.AddWithValue("@apellido", "");
            comando.Parameters.AddWithValue("@cedula", profesor.cedula);
            comando.Parameters.AddWithValue("@telefono", "");
            comando.Parameters.AddWithValue("@direccion", "");
            comando.Parameters.AddWithValue("@fecha", "");

            return(MetodosDatos.ejecutarComandoSelect(comando));
        }