Beispiel #1
0
        public static List <IES.JW.Model.User> ClassUserHistory_List(int TeachingClassID, string Key, int PageIndex, int PageSize)
        {
            TeachingClass model = new TeachingClass {
                TeachingClassID = TeachingClassID, Key = Key
            };

            return(new MyGroupBLL().ClassUserHistory_List(model, PageIndex, PageSize));
        }
Beispiel #2
0
        protected override void Seed(EntityFramework_Demo.DAL.MyContext context)
        {
            //  This method will be called after migrating to the latest version.

            //  You can use the DbSet<T>.AddOrUpdate() helper extension method
            //  to avoid creating duplicate seed data.

            //---------
            //Adding Classes
            var Clss = new TeachingClass()
            {
                ClassName = "Class A"
            };

            context.TeachingClasses.AddOrUpdate(Clss);
            context.TeachingClasses.AddOrUpdate(new TeachingClass()
            {
                ClassName = "Class B"
            });
            context.SaveChanges();
            //---------
            //Adding Students
            context.Students.Add(new Student()
            {
                StudentName = "Anas", Age = 40, TeachingClassId = Clss.Id
            });

            var Std2 = new Student()
            {
                StudentName = "Mohammad", Age = 30, TeachingClassId = Clss.Id
            };

            context.Students.Add(Std2);
            context.Students.Add(new Student()
            {
                StudentName = "Bisher", Age = 30, TeachingClassId = Clss.Id
            });
            context.SaveChanges();
            //---------
            //Adding Homeworks
            context.Homework.Add(new Homework()
            {
                Title = "homework 1", StudentId = Std2.StudentId,
            });
            context.Homework.Add(new Homework()
            {
                Title = "homework 2", StudentId = Std2.StudentId,
            });
            context.Homework.Add(new Homework()
            {
                Title = "homework 3", StudentId = Std2.StudentId,
            });

            context.SaveChanges();
            //---------
        }
Beispiel #3
0
        //public ActionResult CheckSubjectSlotAvialability(string subject, string level, string StartHourclinet, string StartMinuteclinet)
        public ActionResult CheckDaySlotAvialability(string levels)
        {
            //var theValue = $('#Subject').val() + ";" + $('#Class').val() + ";" + $('#StratTimeHour').val() + ";" + $('#StratTimeMinute').val() + ";" + $('#Teacher').val() + ";" + $('#Day').val();
            string[] theLEvel          = levels.Split(';');
            string   subject           = theLEvel[0];
            string   level             = theLEvel[1];
            string   StartHourclinet   = theLEvel[2];
            string   StartMinuteclinet = theLEvel[3];
            string   day1 = theLEvel[5];
            //  string day1 = theLEvel[5];
            Day       day = DayHelper.GetDay(day1);
            smContext db  = new smContext();


            List <TeachingDay> theTeachingDay = db.TeachingDay.Include("TeachingSubject").Where(a => a.TeachingClass.ClassName == level && a.theDay == day).ToList();

            foreach (TeachingDay td in theTeachingDay)
            {
                TeachingClass theTeachingClass = db.TeachingClass.Where(a => a.TeachingClassID == td.TeachingClassID).First();
                string        theClass         = theTeachingClass.ClassName;
                // string theClass = td.TeachingClass.ClassName;
                foreach (TeachingSubject ts in td.TeachingSubject)
                {
                    String Day        = ts.TeachingDay.theDay.ToString();
                    string theSubject = ts.SubjectName;
                    string EndHour    = ts.TeachingDay.EndTimeHour;
                    string EndMinutes = ts.TeachingDay.EndTimeMinute;

                    string StartHour    = ts.TeachingDay.StratTimeHour;
                    string StartMinutes = ts.TeachingDay.StratTimeMinute;

                    StringBuilder EndHourEndMinutes = new StringBuilder();

                    EndHourEndMinutes.Append(EndHour);
                    EndHourEndMinutes.Append(EndMinutes);


                    int           time = Convert.ToInt16(EndHourEndMinutes.ToString()); //= Convert.ToInt16(EndHour) + Convert.ToInt16(EndMinutes);
                    StringBuilder StartHourStartMinuteclinets = new StringBuilder();
                    StartHourStartMinuteclinets.Append(StartHourclinet).Append(StartMinuteclinet);
                    int timeClient = Convert.ToInt16(StartHourStartMinuteclinets.ToString());//Convert.ToInt16(StartHourclinet) + Convert.ToInt16(StartMinuteclinet);

                    if (timeClient < time)
                    {
                        string theAlert = theSubject + "  has been fixed  for " + theClass + " which starts " + StartHour + ":" + StartMinutes + " ends at " + EndHour + ":" + EndMinutes;
                        return(Json(theAlert, JsonRequestBehavior.AllowGet));
                    }
                }
            }

            //  }


            return(Json("", JsonRequestBehavior.AllowGet));
        }
