bool SaveSubyear() { using (var helper = new DbHelper.Structure()) { var subyear = new Academic.DbEntities.Structure.SubYear() { Name = txtName.Text , Description = txtDescription.Text , Id = this.StructureId , YearId = ParentId , Position = Convert.ToInt32(string.IsNullOrEmpty(txtPosition.Text) ? "0" : txtPosition.Text) }; if (StructureId == 0) { subyear.CreatedDate = DateTime.Now; } var saved = helper.AddOrUpdateSubYear(subyear); return(saved != null); } }
protected void btnSave_Click(object sender, EventArgs e) { bool isValid = true; if (string.IsNullOrEmpty(txtName.Text)) { isValid = false; valiTxtName.Visible = true; } if (string.IsNullOrEmpty(txtPosition.Text)) { isValid = false; valiPostion.Visible = true; } if (cmbYear.SelectedValue == "" || cmbYear.SelectedValue == "0") { isValid = false; valiCmbYear.Visible = true; } if (isValid) { var subYear = new Academic.DbEntities.Structure.SubYear() { Name = txtName.Text , Description = txtDescription.Text , Position = Convert.ToInt32(txtPosition.Text) , YearId = Convert.ToInt32(cmbYear.SelectedValue) }; if (cmbParent.SelectedValue != "" && cmbParent.SelectedValue != "0") { subYear.ParentId = Convert.ToInt32(cmbParent.SelectedValue); } using (var helper = new DbHelper.Structure()) { var saved = helper.AddOrUpdateSubYear(subYear); if (saved != null) { if (OnSaveClicked != null) { OnSaveClicked(this, DbHelper.StaticValues.SuccessSaveMessageEventArgs); } ClearCreateTextBoxes(); } else { if (OnSaveClicked != null) { OnSaveClicked(this, DbHelper.StaticValues.ErrorSaveMessageEventArgs); } } } } }
protected void Button1_Click(object sender, EventArgs e) { if (cmbProgram.SelectedValue == "") { valiProg.IsValid = false; } if (IsValid) { //save year using (var helper = new DbHelper.Structure()) { var section = new Academic.DbEntities.Structure.SubYear() { Name = txtName.Text , YearId = Convert.ToInt32(cmbProgram.SelectedValue) , }; var saved = helper.AddOrUpdateSubYear(section); if (saved != null) { if (OnSaveClicked != null) { OnSaveClicked(this, DbHelper.StaticValues.SuccessSaveMessageEventArgs); } } else { if (OnSaveClicked != null) { OnSaveClicked(this, DbHelper.StaticValues.ErrorSaveMessageEventArgs); } } //Response.Write("Error while saving."); } } }