protected void btnSaveClass_Click(object sender, EventArgs e) { try { ClassBL objClasstBl = new ClassBL(); ClassBO objClassBo = new ClassBO(); DivisionTBO objDivisionBo = new DivisionTBO(); DivisionTBL objDivisionBl = new DivisionTBL(); Controls objControls = new Controls(); ApplicationResult objResults = new ApplicationResult(); if (ValidateName() == true) { ClientScript.RegisterStartupScript(typeof(Page), "MessagePopUp", "<script language='javascript'>alert('Class Name " + txtClassName.Text + " And Divsion " + txtDivisionName.Text + " already Exists.');</script>"); goto Exit; } objClassBo.SchoolMID = Convert.ToInt32(Session[ApplicationSession.SCHOOLID].ToString()); objClassBo.SectionTID = Convert.ToInt32(ddlSection.SelectedValue); objClassBo.SchoolMID = Convert.ToInt32(Session[ApplicationSession.SCHOOLID]); objClassBo.ClassName = txtClassName.Text; objClassBo.NoOfPeriod = Convert.ToInt32(txtNoOfPeriod.Text); objClassBo.ApprovalNo = txtApprovalNo.Text; objClassBo.ApprovalDate = txtApprovalDate.Text; objClassBo.LastModifiedDate = DateTime.UtcNow.AddHours(5.5).ToString(); objClassBo.LastModifiedUserID = Convert.ToInt32(Session[ApplicationSession.USERID]); objDivisionBo.LastModifiedDate = DateTime.UtcNow.AddHours(5.5).ToString(); objDivisionBo.LastModifiedUserID = Convert.ToInt32(Session[ApplicationSession.USERID]); #region RollBack Transaction Starts DatabaseTransaction.OpenConnectionTransation(); if (ViewState["Mode"].ToString() == "Save") { //objResults = objClasstBl.Class_ValidateName(txtClassName.Text, Convert.ToInt32(Session[ApplicationSession.SCHOOLID])); //if (objResults != null) //{ // if (objResults.resultDT.Rows.Count > 0) // { // ViewState["ClassMID"] = Convert.ToInt32(objResults.resultDT.Rows[0][0].ToString()); // SaveClass_T(); // } // else // { objResults = objClasstBl.Class_Insert(objClassBo); if (objResults != null) { if (objResults.resultDT.Rows.Count > 0) { ViewState["ClassMID"] = Convert.ToInt32(objResults.resultDT.Rows[0][0].ToString()); SaveClass_T(); ClearAll(); ClientScript.RegisterStartupScript(typeof(Page), "MessagePopUp", "<script language='javascript'>alert('Record saved successfully.');</script>"); GridDataBind(); PanelGrid_VisibilityMode(1); } else { ClientScript.RegisterStartupScript(typeof(Page), "MessagePopUp", "<script language='javascript'>alert('Class Name " + txtClassName.Text + " Already Exists.');</script>"); } } // } //} } else { objClassBo.ClassMID = Convert.ToInt32(ViewState["ClassMID"].ToString()); objDivisionBo.ClassMID = Convert.ToInt32(ViewState["ClassMID"].ToString()); objResults = objClasstBl.Class_Update(objClassBo); if (objResults.status == ApplicationResult.CommonStatusType.SUCCESS) { //ApplicationResult objResultsDivisionUpdate = new ApplicationResult(); //objResultsDivisionUpdate = // objDivisionBl.DivisionT_Delete_By_Class(Convert.ToInt32(ViewState["ClassMID"].ToString())); //DataTable dtTask = (DataTable)ViewState["Division"]; //for (int i = 0; i < dtTask.Rows.Count; i++) //{ // objDivisionBo.DivisionName = dtTask.Rows[i]["DivisionName"].ToString(); // objResultsDivisionUpdate = objDivisionBl.DivisionT_Insert(objDivisionBo); //} ClientScript.RegisterStartupScript(typeof(Page), "MessagePopUp", "<script language='javascript'>alert('Record updated successfully.');</script>"); ClearAll(); GridDataBind(); objControls.ClearForm(Master.FindControl("ContentPlaceHolder1")); ViewState["Mode"] = "Save"; } else { ClientScript.RegisterStartupScript(typeof(Page), "MessagePopUp", "<script language='javascript'>alert('Class Name " + txtClassName.Text + " Already Exists.');</script>"); } } DatabaseTransaction.CommitTransation(); #endregion Exit :; } catch (Exception ex) { logger.Error("Error", ex); ClientScript.RegisterStartupScript(typeof(Page), "MessagePopUp", "<script>alert('Oops! There is some technical issue. Please Contact to your administrator.');</script>"); } }