private void ProcessForm(int myobId, bool isDelete) { try { using (TransactionScope ts = new TransactionScope()) { MYOBCardFileBO objMYOB = new MYOBCardFileBO(this.ObjContext); if (myobId > 0) { objMYOB.ID = myobId; objMYOB.GetObject(); objMYOB.Name = this.txtMYOBCardFileName.Text; objMYOB.Description = this.txtDescription.Text; if (isDelete) { objMYOB.Delete(); } } else { objMYOB.Name = this.txtMYOBCardFileName.Text; objMYOB.Description = this.txtDescription.Text; objMYOB.Add(); } this.ObjContext.SaveChanges(); ts.Complete(); } } catch (Exception ex) { //throw ex; } }
private void PopulateDataGrid() { { // Hide Controls this.dvEmptyContent.Visible = false; this.dvDataContent.Visible = false; this.dvNoSearchResult.Visible = false; // Search text string searchText = this.txtSearch.Text.ToLower().Trim(); // Populate Items MYOBCardFileBO objMYOBCardFile = new MYOBCardFileBO(); List <MYOBCardFileBO> lstMYOBCardFiles; if ((searchText != string.Empty) && (searchText != "search")) { lstMYOBCardFiles = (from o in objMYOBCardFile.SearchObjects().ToList() where o.Name.ToLower().Contains(searchText) || (o.Description != null ? o.Description.ToLower().Contains(searchText) : false) select o).ToList(); } else { lstMYOBCardFiles = objMYOBCardFile.SearchObjects().ToList(); } if (lstMYOBCardFiles.Count > 0) { this.RadGridMYOBCardFile.AllowPaging = (lstMYOBCardFiles.Count > this.RadGridMYOBCardFile.PageSize); this.RadGridMYOBCardFile.DataSource = lstMYOBCardFiles; this.RadGridMYOBCardFile.DataBind(); Session["MYOBCardFileDetails"] = lstMYOBCardFiles; this.dvDataContent.Visible = true; } else if ((searchText != string.Empty && searchText != "search")) { this.lblSerchKey.Text = searchText + ((searchText != string.Empty) ? " - " : string.Empty); this.dvDataContent.Visible = true; this.dvNoSearchResult.Visible = true; } else { this.dvEmptyContent.Visible = true; this.btnAddMYOB.Visible = false; } this.RadGridMYOBCardFile.Visible = (lstMYOBCardFiles.Count > 0); } }
protected void RadGridMYOBCardFile_ItemDataBound(object sender, GridItemEventArgs e) { if (e.Item is GridDataItem) { var item = e.Item as GridDataItem; if (item.ItemIndex > -1 && item.DataItem is MYOBCardFileBO) { MYOBCardFileBO objMYOBCardFile = (MYOBCardFileBO)item.DataItem; HyperLink linkEdit = (HyperLink)item.FindControl("linkEdit"); linkEdit.Attributes.Add("qid", objMYOBCardFile.ID.ToString()); HyperLink linkDelete = (HyperLink)item.FindControl("linkDelete"); linkDelete.Attributes.Add("qid", objMYOBCardFile.ID.ToString()); linkDelete.Visible = !(objMYOBCardFile.OrdersWhereThisIsMYOBCardFile.Any()); } } }