Beispiel #1
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            var book = new Academic.DbEntities.ActivityAndResource.BookResource()
            {
                Id   = BookId,
                Name = txtName.Text
                ,
                Description = CKEditor1.Text
                ,
                ChapterFormatting = (byte)ddlChapterFormatting.SelectedIndex
                ,
                CustomTitles = false
                ,
                StyleOfNavigation = (byte)ddlStyleOfNavigation.SelectedIndex
                ,
                DisplayDescriptionOnCourePage = chkDisplayDescription.Checked
                ,
            };

            var restriction = RestrictionUC.GetRestriction();

            if (!RestrictionUC.IsValid)
            {
                lblError.Visible = true;
                return;
            }
            using (var helper = new DbHelper.ActAndRes())
            {
                var saved = helper.AddOrUpdateBook(book, SectionId, restriction);
                if (saved != null)
                {
                    if (saved.Chapters.Any())
                    {
                        Response.Redirect(DbHelper.StaticValues.WebPagePath.CourseDetailPage(SubjectId, SectionId));
                    }
                    else
                    {
                        Response.Redirect("~/Views/ActivityResource/Book/ChapterCreate.aspx?bId=" + saved.Id +
                                          "&pcId=0&SubId=" + SubjectId
                                          + "&secId=" + SectionId);
                    }
                }
                //Response.Redirect(DbHelper.StaticValues.WebPagePath.CourseDetailPage(SubjectId, SectionId));
                //Response.Redirect("~/Views/Course/Section/?SubId="
                //        + SubjectId + "#section_" + SectionId);//
            }
        }
Beispiel #2
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            //if (string.IsNullOrEmpty(ddlSubmissionType.SelectedValue))
            //    submissionListVali.IsValid = false;
            var isValid = true;

            var grade = GradeInActivityUc1.GetGrade();

            if (grade == null)
            {
                return;
            }
            //if (string.IsNullOrEmpty(ddlGradeType.SelectedValue))
            //    gradeListVali.IsValid = false;


            using (var helper = new DbHelper.ActAndRes())
            {
                var user = Page.User as CustomPrincipal;

                if (user.IsInRole("teacher") || user.IsInRole("manager") ||
                    user.IsInRole(DbHelper.StaticValues.Roles.CourseEditor))
                {
                    var restriction = RestrictionUC.GetRestriction();
                    if (!RestrictionUC.IsValid)
                    {
                        lblError.Visible = true;
                        isValid          = false;
                    }

                    if (SectionId > 0)
                    {
                        try
                        {
                            var assg = new Academic.DbEntities.ActivityAndResource.Assignment()
                            {
                                Id = AssignmentId
                                ,
                                CreatedDate = DateTime.Now
                                ,
                                Description = CKEditor1.Text
                                ,
                                DispalyDescriptionOnPage = chkDisplayDesc.Checked
                                ,
                                Name = txtName.Text
                                ,
                                FileSubmission = chkFileSubmission.Checked
                                ,
                                OnlineText = chkOnlineSubmission.Checked
                            };

                            if (grade.GradeTypeId > 0)
                            {
                                assg.GradeTypeId  = grade.GradeTypeId;
                                assg.MaximumGrade = grade.MaximumGradeInString; //ddlMaximumGrade.SelectedValue;
                                assg.GradeToPass  = grade.GradeToPassInString;  //ddlGradeToPass.SelectedValue;
                            }

                            //if (ddlGradeType.SelectedValue != "0")
                            //{
                            //    assg.GradeTypeId = Convert.ToInt32(ddlGradeType.SelectedValue);
                            //    if (ddlMaximumGrade.Visible && ddlGradeToPass.Visible)
                            //    {
                            //        assg.MaximumGrade = ddlMaximumGrade.SelectedValue;
                            //        assg.GradeToPass = ddlGradeToPass.SelectedValue;
                            //    }
                            //    else if (txtMaxGradde.Visible && txtGradeToPass.Visible)
                            //    {
                            //        assg.MaximumGrade = txtMaxGradde.Text;
                            //        assg.GradeToPass = txtGradeToPass.Text;
                            //    }
                            //}



                            #region File and online submission

                            if (chkFileSubmission.Checked)
                            {
                                try
                                {
                                    assg.MaximumNoOfUploadedFiles = Convert.ToInt32(txtMaxFiles.Text);
                                }
                                catch (Exception)
                                {
                                    lblValiMaxFile.Visible = true;
                                    isValid = false;
                                }
                                try
                                {
                                    assg.MaximumSubmissionSize = Convert.ToInt32(txtMaxSize.Text);
                                }
                                catch
                                {
                                    lblValiSubmissionSize.Visible = true;
                                    isValid = false;
                                }
                            }
                            else
                            {
                                assg.MaximumNoOfUploadedFiles = null;
                                assg.MaximumSubmissionSize    = null;
                            }

                            if (chkOnlineSubmission.Checked)
                            {
                                try
                                {
                                    assg.WordLimit = Convert.ToInt32(txtWordLimit.Text);
                                }
                                catch
                                {
                                    lblValiWordLimit.Visible = true;
                                    isValid = false;
                                }
                            }
                            else
                            {
                                assg.WordLimit = null;
                            }


                            #endregion


                            #region Dates

                            if (chkFrom.Checked)
                            {
                                try
                                {
                                    assg.SubmissionFrom = Convert.ToDateTime(txtFrom.Text);
                                }
                                catch (Exception)
                                {
                                    valiFrom.Visible = true;
                                    isValid          = false;
                                }
                            }
                            else
                            {
                                assg.SubmissionFrom = null;
                            }

                            if (chkDue.Checked)
                            {
                                try
                                {
                                    assg.DueDate = Convert.ToDateTime(txtDue.Text);
                                }
                                catch
                                {
                                    valiDue.Visible = true;
                                    isValid         = false;
                                }
                            }
                            else
                            {
                                assg.DueDate = null;
                            }


                            if (chkCutOff.Checked)
                            {
                                try
                                {
                                    assg.CutOffDate = Convert.ToDateTime(txtCutOff.Text);
                                }
                                catch
                                {
                                    valiCutOff.Visible = true;
                                    isValid            = false;
                                }
                            }
                            else
                            {
                                assg.CutOffDate = null;
                            }
                            #endregion

                            #region Classes

                            var cls = ClassesInActivityChoose1.GetClasses();


                            #endregion

                            if (AssignmentId > 0)
                            {
                                assg.ModifiedDate = DateTime.Now;
                                assg.ModifiedBy   = user.Id;
                            }
                            else
                            {
                                assg.CreatedDate = DateTime.Now;
                                assg.CreatedBy   = user.Id;
                            }

                            //var weight = (float)0.0;
                            var weight = grade.WeightInGradeSheetInFloat ?? 0;
                            assg.ShowGradeToStudents = grade.ShowGradeToStudents;
                            //try
                            //{
                            //    if (!string.IsNullOrEmpty(txtWeightInGradeSheet.Text))
                            //    {
                            //        weight = (float)Convert.ToDecimal(txtWeightInGradeSheet.Text);
                            //        if (weight < 0 || weight > 100)
                            //        {
                            //            valiWeightInGradeSheet.Visible = true;
                            //            return;
                            //        }
                            //    }
                            //}
                            //catch
                            //{
                            //    valiWeightInGradeSheet.Visible = true;
                            //    return;
                            //}
                            if (isValid && Page.IsValid)
                            {
                                var saved = helper.AddOrUpdateAssignmentActivity(assg, SectionId, restriction, cls, weight);
                                if (saved != null)
                                {
                                    Response.Redirect(DbHelper.StaticValues.WebPagePath.CourseDetailPage(SubjectId, SectionId));
                                    //Response.Redirect("~/Views/Course/Section/Master/CourseSectionListing.aspx?SubId=" +
                                    //                  SubjectId + "&edit=1#section_" + SectionId);
                                }
                                else
                                {
                                    lblError.Visible = true;
                                }
                            }
                            else
                            {
                                lblError.Visible = true;
                            }
                        }
                        catch { }
                    }
                }
            }
        }
