protected void RadGridOrderTypes_ItemDataBound(object sender, GridItemEventArgs e) { if (e.Item is GridDataItem) { var item = e.Item as GridDataItem; if (item.ItemIndex > -1 && item.DataItem is OrderTypeBO) { OrderTypeBO objOrderType = (OrderTypeBO)item.DataItem; HyperLink linkEdit = (HyperLink)item.FindControl("linkEdit"); linkEdit.Attributes.Add("qid", objOrderType.ID.ToString()); HyperLink linkDelete = (HyperLink)item.FindControl("linkDelete"); linkDelete.Attributes.Add("qid", objOrderType.ID.ToString()); ReturnIntViewBO objReturnInt = new ReturnIntViewBO(); objReturnInt = SettingsBO.ValidateField(0, "OrderDetail", "OrderType", objOrderType.ID.ToString()); linkDelete.Visible = objReturnInt.RetVal == 1; //linkDelete.Visible = (objOrderType.OrderDetailsWhereThisIsOrderType.Count == 0) ? true : false; //linkDelete.Visible = (objOrderType.ReservationsWhereThisIsOrderType.Count == 0); } } }
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 OrderTypeBO objOrderType = new OrderTypeBO(); // Sort by condition //int sortbyStatus = int.Parse(this.ddlSortBy.SelectedItem.Value); //if (sortbyStatus < 2) //{ // //objItem.IsActive = Convert.ToBoolean(sortbyStatus); //} List <OrderTypeBO> lstOrderType = new List <OrderTypeBO>(); if ((searchText != string.Empty) && (searchText != "search")) { lstOrderType = (from o in objOrderType.SearchObjects().AsQueryable().OrderBy(SortExpression).ToList() where o.Name.ToLower().Contains(searchText) || o.Description.ToLower().Contains(searchText) select o).ToList(); } else { lstOrderType = objOrderType.SearchObjects().AsQueryable().OrderBy(SortExpression).ToList(); } if (lstOrderType.Count > 0) { this.RadGridOrderTypes.AllowPaging = (lstOrderType.Count > this.RadGridOrderTypes.PageSize); this.RadGridOrderTypes.DataSource = lstOrderType; this.RadGridOrderTypes.DataBind(); Session["OrderTypesDetails"] = lstOrderType; 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.btnAddOrderType.Visible = false; } this.RadGridOrderTypes.Visible = (lstOrderType.Count > 0); } }
private void ProcessForm(int ordertypeId, bool isDelete) { try { using (TransactionScope ts = new TransactionScope()) { OrderTypeBO objOrderType = new OrderTypeBO(this.ObjContext); if (ordertypeId > 0) { //Update Data objOrderType.ID = ordertypeId; objOrderType.GetObject(); objOrderType.Name = this.txtOrderTypeName.Text; objOrderType.Description = this.txtDescription.Text; if (isDelete) { objOrderType.Delete(); } } else { objOrderType.Name = this.txtOrderTypeName.Text; objOrderType.Description = this.txtDescription.Text; objOrderType.Add(); } this.ObjContext.SaveChanges(); ts.Complete(); } } catch (Exception ex) { //throw ex; } }