Esempio n. 1
0
        private void cmdSelect_Click(object sender, EventArgs e)
        {
            string cmdString = "SELECT faculty_id, faculty_name, office, phone, college, title, email FROM Faculty ";

            cmdString += "WHERE faculty_name LIKE @name";
            SqlDataAdapter FacultyDataAdapter = new SqlDataAdapter();
            SqlCommand     sqlCommand         = new SqlCommand();
            SqlDataReader  sqlDataReader;
            DataTable      sqlDataTable = new DataTable();
            LogInForm      logForm      = new LogInForm();

            logForm = logForm.getLogInForm();

            sqlCommand.Connection  = logForm.sqlConnection;
            sqlCommand.CommandType = CommandType.Text;
            sqlCommand.CommandText = cmdString;
            sqlCommand.Parameters.Add("@name", SqlDbType.Char).Value = ComboName.Text;
            string strName = ShowFaculty(ComboName.Text);

            if (strName == "No Match")
            {
                MessageBox.Show("No Matched Faculty Image found!");
            }

            if (ComboMethod.Text == "DataAdapter Method")
            {
                FacultyDataAdapter.SelectCommand = sqlCommand;
                FacultyDataAdapter.Fill(sqlDataTable);
                if (sqlDataTable.Rows.Count > 0)
                {
                    FillFacultyTable(ref sqlDataTable);
                }
                else
                {
                    MessageBox.Show("No matched faculty found!");
                }
                sqlDataTable.Dispose();
                FacultyDataAdapter.Dispose();
            }
            else if (ComboMethod.Text == "DataReader Method")
            {
                sqlDataReader = sqlCommand.ExecuteReader();
                if (sqlDataReader.HasRows == true)
                {
                    FillFacultyReader(sqlDataReader);
                }
                else
                {
                    MessageBox.Show("No matched faculty found!");
                }
                sqlDataReader.Close();
            }
            else
            {
                MessageBox.Show("Invalid Method Selected!");
            }
        }
Esempio n. 2
0
        private void BuildCommand(ref SqlCommand cmdObj, string cmdString)
        {
            LogInForm logForm = new LogInForm();
            logForm = logForm.getLogInForm();

            cmdObj.Connection = logForm.sqlConnection;
            cmdObj.CommandType = CommandType.StoredProcedure;
            cmdObj.CommandText = cmdString;
        }
Esempio n. 3
0
        private void BuildCommand(ref SqlCommand cmdObj, string cmdString)
        {
            LogInForm logForm = new LogInForm();

            logForm = logForm.getLogInForm();

            cmdObj.Connection  = logForm.sqlConnection;
            cmdObj.CommandType = CommandType.StoredProcedure;
            cmdObj.CommandText = cmdString;
        }
Esempio n. 4
0
        private void cmdSelect_Click(object sender, EventArgs e)
        {
            string strCourse = "SELECT Course.course_id, Course.course FROM Course JOIN Faculty ";

            strCourse += "ON (Course.faculty_id LIKE Faculty.faculty_id) AND (Faculty.faculty_name LIKE @name)";
            SqlDataAdapter CourseDataAdapter = new SqlDataAdapter();
            SqlCommand     sqlCmdCourse      = new SqlCommand();
            DataTable      sqlCourseTable    = new DataTable();
            LogInForm      logForm           = new LogInForm();

            logForm = logForm.getLogInForm();
            SqlDataReader sqlDataReader;

            sqlCmdCourse.Connection  = logForm.sqlConnection;
            sqlCmdCourse.CommandType = CommandType.Text;
            sqlCmdCourse.CommandText = strCourse;
            sqlCmdCourse.Parameters.Add("@name", SqlDbType.Char).Value = ComboName.Text;
            if (ComboMethod.Text == "DataAdapter Method")
            {
                CourseDataAdapter.SelectCommand = sqlCmdCourse;
                CourseDataAdapter.Fill(sqlCourseTable);
                if (sqlCourseTable.Rows.Count > 0)
                {
                    FillCourseTable(sqlCourseTable);
                }
                else
                {
                    MessageBox.Show("No matched course found!");
                }
                sqlCourseTable.Dispose();
                CourseDataAdapter.Dispose();
            }
            else if (ComboMethod.Text == "DataReader Method")
            {
                sqlDataReader = sqlCmdCourse.ExecuteReader();
                if (sqlDataReader.HasRows == true)
                {
                    FillCourseReader(sqlDataReader);
                }
                else
                {
                    MessageBox.Show("No matched course found!");
                }
                sqlDataReader.Close();
                sqlDataReader.Dispose();
            }
            else     //Invalid Method is selected
            {
                MessageBox.Show("Invalid Method Selected!");
            }
            sqlCmdCourse.Dispose();
            CourseList.SelectedIndex = 0;
        }
