/// <summary>
        /// 通过课程查看考试安排
        /// </summary>
        /// <param name="courseNo">课程编号</param>
        /// <returns>课程安排数据集</returns>
        public ExamArrangeList GetExamArrangeByCourseNo(string courseNo)
        {
            ExamArrangeList examArrangeList = null;
            string cmdstring = "SELECT [examArrangeListId],[courseName],[examArrangeTime] ,[examArrageAddress],[remark] ,[teacherName] ,[courseNo]  FROM [USTA].[dbo].[usta_ExamArrangeList] WHERE courseNo=@courseNo";
            SqlParameter[] parameters = new SqlParameter[1]{
               new SqlParameter("@courseNo",courseNo)
            };
            SqlDataReader dr = SqlHelper.ExecuteReader(conn, CommandType.Text, cmdstring, parameters);
            if (dr.Read())
                examArrangeList = new ExamArrangeList
                {
                    examArrangeListId = int.Parse(dr["examArrangeListId"].ToString()),
                    courseName = dr["courseName"].ToString().Trim(),
                    examArrangeTime = Convert.ToDateTime(dr["examArrangeTime"].ToString()),
                    examArrageAddress = dr["examArrageAddress"].ToString(),
                    remark = dr["remark"].ToString().Trim(),
                    teacherName = dr["teacherName"].ToString().Trim(),
                    courseNo = dr["courseNo"].ToString().Trim()

                };
            dr.Close();
            conn.Close();
            return examArrangeList;
        }
Esempio n. 2
0
        /// <summary> 
        ///将Excel表的信息数据保存到数据库
        /// </summary>
        /// <param name="dt">文件名称</param> 
        /// <param name="tableType">表类型</param> 
        /// <returns>删除是否成功</returns> 
        public int DataTabletoDBTables(DataTable dt,string tableType)
        {
            if (tableType.Equals("学生信息"))
            {
                    if (dt.Rows.Count > 0)
                    {
                        for (int i = 0; i < dt.Rows.Count; i++)
                            {
                                StudentsList student = new StudentsList();
                                student.studentNo = dt.Rows[i][1].ToString().Trim();
                                student.studentName = dt.Rows[i][2].ToString().Trim();
                                student.studentSpeciality = dt.Rows[i][3].ToString().Trim();
                                student.classNo = dt.Rows[i][4].ToString().Trim();
                                student.mobileNo = dt.Rows[i][5].ToString().Trim();
                                student.emailAddress = dt.Rows[i][6].ToString().Trim();
                                student.remark = dt.Rows[i][7].ToString().Trim();
                                student.studentUserPwd = student.studentNo;//密码默认与学号相同
                                this.AddStudent(student);
                            }
                       return dt.Rows.Count;
                    }
            }
            else if (tableType.Equals("教师信息"))
            {
                if (dt.Rows.Count > 0)
                {
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        TeachersList teacher = new TeachersList();
                        teacher.teacherNo = dt.Rows[i][1].ToString().Trim();
                        teacher.teacherName = dt.Rows[i][2].ToString().Trim();
                        teacher.emailAddress = dt.Rows[i][3].ToString().Trim();
                        teacher.officeAddress = dt.Rows[i][4].ToString().Trim();
                        teacher.remark = dt.Rows[i][5].ToString().Trim();
                        teacher.teacherUserPwd = teacher.teacherNo;//密码默认与教师编号相同
                        this.AddTeacher(teacher);
                    }
                    return dt.Rows.Count;
                }
            }
            else if (tableType.Equals("助教信息"))
            {
                if (dt.Rows.Count > 0)
                {
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        AssistantsList assistant = new AssistantsList();
                        assistant.assistantNo = dt.Rows[i][1].ToString().Trim();
                        assistant.assistantName = dt.Rows[i][2].ToString().Trim();
                        assistant.emailAddress = dt.Rows[i][3].ToString().Trim();
                        assistant.officeAddress = dt.Rows[i][4].ToString().Trim();
                        assistant.remark = dt.Rows[i][5].ToString().Trim();
                        assistant.assistantUserPwd = assistant.assistantNo;//密码默认与助教编号相同
                        this.AddAssistant(assistant);
                    }
                    return dt.Rows.Count;
                }
            }
            else if (tableType.Equals("课程信息"))
            {
                if (dt.Rows.Count > 0)
                {
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        Courses course = new Courses();
                        course.courseNo = dt.Rows[i][1].ToString().Trim();
                        course.courseName= dt.Rows[i][2].ToString().Trim();
                        course.period =dt.Rows[i][3].ToString().Trim();
                        course.credit=float.Parse( dt.Rows[i][4].ToString().Trim());
                        course.courseSpeciality= dt.Rows[i][5].ToString();

                        course.termTag =dt.Rows[i][6].ToString().Trim();//学期标识
                        new DalOperationAboutCourses().AddCourse(course);
                    }
                    return dt.Rows.Count;
                }
            }
            else if (tableType.Equals("考试安排"))
            {
                if (dt.Rows.Count > 0)
                {
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        ExamArrangeList examTime = new ExamArrangeList();
                        examTime.courseName= dt.Rows[i][1].ToString().Trim();
                        examTime.examArrangeTime =DateTime.Parse(dt.Rows[i][2].ToString().Trim());
                        examTime.examArrageAddress = dt.Rows[i][3].ToString().Trim();
                        examTime.remark =dt.Rows[i][4].ToString().Trim();
                        examTime.teacherName = dt.Rows[i][5].ToString();
                        examTime.courseNo= dt.Rows[i][6].ToString().Trim();
                        this.AddExamArrange(examTime);
                    }
                    return dt.Rows.Count;
                }
            }
            return 0;
        }
Esempio n. 3
0
 //----------------------------------------
 /// <summary>
 /// 增加考试安排信息
 /// </summary>
 /// <param name="examTime">考试安排信息</param>
 public void AddExamArrange(ExamArrangeList examTime)
 {
     try
     {
         string sql = "INSERT INTO usta_ExamArrangeList VALUES(@courseName,@examArrangeTime,@examArrageAddress,@remark, @teacherName,@courseNo)";
         SqlParameter[] parameters = {
             new SqlParameter("@courseName", SqlDbType.NChar,50),
             new SqlParameter("@examArrangeTime", SqlDbType.DateTime),
             new SqlParameter("@examArrageAddress", SqlDbType.NChar,50),
             new SqlParameter("@remark", SqlDbType.NVarChar,500),
             new SqlParameter("@teacherName", SqlDbType.NChar,10),
             new SqlParameter("@courseNo", SqlDbType.NChar,20)};
         parameters[0].Value = examTime.courseName;
         parameters[1].Value = examTime.examArrangeTime;
         parameters[2].Value = examTime.examArrageAddress;
         parameters[3].Value = examTime.remark;
         parameters[4].Value = examTime.teacherName;
         parameters[5].Value = examTime.courseNo;
         SqlHelper.ExecuteNonQuery(conn, CommandType.Text, sql, parameters);
     }
     catch (Exception ex)
     {
        MongoDBLog.LogRecord(ex);
         CommonUtility.RedirectUrl();
     }
     finally
     {
         conn.Close();
     }
 }