示例#1
0
        /// <summary>
        /// 返回查询的对象
        /// </summary>
        /// <returns></returns>
        public Modle showInfoSingle(string sql)
        {
            Modle model = new Modle();

            conn = new SqlConnection(strConnect);
            SqlCommand comd = new SqlCommand(sql, conn);

            try
            {
                conn.Open();
                SqlDataReader dr = comd.ExecuteReader();
                while (dr.Read())
                {
                    //管理员信息
                    if (sql.Substring(0, 15).Equals("select * from A"))
                    {
                        model.adminid   = dr["adminid"].ToString();
                        model.adminname = dr["adminname"].ToString();
                    }


                    //学生信息
                    if (sql.Substring(0, 15).Equals("select * from S"))
                    {
                        model.stuid      = dr["stuid"].ToString();
                        model.stuname    = dr["stuname"].ToString();
                        model.stuclass   = dr["stuclass"].ToString();
                        model.stuage     = dr["stuage"].ToString();
                        model.major      = dr["major"].ToString();
                        model.dapartment = dr["dapartment"].ToString();
                        model.note       = dr["note"].ToString();
                    }


                    //老师信息
                    if (sql.Substring(0, 15).Equals("select * from T"))
                    {
                        model.teacherid  = dr["teacherid"].ToString();
                        model.teaname    = dr["teaname"].ToString();
                        model.department = dr["department"].ToString();
                        model.teacherage = dr["teacherage"].ToString();
                        model.note       = dr["note"].ToString();
                    }
                    //公共信息
                    model.password = dr["password"].ToString();
                    // model.purviewid = dr["purviewid"].ToString();
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            finally
            {
                conn.Close();
            }

            return(model);
        }
示例#2
0
        /// <summary>
        /// 窗口加载事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public void Admin_Load(object sender, EventArgs e)
        {
            //主内容控件跟随窗口变大而变大事件
            AutoScale(this);


            this.DialogResult = DialogResult.OK;
            //一开始就把数据库的学生、老师、管理员表值添加到学生页面的DataGridView中
            Baind();



            //把当前管理员的基本信息显示出来
            Modle modle = dl.showInfoSingle(static_SQL_CRUD.AdminId());

            this.ID_txt.Text       = modle.adminid;
            this.Name_txt.Text     = modle.adminname;
            this.password_txt.Text = modle.password;
            this.UserType_txt.Text = "管理员";



            //显示当前课程管理的科目
            this.CourseChoose_cob.DataSource    = dl.ShowInfo(static_SQL_CRUD.AllInfoOfCourse).Tables["info"];
            this.CourseChoose_cob.DisplayMember = "coursename";
            this.CourseChoose_cob.ValueMember   = "courseid";


            //把文本框圆角化
            //this.TeacherSearchBar_txt.Region = Round(this.TeacherSearchBar_txt.Width, this.TeacherSearchBar_txt.Height, 20);
            //0this.StudentSearchBar_txt.Region = Round(this.StudentSearchBar_txt.Width, this.StudentSearchBar_txt.Height, 20);


            //创建考试时,要添加试题,一开始把所有题都显示再在这个dataview里面
            this.questions_dataView.DataSource = dl.ShowInfo(static_SQL_CRUD.AllInfoOfQuestionsBank).Tables["info"];

            //录题库时,要显示当前题库已存在的题
            this.questionsDisplay.DataSource = dl.ShowInfo(static_SQL_CRUD.AllInfoOfQuestionsBank).Tables["info"];



            //显示考试数据
            this.examDisplay_data.DataSource = dl.ShowInfo(static_SQL_CRUD.AllInfoOfExam).Tables["info"];

            if (this.examDisplay_data.RowCount > 0)
            {
                this.examDisplay_data.Visible  = true;
                this.isDisplayExam_txt.Visible = false;
            }
            else
            {
                this.examDisplay_data.Visible  = false;
                this.isDisplayExam_txt.Visible = true;
            }
        }
示例#3
0
        /// <summary>
        /// 加载事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void AddStudent_Load(object sender, EventArgs e)
        {
            //窗口圆角化
            this.Region = new Admin(null, null).Round(this.Width, this.Height, 20);



            //当修改页面显示时,在加载相应的信息 如果是添加信息时,该页面就不会加载信息
            if (this.AddStudent_pal.Visible && this.Updata_btn.Visible)
            {
                //修改页面加载学生的信息
                Modle model = dl.showInfoSingle(static_SQL_CRUD.StudentInfoSingle());

                //学生信息
                this.stuid_txt.Text           = model.stuid;
                this.stuname_txt.Text         = model.stuname;
                this.stuclass_txt.Text        = model.stuclass;
                this.stuage_txt.Text          = model.stuage;
                this.major_txt.Text           = model.major;
                this.dapartment_txt.Text      = model.dapartment;
                this.Studentpassword_txt.Text = model.password;
                this.StudentNote_txt.Text     = model.note;
            }
            if (this.AddTeacher_pal.Visible && this.Updata_btn.Visible)
            {
                //修改页面加载老师的信息
                Modle teacherInfo = dl.showInfoSingle(static_SQL_CRUD.TeacherInfoSingle());
                //老师信息
                this.teacherid_txt.Text       = teacherInfo.teacherid;
                this.teaname_txt.Text         = teacherInfo.teaname;
                this.teacherage_txt.Text      = teacherInfo.teacherage;
                this.department_txt.Text      = teacherInfo.department;
                this.teacherage_txt.Text      = teacherInfo.teacherage;
                this.Teacherpassword_txt.Text = teacherInfo.password;
                this.Teachernote_txt.Text     = teacherInfo.note;
            }
        }