예제 #1
0
    protected void Set_Table_Filtered(string filter, string filterIDstr)
    {
        DataTable dt;
        DataClassesAlbertDataContext db;
        GoDine a;

        db = new DataClassesAlbertDataContext();
        dt = new DataTable("GiftCards");
        a = new GoDine();

        dt.Columns.Add("BarCode", typeof(string));
        dt.Columns.Add("UserName", typeof(string));
        dt.Columns.Add("$TotalIn", typeof(decimal));
        dt.Columns.Add("$MoneyLeft", typeof(decimal));
        dt.Columns.Add("%SaleDealRate", typeof(decimal));
        dt.Columns.Add("Company", typeof(string));
        dt.Columns.Add("Seller", typeof(string));
        dt.Columns.Add("Forced", typeof(bool));
        dt.Columns.Add("CreationDate", typeof(DateTime));
        dt.Columns.Add("Mode", typeof(string));
        dt.Columns.Add("EmailFrom", typeof(string));

        if (filterIDstr == "It's a sales filter" || filterIDstr == "It's a company filter")
        {
            var giftcards = from c in db.GiftCards select c;
            if (filterIDstr == "It's a company filter")
            {
                giftcards = from c in db.GiftCards where c.CompanyID == filter select c; // THIS IS A SELECTED TABLE ACQUISITION
            }
            else
            {
                giftcards = from c in db.GiftCards where c.SellerID == filter select c; // THIS IS A SELECTED TABLE ACQUISITION
            }

            foreach (GiftCard giftcard in giftcards)
            {
                GiftCardExtras extra = a.getExtraFieldsFor(giftcard);
                string giftcard_userkey = giftcard.EmailTo;
                    DataRow tablerow = dt.NewRow();
                    tablerow["UserName"] = giftcard_userkey;
                    tablerow["$TotalIn"] = giftcard.TotalIn;
                    tablerow["$MoneyLeft"] = giftcard.Money;
                    tablerow["%SaleDealRate"] = giftcard.SalesDealRate;
                    tablerow["Company"] = extra.compName;
                    tablerow["Seller"] = extra.salesPerson;
                    tablerow["BarCode"] = UTILITIES.appendChecksum(giftcard.BarCode);
                    tablerow["Forced"] = giftcard.Forced;
                    tablerow["CreationDate"] = giftcard.Date;
                    tablerow["Mode"] = giftcard.MODE;
                    tablerow["EmailFrom"] = giftcard.EmailFrom;
                    dt.Rows.Add(tablerow);
            }
        }
        else
        {
            var giftcards = from c in db.GiftCards select c; // THIS IS A SELECTED TABLE ACQUISITION
            foreach (GiftCard giftcard in giftcards)
            {
                GiftCardExtras extra = a.getExtraFieldsFor(giftcard);
                string giftcard_userkey = giftcard.EmailTo;
                //MembershipUser memberi = Membership.GetUser(userkey_email);
                if (((filterIDstr == null) && (giftcard_userkey.Contains(filter) || giftcard_userkey.Contains(filter))) || filterIDstr == giftcard.GiftCardID.ToString())
                {
                    DataRow tablerow = dt.NewRow();
                    tablerow["UserName"] = giftcard_userkey;
                    tablerow["$TotalIn"] = giftcard.TotalIn;
                    tablerow["$MoneyLeft"] = giftcard.Money;
                    tablerow["%SaleDealRate"] = giftcard.SalesDealRate;
                    tablerow["Company"] = extra.compName;
                    tablerow["Seller"] = extra.salesPerson;
                    tablerow["BarCode"] = UTILITIES.appendChecksum(giftcard.BarCode);
                    tablerow["Forced"] = giftcard.Forced;
                    tablerow["CreationDate"] = giftcard.Date;
                    tablerow["Mode"] = giftcard.MODE;
                    tablerow["EmailFrom"] = giftcard.EmailFrom;
                    dt.Rows.Add(tablerow);
                }
            }
        }

        Session["dt"] = dt;
        GV.DataSource = dt;
        GV.AllowSorting = true;
        GV.AllowPaging = true;
        GV.PageSize = 1000000;
        //GV.Columns["Money"].ItemStyle.HorizontalAlign = HorizontalAlign.Right;
        GV.DataBind();
    }