protected void LoadItems() { phHasItems.Visible = true; phHasNoItems.Visible = false; //DateTime from, to = new DateTime(); //DateTime.TryParse(datepickerFrom.Text.ToString(), out from); //DateTime.TryParse(datepickerTo.Text.ToString(), out to); dgBids.VirtualItemCount = BidController.GetSupplierBids(SupplierId, Action, FromDate, ToDate, BidId).Count; if (dgBids.VirtualItemCount == 0) { phHasItems.Visible = false; phHasNoItems.Visible = true; lblNoItems.Text = BidString.GetText(@"MessageNoBidsFound"); } else { phHasItems.Visible = true; phHasNoItems.Visible = false; if (dgBids.PageSize * dgBids.CurrentPageIndex > dgBids.VirtualItemCount) { dgBids.CurrentPageIndex = 0; hfCurrentPageIndex_dgBids.Value = dgBids.CurrentPageIndex.ToString(); } List <BidUI> coll = BidController.GetSupplierBids(SupplierId, Action, FromDate, ToDate, BidId, dgBids.PageSize, dgBids.CurrentPageIndex); BindList(coll); } }
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(@"TotalPrice"), typeof(string))); dt.Columns.Add(new System.Data.DataColumn(BidString.GetText(@"Products"), typeof(string))); if (Action == "Win" || Action == "Offers") { dt.Columns.Add(new System.Data.DataColumn(BidString.GetText(@"OrderDate1"), typeof(string))); } List <BidUI> coll = BidController.GetSupplierBids(SupplierId, Action, FromDate, ToDate, BidId); 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.Price; row[i++] = (bid.LstProduct.Count == 0 || bid.LstProduct == null) ? "" : String.Join(", ", bid.LstProduct.Select(o => o.ProductName)); if (Action == "Win" || Action == "Offers") { row[i++] = "\"" + bid.OrderDate + "\""; } dt.Rows.Add(row); } SpreadsheetWriter ex = SpreadsheetWriter.FromDataTable(dt, false, true); Response.Clear(); Response.AddHeader(@"content-disposition", @"attachment;filename=Supplier" + SupplierId + Action + "BidsExport_" + 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(); }