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; }
/////////////////////////////////////////////////////////////////////////// FOR COMPANY PAYMENTS protected void ddPaidAmount_SelectedIndexChanged(object sender, EventArgs e) { GoDine GD = new GoDine(); if (!(ddPaidAmount.SelectedValue.Contains("---"))) { int companyID = GD.Get_CompanyID_By_CompanyName(ddPaidAmount.SelectedValue); CompanyGiftcardSales giftcards = GD.GetGiftcardSalesForCompany(companyID); lblPaidAmount.Text = "Amount left to pay for this company = " + Math.Round(GD.CompanyStatus_from_CompanyID(companyID).toPay + giftcards.totalInFromGCDiscounted, 2); } else { tbPaidAmount.Text = ""; } }
protected void Set_Table_Filtered(string filter) { DataTable dt; DataClassesAlbertDataContext db; db = new DataClassesAlbertDataContext(); dt = new DataTable("Companies"); //var companies = db.Companies; // THIS IS A FULL TABLE ACQUISITION FROM DATABASE var companies = from c in db.Companies where c.Name.Contains(filter) select c; // THIS IS A SELECTED TABLE ACQUISITION dt.Columns.Add("Name", typeof(string)); dt.Columns.Add("UserName", typeof(string)); dt.Columns.Add("CUsers", typeof(int)); dt.Columns.Add("$ATGC Redemptions", typeof(decimal)); dt.Columns.Add("$OwedFromRedemptions", typeof(decimal)); dt.Columns.Add("$OwedFromGiftcards", typeof(decimal)); dt.Columns.Add("$AlreadyPaid", typeof(decimal)); dt.Columns.Add("$LeftToPay", typeof(decimal)); dt.Columns.Add("%TransDealRate", typeof(decimal)); dt.Columns.Add("%GCSaleDealRate", typeof(decimal)); dt.Columns.Add("CreationDate", typeof(DateTime)); foreach (Company company in companies) { DataRow tablerow = dt.NewRow(); Guid userkey = company.UserID; MembershipUser membership = Membership.GetUser(userkey); if (membership == null) { log.Error("The following company has an invalid configuration (missing Membership): CompanyID=" + company.CompanyID); } else { GoDine GD = new GoDine(); CompanyStatus status = GD.CompanyStatus_from_CompanyID(company.CompanyID); CompanyGiftcardSales giftcards = GD.GetGiftcardSalesForCompany(company.CompanyID); tablerow["Name"] = status.CompanyName; tablerow["UserName"] = membership.UserName; tablerow["CUsers"] = status.CUserCount; tablerow["$ATGC Redemptions"] = Math.Round(status.TotalIn, 2); tablerow["$OwedFromRedemptions"] = Math.Round(status.TotalInDiscounted, 2); tablerow["$OwedFromGiftcards"] = Math.Round(giftcards.totalInFromGCDiscounted, 2); tablerow["$AlreadyPaid"] = Math.Round(status.Paid,2); tablerow["$LeftToPay"] = Math.Round(status.toPay + giftcards.totalInFromGCDiscounted, 2); tablerow["%TransDealRate"] = Math.Round(status.DealRate,2); tablerow["%GCSaleDealRate"] = Math.Round(giftcards.gcDealRate, 2); tablerow["CreationDate"] = status.Date; dt.Rows.Add(tablerow); } } Session["dt"] = dt; GV.DataSource = dt; GV.AllowSorting = true; GV.AllowPaging = true; GV.PageSize = 30; //GV.Columns["Money"].ItemStyle.HorizontalAlign = HorizontalAlign.Right; GV.DataBind(); }