Пример #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                int    c_id   = Int32.Parse(textBox1.Text);
                int    f_id   = Int32.Parse(textBox2.Text);
                string cName  = textBox3.Text;
                string cDesc  = textBox4.Text;
                string cReq   = textBox5.Text;
                int    online = Int32.Parse(textBox6.Text);
                int    pcReq  = Int32.Parse(textBox8.Text);

                sqlConn.Open();

                SqlCommand cmd = new SqlCommand("insert into course.course_offerings(c_id_num, f_id_num, course_name, course_desc, course_requirements, online_available, pc_required)" +
                                                " values ('" + c_id + "','" + f_id + "','" + cName + "','" + cDesc + "','" + cReq + "','" + online + "','" + pcReq + "')", sqlConn);
                cmd.ExecuteScalar();

                sqlConn.Close();

                frmAdmin objFrmAdmin = new frmAdmin();
                this.Hide();
                objFrmAdmin.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);
                    }
                }
            }
        }
Пример #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                int    s_id  = Int32.Parse(textBox1.Text);
                string age   = textBox2.Text;
                string fName = textBox3.Text;
                string lName = textBox4.Text;
                string addr  = textBox5.Text;
                string year  = textBox6.Text;

                sqlConn.Open();

                SqlCommand cmd = new SqlCommand("insert into student.student_records(s_id_num, age, first_name, last_name, addr, school_year)" +
                                                " values ('" + s_id + "','" + age + "','" + fName + "','" + lName + "','" + addr + "','" + year + "')", sqlConn);
                cmd.ExecuteScalar();

                sqlConn.Close();

                frmAdmin objFrmAdmin = new frmAdmin();
                this.Hide();
                objFrmAdmin.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);
                    }
                }
            }
        }
Пример #3
0
        private void button2_Click(object sender, EventArgs e)
        {
            try
            {
                int c_id_del = Int32.Parse(textBox7.Text);
                sqlConn.Open();

                SqlCommand cmd2 = new SqlCommand("delete from course.course_offerings where c_id_num ='" + c_id_del + "'", sqlConn);
                cmd2.ExecuteScalar();

                sqlConn.Close();

                frmAdmin objFrmAdmin = new frmAdmin();
                this.Hide();
                objFrmAdmin.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);
                    }
                }
            }
        }
Пример #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);
                    }
                }
            }
        }