protected void btnSave_Click(object sender, EventArgs e) { var user = Page.User as CustomPrincipal; if (user != null) { if (Page.IsValid) { Subject subject = new Subject() { Id = CourseId, FullName = txtName.Text, ShortName = txtShortName.Text, Code = txtCode.Text, Credit = Convert.ToInt32(string.IsNullOrEmpty(txtCredit.Text) ? "0" : txtCredit.Text), SubjectCategoryId = CategoryId, Summary = CKEditor1.Text }; if (CourseId == 0) { subject.CreatedDate = DateTime.Now.Date; subject.CreatedById = user.Id; } using (var helper = new DbHelper.Subject()) { var saved = helper.AddOrUpdateSubject(subject); if (saved) { if (CourseId > 0) { Response.Redirect("~/Views/Course/CourseDetail.aspx?cId=" + CourseId); } else { Response.Redirect("~/Views/Course/?catId=" + CategoryId); } } else { lblError.Visible = true; } } } } }
protected void btnSave_Click(object sender, EventArgs e) { //if (cmbCategory.SelectedValue == "" || cmbCategory.SelectedValue == "0" || cmbCategory.SelectedValue == "-1") //{ // RequiredFieldValidator1.IsValid = false; //} var user = Page.User as CustomPrincipal; if (user != null) { if (Page.IsValid) { var credit = txtCredit.Text; Subject subject = new Subject() { Id = SubjectId, FullName = txtName.Text, ShortName = txtShortName.Text, Code = txtCode.Text, //HasTheory = chkListHas.Items[0].Selected, //HasLab = chkListHas.Items[1].Selected, //HasTutorial = chkListHas.Items[2].Selected, //HasProject = chkListHas.Items[3].Selected, //IsElective = chkListIs.Items[0].Selected, //IsOutOfSyllabus = chkListIs.Items[1].Selected, CreatedDate = DateTime.Now.Date, CreatedById = user.Id, //IsActive = ckhIsActive.Checked //, //SubjectCategoryId = Convert.ToInt32(cmbCategory.SelectedValue) SubjectCategoryId = CategoryId }; //if (string.IsNullOrEmpty(txtCredit.Text)) //{ // subject.Credit = Convert.ToByte(txtCode.Text == "" ? "0" : txtCode.Text); //} //if (!String.IsNullOrEmpty(txtFullMarks.Text)) //{ // subject.FullMarks = Convert.ToInt32(txtFullMarks.Text); //} //if (!string.IsNullOrEmpty(txtPassPercent.Text)) //{ // subject.PassPercentage = Convert.ToByte(txtPassPercent.Text); //} //if (!string.IsNullOrEmpty(txtCompletionHours.Text)) //{ // subject.CompletionHours = Convert.ToInt16(txtCompletionHours.Text); //} using (var helper = new DbHelper.Subject()) { var saved = helper.AddOrUpdateSubject(subject); //Response.Redirect("~/Views/Course/"); if (SaveClicked != null) { if (saved) { SaveClicked(this, DbHelper.StaticValues.SuccessSaveMessageEventArgs); } else { SaveClicked(this, DbHelper.StaticValues.ErrorSaveMessageEventArgs); } } } } } }