Esempio n. 5
0
        private void CourseList_SelectedIndexChanged(object sender, EventArgs e)
        {
            string cmdString = "SELECT course, credit, classroom, schedule, enrollment, course_id FROM Course ";

            cmdString += "WHERE course_id LIKE @courseid";
            SqlDataAdapter CourseDataAdapter = new SqlDataAdapter();
            SqlCommand     sqlCommand        = new SqlCommand();
            DataTable      sqlDataTable      = new DataTable();
            SqlDataReader  sqlDataReader;
            LogInForm      logForm = new LogInForm();

            logForm = logForm.getLogInForm();

            sqlCommand.Connection  = logForm.sqlConnection;
            sqlCommand.CommandType = CommandType.Text;
            sqlCommand.CommandText = cmdString;
            sqlCommand.Parameters.Add("@courseid", SqlDbType.Char).Value = CourseList.SelectedItem;

            if (ComboMethod.Text == "DataAdapter Method")
            {
                CourseDataAdapter.SelectCommand = sqlCommand;
                CourseDataAdapter.Fill(sqlDataTable);
                if (sqlDataTable.Rows.Count > 0)
                {
                    FillCourseTextBox(sqlDataTable);
                }
                else
                {
                    MessageBox.Show("No matched course information found!");
                }
                sqlDataTable.Dispose();
                CourseDataAdapter.Dispose();
            }
            else if (ComboMethod.Text == "DataReader Method")
            {
                sqlDataReader = sqlCommand.ExecuteReader();
                if (sqlDataReader.HasRows == true)
                {
                    FillCourseReaderTextBox(sqlDataReader);
                }
                else
                {
                    MessageBox.Show("No matched course information found!");
                }
                sqlDataReader.Close();
                sqlDataReader.Dispose();
            }
            else      //Invalid Method is selected
            {
                MessageBox.Show("Invalid Method Selected!");
            }
            sqlCommand.Dispose();
        }
Esempio n. 6
0
 private void cmdExit_Click(object sender, EventArgs e)
 {
     LogInForm logForm = new LogInForm();
     logForm = logForm.getLogInForm();
     if (logForm.sqlConnection.State == ConnectionState.Open)
         logForm.sqlConnection.Close();
     logForm.Close();
     courseForm.Close();
     facultyForm.Close();
     studentForm.Close();
     spForm.Close();
     Application.Exit();
 }
