コード例 #1
0
        //Loading lecturer name into the combo box
        void LecturerCombo()
        {
            SqlConnection conn = new SqlConnection(myconnstring);  //Connect to DB
            string        sql  = "select * from Lecturer_Table";
            SqlCommand    cmd  = new SqlCommand(sql, conn);


            SqlDataReader LecturerRead;

            try
            {
                conn.Open();
                LecturerRead = cmd.ExecuteReader();

                while (LecturerRead.Read())
                {
                    string Title     = LecturerRead["Title"].ToString();
                    string FirstName = LecturerRead["FirstName"].ToString();
                    string LastName  = LecturerRead["LastName"].ToString();

                    cmdLecturer1MS.Items.Add(Title + " " + FirstName + " " + LastName);
                    cmdLecturer2MS.Items.Add(Title + " " + FirstName + " " + LastName);
                }
            }
            catch (Exception ex)
            {
            }
            finally
            {
                conn.Close();
            }
        }
コード例 #2
0
        void loadLecturer()
        {
            string     sql = "SELECT * FROM Lecturer_Table";
            SqlCommand cmd = new SqlCommand(sql, conn);

            SqlDataReader LecturerRead;

            try
            {
                conn.Open();
                LecturerRead = cmd.ExecuteReader();

                while (LecturerRead.Read())
                {
                    string Title = LecturerRead["Title"].ToString();
                    string FName = LecturerRead["FirstName"].ToString();
                    string LName = LecturerRead["LastName"].ToString();
                    lec_cmb.Items.Add(Title + " " + FName + " " + LName);
                }
            }
            catch (Exception)
            {
            }
            finally
            {
                conn.Close();
            }
        }
コード例 #3
0
        private void Location_Load(object sender, EventArgs e)
        {
            SqlConnection conn = new SqlConnection(con);  //Connect to DB
            string        sql  = "select * from tbl_location";
            SqlCommand    cmd  = new SqlCommand(sql, conn);


            SqlDataReader LecturerRead;

            try
            {
                conn.Open();
                LecturerRead = cmd.ExecuteReader();

                while (LecturerRead.Read())
                {
                    string FirstName = LecturerRead["BuildingName"].ToString();
                    string LastName  = LecturerRead["RoomName"].ToString();

                    cmdLecturer1.Items.Add(" " + FirstName + "  " + LastName);
                }
            }
            catch (Exception ex)
            {
            }
            finally
            {
                conn.Close();
            }

            dataGridView.Columns.Add("Column", "");
            dataGridView.Columns.Add("Column", "Monday");
            dataGridView.Columns.Add("Column", "Tuesday");
            dataGridView.Columns.Add("Column", "Wednesday");
            dataGridView.Columns.Add("Column", "Thursday");
            dataGridView.Columns.Add("Column", "Friday");
            dataGridView.Columns.Add("Column", "Saturday");
            dataGridView.Columns.Add("Column", "Sunday");
            dataGridView.Columns.Add("Column", "");

            dataGridView.Rows.Add("7.30 - 8.30");
            dataGridView.Rows.Add("8.30 - 9.30");
            dataGridView.Rows.Add("9.30 - 10.30");
            dataGridView.Rows.Add("10.30 - 11.30");
            dataGridView.Rows.Add("11.30 - 12.30");
            dataGridView.Rows.Add("12.30 - 13.30");
            dataGridView.Rows.Add("13.30 - 14.30");
            dataGridView.Rows.Add("14.30 - 15.30");
            dataGridView.Rows.Add("15.30 - 16.30");
            dataGridView.Rows.Add("16.30 - 17.30");
        }