Beispiel #1
0
        private void button4_Click(object sender, EventArgs e)
        {
            try
            {
                this.Hide();
                frmStudent objFrmStudent = new frmStudent(s_id, userName);
                objFrmStudent.Show();
            }
            catch (Exception ex)
            {
                MessageBox.Show("An error occurred but your application did not crash.  Please contact a system admin if this continues.");
                string filePath = @"C:\Users\Error.txt";

                using (StreamWriter writer = new StreamWriter(filePath, true))
                {
                    writer.WriteLine("-----------------------------------------------------------------------------");
                    writer.WriteLine("Date : " + DateTime.Now.ToString());
                    writer.WriteLine();

                    while (ex != null)
                    {
                        writer.WriteLine(ex.GetType().FullName);
                        writer.WriteLine("Message : " + ex.Message);
                        writer.WriteLine("StackTrace : " + ex.StackTrace);
                    }
                }
            }
        }
Beispiel #2
0
        private void FillData()
        {
            sqlConn.Open();

            SqlCommand     cmd  = new SqlCommand("select c_id_num from course.course_records where s_id_num = '" + s_id + "' and current_course = '" + 1 + "'", sqlConn);
            SqlDataAdapter sda  = new SqlDataAdapter(cmd);
            DataTable      dtbl = new DataTable();

            sda.Fill(dtbl);

            if (dtbl.Rows.Count == 0)
            {
                MessageBox.Show("You have not enrolled in any courses as of yet.");

                this.Hide();
                frmStudent objFrmStudent = new frmStudent(s_id, userName);
                objFrmStudent.Show();
            }
            else
            {
                for (int i = 0; i < dtbl.Rows.Count; i++)
                {
                    int        result = Convert.ToInt32(dtbl.Rows[i]["c_id_num"]);
                    SqlCommand cmd2   = new SqlCommand("select course_name from course.course_offerings where c_id_num = '" + result + "'", sqlConn);

                    string course = cmd2.ExecuteScalar().ToString();
                    listView1.Items.Add(course);
                }
            }
        }
Beispiel #3
0
        private void listView1_SelectedIndexChanged(object sender, EventArgs e)
        {
            int cId;
            int fId;

            if (this.listView1.SelectedItems.Count == 0)
            {
                return;
            }

            string selCourse1 = this.listView1.SelectedItems[0].Text;

            sqlConn.Open();

            SqlCommand     cmd5  = new SqlCommand("select c_id_num, f_id_num from course.course_offerings where course_name = '" + selCourse1 + "' ", sqlConn);
            SqlDataAdapter sda4  = new SqlDataAdapter(cmd5);
            DataTable      dtbl3 = new DataTable();

            sda4.Fill(dtbl3);

            SqlCommand     cmd6  = new SqlCommand("select current_course from course.course_records where current_course = '" + 1 + "' and s_id_num = '" + s_id + "'", sqlConn);
            SqlDataAdapter sda5  = new SqlDataAdapter(cmd6);
            DataTable      dtbl4 = new DataTable();

            sda5.Fill(dtbl4);

            if (dtbl4.Rows.Count > 2)
            {
                MessageBox.Show("You can only take 3 courses at one time.");
            }
            else
            {
                for (int i = 0; i < dtbl3.Rows.Count; i++)
                {
                    cId = Convert.ToInt32(dtbl3.Rows[i]["c_id_num"]);
                    fId = Convert.ToInt32(dtbl3.Rows[i]["f_id_num"]);

                    SqlCommand cmd7 = new SqlCommand("insert into course.course_records(c_id_num, f_id_num, s_id_num, student_grade, current_course, student_finished_course)" +
                                                     "values ('" + cId + "', '" + fId + "', '" + s_id + "', '" + "a" + "', '" + 1 + "', '" + 0 + "')", sqlConn);

                    cmd7.ExecuteScalar();
                }
            }

            sqlConn.Close();

            this.Hide();
            frmStudent objFrmStudent = new frmStudent(s_id, userName);

            objFrmStudent.Show();
        }
Beispiel #4
0
        private void btnLogin_Click_1(object sender, EventArgs e)
        {
            try
            {
                string userName = textUsername.Text;
                string passWord = textPassword.Text;

                SqlCommand     cmd  = new SqlCommand("select username,password from tbl_Login where username ='******'and password ='******'", sqlConn);
                SqlDataAdapter sda  = new SqlDataAdapter(cmd);
                DataTable      dtbl = new DataTable();
                sda.Fill(dtbl);

                if (dtbl.Rows.Count > 0)
                {
                    sqlConn.Open();

                    SqlCommand cmd2 = new SqlCommand("select login_type from tbl_Login where username ='******' and password ='******'", sqlConn);


                    // Get result
                    int result = ((int)cmd2.ExecuteScalar());

                    // Admin Dashboard
                    if (result == 1)
                    {
                        frmAdmin objFrmDash = new frmAdmin();
                        this.Hide();
                        objFrmDash.Show();
                    }
                    // Faculty Dashboard
                    else if (result == 2)
                    {
                        frmFaculty objFrmDash = new frmFaculty();
                        this.Hide();
                        objFrmDash.Show();
                    }
                    // Student Dashboard
                    else if (result == 3)
                    {
                        int s_id;

                        string uName = userName.Substring(userName.IndexOf('.') + 1);

                        SqlCommand cmd1 = new SqlCommand("select s_id_num from student.student_records where last_name like '%" + uName + "%'", sqlConn);

                        s_id = ((int)cmd1.ExecuteScalar());

                        frmStudent objFrmDash = new frmStudent(s_id, userName);
                        this.Hide();
                        objFrmDash.Show();
                    }
                }
                else
                {
                    MessageBox.Show("Check your username or password.");
                    textUsername.Clear();
                    textPassword.Clear();
                }
                sqlConn.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show("An error occurred but your application did not crash.  Please contact a system admin if this continues.");
                string filePath = @"C:\Users\Error.txt";

                using (StreamWriter writer = new StreamWriter(filePath, true))
                {
                    writer.WriteLine("-----------------------------------------------------------------------------");
                    writer.WriteLine("Date : " + DateTime.Now.ToString());
                    writer.WriteLine();

                    while (ex != null)
                    {
                        writer.WriteLine(ex.GetType().FullName);
                        writer.WriteLine("Message : " + ex.Message);
                        writer.WriteLine("StackTrace : " + ex.StackTrace);
                    }
                }
            }
        }