protected Decimal2_int1 Set_Table_Filtered_by_CUsers(int companyID, string filterUser) { DataTable dt; DataClassesAlbertDataContext db; db = new DataClassesAlbertDataContext(); dt = new DataTable("Company Users"); GoDine CS = new GoDine(); CompanyStatus this_company_status = CS.CompanyStatus_from_CompanyID(companyID); decimal expensesTOT = this_company_status.TotalIn; decimal expensesTOTafterdisc = this_company_status.TotalInDiscounted; //var companies = db.Companies; // THIS IS A FULL TABLE ACQUISITION FROM DATABASE var Cusers = from cu in db.CUsers where cu.CompanyID == companyID && cu.UserCode.Contains(filterUser) select cu; ; // THIS IS A SELECTED TABLE ACQUISITION dt.Columns.Add("Employee Name", typeof(string)); dt.Columns.Add("Total Gift $ Redeemed", typeof(decimal)); dt.Columns.Add("Date Employee Added", typeof(DateTime)); int numusers = 0; foreach (var cuser in Cusers) { DataRow tablerow = dt.NewRow(); tablerow["Employee Name"] = cuser.UserCode; tablerow["Total Gift $ Redeemed"] = CS.Cuser_TotalIn_CuserID(cuser.CUserID).ToString("0.00"); tablerow["Date Employee Added"] = cuser.Date; dt.Rows.Add(tablerow); numusers = numusers + 1; } Session["dt"] = dt; GV.DataSource = dt; GV.AllowSorting = true; GV.AllowPaging = true; GV.PageSize = 50; //GV.Columns["Money"].ItemStyle.HorizontalAlign = HorizontalAlign.Right; GV.DataBind(); Company company = (from c in db.Companies where c.CompanyID == companyID select c).Single(); compname.Text = company.Name; var giftcards = (from g in db.GiftCards where g.CompanyID == company.UserID.ToString() select g); decimal totalGiftcardSales = 0; decimal totalGiftcardSalesAfterComish = 0; foreach (var card in giftcards) { totalGiftcardSales += card.TotalIn; totalGiftcardSalesAfterComish += Math.Round((card.TotalIn * ((100 - card.SalesDealRate) / 100)),2); } Decimal2_int1 toreturn = new Decimal2_int1(); toreturn.dec1 = expensesTOT; toreturn.dec2 = expensesTOTafterdisc; toreturn.num = numusers; toreturn.gcsalesDealRate = company.GCSaleDealRate; toreturn.giftcardSales = totalGiftcardSales; toreturn.giftcardSalesAfterComish = totalGiftcardSalesAfterComish; return toreturn; }