Ejemplo n.º 1
0
        protected void btnExport_Click(object sender, EventArgs e)
        {
            System.Data.DataTable dt = new System.Data.DataTable();

            dt.Columns.Add(new System.Data.DataColumn(BidString.GetText(@"BidId"), typeof(string)));
            dt.Columns.Add(new System.Data.DataColumn(BidString.GetText(@"StartDate"), typeof(string)));
            dt.Columns.Add(new System.Data.DataColumn(BidString.GetText(@"EndDate"), typeof(string)));
            dt.Columns.Add(new System.Data.DataColumn(BidString.GetText(@"OffersCount"), typeof(string)));
            dt.Columns.Add(new System.Data.DataColumn(BidString.GetText(@"Products"), typeof(string)));
            if (bidType != BidType.BidCount || bidType != BidType.BidPurchase)
            {
                dt.Columns.Add(new System.Data.DataColumn(BidString.GetText(@"OrderDate"), typeof(string)));
            }
            List <BidUI> coll;

            if (AllBids)
            {
                coll = BidController.GetAllBidByCustomerTypeAndBidType(customerType, bidType, BidLeave, 0, 0);
            }
            else
            {
                coll = BidController.GetAllBidByCustomerIdAndBidType(CustomerId, customerType, bidType, 0, 0);
            }
            foreach (BidUI Bid in coll)
            {
                int i = 0;
                System.Data.DataRow row = dt.NewRow();
                row[i++] = Bid.BidId;
                row[i++] = "\"" + Bid.StartDate + "\"";
                row[i++] = "\"" + Bid.EndDate + "\"";
                row[i++] = Bid.OfferNum;
                row[i++] = Bid.Products.Replace("<br>", ",");
                if (bidType != BidType.BidCount || bidType != BidType.BidPurchase)
                {
                    row[i++] = "\"" + Bid.OrderDate + "\"";
                }
                dt.Rows.Add(row);
            }

            SpreadsheetWriter ex = SpreadsheetWriter.FromDataTable(dt, false, true);

            Response.Clear();
            Response.AddHeader(@"content-disposition", @"attachment;filename=MyBidsExport_" + DateTime.UtcNow.ToString(@"yyyy_MM_dd_HH_mm_ss") + "." + ex.FileExtension);
            Response.Charset         = @"UTF-8";
            Response.ContentEncoding = System.Text.Encoding.UTF8;
            Response.Cache.SetCacheability(HttpCacheability.NoCache);
            Response.ContentType = ex.FileContentType;
            Response.BinaryWrite(System.Text.Encoding.UTF8.GetPreamble());
            Response.Write(ex.ToString());
            Response.End();
        }
Ejemplo n.º 2
0
 protected void LoadItems()
 {
     if (!HasEditPermission)
     {
         dgMyBids.Columns[dgMyBids.Columns.Count - 1].Visible = false;
     }
     if (AllBids)
     {
         dgMyBids.VirtualItemCount = Convert.ToInt32(BidController.GetCountAllBidByCustomerTypeAndBidType(customerType, bidType, BidLeave));
     }
     else
     {
         dgMyBids.VirtualItemCount = Convert.ToInt32(BidController.GetCountBidByCustomerIdAndBidType(CustomerId, customerType, bidType));
     }
     if (dgMyBids.VirtualItemCount == 0)
     {
         phHasItems.Visible   = false;
         phHasNoItems.Visible = true;
         lblNoItems.Text      = BidString.GetText(@"MessageNoBidsFound");
     }
     else
     {
         phHasItems.Visible   = true;
         phHasNoItems.Visible = false;
         if (dgMyBids.PageSize * dgMyBids.CurrentPageIndex > dgMyBids.VirtualItemCount)
         {
             dgMyBids.CurrentPageIndex         = 0;
             hfCurrentPageIndex_dgMyBids.Value = dgMyBids.CurrentPageIndex.ToString();
         }
         if (AllBids)
         {
             List <BidUI> coll = BidController.GetAllBidByCustomerTypeAndBidType(customerType, bidType, BidLeave, dgMyBids.PageSize, dgMyBids.CurrentPageIndex);
             BindList(coll);
         }
         else
         {
             List <BidUI> coll = BidController.GetAllBidByCustomerIdAndBidType(CustomerId, customerType, bidType, dgMyBids.PageSize, dgMyBids.CurrentPageIndex);
             BindList(coll);
         }
     }
 }