コード例 #1
0
        private void updatestudent_Load(object sender, EventArgs e)
        {
            MySqlConnection con = Database.dbConnect.Initialize();

            Database.info il = new Database.info();
            il.datagridview_load("SELECT class_roll as 'Class Roll', exam_roll as 'Exam Roll', name as 'Name', session as 'Session', gender as 'Gender', hall as 'Hall', email as 'Email', phone as 'Phone' FROM student", stuDGV);
            con.Open();
            string          Sql = "select * from session";
            MySqlCommand    cmd = new MySqlCommand(Sql, con);
            MySqlDataReader dr  = cmd.ExecuteReader();

            while (dr.Read())
            {
                sessionCB.Items.Add(dr[0]);
                session2CB.Items.Add(dr[0]);
            }
        }
コード例 #2
0
        private void courseinfo_Load(object sender, EventArgs e)
        {
            MySqlConnection con = Database.dbConnect.Initialize();

            Database.info il = new Database.info();
            il.datagridview_load("SELECT course_code as 'Course Code', course_title as 'Course Title', course_credit as 'Course Credit', course as 'Course Type', session as 'Session', year as 'Year', semester as 'semester' FROM course", courseDGV);
            con.Open();
            string          Sql = "select session from session";
            MySqlCommand    cmd = new MySqlCommand(Sql, con);
            MySqlDataReader dr  = cmd.ExecuteReader();

            while (dr.Read())
            {
                sessionCB.Items.Add(dr[0]);
                session2CB.Items.Add(dr[0]);
            }
        }
