/// <summary> /// To Insert details of Holiday in tbl_Holiday_M table /// Created By : Nirmal, 04-01-2016 /// Modified By : /// </summary> public ApplicationResult Holiday_Insert(HolidayBo objHolidayBo) { try { pSqlParameter = new SqlParameter[7]; pSqlParameter[0] = new SqlParameter("@Name", SqlDbType.VarChar); pSqlParameter[0].Direction = ParameterDirection.Input; pSqlParameter[0].Value = objHolidayBo.Name; pSqlParameter[1] = new SqlParameter("@AcademicYear", SqlDbType.VarChar); pSqlParameter[1].Direction = ParameterDirection.Input; pSqlParameter[1].Value = objHolidayBo.AcademicYear; pSqlParameter[2] = new SqlParameter("@StartDate", SqlDbType.VarChar); pSqlParameter[2].Direction = ParameterDirection.Input; pSqlParameter[2].Value = objHolidayBo.StartDate; pSqlParameter[3] = new SqlParameter("@EndDate", SqlDbType.VarChar); pSqlParameter[3].Direction = ParameterDirection.Input; pSqlParameter[3].Value = objHolidayBo.EndDate; pSqlParameter[4] = new SqlParameter("@Description", SqlDbType.VarChar); pSqlParameter[4].Direction = ParameterDirection.Input; pSqlParameter[4].Value = objHolidayBo.Description; pSqlParameter[5] = new SqlParameter("@CreatedBy", SqlDbType.Int); pSqlParameter[5].Direction = ParameterDirection.Input; pSqlParameter[5].Value = objHolidayBo.CreatedBy; pSqlParameter[6] = new SqlParameter("@CreatedDate", SqlDbType.VarChar); pSqlParameter[6].Direction = ParameterDirection.Input; pSqlParameter[6].Value = objHolidayBo.CreatedDate; sSql = "usp_tbl_Holiday_M_Insert"; int iResult = Database.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 { objHolidayBo = null; } }
protected void btnSaveClass_OnClick(object sender, EventArgs e) { try { HolidayBo objHolidayBO = new HolidayBo(); HolidayBl objHolidayBL = new HolidayBl(); ApplicationResult objResult = new ApplicationResult(); DataTable dtResult = new DataTable(); int intHolidayID = 0; objHolidayBO.Name = txtHolidayName.Text.Trim(); objHolidayBO.AcademicYear = ddlAcademicYear.Text; objHolidayBO.StartDate = txtFromDate.Text.Trim(); objHolidayBO.EndDate = txtToDate.Text.Trim(); objHolidayBO.Description = txtDescription.Text.Trim(); //Code For Validate Holiday Name if (ViewState["Mode"].ToString() == "Save") { intHolidayID = -1; } else if (ViewState["Mode"].ToString() == "Edit") { intHolidayID = Convert.ToInt32(ViewState["HolidayID"].ToString()); } objResult = objHolidayBL.Holiday_ValidateName(intHolidayID, objHolidayBO.StartDate, objHolidayBO.AcademicYear); if (objResult != null) { dtResult = objResult.resultDT; if (dtResult.Rows.Count > 0) { ClientScript.RegisterStartupScript(typeof(Page), "MessagePopUp", "<script>alert('Holiday already exist.');</script>"); } else { if (ViewState["Mode"].ToString() == "Save") { objHolidayBO.CreatedBy = Convert.ToInt32(Session[ApplicationSession.USERID]); objHolidayBO.CreatedDate = DateTime.UtcNow.AddHours(5.5).ToString(); objResult = objHolidayBL.Holiday_Insert(objHolidayBO); if (objResult.status == ApplicationResult.CommonStatusType.SUCCESS) { ClientScript.RegisterStartupScript(typeof(Page), "MessagePopUp", "<script>alert('Record saved successfully.');</script>"); } } else if (ViewState["Mode"].ToString() == "Edit") { objHolidayBO.HolidayId = Convert.ToInt32(ViewState["HolidayID"].ToString()); objHolidayBO.LastModifiedBy = Convert.ToInt32(Session[ApplicationSession.USERID]); objHolidayBO.LastModifiedDate = DateTime.UtcNow.AddHours(5.5).ToString(); objResult = objHolidayBL.Holiday_Update(objHolidayBO); if (objResult.status == ApplicationResult.CommonStatusType.SUCCESS) { ClientScript.RegisterStartupScript(typeof(Page), "MessagePopUp", "<script>alert('Record updated successfully.');</script>"); } } ClearAll(); BindHoliday(); PanelVisibility(1); } } } 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>"); } }