Beispiel #4
0
 //获取历史班级下的学生
 public static List<User> ClassUserHistory_List(TeachingClass model, int PageIndex, int PageSize)
 {
     try
     {
         using (var conn = DbHelper.CCService())
         {
             var p = new DynamicParameters();
             p.Add("@Key", model.Key);
             p.Add("@TeachingClassID", model.TeachingClassID);
             p.Add("@PageIndex", PageIndex);
             p.Add("@PageSize", PageSize);
             return conn.Query<User>("ClassUserHistory_List", p, commandType: CommandType.StoredProcedure).ToList();
         }
     }
     catch (Exception e)
     {
         return new List<User>();
     }
 }
Beispiel #5
0
 //获取历史班级下的学生
 public List<User> ClassUserHistory_List(TeachingClass model, int PageIndex, int PageSize)
 {
     return MyGroupDAL.ClassUserHistory_List(model, PageIndex, PageSize);
 }
Beispiel #6
0
        public ActionResult Create(TimeTable model)
        {
            List <Level>          theLevels = work.LevelRepository.Get().ToList();
            List <SelectListItem> theItem   = new List <SelectListItem>();

            theItem.Add(new SelectListItem()
            {
                Text = "None", Value = ""
            });
            foreach (var level in theLevels)
            {
                theItem.Add(new SelectListItem()
                {
                    Text = level.LevelName + ":" + level.Type, Value = level.LevelName + ":" + level.Type
                });
            }
            ViewData["Level"] = theItem;


            List <Subject>        theSubject      = work.SubjectRepository.Get().ToList();
            List <SelectListItem> theSubjectsItem = new List <SelectListItem>();

            theSubjectsItem.Add(new SelectListItem()
            {
                Text = "None", Value = ""
            });
            foreach (var sub in theSubject)
            {
                theSubjectsItem.Add(new SelectListItem()
                {
                    Text = sub.Name, Value = sub.Name
                });
            }
            ViewData["Subject"] = theSubjectsItem;



            List <PrimarySchoolStaff> staff        = work.PrimarySchoolStaffRepository.Get().OrderBy(a => a.LastName).ToList();
            List <SelectListItem>     theStaffItem = new List <SelectListItem>();

            theStaffItem.Add(new SelectListItem()
            {
                Text = "None", Value = ""
            });
            foreach (var s in staff)
            {
                theStaffItem.Add(new SelectListItem()
                {
                    Text = s.LastName + " " + s.Middle + " " + s.FirstName, Value = s.LastName + " " + s.Middle + " " + s.FirstName
                });
            }
            ViewData["Staff"] = theStaffItem;
            try
            {
                string v = model.Subject + ";" + model.Class + ";" + model.StratTimeHour + ";" + model.StratTimeMinute + ";" + model.Teacher + ";" + model.Day;

                string theReturnedValue        = TimeTableCollisionAviodance.CheckDaySlotAvialability(v);
                string theReturnedValueSubject = TimeTableCollisionAviodance.CheckSubjectSlotAvialability(v);
                string theReturnedValueStaff   = TimeTableCollisionAviodance.CheckStaffSlotAvialability(v);
                if (!(string.IsNullOrEmpty(theReturnedValue)))
                {
                    // ModelState.AddModelError("", "Create a Class Subjects First for Class " + theStudent.PresentLevel);
                    // return View(theReg);
                    ModelState.AddModelError("", theReturnedValue);

                    return(View(model));
                }

                int start  = Convert.ToInt32(model.StratTimeHour);
                int finish = Convert.ToInt32(model.EndTimeHour);

                if (finish < start)
                {
                    ModelState.AddModelError("", "Start Time of a Subject must be greater than its finish time!");

                    return(View(model));
                }

                if (!(string.IsNullOrEmpty(theReturnedValueSubject)))
                {
                    ModelState.AddModelError("", theReturnedValueSubject);

                    return(View(model));
                }

                if (!(string.IsNullOrEmpty(theReturnedValueStaff)))
                {
                    ModelState.AddModelError("", theReturnedValueStaff);

                    return(View(model));
                }
                //var theValue = $('#Subject').val() + ";" + $('#Class').val() + ";" + $('#StratTimeHour').val() + ";" + $('#StratTimeMinute').val() + ";" + $('#Teacher').val() + ";" + $('#Day').val();
                TeachingSubject ts = new TeachingSubject();
                ts.SubjectName = model.Subject;

                TeachingDay td = new TeachingDay();
                td.StratTimeHour   = model.StratTimeHour;
                td.StratTimeMinute = model.StratTimeMinute;
                td.EndTimeHour     = model.EndTimeHour;
                td.EndTimeMinute   = model.EndTimeMinute;

                if (model.Day == "SUNDAY")
                {
                    td.theDay = Day.SUNDAY;
                }

                if (model.Day == "MONDAY")
                {
                    td.theDay = Day.MONDAY;
                }

                if (model.Day == "TUESDAY")
                {
                    td.theDay = Day.TUESDAY;
                }

                if (model.Day == "WEDNESDAY")
                {
                    td.theDay = Day.WEDNESDAY;
                }

                if (model.Day == "THURSDAY")
                {
                    td.theDay = Day.THURSDAY;
                }

                if (model.Day == "FRIDAY")
                {
                    td.theDay = Day.FRIDAY;
                }


                if (model.Day == "SATURDAY")
                {
                    td.theDay = Day.SATURDAY;
                }

                TeachingClass tc = new TeachingClass();
                tc.ClassName = model.Class;


                List <TeachingSubject> tss = new List <TeachingSubject>();
                tss.Add(ts);

                td.TeachingSubject = tss;

                List <TeachingDay> tdd = new List <TeachingDay>();
                tdd.Add(td);
                tc.TheTeachingDay = tdd;;


                List <TeachingClass> tt = new List <TeachingClass>();
                tt.Add(tc);
                Teacher t = new Teacher();
                //  work.PrimarySchoolStaffRepository.ge
                t.TeacherName = model.Teacher;

                string[] theTeacher = model.Teacher.Split(' ');
                string   firstName  = theTeacher[2];
                string   lastName   = theTeacher[0];
                List <PrimarySchoolStaff> priStaff = work.PrimarySchoolStaffRepository.Get(a => a.LastName.Equals(lastName) && a.FirstName.Equals(firstName)).ToList();
                t.ThePersonID      = priStaff[0].PersonID;
                t.TheTeachingClass = tt;
                work.TeacherRepository.Insert(t);
                work.Save();

                // td.theDay =  model.Day;
                // TODO: Add insert logic here

                return(RedirectToAction("Create"));
                //  return RedirectToAction("Index");
            }
            catch
            {
                return(View());
            }
        }
Beispiel #7
0
 public static List<IES.JW.Model.User> ClassUserHistory_List(int TeachingClassID, string Key, int PageIndex, int PageSize)
 {
     TeachingClass model = new TeachingClass { TeachingClassID = TeachingClassID, Key = Key };
     return new MyGroupBLL().ClassUserHistory_List(model, PageIndex, PageSize);
 }