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 { } } } } }