コード例 #1
0
        public JsonResult UpdateCourseDetailsMaster(SITSPL_tblCourseStructure cs, int Course, decimal Fees,
                                                    int Discount, decimal NetAmount, DateTime ValidFrom, DateTime ValidTo, int StructureId, int DurationId, string DurationName
                                                    , int StudentCategoryId, bool IsPublished, Int64?BatchId, int StudentSubCategoryId)
        {
            try
            {
                db = new CourseDataContext();
                bool result = false;

                SITSPL_tblCourseStructure coursestr = db.SITSPL_tblCourseStructures.Where(x => x.CourseId == Course &&
                                                                                          x.StructureId == StructureId && x.IsDeleted == false).FirstOrDefault();
                DateTime ValidFromdate = DateTime.Parse(Convert.ToDateTime(ValidFrom).ToShortDateString());
                DateTime ValidTodate   = DateTime.Parse(Convert.ToDateTime(ValidTo).ToShortDateString());

                if (ValidFromdate > ValidTodate)
                {
                    return(Json("ValidTo"));
                }
                else if (coursestr != null)
                {
                    coursestr.CourseId             = Course;
                    coursestr.Fees                 = Fees;
                    coursestr.DiscountPercent      = Discount;
                    coursestr.NetAmount            = NetAmount;
                    coursestr.ValidFrom            = ValidFrom;
                    coursestr.ValidTo              = ValidTo;
                    coursestr.DurationId           = DurationId;
                    coursestr.StdCatgId            = StudentCategoryId;
                    coursestr.StudentSubCategoryId = StudentSubCategoryId;
                    coursestr.BatchId              = BatchId;

                    if (IsPublished)
                    {
                        if (!coursestr.IsPublished)
                        {
                            coursestr.DatePublished = DateTime.Now;
                            coursestr.PublishedBy   = "Admin";
                        }
                    }
                    coursestr.IsPublished = IsPublished;
                    coursestr.LastUpdated = DateTime.Now;
                    coursestr.UpdatedBy   = "Admin";
                    db.SubmitChanges();
                    result = true;
                    return(Json(result, JsonRequestBehavior.AllowGet));
                }
                else
                {
                    result = false;
                    return(Json(result, JsonRequestBehavior.AllowGet));
                }
            }
            catch (Exception ex)
            {
                return(Json(ex.Message, JsonRequestBehavior.AllowGet));
            }
        }
コード例 #2
0
        public JsonResult AddCourseStructure(SITSPL_tblCourseStructure courseStructure)
        {
            try
            {
                bool result = false;
                db = new CourseDataContext();
                courseStructure.DateCreated = DateTime.Now;

                if (courseStructure.IsPublished == true)
                {
                    courseStructure.DatePublished = DateTime.Now;
                }

                courseStructure.CreatedBy = "Admin";
                db.SITSPL_tblCourseStructures.InsertOnSubmit(courseStructure);
                db.SubmitChanges();
                result = true;
                return(Json(result, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                return(Json(ex.Message, JsonRequestBehavior.AllowGet));
            }
        }