protected void Page_Load(object sender, EventArgs e) { int CurrentPageIndex = 0; if (!int.TryParse(hfCurrentPageIndex_dgOffers.Value, out CurrentPageIndex)) { CurrentPageIndex = 0; } if (CurrentPageIndex < 0) { CurrentPageIndex = 0; } dgOffers.CurrentPageIndex = CurrentPageIndex; if (!IsPostBack) { Bid b = Bid.FetchByID(BidId); if (b.AppUserId != null) { AppUser a = AppUser.FetchByID(b.AppUserId); Master.PageTitle = String.Format(BidString.GetText(@"OffersTitle"), BidId.ToString(), a.FirstName + " " + a.LastName); } else if (b.TempAppUserId != null) { Master.PageTitle = String.Format(BidString.GetText(@"OffersTitle"), BidId.ToString(), BidString.GetText("Temp")); } } LoadItems(); }
protected void bt_resend_Click(object sender, EventArgs e) { try { string arguments = Request.QueryString["bidId"]; long bidId; long.TryParse(arguments, out bidId); List <BidMessage> bidMessages = BIdMessageController.GetAllMessagesByBidId(bidId); foreach (BidMessage message in bidMessages) { message.IsActive = false; message.Save(); } BIdMessageController.AddNewMessage(bidId, long.Parse(ddlSuppliers.SelectedValue), bidMessages[0].OriginalSupplierId); Bid bid = Bid.FetchByID(bidId); bid.IsActive = true; bid.EndDate = DateTime.UtcNow.AddHours(Convert.ToDouble(Settings.GetSettingDecimal(Settings.Keys.END_BID_TIME_MIN, 15))); bid.Save(); Master.MessageCenter.DisplaySuccessMessage(BidString.GetText(@"ResendDealSucceed").Replace("XXX", ddlSuppliers.SelectedItem.Text)); } catch (Exception) { Master.MessageCenter.DisplayErrorMessage(BidString.GetText(@"ResendDealFail")); throw; } }
protected void Page_Load(object sender, EventArgs e) { int CurrentPageIndex = 0; if (!int.TryParse(hfCurrentPageIndex_dgBids.Value, out CurrentPageIndex)) { CurrentPageIndex = 0; } if (CurrentPageIndex < 0) { CurrentPageIndex = 0; } dgBids.CurrentPageIndex = CurrentPageIndex; if (!IsPostBack) { if (AllBids) { Master.PageTitle = BidString.GetText(@"TitleGlobalSupplierBids"); } else { Master.PageTitle = String.Format(BidString.GetText(@"TitleSupplierBids" + Action), AppSupplier.FetchByID(SupplierId).ContactName); } if (Action == "Active" || Action == "NoWin") { dgBids.Columns[dgBids.Columns.Count - 1].Visible = false; } } LoadItems(); }
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(@"SupplierName"), typeof(string))); dt.Columns.Add(new System.Data.DataColumn(BidString.GetText(@"Price"), typeof(string))); dt.Columns.Add(new System.Data.DataColumn(BidString.GetText(@"Gift"), typeof(string))); dt.Columns.Add(new System.Data.DataColumn(BidString.GetText(@"IsOrder"), typeof(string))); List <OfferUI> coll = OfferController.GetAllOfferByBidIdWithIsOrder(BidId); foreach (OfferUI offer in coll) { int i = 0; System.Data.DataRow row = dt.NewRow(); row[i++] = offer.SupplierName; row[i++] = offer.TotalPrice; row[i++] = offer.Gift; row[i++] = GlobalStrings.GetYesNo(offer.IsOrder); dt.Rows.Add(row); } SpreadsheetWriter ex = SpreadsheetWriter.FromDataTable(dt, false, true); Response.Clear(); Response.AddHeader(@"content-disposition", @"attachment;filename=OffersExport_" + 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(); }
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 Page_PreRender(object sender, EventArgs e) { if (filterSearch != null) { linksSearch.Visible = false; BidsCountLabel.Visible = true; if (filterSearch == "ActiveBids") { Master.PageTitle = BidString.GetText(@"DetailsMyActiveBidsPageTitle"); // BidsCountLabel.Text = BidString.GetText(@"SumActiveBids"); } if (filterSearch == "BidsWithOffers") { Master.PageTitle = BidString.GetText(@"DetailsMyCountBidsPageTitle"); // BidsCountLabel.Text = BidString.GetText(@"SumCountBids"); } if (filterSearch == "BidsWithOutOffers") { Master.PageTitle = BidString.GetText(@"DetailsMyWithNotOffersPageTitle"); } if (filterSearch == "PurchaseBids") { Master.PageTitle = BidString.GetText(@"DetailsMyBidsPurchasePageTitle"); //BidsCountLabel.Text = BidString.GetText(@"SumPurchaseBids"); } } else { BidsCountLabel.Visible = false; linksSearch.Visible = true; Master.PageTitle = BidString.GetText(@"BidsPageTitle"); } Master.ActiveMenu = "Bids"; Master.AddClientScriptInclude(@"dgDateManager.js"); }
protected void LoadItems(bool fromDb) { if (!HasEditPermission) { dgBids.Columns[dgBids.Columns.Count - 1].Visible = false; } DateTime from = new DateTime(), to = new DateTime(); DateTime.TryParse(dpSearchCreateDateFrom.Value.ToString(), out from); DateTime.TryParse(dpSearchCreateDateTo.Value.ToString(), out to); Int64 _BidId = -1; if (txtBidNumber.Text != "") { Int64.TryParse(txtBidNumber.Text, out _BidId); } if (fromDb) { // au = BidController.GetUntakenBidsTempForCampaign(filterSearch, from, to, txtSearchPhone.Text, txtCustomerId.Text, _BidId, txtCityName.Text); au = BidController.GetUntakenBids(filterSearch, from, to, txtSearchPhone.Text, txtCustomerId.Text, _BidId, txtCityName.Text); ViewState["au"] = au; } dgBids.VirtualItemCount = au.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(); } if (filterSearch == null) { //lblSumAbandonedBidsWithOffers.Text = au.Count(b => b.OfferNum > 0 && b.OrderDate == (DateTime?)null && b.EndDate < DateTime.Now).ToString(); //lblSumAbandonedBidsWithOutOffers.Text = au.Count(b => b.OfferNum == 0 && b.OrderDate == (DateTime?)null && b.EndDate < DateTime.Now).ToString(); //lblSumActiveBids.Text = au.Count(b => b.EndDate >= DateTime.Now).ToString(); //lblSumPurchaseBids.Text = au.Count(b => b.OrderDate != (DateTime?)null).ToString(); } else { dgBids.VirtualItemCount = au.Count(); } // List<BidUI> app_users = BidController.GetUntakenBids(filterSearch, from, to, txtSearchPhone.Text, txtCustomerId.Text, _BidId, txtCityName.Text, dgBids.PageSize, dgBids.CurrentPageIndex); BindList(au); } }
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(); }
protected void LoadItems() { phHasItems.Visible = true; phHasNoItems.Visible = false; if (dgCustomers.PageSize * dgCustomers.CurrentPageIndex > dgCustomers.VirtualItemCount) { dgCustomers.CurrentPageIndex = 0; hfCurrentPageIndex_dgCustomers.Value = dgCustomers.CurrentPageIndex.ToString(); } CustomerUI customer = BidController.GetCustomerData(CustomerId, customerType); Master.PageTitle = customerType == CustomerType.AppUser ? BidString.GetText(@"CustomersPageTitle") + customer.CustomerName : BidString.GetText(@"CustomersTempPageTitle"); BindList(customer); }
protected void Page_PreRender(object sender, EventArgs e) { if (filterSearch != null) { linksSearch.Visible = false; BidsCountLabel.Visible = true; } else { BidsCountLabel.Visible = false; linksSearch.Visible = true; Master.PageTitle = BidString.GetText(@"AdminRejectTitle"); } Master.ActiveMenu = "UntakedBids"; Master.AddClientScriptInclude(@"dgDateManager.js"); }
protected void rejectDeal(object sender, EventArgs e) { Button btn = (Button)(sender); var arguments = btn.CommandArgument; int bidId; Int32.TryParse(arguments, out bidId); if (!saveRejectDeal(bidId)) { Master.MessageCenter.DisplayErrorMessage(BidString.GetText(@"ErrorCancelBid")); //LoadItems(false); } else { Master.MessageCenter.DisplaySuccessMessage(BidString.GetText(@"SuccessCancelBid")); LoadItems(true); } }
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(); }
protected void btnCancelBid_Click(object sender, EventArgs e) { Button btn = (Button)(sender); var arguments = btn.CommandArgument; long bidId; long.TryParse(arguments, out bidId); if (!cancelBid(bidId)) { Master.MessageCenter.DisplayErrorMessage(BidString.GetText(@"ErrorCancelBid")); //LoadItems(false); } else { Master.MessageCenter.DisplaySuccessMessage(BidString.GetText(@"SuccessCancelBid")); LoadItems(); } Page.Response.Redirect(Page.Request.Url.AbsoluteUri); }
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); } } }
protected void Page_PreRender(object sender, EventArgs e) { Master.PageTitle = BidString.GetText(@"ResendDealTitle"); Master.ActiveMenu = "UntakedBids"; }
protected void Page_PreRender(object sender, EventArgs e) { if (!AllBids) { CustomerUI customer = BidController.GetCustomerData(CustomerId, customerType); if (bidType == BidType.BidActive) { Master.PageTitle = customerType == CustomerType.AppUser ? BidString.GetText(@"MyActiveBidsPageTitle") + " " + customer.CustomerName : BidString.GetText(@"CustomersTempPageTitle"); BidsCountLabel.Text = BidString.GetText(@"SumActiveBids"); } if (bidType == BidType.BidCount) { Master.PageTitle = customerType == CustomerType.AppUser ? BidString.GetText(@"MyCountBidsPageTitle") + " " + customer.CustomerName : BidString.GetText(@"CustomersTempPageTitle"); BidsCountLabel.Text = BidString.GetText(@"SumCountBids"); } if (bidType == BidType.BidAbandoned) { Master.PageTitle = customerType == CustomerType.AppUser ? BidString.GetText(@"MyBidsAbandonedPageTitle") + " " + customer.CustomerName : BidString.GetText(@"CustomersTempPageTitle"); BidsCountLabel.Text = BidString.GetText(@"SumAbandonedBids"); } if (bidType == BidType.BidPurchase) { Master.PageTitle = customerType == CustomerType.AppUser ? BidString.GetText(@"MyBidsPurchasePageTitle") + " " + customer.CustomerName : BidString.GetText(@"CustomersTempPageTitle"); BidsCountLabel.Text = BidString.GetText(@"SumPurchaseBids"); } } else { if (bidType == BidType.BidActive) { Master.PageTitle = customerType == CustomerType.AppUser ? BidString.GetText(@"DetailsMyActiveBidsPageTitle") : BidString.GetText(@"CustomersTempPageTitle"); BidsCountLabel.Text = BidString.GetText(@"SumActiveBids"); } if (bidType == BidType.BidCount) { Master.PageTitle = customerType == CustomerType.AppUser ? BidString.GetText(@"DetailsMyCountBidsPageTitle") : BidString.GetText(@"CustomersTempPageTitle"); BidsCountLabel.Text = BidString.GetText(@"SumCountBids"); } if (bidType == BidType.BidAbandoned) { if (BidLeave) { Master.PageTitle = customerType == CustomerType.AppUser ? BidString.GetText(@"DetailsMyWithNotOffersPageTitle") : BidString.GetText(@"CustomersTempPageTitle"); BidsCountLabel.Text = BidString.GetText(@"SumAbandonedBids"); } else { Master.PageTitle = customerType == CustomerType.AppUser ? BidString.GetText(@"DetailsMyBidsAbandonedPageTitle") : BidString.GetText(@"CustomersTempPageTitle"); BidsCountLabel.Text = BidString.GetText(@"SumAbandonedBids"); } } if (bidType == BidType.BidPurchase) { Master.PageTitle = customerType == CustomerType.AppUser ? BidString.GetText(@"DetailsMyBidsPurchasePageTitle") : BidString.GetText(@"CustomersTempPageTitle"); BidsCountLabel.Text = BidString.GetText(@"SumPurchaseBids"); } } Master.ActiveMenu = "MyBids"; Master.AddClientScriptInclude(@"dgDateManager.js"); }
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(@"CustomerId"), typeof(string))); dt.Columns.Add(new System.Data.DataColumn(BidString.GetText(@"CustomerName"), typeof(string))); dt.Columns.Add(new System.Data.DataColumn(BidString.GetText(@"Phone"), typeof(string))); dt.Columns.Add(new System.Data.DataColumn(BidString.GetText(@"CityName"), typeof(string))); dt.Columns.Add(new System.Data.DataColumn(BidString.GetText(@"OffersCount"), typeof(string))); dt.Columns.Add(new System.Data.DataColumn(BidString.GetText(@"SupplierName"), typeof(string))); dt.Columns.Add(new System.Data.DataColumn(BidString.GetText(@"Price"), typeof(string))); dt.Columns.Add(new System.Data.DataColumn(BidString.GetText(@"Products"), typeof(string))); dt.Columns.Add(new System.Data.DataColumn(BidString.GetText(@"OrderStatus"), typeof(string))); dt.Columns.Add(new System.Data.DataColumn(BidString.GetText(@"IsActive"), typeof(string))); DateTime from = new DateTime(), to = new DateTime(); DateTime.TryParse(dpSearchCreateDateFrom.Value.ToString(), out from); DateTime.TryParse(dpSearchCreateDateTo.Value.ToString(), out to); Int64 _BidId = -1; if (txtBidNumber.Text != "") { Int64.TryParse(txtBidNumber.Text, out _BidId); } List <BidUI> app_users = BidController.GetAllBids(filterSearch, from, to, txtSearchPhone.Text, txtCustomerId.Text, _BidId, txtCityName.Text); foreach (BidUI Bid in app_users) { int i = 0; System.Data.DataRow row = dt.NewRow(); row[i++] = Bid.BidId; row[i++] = "\"" + Bid.StartDate + "\""; row[i++] = "\"" + Bid.EndDate + "\""; row[i++] = Bid.CustomerId; row[i++] = Bid.CustomerType == CustomerType.Temp ? BidString.GetText("Temp"): Bid.CustomerName; row[i++] = Bid.Phone; row[i++] = Bid.City; row[i++] = Bid.OfferNum; row[i++] = Bid.SupplierName; row[i++] = Bid.Price; row[i++] = Bid.Products; row[i++] = Bid.OrderStatus == OrderDeliveryStatus.None?"": BidString.GetText(Bid.OrderStatus.ToString()).Replace("XXX", Bid.SuppliedDate.ToString()); row[i++] = GlobalStrings.GetYesNo(Bid.IsActive); dt.Rows.Add(row); } SpreadsheetWriter ex = SpreadsheetWriter.FromDataTable(dt, false, true); Response.Clear(); Response.AddHeader(@"content-disposition", @"attachment;filename=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(); }
protected void btnExportForCRM_Click(object sender, EventArgs e) { System.Data.DataTable dt = new System.Data.DataTable(); dt.Columns.Add(new System.Data.DataColumn(BidString.GetText(@"CustomerId"), typeof(string))); dt.Columns.Add(new System.Data.DataColumn(AppUsersStrings.GetText(@"FirstName"), typeof(string))); dt.Columns.Add(new System.Data.DataColumn(AppUsersStrings.GetText(@"LastName"), typeof(string))); dt.Columns.Add(new System.Data.DataColumn(AppUsersStrings.GetText(@"Email"), typeof(string))); dt.Columns.Add(new System.Data.DataColumn(BidString.GetText(@"Phone"), typeof(string))); dt.Columns.Add(new System.Data.DataColumn(AppUsersStrings.GetText(@"Address"), typeof(string))); dt.Columns.Add(new System.Data.DataColumn(BidString.GetText(@"CityName"), typeof(string))); dt.Columns.Add(new System.Data.DataColumn(AppUsersStrings.GetText(@"CreateDate"), typeof(string))); dt.Columns.Add(new System.Data.DataColumn(BidString.GetText(@"BidId"), typeof(string))); dt.Columns.Add(new System.Data.DataColumn(BidString.GetText(@"Products"), typeof(string))); dt.Columns.Add(new System.Data.DataColumn(BidString.GetText(@"Price"), typeof(string))); dt.Columns.Add(new System.Data.DataColumn(BidString.GetText(@"OrderDate"), typeof(string))); dt.Columns.Add(new System.Data.DataColumn(OrdersStrings.GetText(@"ActionType"), typeof(string))); DateTime from = new DateTime(), to = new DateTime(); DateTime.TryParse(dpSearchCreateDateFrom.Value.ToString(), out from); DateTime.TryParse(dpSearchCreateDateTo.Value.ToString(), out to); Int64 _BidId = -1; if (txtBidNumber.Text != "") { Int64.TryParse(txtBidNumber.Text, out _BidId); } List <BidUI> app_users = BidController.GetAllBids(filterSearch, from, to, txtSearchPhone.Text, txtCustomerId.Text, _BidId, txtCityName.Text); foreach (BidUI Bid in app_users) { int i = 0; System.Data.DataRow row = dt.NewRow(); var appUser = AppUser.FetchByID(Bid.CustomerId); row[i++] = Bid.CustomerId; row[i++] = Bid.CustomerType == CustomerType.Temp ? BidString.GetText("Temp") : appUser.FirstName; row[i++] = Bid.CustomerType == CustomerType.Temp ? BidString.GetText("Temp") : appUser.LastName; row[i++] = Bid.CustomerType == CustomerType.Temp ? BidString.GetText("Temp") : appUser.Email; row[i++] = Bid.CustomerType == CustomerType.Temp ? BidString.GetText("Temp") : "=\"" + appUser.Phone + "\""; row[i++] = Bid.CustomerType == CustomerType.Temp ? BidString.GetText("Temp") : appUser.Street + " " + appUser.HouseNum; row[i++] = Bid.City; row[i++] = Bid.CustomerType == CustomerType.Temp ? BidString.GetText("Temp") : appUser.CreateDate.ToString(); row[i++] = Bid.BidId; row[i++] = Bid.Products; row[i++] = Bid.Price; row[i++] = Bid.OrderDate; row[i++] = "רכישה"; dt.Rows.Add(row); } SpreadsheetWriter ex = SpreadsheetWriter.FromDataTable(dt, false, true); Response.Clear(); Response.AddHeader(@"content-disposition", @"attachment;filename=BidsExportForCRM_" + 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(); }