Example #1
0
        public MySqlDataReader execute()
        {
            conn = CP.getConnection();
            MySqlCommand    cmd    = new MySqlCommand(sql, conn);
            MySqlDataReader reader = cmd.ExecuteReader();

            return(reader);
        }
        public int insert(apply applyDemo)
        {
            MySqlConnection conn = CP.getConnection();
            string          sql;

            sql = "insert into tb_apply(stu_ID,tutor_ID,instructor_ID,apply_time,apply_start,apply_end," +
                  "apply_reason,check_tutor,check_instructor,apply_editTime) values" +
                  $"({applyDemo.getStu_ID()},{applyDemo.getTutor_ID()},{applyDemo.getInstructor_ID()}," +
                  $"'{applyDemo.getApply_time()}','{applyDemo.getApply_start()}','{applyDemo.getApply_end()}'," +
                  $"'{applyDemo.getApply_reason()}',{applyDemo.getCheck_tutor()},{applyDemo.getCheck_instructor()}," +
                  $"'{applyDemo.getApply_editTime()}')";
            MySqlCommand cmd = new MySqlCommand(sql, conn);
            int          j   = cmd.ExecuteNonQuery();

            CP.closeConnection(CP.getConnection());
            return(j);
        }
        public login()
        {
            connecter connecter = new connecter();

            conn = CP.getConnection();
            InitializeComponent();
            label3.Hide();
            pictureBox7.Hide();
            label2.Hide();
            pictureBox8.Hide();
            label4.Hide();
            pictureBox9.Hide();
        }
        int getID(teacher teacherDemo)
        {
            MySqlConnection conn   = CP.getConnection();
            string          sql    = $"select * from tb_teacher where teacher_num = '{teacherDemo.getTeacher_num()}'";
            MySqlCommand    cmd    = new MySqlCommand(sql, conn);
            MySqlDataReader reader = cmd.ExecuteReader();

            reader.Read();
            int j = reader.GetInt32("teacher_ID");

            reader.Dispose();
            CP.closeConnection(conn);
            teacherDemo.setTeacher_ID(j);
            return(j);
        }
        public int insert(student stu)
        {
            MySqlConnection conn = CP.getConnection();
            string          sql  = $"insert into tb_student(clazz_ID,stu_num,stu_name,stu_sex,stu_tel,stu_password,stu_addTime,stu_editTime) " +
                                   $"values ({stu.getClazz_ID()},'{stu.getStu_num()}','{stu.getStu_name()}',{stu.getStu_sex()},'{stu.getStu_tel()}','{stu.getStu_password()}','{stu.getStu_addTime().ToString()}','{stu.getStu_editTime().ToString()}')";
            MySqlCommand cmd = new MySqlCommand(sql, conn);
            int          j   = cmd.ExecuteNonQuery();

            CP.closeConnection(conn);
            return(j);
        }
Example #6
0
        public MySqlConnection connection()
        {
            MySqlConnection conn = CP.getConnection();

            try
            {
                conn.Open();
                MessageBox.Show("连接成功!", "系统连接提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
            }
            catch (MySqlException ex)
            {
                Console.WriteLine(ex.Message);
                MessageBox.Show("连接失败,无法继续操作,系统关闭!", "系统连接提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                Environment.Exit(0);
            }
            finally
            {
                conn.Close();
            }
            return(conn);
        }