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 #3
0
 public void end()
 {
     CP.closeConnection(conn);
 }