private void SaveProduct() { try { int result = 0; objProductLookUp = new ProductLookupDal(); LookupBDto objProduct = new LookupBDto(); objLookUpBDto = new LookupBDto(); objLookUpBDto.Description = txtProductDesc.Text; objLookUpBDto.UserProfile = objAuthorizationBDto.UserProfile; result = objProductLookUp.InsertProduct(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 ProductLookup grid /// </summary> private void BindGrid() { objProductLookUp = new ProductLookupDal(); DataSet dsProduct = objProductLookUp.GetproductDesc(""); radgrdProduct.DataSource = dsProduct; radgrdProduct.DataBind(); ViewState[vsProduct] = dsProduct; }
/// <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 acbProduct_SaveClick(object sender, EventArgs e) { try { int result = 0; objProductLookUp = new ProductLookupDal(); switch (acbProduct.SaveButton.CommandName) { case "Save": SaveProduct(); pnlAddNewMode.Visible = false; acbProduct.EditableMode = false; BindGrid(); break; case "Update": String xmlData = GenerateXmlString(radgrdProduct); result = objProductLookUp.UpdateProduct(xmlData); if (result == 1) { acbProduct.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++) radgrdProduct.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 acbProduct_SearchClick(object sender, EventArgs e) { try { objProductLookUp = new ProductLookupDal(); DataSet dsProduct = objProductLookUp.GetproductDesc(acbProduct.SearchTextBox.Text); radgrdProduct.DataSource = dsProduct; radgrdProduct.DataBind(); ViewState[vsProduct] = dsProduct; 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 acbProduct_DeleteClick(object sender, EventArgs e) { StringBuilder ProductId = new StringBuilder(); int result = 0; try { if (ViewState[PageConstants.vsItemIndexes] != null) htItemIndex = (Hashtable)ViewState[PageConstants.vsItemIndexes]; if (htItemIndex != null) { foreach (int i in htItemIndex.Values) { Label lblProductId = (Label)radgrdProduct.Items[i].FindControl("lblGrdProductIdItem"); if (lblProductId != null) { ProductId.Append(lblProductId.Text + ","); } } } objProductLookUp = new ProductLookupDal(); String ProductDescId = ProductId.ToString().TrimEnd(','); result = objProductLookUp.DeleteProduct(ProductDescId); 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; } } }