Exemple #1
0
        private void view_id_Click(object sender, EventArgs e)
        {
            int enroll = 0;

            if (ShowMenuPanel.Visible == false)
            {
                try
                {
                    classRoom = new DataBaseModel();
                    int id;
                    id = Convert.ToInt32(Prompt.ShowDialog("Enter Course ID you Want to Show", "Search by ID"));
                    List <StdCourse> courses = new List <StdCourse>();
                    StdCourse        course  = classRoom.selectOneCourses(id);
                    courses.Add(course);
                    OpenView(new StdViewCourses(courses, LoggedInUser, enroll));
                    menu_trans.ShowSync(ShowMenuPanel);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
            else
            {
                menu_trans.HideSync(ShowMenuPanel);
            }
        }
        public List <StdCourse> selectStudentCourses(int stdID)
        {
            List <StdCourse> CourseList = new List <StdCourse>();

            //try
            {
                conn = new OracleConnection(connectionPath);
                conn.Open();

                StdCourse     course;
                OracleCommand cmd = new OracleCommand();
                cmd.Connection  = conn;
                cmd.CommandText = "SELECTSTUDENTCOURSES";
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.Add("id", OracleDbType.Int32).Value          = stdID;
                cmd.Parameters.Add("Cou", OracleDbType.RefCursor).Direction = ParameterDirection.Output;
                OracleDataReader objReader = cmd.ExecuteReader();
                while (objReader.Read())
                {
                    int    CouID     = (int)objReader["COURSE_ID"];
                    string CouName   = (string)objReader["C_NAME"];
                    string subject   = (string)objReader["SUBJECT"];
                    int    InsID     = (int)objReader["USER_ID"];
                    string inst_name = objReader["USER_NAME"].ToString();
                    course = new StdCourse(CouID, CouName, subject, inst_name, InsID);
                    CourseList.Add(course);
                }
                conn.Close();
            }
            //catch (Exception)
            {
                //MessageBox.Show("errore in database when select all courses");
            }
            return(CourseList);
        }
 public List <StdCourse> selectAllCourses()
 {
     try
     {
         List <StdCourse> CourseList = new List <StdCourse>();
         string           callstr    = "Select * FROM COURSE";
         adapter = new OracleDataAdapter(callstr, connectionPath);
         ds      = new DataSet();
         adapter.Fill(ds);
         DataTable table = ds.Tables[0];
         int       x     = table.Rows.Count;
         int       y     = table.Rows.Count - 1;
         DataRow   row;
         StdCourse course;
         while (x > 0)
         {
             row = (DataRow)table.Rows[y];
             int    CouID     = (int)row["COURSE_ID"];
             string CouName   = (string)row["C_NAME"];
             string subject   = (string)row["SUBJECT"];
             int    InsID     = (int)row["USER_ID"];
             string inst_name = (string)row["USER_NAME"];
             course = new StdCourse(CouID, CouName, subject, inst_name, InsID);
             CourseList.Add(course);
             x--;
             y--;
         }
         return(CourseList);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
         return(null);
     }
 }
        public StdCourse selectOneCourses(int id)
        {
            StdCourse Stdcourse = new StdCourse();

            try
            {
                conn = new OracleConnection(connectionPath);
                conn.Open();
                OracleCommand cmd = new OracleCommand();
                cmd.Connection  = conn;
                cmd.CommandText = "SELECTONECOURSE";
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.Add("cours_id", OracleDbType.Int32).Value    = id;
                cmd.Parameters.Add("cid", OracleDbType.RefCursor).Direction = ParameterDirection.Output;
                OracleDataReader objReader = cmd.ExecuteReader();

                while (objReader.Read())
                {
                    int    CouID     = (int)objReader["COURSE_ID"];
                    string CouName   = (string)objReader["C_NAME"];
                    string subject   = (string)objReader["SUBJECT"];
                    int    InsID     = (int)objReader["USER_ID"];
                    string inst_name = (string)objReader["USER_NAME"];
                    Stdcourse.courseID   = CouID;
                    Stdcourse.courseName = CouName;
                    Stdcourse.courseSub  = subject;
                    Stdcourse.instID     = InsID;
                    Stdcourse.instName   = inst_name;
                }
                conn.Close();
            }
            catch (Exception)
            {
                MessageBox.Show("errore in database when select all courses");
            }
            return(Stdcourse);
        }