public teacher_check(ConnectionPool CP, teacher teacherDemo)
        {
            InitializeComponent();
            pictureBox7.Hide();
            label3.Hide();
            this.CP          = CP;
            this.teacherDemo = teacherDemo;
            string sql = $"select * from tb_apply where tutor_ID={teacherDemo.getTeacher_ID()} " +
                         $"or instructor_ID={teacherDemo.getTeacher_ID()}";
            selecter        selecterDemo = new selecter(CP, sql);
            apply           applyDemo;
            MySqlDataReader reader = selecterDemo.execute();

            while (reader.Read())
            {
                applyDemo = new apply();
                applyDemo.setApply_ID(reader.GetInt32("apply_ID"));
                applyDemo.setStu_ID(reader.GetInt32("stu_ID"));
                applyDemo.setTutor_ID(reader.GetInt32("tutor_ID"));
                applyDemo.setInstructor_ID(reader.GetInt32("instructor_ID"));
                applyDemo.setApply_time(reader.GetDateTime("apply_time"));
                applyDemo.setApply_start(reader.GetDateTime("apply_start"));
                applyDemo.setApply_end(reader.GetDateTime("apply_end"));
                applyDemo.setApply_reason(reader.GetString("apply_reason"));
                applyDemo.setCheck_tutor(reader.GetInt32("check_tutor"));
                applyDemo.setCheck_instructor(reader.GetInt32("check_instructor"));
                if (teacherDemo.getTeacher_pos() == 1)
                {
                    if (applyDemo.getCheck_tutor() == 0 && applyDemo.getTutor_ID() == teacherDemo.getTeacher_ID())
                    {
                        applyList.Add(applyDemo);
                    }
                }
                else
                {
                    if (applyDemo.getCheck_instructor() == 0 && applyDemo.getCheck_tutor() == 1 && applyDemo.getInstructor_ID() == teacherDemo.getTeacher_ID())
                    {
                        applyList.Add(applyDemo);
                    }
                }
            }
            selecterDemo.end();
            sql_student     ss = new sql_student(CP);
            DataGridViewRow dr = new DataGridViewRow();

            foreach (apply ap in applyList)
            {
                int index = dataGridView1.Rows.Add();
                dataGridView1.Rows[index].Cells[0].Value = ss.getNumByID(ap.getStu_ID());
                dataGridView1.Rows[index].Cells[1].Value = ss.getNameByID(ap.getStu_ID());
                dataGridView1.Rows[index].Cells[2].Value = ap.getApply_start();
                dataGridView1.Rows[index].Cells[3].Value = ap.getApply_end();
                dataGridView1.Rows[index].Cells[4].Value = ap.getApply_reason();
                dataGridView1.Rows[index].Cells[5].Value = ap.getApply_time();
            }
        }
Exemplo n.º 2
0
        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);
        }