/// <summary> /// To Insert details of SectionT in SectionT table /// Created By : NafisaMulla, 12/6/2014 /// Modified By : /// </summary> /// <param name="objSectionTBO"></param> /// <returns></returns> public ApplicationResult SectionT_Insert(SectionTBO objSectionTBO) { try { pSqlParameter = new SqlParameter[6]; pSqlParameter[0] = new SqlParameter("@SectionMID", SqlDbType.Int); pSqlParameter[0].Direction = ParameterDirection.Input; pSqlParameter[0].Value = objSectionTBO.SectionMID; pSqlParameter[1] = new SqlParameter("@SchoolMID", SqlDbType.Int); pSqlParameter[1].Direction = ParameterDirection.Input; pSqlParameter[1].Value = objSectionTBO.SchoolMID; pSqlParameter[2] = new SqlParameter("@MediumMID", SqlDbType.Int); pSqlParameter[2].Direction = ParameterDirection.Input; pSqlParameter[2].Value = objSectionTBO.MediumMID; pSqlParameter[3] = new SqlParameter("@LastModifiedUserID", SqlDbType.Int); pSqlParameter[3].Direction = ParameterDirection.Input; pSqlParameter[3].Value = objSectionTBO.LastModifiedUserID; pSqlParameter[4] = new SqlParameter("@LastModifiedDate", SqlDbType.VarChar); pSqlParameter[4].Direction = ParameterDirection.Input; pSqlParameter[4].Value = objSectionTBO.LastModifiedDate; pSqlParameter[5] = new SqlParameter("@IsDeleted", SqlDbType.Int); pSqlParameter[5].Direction = ParameterDirection.Input; pSqlParameter[5].Value = objSectionTBO.IsDeleted; sSql = "usp_tbl_Section_T_Insert"; int iResult = DatabaseTransaction.ExecuteNonQuery(CommandType.StoredProcedure, sSql, pSqlParameter); if (iResult > 0) { ApplicationResult objResults = new ApplicationResult(); objResults.status = ApplicationResult.CommonStatusType.SUCCESS; return(objResults); } else { ApplicationResult objResults = new ApplicationResult(); objResults.status = ApplicationResult.CommonStatusType.FAILURE; return(objResults); } } catch (Exception ex) { throw ex; } finally { objSectionTBO = null; } }
protected void btnSave_Click(object sender, EventArgs e) { try { ApplicationResult objResults = new ApplicationResult(); SectionBO objSectionBO = new SectionBO(); SectionBL objSectionBL = new SectionBL(); SectionTBO objSectionTBO = new SectionTBO(); objSectionBO.SectionName = txtSectionName.Text; objSectionBO.SectionAvbbreviation = txtAbbreviation.Text; objSectionBO.Description = txtSectionDesc.Text; objSectionBO.LastModifiedDate = DateTime.UtcNow.AddHours(5.5).ToString(); objSectionBO.LastModifiedUserID = Convert.ToInt32(Session[ApplicationSession.USERID]); if (ValidateName() == true) { ClientScript.RegisterStartupScript(typeof(Page), "MessagePopUp", "<script language='javascript'>alert('Section Name or/and Section Abbrev " + txtSectionName.Text + "/" + txtAbbreviation.Text + " Already Exists.');</script>"); goto Exit; } #region RollBack Transaction Starts DatabaseTransaction.OpenConnectionTransation(); if (ViewState["Mode"].ToString() == "Save") { objResults = objSectionBL.Section_Insert(objSectionBO); if (objResults != null) { if (objResults.resultDT.Rows.Count > 0) { ViewState["SectionMID"] = Convert.ToInt32(objResults.resultDT.Rows[0][0].ToString()); objSectionTBO.SectionMID = Convert.ToInt32(ViewState["SectionMID"].ToString()); objSectionTBO.SchoolMID = Convert.ToInt32(Session[ApplicationSession.SCHOOLID]); objSectionTBO.MediumMID = 1; objSectionTBO.LastModifiedDate = DateTime.UtcNow.AddHours(5.5).ToString(); objSectionTBO.LastModifiedUserID = Convert.ToInt32(Session[ApplicationSession.USERID]); objResults = objSectionBL.SectionT_Insert(objSectionTBO); if (objResults.status == ApplicationResult.CommonStatusType.SUCCESS) { } } } ClearAll(); ClientScript.RegisterStartupScript(typeof(Page), "MessagePopUp", "<script language='javascript'>alert('Section Created Successfully.');</script>"); //GridDataBind(); PanelGrid_VisibilityMode(1); } else { ApplicationResult objResultsUpdate = new ApplicationResult(); objSectionBO.SectionMID = Convert.ToInt32(ViewState["SectionMID"].ToString()); objResultsUpdate = objSectionBL.Section_Update(objSectionBO); if (objResultsUpdate.status == ApplicationResult.CommonStatusType.SUCCESS) { ClientScript.RegisterStartupScript(typeof(Page), "MessagePopUp", "<script language='JavaScript'>alert('Section updated successfully.');</script>"); ClearAll(); } } DatabaseTransaction.CommitTransation(); GridDataBind(); #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>"); } }