Ejemplo n.º 1
0
        public PlaceModel getPlacebyPid(int pid)
        {
            MySqlConnection conn = GetConn.getConn();
            PlaceModel pModel = new PlaceModel();
            try
            {
                conn.Open();

                MySqlCommand cmd = new MySqlCommand("select * from `tb_place` where `pid`=@pid", conn);
                cmd.Parameters.AddWithValue("@pid", pid);
                MySqlDataReader reader = cmd.ExecuteReader();
                if (reader.Read())
                {
                    pModel.Pid = int.Parse(reader["pid"].ToString());
                    pModel.Pname = (string)reader["pname"];
                }
                conn.Close();
                return pModel;
            }
            catch (Exception)
            {
                conn.Close();
                return null;
            }
        }
Ejemplo n.º 2
0
        public CourseInfo(CourseModel cModel, TeacherModel tModel, PlaceModel pModel, String precName)
        {
            this.cModel = cModel;
            this.tModel = tModel;
            this.pModel = pModel;
            this.precourseName = precName;

            updateCourseInfo();
        }
        public List<CourseInfo> getTimetable(int sid)
        {
            int startyear = int.Parse(new StudentBusiness().getStuBySid(sid).Startyear.ToString());
            int year = DateTime.Now.Year;
            int month = DateTime.Now.Month;
            int semester = (month >= 1 && month <= 6) ? 2 * (year - startyear) : 2 * (year - startyear) + 1;

            courseModelList = new CourseService().getAllCourseBySid(sid, semester);
            if (courseModelList != null)
            {
                foreach (CourseModel cModel in courseModelList)
                {
                    tModel = new TeacherService().getTeacherByTid(cModel.Tid);
                    pModel = new PlaceService().getPlacebyPid(cModel.Pid);
                    precName = (new CourseService().getCoursebyCid(cModel.Precourse)).Cname;
                    courseInfo = new CourseInfo(cModel, tModel, pModel, precName);
                    courseInfoList.Add(courseInfo);
                }
            }

            return courseInfoList;
        }