Beispiel #3
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            var user = Page.User as CustomPrincipal;

            if (user != null)
            {
                var file = new Academic.DbEntities.ActivityAndResource.FileResource()
                {
                    Id   = FileResourceId,
                    Name = txtName.Text
                    ,
                    Description = CKEditor1.Text
                    ,
                    //Display = (byte)ddlDisplay.SelectedIndex
                    //,
                    ShowSize = chkShowSize.Checked
                    ,
                    ShowType = chkShowType.Checked
                    ,
                    ShowUploadModifiedDate = chkShowUploadModifiedDate.Checked
                    ,
                    ShowDescriptionOnCoursePage = chkDisplayDescription.Checked
                    ,
                };
                if (ddlDisplay.SelectedIndex == 0)
                {
                    file.Display = 2;
                }
                else
                {
                    file.Display = 4;
                }
                //files
                var list  = new List <Academic.DbEntities.Subjects.SubjectFile>();
                var files = FilesDisplay1.GetFiles();
                if (files != null)
                {
                    foreach (var f in files)
                    {
                        var fileName = Path.GetFileName(f.FilePath);
                        var fi       = new Academic.DbEntities.Subjects.SubjectFile()
                        {
                            Id        = f.Id,
                            CreatedBy = user.Id
                            ,
                            CreatedDate = DateTime.Now
                            ,
                            DisplayName = f.FileDisplayName                           //Path.GetFileName(imageFile.FileName)
                            ,
                            FileDirectory = DbHelper.StaticValues.CourseFilesLocation //StaticValue.UserImageDirectory
                            ,
                            FileName = fileName
                                       //Guid.NewGuid().ToString() + GetExtension(imageFile.FileName, imageFile.ContentType)
                            ,
                            FileSizeInBytes = f.FileSizeInBytes //imageFile.ContentLength
                            ,
                            FileType = f.FileType               //imageFile.ContentType
                            ,
                            IconPath = f.IconPath
                            ,
                            SubjectId = SubjectId
                            ,
                            Void = !f.Visible
                        };
                        list.Add(fi);
                    }
                }
                var restriction = RestrictionUC.GetRestriction();

                if (!RestrictionUC.IsValid)
                {
                    return;
                }
                using (var helper = new DbHelper.ActAndRes())
                {
                    var saved = helper.AddOrUpdateFileResource(file, list, SectionId, restriction);
                    if (saved != null)
                    {
                        Response.Redirect(DbHelper.StaticValues.WebPagePath.CourseDetailPage(SubjectId, SectionId));
                        //Response.Redirect("~/Views/Course/Section/Master/CourseSectionListing.aspx?SubId=" + SubjectId + "&edit=1#section_" + SectionId);
                    }
                }
            }
        }