コード例 #3
0
        private void updateB_Click(object sender, EventArgs e)
        {
            String classroll = crTB.Text;
            String examroll  = erTB.Text;
            String name      = nameTB.Text;
            String ses       = sessionCB.Text;
            String gender    = genderCB.Text;

            MySqlConnection con = Database.dbConnect.Initialize();

            con.Open();
            String sql = "";

            sql = "UPDATE student SET class_roll='" + classroll + "', exam_roll='" + examroll + "', name='" + name + "', session='" + ses + "', gender='" + gender + "', hall = '" + hallTB.Text + "', email = '" + mailTB.Text + "', phone = '" + phoneTB.Text + "' WHERE `class_roll`='" + classroll + "' and session = '" + ses + "'";
            MySqlCommand cmd = new MySqlCommand(sql, con);

            try
            {
                DialogResult d = MessageBox.Show("Are you sure to update data?", "Confirm", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (d == DialogResult.Yes)
                {
                    MySqlCommand comd = new MySqlCommand(sql, con);
                    comd.ExecuteNonQuery();
                    MessageBox.Show("Successfully data updated.", "Success");
                }
                con.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error Message:" + ex.Message);
                con.Close();
            }
            Database.info il = new Database.info();
            il.datagridview_load("SELECT class_roll as 'Class Roll', exam_roll as 'Exam Roll', name as 'Name', session as 'Session', gender as 'Gender', hall as 'Hall', email as 'Email', phone as 'Phone' FROM student", stuDGV);
            crTB.Text      = "";
            erTB.Text      = "";
            nameTB.Text    = "";
            sessionCB.Text = "";
            genderCB.Text  = "";
            hallTB.Text    = "";
            mailTB.Text    = "";
            phoneTB.Text   = "";
        }
コード例 #4
0
        private void deleteB_Click(object sender, EventArgs e)
        {
            String          ccode           = ccodeTB.Text;
            String          ctitle          = ctitleTB.Text;
            String          ccredit         = ccreditCB.Text;
            String          c               = cTB.Text;
            String          session         = sessionCB.Text;
            String          sem             = yearCB.Text;
            String          search_code_str = searchccodeTB.Text;
            MySqlConnection con             = Database.dbConnect.Initialize();

            con.Open();
            String sql = "";

            sql = "delete from course WHERE `course_code`='" + ccode + "' and session = '" + session + "'";;
            MySqlCommand cmd = new MySqlCommand(sql, con);

            try
            {
                DialogResult d = MessageBox.Show("Are you sure to delete data?", "Confirm", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (d == DialogResult.Yes)
                {
                    MySqlCommand comd = new MySqlCommand(sql, con);
                    comd.ExecuteNonQuery();
                    MessageBox.Show("Successfully data deleted.", "Success");
                }
                con.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error Message:" + ex.Message);
                con.Close();
            }
            Database.info il = new Database.info();
            il.datagridview_load("SELECT course_code as 'Course Code', course_title as 'Course Title', course_credit as 'Course Credit', course as 'Course Type', session as 'Session', year as 'Year', semester as 'Semester' FROM course", courseDGV);
            ccodeTB.Text   = "";
            ctitleTB.Text  = "";
            ccreditCB.Text = "";
            cTB.Text       = "";
            sessionCB.Text = "";
            yearCB.Text    = "";
            semCB.Text     = "";
        }
コード例 #5
0
        private void addB_Click(object sender, EventArgs e)
        {
            MySqlConnection con = Database.dbConnect.Initialize();

            if (crTB.Text == "" || erTB.Text == "" || nameTB.Text == "" || sessionCB.Text == "" || genderCB.Text == "" || hallTB.Text == "" || mailTB.Text == "" || phoneTB.Text == "")
            {
                MessageBox.Show("Empty field is not allow. Please try again.");
                return;
            }
            con.Open();
            this.testDatabaseExists();
            String sql = "INSERT into student (class_roll, exam_roll, name, session, gender, hall, email, phone) values('" + crTB.Text + "','" + erTB.Text + "','" + nameTB.Text + "','" + sessionCB.Text + "','" + genderCB.Text + "', '" + hallTB.Text + "', '" + mailTB.Text + "', '" + phoneTB.Text + "')";

            try
            {
                DialogResult d = MessageBox.Show("Are you sure to insert data?", "Confirm", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (d == DialogResult.Yes)
                {
                    MySqlCommand cmd = new MySqlCommand(sql, con);
                    cmd.ExecuteNonQuery();
                }
                con.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error Message:" + ex.Message);
                con.Close();
            }


            Database.info il = new Database.info();
            il.datagridview_load("SELECT class_roll as 'Class Roll', exam_roll as 'Exam Roll', name as 'Name', session as 'Session', gender as 'Gender' FROM student, hall as 'Hall', email as 'Email', phone as 'Phone' from student", stuDGV);
            crTB.Text      = "";
            erTB.Text      = "";
            nameTB.Text    = "";
            sessionCB.Text = "";
            genderCB.Text  = "";
            hallTB.Text    = "";
            mailTB.Text    = "";
            phoneTB.Text   = "";
        }
コード例 #6
0
        private void addB_Click(object sender, EventArgs e)
        {
            MySqlConnection con = Database.dbConnect.Initialize();

            if (ccodeTB.Text == "" || ctitleTB.Text == "" || ccreditCB.Text == "" || cTB.Text == "" || sessionCB.Text == "" || yearCB.Text == "" || semCB.Text == "")
            {
                MessageBox.Show("Empty field is not allow,Please try again.");
                return;
            }
            con.Open();
            this.testDatabaseExists();
            String sql = "insert into course (course_code, course_title, course_credit, course, session, year, semester) values('" + ccodeTB.Text + "','" + ctitleTB.Text + "','" + ccreditCB.Text + "', '" + cTB.Text + "','" + sessionCB.Text + "','" + yearCB.Text + "', '" + semCB.Text + "')";

            try
            {
                DialogResult d = MessageBox.Show("Are you sure to insert data?", "Confirm", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (d == DialogResult.Yes)
                {
                    MySqlCommand cmd = new MySqlCommand(sql, con);
                    cmd.ExecuteNonQuery();
                    MessageBox.Show("Successfully data inserted.", "Success");
                }
                con.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error Message:" + ex.Message);
                con.Close();
            }
            Database.info il = new Database.info();
            il.datagridview_load("SELECT course_code as 'Course Code', course_title as 'Course Title', course_credit as 'Course Credit', course as 'Course Type', session as 'Session', year as 'Year', semester as 'Semester' FROM course", courseDGV);
            ccodeTB.Text   = "";
            ctitleTB.Text  = "";
            ccreditCB.Text = "";
            cTB.Text       = "";
            sessionCB.Text = "";
            yearCB.Text    = "";
            semCB.Text     = "";
        }