/////////////////////////////////////////////////////////////////////////// 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();
    }