Exemplo n.º 1
0
 private void lvQuery_MouseDoubleClick(object sender, MouseEventArgs e)
 {
     if (currentSelectedItem != null)
     {
         string    sql = (currentSelectedItem as MyListViewItem).SQL;
         DataTable dt  = StaticSQLiteHelper.ExecuteQuery(sql);
         dataGridView1.DataSource = dt;
         //MessageBox.Show(sql);
     }
 }
Exemplo n.º 2
0
        private void loadSubjectList()
        {
            //_subjectList = new List<string>();
            string    sql = "select distinct(学科名字) as 学科 from class_course order by  学科";
            DataTable dt  = StaticSQLiteHelper.ExecuteQuery(sql);

            cbSubject.SelectedIndexChanged -= new EventHandler(cbSubject_SelectedIndexChanged);
            cbSubject.ValueMember           = "学科";
            cbSubject.DisplayMember         = "学科";
            cbSubject.DataSource            = dt;
            cbSubject.SelectedIndexChanged += new EventHandler(cbSubject_SelectedIndexChanged);
        }
Exemplo n.º 3
0
        private void loadHistory()
        {
            clbHistory.Items.Clear();
            DataTable dt = StaticSQLiteHelper.ExecuteQuery("select time,description from history order by id desc");

            foreach (DataRow r in dt.Rows)
            {
                clbHistory.Items.Add(r[1]);
            }
            if (clbHistory.Items.Count != 0)
            {
                clbHistory.SetItemChecked(0, true);
            }
        }
Exemplo n.º 4
0
        private void cbSubject_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (cbSubject.SelectedItem == null)
            {
                return;
            }

            sn = cbSubject.Text;
            string    sql = string.Format("select distinct(班级)+1 as 班级 from class_course where 学科名字='{0}' order by 班级;", sn);
            DataTable dt  = StaticSQLiteHelper.ExecuteQuery(sql);

            cbClass.SelectedIndexChanged -= new EventHandler(cbClass_SelectedIndexChanged);
            cbClass.BeginUpdate();
            cbClass.ValueMember   = "班级";
            cbClass.DisplayMember = "班级";
            cbClass.DataSource    = dt;
            cbClass.SelectedIndex = 0;
            cbClass.EndUpdate();
            cbClass.SelectedIndexChanged += new EventHandler(cbClass_SelectedIndexChanged);
        }
Exemplo n.º 5
0
        private void cbClass_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (cbSubject.SelectedItem == null)
            {
                return;
            }
            cn = Convert.ToInt32(cbClass.SelectedValue);
            ci = cn - 1;
            string sql = "select 教师姓名 from class_course where 班级=" + ci.ToString() + " and 学科名字='" + sn + "'";

            otn = StaticSQLiteHelper.ExecuteScalar(sql).ToString();
            sql = "select distinct(教师姓名) as 教师姓名 from teacher where 教师姓名<>'" + otn + "' and  学科名字='" + sn + "'";
            DataTable dt = StaticSQLiteHelper.ExecuteQuery(sql);

            cbTeacherName.BeginUpdate();
            cbTeacherName.ValueMember   = "教师姓名";
            cbTeacherName.DisplayMember = "教师姓名";
            cbTeacherName.DataSource    = dt;
            cbTeacherName.EndUpdate();
        }
Exemplo n.º 6
0
        public void ReportTeacherSchedule(string fileName)
        {
            string[] week = new string[7] {
                "星期一", "星期二", "星期三", "星期四", "星期五", "星期六", "星期天"
            };
            string[] subjects;
            using (DataTable dt = StaticSQLiteHelper.ExecuteQuery("select distinct(学科名字) from teacher;"))
            {
                subjects = new string[dt.Rows.Count];
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    subjects[i] = dt.Rows[i][0].ToString();
                }
            }
            DataTable   dts;
            int         ti, start_row, start_column;
            ExcelWriter ew = new ExcelWriter();

            for (int s = 0; s < subjects.Length; s++)
            {
                ew.CreateSheet(subjects[s]);
                dts = StaticSQLiteHelper.ExecuteQuery(string.Format("select 教师编号 from teacher where 学科名字='{0}' and  教师姓名 in (select 教师姓名 from class_course);", subjects[s]));
                for (int i = 0; i < dts.Rows.Count; i++)
                {
                    ti = Convert.ToInt32(dts.Rows[i][0]);
                    if (ti == 0)
                    {
                        continue;
                    }
                    ew.Write(i * (Global.LessonPerDay + Global.NightLessonPerDay + 3), 0, Global.GradeTeachers[ti].Name);
                    start_row    = i * (Global.LessonPerDay + Global.NightLessonPerDay + 3) + 1;
                    start_column = 0;
                    for (int w = 0; w < Global.DayPerWeek; w++)
                    {
                        ew.Write(start_row, w + 1, week[w]);
                    }

                    for (int sec = 1; sec <= Global.LessonPerDay + Global.NightLessonPerDay; sec++)
                    {
                        if (chbContainNight.Checked && sec > Global.LessonPerDay)
                        {
                            ew.Write(start_row + sec, 0, (sec - Global.LessonPerDay).ToString());
                        }
                        else
                        {
                            ew.Write(start_row + sec, 0, sec.ToString());
                        }
                    }

                    foreach (TeacherLesson tl in _schedule.TeacherSchedule[ti])
                    {
                        ew.Write(start_row + tl.Section + 1, start_column + tl.DayOfWeek + 1, tl.ClassNameListString);
                    }
                    //如果包含晚自习
                    if (chbContainNight.Checked && _nightSchedule.TeacherSchedule.ContainKey(ti))
                    {
                        foreach (TeacherLesson tl in _nightSchedule.TeacherSchedule[ti])
                        {
                            ew.Write(start_row + tl.Section + Global.LessonPerDay + 1, start_column + tl.DayOfWeek + 1, tl.ClassNameListString);
                        }
                    }
                }
            }
            ew.SaveAs(fileName);
        }