Esempio n. 1
0
        public ActionResult ShowEditTimeTbl(long SeqNo)
        {
            TimeTableModel TModel = new TimeTableModel();

            tblTimeTable TCtable = Connection.tblTimeTables.SingleOrDefault(x => x.SeqNo == SeqNo);

            DateTime F = DateTime.Parse(TCtable.FromTime.ToString());
            DateTime T = DateTime.Parse(TCtable.ToTime.ToString());

            TModel.FromTime_String = F.ToString("hh:mm tt");
            TModel.ToTime_String   = T.ToString("hh:mm tt");
            TModel.SubjectId       = TCtable.SubjectId;
            TModel.GradeId         = TCtable.GradeId;
            TModel.ClassId         = TCtable.ClassId;
            TModel.SchoolId        = TCtable.SchoolId;

            var GradeSubject = Connection.SMGTgetGradeSubjects(TModel.GradeId, "CKC").ToList();//Need to Pass a Session Schoolid
            List <tblSubject> EGradeSubjectList = GradeSubject.Select(x => new tblSubject
            {
                SubjectId   = x.SubjectId,
                ShortName   = x.ShortName,
                SubjectName = x.SubjectName,
                IsActive    = x.IsActive
            }).ToList();

            ViewBag.SubjectEdit = new SelectList(EGradeSubjectList, "SubjectId", "SubjectName");
            return(PartialView("EditTimeTbl", TModel));
        }
Esempio n. 2
0
        public ActionResult Delete(TimeTableModel Model)
        {
            try
            {
                tblTimeTable TCtable = Connection.tblTimeTables.Find(Model.SeqNo);
                Connection.tblTimeTables.Remove(TCtable);
                Connection.SaveChanges();

                return(Json(true, JsonRequestBehavior.AllowGet));
            }
            catch
            {
                return(Json(false, JsonRequestBehavior.AllowGet));
            }
        }
Esempio n. 3
0
        public ActionResult Create(TimeTableModel Model)
        {
            try
            {
                tblTimeTable TimeTbl = new tblTimeTable();

                TimeTbl.CreatedBy    = "ADMIN";
                TimeTbl.CreatedDate  = DateTime.Now;
                TimeTbl.AcademicYear = "2017"; // Parameter
                TimeTbl.SchoolId     = "CKC";  //Session
                TimeTbl.GradeId      = Model.GradeId;
                TimeTbl.ClassId      = Model.ClassId;
                TimeTbl.Day          = Model.Day;
                TimeTbl.SubjectId    = Model.SubjectId;

                DateTime F = DateTime.Parse(Model.FromTime_String);
                DateTime T = DateTime.Parse(Model.ToTime_String);

                TimeTbl.FromTime         = TimeSpan.Parse(F.ToString("HH:mm"));
                TimeTbl.ToTime           = TimeSpan.Parse(T.ToString("HH:mm"));
                TimeTbl.IsActive         = "Y";
                TimeTbl.PeriodSequenceNo = Model.PeriodSeqNo;

                Connection.tblTimeTables.Add(TimeTbl);
                Connection.SaveChanges();

                var result = new { r = "S", Grade = Model.GradeId, Class = Model.ClassId, Day = Model.Day };
                return(Json(result, JsonRequestBehavior.AllowGet));
            }
            catch (Exception Ex)
            {
                var result = new { r = "E" };
                Errorlog.ErrorManager.LogError("@ ActionResult Create(TimeTableModel Model)", Ex);
                return(Json(result, JsonRequestBehavior.AllowGet));
            }
        }
Esempio n. 4
0
        public JsonResult EditTimeTable(TimeTableModel Model)
        {
            try
            {
                tblTimeTable Newt = Connection.tblTimeTables.SingleOrDefault(x => x.SeqNo == Model.SeqNo);

                Newt.ModifiedBy   = "ADMIN";
                Newt.ModifiedDate = DateTime.Now;

                DateTime F = DateTime.Parse(Model.FromTime_String);
                DateTime T = DateTime.Parse(Model.ToTime_String);

                Newt.FromTime  = TimeSpan.Parse(F.ToString("HH:mm"));
                Newt.ToTime    = TimeSpan.Parse(T.ToString("HH:mm"));
                Newt.SubjectId = Model.SubjectId;

                Connection.SaveChanges();

                return(Json(true, JsonRequestBehavior.AllowGet));
            }
            catch (System.Data.Entity.Validation.DbEntityValidationException dbEx)
            {
                Exception raise = dbEx;
                foreach (var validationErrors in dbEx.EntityValidationErrors)
                {
                    foreach (var validationError in validationErrors.ValidationErrors)
                    {
                        string message = string.Format("{0}:{1}",
                                                       validationErrors.Entry.Entity.ToString(),
                                                       validationError.ErrorMessage);
                        raise = new InvalidOperationException(message, raise);
                    }
                }
                throw raise;
            }
        }