private void SaveReligion() { try { int result = 0; objReligionLookUp = new ReligionLookUpDal(); LookupBDto objReligion = new LookupBDto(); objLookUpBDto = new LookupBDto(); objLookUpBDto.LookupName = txtReligionName.Text; objLookUpBDto.UserProfile = objAuthorizationBDto.UserProfile; result = objReligionLookUp.InsertRelagion(objLookUpBDto); if (result >= 1) { Master.DisplayMessage(ConfigurationSettings.AppSettings[SuccessMessage.Save].ToString()); Master.MessageCssClass = "successMessage"; } else { Master.DisplayMessage(ConfigurationSettings.AppSettings[FailureMessage.Save].ToString()); Master.MessageCssClass = "errorMessage"; } BindGrid(); Reset(); } catch (Exception ex) { bool rethrow = ExceptionPolicy.HandleException(ex, DALHelper.DAL_EXP_POLICYNAME); if (rethrow) { throw ex; } } }
/// <summary> /// Bind ReligionLookUp grid /// </summary> private void BindGrid() { objReligionLookUp = new ReligionLookUpDal(); DataSet dsReligion = objReligionLookUp.GetReligionName(""); radgrdReligion.DataSource = dsReligion; radgrdReligion.DataBind(); ViewState[vsReligion] = dsReligion; }
/// <summary> /// Action bar's save button event which saves grid data by xml. /// </summary> /// <param name="sender">The object which raised the event</param> /// <param name="e">The event listener object</param> protected void acbReligion_SaveClick(object sender, EventArgs e) { try { int result = 0; objReligionLookUp = new ReligionLookUpDal(); switch (acbReligion.SaveButton.CommandName) { case "Save": SaveReligion(); pnlAddNewMode.Visible = false; acbReligion.EditableMode = false; BindGrid(); break; case "Update": String xmlData = GenerateXmlString(radgrdReligion); result = objReligionLookUp.UpdateReligion(xmlData); if (result == 1) { acbReligion.DefaultMode = true; Master.DisplayMessage(ConfigurationSettings.AppSettings[SuccessMessage.Update].ToString()); Master.MessageCssClass = "successMessage"; if (ViewState[PageConstants.vsItemIndexes] != null) htItemIndex = (Hashtable)ViewState[PageConstants.vsItemIndexes]; for (int i = 0; i < htItemIndex.Count; i++) { radgrdReligion.Items[Convert.ToInt32(htItemIndex[i])].Edit = false; } bisEdit = false; ViewState[PageConstants.vsItemIndexes] = null; BindGrid(); } else { Master.DisplayMessage(ConfigurationSettings.AppSettings[FailureMessage.Update].ToString()); Master.MessageCssClass = "errorMessage"; } break; } }catch (Exception ex) { bool rethrow = ExceptionPolicy.HandleException(ex, DALHelper.DAL_EXP_POLICYNAME); if (rethrow) { throw ex; } } Reset(); }
protected void acbReligion_SearchClick(object sender, EventArgs e) { try { objReligionLookUp = new ReligionLookUpDal(); DataSet dsReligion = objReligionLookUp.GetReligionName(acbReligion.SearchTextBox.Text); radgrdReligion.DataSource = dsReligion; radgrdReligion.DataBind(); ViewState[vsReligion] = dsReligion; Reset(); } catch (Exception ex) { bool rethrow = ExceptionPolicy.HandleException(ex, DALHelper.DAL_EXP_POLICYNAME); if (rethrow) { throw ex; } } }
/// <summary> /// Action bar's delete button event which delete records physically from database. /// </summary> /// <param name="sender">The object which raised the event</param> /// <param name="e">The event listener object</param> protected void acbReligion_DeleteClick(object sender, EventArgs e) { try { StringBuilder religionId = new StringBuilder(); int result = 0; if (ViewState[PageConstants.vsItemIndexes] != null) htItemIndex = (Hashtable)ViewState[PageConstants.vsItemIndexes]; if (htItemIndex != null) { foreach (int i in htItemIndex.Values) { Label lblReligionId = (Label)radgrdReligion.Items[i].FindControl("lblGrdReligionIdItem"); if (lblReligionId != null) { religionId.Append(lblReligionId.Text + ","); } } } objReligionLookUp = new ReligionLookUpDal(); String religId = religionId.ToString().TrimEnd(','); result = objReligionLookUp.DeleteReligion(religId); if (result == 1) { Master.DisplayMessage(ConfigurationSettings.AppSettings[SuccessMessage.Delete].ToString()); Master.MessageCssClass = "successMessage"; ViewState[PageConstants.vsItemIndexes] = null; BindGrid(); } else if (result == 547) { Master.DisplayMessage(ConfigurationSettings.AppSettings[FailureMessage.Delete].ToString()); Master.MessageCssClass = "errorMessage"; } } catch (Exception ex) { bool rethrow = ExceptionPolicy.HandleException(ex, DALHelper.DAL_EXP_POLICYNAME); if (rethrow) { throw ex; } } }