Esempio n. 7
0
        private void cmdExit_Click(object sender, EventArgs e)
        {
            LogInForm logForm = new LogInForm();

            logForm = logForm.getLogInForm();
            if (logForm.sqlConnection.State == ConnectionState.Open)
            {
                logForm.sqlConnection.Close();
            }
            logForm.Close();
            courseForm.Close();
            facultyForm.Close();
            studentForm.Close();
            spForm.Close();
            Application.Exit();
        }
        private void cmdSelect_Click(object sender, EventArgs e)
        {
            string cmdString = "SELECT faculty_id, faculty_name, office, phone, college, title, email FROM Faculty ";
            cmdString += "WHERE faculty_name LIKE @name";
            SqlDataAdapter FacultyDataAdapter= new SqlDataAdapter();
            SqlCommand sqlCommand = new SqlCommand();
            SqlDataReader sqlDataReader;
            DataTable sqlDataTable = new DataTable();
            LogInForm logForm = new LogInForm();
            logForm = logForm.getLogInForm();

            sqlCommand.Connection = logForm.sqlConnection;
            sqlCommand.CommandType = CommandType.Text;
            sqlCommand.CommandText = cmdString;
            sqlCommand.Parameters.Add("@name", SqlDbType.Char).Value = ComboName.Text;
            string strName = ShowFaculty(ComboName.Text);
            if (strName == "No Match")
                MessageBox.Show("No Matched Faculty Image found!");

            if (ComboMethod.Text == "DataAdapter Method")
            {
                FacultyDataAdapter.SelectCommand = sqlCommand;
                FacultyDataAdapter.Fill(sqlDataTable);
                if (sqlDataTable.Rows.Count > 0)
                    FillFacultyTable(ref sqlDataTable);
                else
                    MessageBox.Show("No matched faculty found!");
                sqlDataTable.Dispose();
                FacultyDataAdapter.Dispose();
            }
            else if (ComboMethod.Text == "DataReader Method")
            {
                sqlDataReader = sqlCommand.ExecuteReader();
                if (sqlDataReader.HasRows == true)
                    FillFacultyReader(sqlDataReader);
                else
                    MessageBox.Show("No matched faculty found!");
                sqlDataReader.Close();
            }
            else
                MessageBox.Show("Invalid Method Selected!");
        }
        private void cmdSelect_Click(object sender, EventArgs e)
        {
            string strCourse = "SELECT Course.course_id, Course.course FROM Course JOIN Faculty ";
            strCourse += "ON (Course.faculty_id LIKE Faculty.faculty_id) AND (Faculty.faculty_name LIKE @name)";
            SqlDataAdapter CourseDataAdapter = new SqlDataAdapter();
            SqlCommand sqlCmdCourse = new SqlCommand();
            DataTable sqlCourseTable = new DataTable();
            LogInForm logForm = new LogInForm();
            logForm = logForm.getLogInForm();
            SqlDataReader sqlDataReader;

            sqlCmdCourse.Connection = logForm.sqlConnection;
            sqlCmdCourse.CommandType = CommandType.Text;
            sqlCmdCourse.CommandText = strCourse;
            sqlCmdCourse.Parameters.Add("@name", SqlDbType.Char).Value = ComboName.Text;
            if (ComboMethod.Text == "DataAdapter Method")
            {
                CourseDataAdapter.SelectCommand = sqlCmdCourse;
                CourseDataAdapter.Fill(sqlCourseTable);
                if (sqlCourseTable.Rows.Count > 0)
                    FillCourseTable(sqlCourseTable);
                else
                    MessageBox.Show("No matched course found!");
                sqlCourseTable.Dispose();
                CourseDataAdapter.Dispose();
            }
            else if (ComboMethod.Text == "DataReader Method")
            {
                sqlDataReader = sqlCmdCourse.ExecuteReader();
                if (sqlDataReader.HasRows == true)
                    FillCourseReader(sqlDataReader);
                else
                    MessageBox.Show("No matched course found!");
                sqlDataReader.Close();
                sqlDataReader.Dispose();
            }
            else     //Invalid Method is selected
                MessageBox.Show("Invalid Method Selected!");
            sqlCmdCourse.Dispose();
            CourseList.SelectedIndex = 0;
        }
Esempio n. 10
0
        private void CourseList_SelectedIndexChanged(object sender, EventArgs e)
        {
            string cmdString = "SELECT course, credit, classroom, schedule, enrollment, course_id FROM Course ";
            cmdString += "WHERE course_id LIKE @courseid";
            SqlDataAdapter CourseDataAdapter = new SqlDataAdapter();
            SqlCommand sqlCommand = new SqlCommand();
            DataTable sqlDataTable = new DataTable();
            SqlDataReader sqlDataReader;
            LogInForm logForm = new LogInForm();
            logForm = logForm.getLogInForm();

            sqlCommand.Connection = logForm.sqlConnection;
            sqlCommand.CommandType = CommandType.Text;
            sqlCommand.CommandText = cmdString;
            sqlCommand.Parameters.Add("@courseid", SqlDbType.Char).Value = CourseList.SelectedItem;

            if (ComboMethod.Text == "DataAdapter Method")
            {
                CourseDataAdapter.SelectCommand = sqlCommand;
                CourseDataAdapter.Fill(sqlDataTable);
                if (sqlDataTable.Rows.Count > 0)
                    FillCourseTextBox(sqlDataTable);
                else
                    MessageBox.Show("No matched course information found!");
                sqlDataTable.Dispose();
                CourseDataAdapter.Dispose();
            }
            else if (ComboMethod.Text == "DataReader Method")
            {
                sqlDataReader = sqlCommand.ExecuteReader();
                if (sqlDataReader.HasRows == true)
                    FillCourseReaderTextBox(sqlDataReader);
                else
                    MessageBox.Show("No matched course information found!");
                sqlDataReader.Close();
                sqlDataReader.Dispose();
            }
            else      //Invalid Method is selected
                MessageBox.Show("Invalid Method Selected!");
            sqlCommand.Dispose();
        }