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 btnExport_Click(object sender, EventArgs e) { System.Data.DataTable dt = new System.Data.DataTable(); dt.Columns.Add(new System.Data.DataColumn(SupplierProfileStrings.GetText(@"OrderId"), typeof(string))); dt.Columns.Add(new System.Data.DataColumn(SupplierProfileStrings.GetText(@"OrderDate"), typeof(string))); dt.Columns.Add(new System.Data.DataColumn(SupplierProfileStrings.GetText(@"BidId"), typeof(string))); dt.Columns.Add(new System.Data.DataColumn(SupplierProfileStrings.GetText(@"TotalPrice"), typeof(string))); dt.Columns.Add(new System.Data.DataColumn(SupplierProfileStrings.GetText(@"ApprovedDeal"), typeof(string))); dt.Columns.Add(new System.Data.DataColumn(SupplierProfileStrings.GetText(@"DealDetails"), typeof(string))); int year = Convert.ToInt32(ddlyear.SelectedValue); int month = Convert.ToInt32(ddlMonth.SelectedValue); int from = Convert.ToInt32(ddlDayFrom.SelectedValue); int to = Convert.ToInt32(ddlDayTo.SelectedValue); DateTime?start = null; DateTime?end = null; if (year != 0 && month != 0 && from != 0) { start = new DateTime(year, month, from); end = (to != 0 ? new DateTime(year, month, to) : end = new DateTime(year, month, DateTime.DaysInMonth(year, month))); } else if (year != 0 && month != 0) { start = new DateTime(year, month, 1); end = new DateTime(year, month, DateTime.DaysInMonth(year, month)); } else if (year != 0) { start = new DateTime(year, 1, 1); end = new DateTime(year, 12, 31); } List <OrderUI> orders = OrderController.GetOrderSupplierHistoryExcel(SuppliersSessionHelper.SupplierId(), start, end); foreach (OrderUI order in orders) { int i = 0; System.Data.DataRow row = dt.NewRow(); row[i++] = order.OrderId; row[i++] = order.OrderDate; row[i++] = order.BidId; row[i++] = order.Price; row[i++] = GlobalStrings.GetYesNo(order.IsPayed); row[i++] = ListTostring(order.LstProduct); dt.Rows.Add(row); } SpreadsheetWriter ex = SpreadsheetWriter.FromDataTable(dt, true, true); Response.Clear(); Response.AddHeader(@"content-disposition", @"attachment;filename=Deals_" + 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 btnExport_Click(object sender, EventArgs e) { System.Data.DataTable dt = new System.Data.DataTable(); dt.Columns.Add(new System.Data.DataColumn(AppUsersStrings.GetText(@"Email"), 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(@"IsLocked"), typeof(string))); dt.Columns.Add(new System.Data.DataColumn(AppUsersStrings.GetText(@"Phone"), typeof(string))); dt.Columns.Add(new System.Data.DataColumn(AppUsersStrings.GetText(@"Address"), typeof(string))); dt.Columns.Add(new System.Data.DataColumn(AppUsersStrings.GetText(@"IsAdv"), typeof(string))); dt.Columns.Add(new System.Data.DataColumn(AppUsersStrings.GetText(@"LastLogin"), typeof(string))); dt.Columns.Add(new System.Data.DataColumn(AppUsersStrings.GetText(@"CreateDate"), typeof(string))); dt.Columns.Add(new System.Data.DataColumn(AppUsersStrings.GetText(@"UserId"), typeof(string))); string searchName = "%" + txtSearchName.Text.Trim() + "%"; string searchPhone = "%" + txtSearchPhone.Text.Trim() + "%"; DateTime from, to = new DateTime(); DateTime.TryParse(dpSearchCreateDateFrom.Value.ToString(), out from); DateTime.TryParse(dpSearchCreateDateTo.Value.ToString(), out to); List <AppUserUI> app_users = AppUserUI.GetAllAppUserUI(from, to, searchName, searchPhone); foreach (AppUserUI appUser in app_users) { System.Data.DataRow row = dt.NewRow(); row[0] = appUser.Email; row[1] = appUser.FirstName; row[2] = appUser.LastName; row[3] = GlobalStrings.GetYesNo(appUser.IsLocked); row[4] = "\"" + appUser.Phone + "\""; row[5] = appUser.Street + " " + appUser.HouseNum + "\n" + AppUsersStrings.GetText(@"Floor") + " " + appUser.Floor + "\n" + AppUsersStrings.GetText(@"ApartmentNumber") + " " + appUser.ApartmentNumber + "\n" + appUser.CityName; row[6] = GlobalStrings.GetYesNo(appUser.IsAdv); row[7] = "\"" + appUser.LastLogin + "\""; row[8] = "\"" + appUser.CreateDate + "\""; row[9] = "\"" + appUser.AppUserId + "\""; dt.Rows.Add(row); } SpreadsheetWriter ex = SpreadsheetWriter.FromDataTable(dt, false, true); Response.Clear(); Response.AddHeader(@"content-disposition", @"attachment;filename=AppUsersExport_" + 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 btnExport_Click(object sender, EventArgs e) { System.Data.DataTable dt = new System.Data.DataTable(); dt.Columns.Add(new System.Data.DataColumn(OrdersStrings.GetText(@"BidId"), typeof(string))); dt.Columns.Add(new System.Data.DataColumn(OrdersStrings.GetText(@"BidEndDate"), typeof(string))); dt.Columns.Add(new System.Data.DataColumn(OrdersStrings.GetText(@"LstProducts"), typeof(string))); dt.Columns.Add(new System.Data.DataColumn(OrdersStrings.GetText(@"Gift"), typeof(string))); dt.Columns.Add(new System.Data.DataColumn(OrdersStrings.GetText(@"DonationPrice"), typeof(string))); dt.Columns.Add(new System.Data.DataColumn(OrdersStrings.GetText(@"TotalPrice"), typeof(string))); dt.Columns.Add(new System.Data.DataColumn(OrdersStrings.GetText(@"PrecentDiscount"), typeof(string))); dt.Columns.Add(new System.Data.DataColumn(OrdersStrings.GetText(@"PriceAfterDiscount"), typeof(string))); dt.Columns.Add(new System.Data.DataColumn(OrdersStrings.GetText(@"CampaignName"), typeof(string))); dt.Columns.Add(new System.Data.DataColumn(OrdersStrings.GetText(@"IsSendReceived"), typeof(string))); dt.Columns.Add(new System.Data.DataColumn(OrdersStrings.GetText(@"OrderDate1"), typeof(string))); DateTime from, to = new DateTime(); DateTime.TryParse(datepickerFrom.Value.ToString(), out from); DateTime.TryParse(datepickerTo.Value.ToString(), out to); string SearchBid = "%" + txtSearchBid.Text.Trim() + "%"; List <OrderUI> orders = OrderController.GetAllAppUserOrders(AppUserId, from, to, SearchBid); foreach (OrderUI order in orders) { System.Data.DataRow row = dt.NewRow(); row[0] = order.BidId; row[1] = "\"" + order.BidEndDate + "\""; row[2] = (order.LstProduct.Count == 0 || order.LstProduct == null) ? "" : String.Join(", ", order.LstProduct.Select(p => p.Amount + " " + p.ProductName)); row[3] = order.Gift; row[4] = order.DonationPrice; row[5] = order.TotalPrice; row[6] = order.PrecentDiscount + "%"; row[7] = order.PriceAfterDiscount; row[8] = order.CampaignName; row[9] = GlobalStrings.GetYesNo(order.IsSendReceived); row[10] = "\"" + order.OrderDate + "\""; dt.Rows.Add(row); } System.Data.DataRow sumRow = dt.NewRow(); dt.Rows.Add(sumRow); System.Data.DataRow sumRowTotalPrice = dt.NewRow(); sumRowTotalPrice[0] = OrdersStrings.GetText(@"SumTotalPrice") + " " + orders.Sum(o => o.TotalPrice); dt.Rows.Add(sumRowTotalPrice); System.Data.DataRow sumRowPriceAfterDiscount = dt.NewRow(); sumRowPriceAfterDiscount[0] = OrdersStrings.GetText(@"SumPriceAfterDiscount") + " " + orders.Sum(o => o.PriceAfterDiscount); dt.Rows.Add(sumRowPriceAfterDiscount); System.Data.DataRow sumRowSumDonation = dt.NewRow(); sumRowSumDonation[0] = OrdersStrings.GetText(@"SumDonation") + " " + orders.Sum(o => o.DonationPrice); dt.Rows.Add(sumRowSumDonation); SpreadsheetWriter ex = SpreadsheetWriter.FromDataTable(dt, false, true); Response.Clear(); Response.AddHeader(@"content-disposition", @"attachment;filename=AppUserOrdersExport_" + "AppUserId:" + AppUserId + "_Date:" + 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 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 btnExport_Click(object sender, EventArgs e) { System.Data.DataTable dt = new System.Data.DataTable(); dt.Columns.Add(new System.Data.DataColumn(OrdersStrings.GetText(@"SupplierId"), typeof(string))); dt.Columns.Add(new System.Data.DataColumn(OrdersStrings.GetText(@"SupplierName"), typeof(string))); dt.Columns.Add(new System.Data.DataColumn(OrdersStrings.GetText(@"BidId"), typeof(string))); dt.Columns.Add(new System.Data.DataColumn(OrdersStrings.GetText(@"BidEndDate"), typeof(string))); dt.Columns.Add(new System.Data.DataColumn(OrdersStrings.GetText(@"DonationPrice"), typeof(string))); dt.Columns.Add(new System.Data.DataColumn(OrdersStrings.GetText(@"TotalPrice"), typeof(string))); dt.Columns.Add(new System.Data.DataColumn(OrdersStrings.GetText(@"PrecentDiscount"), typeof(string))); dt.Columns.Add(new System.Data.DataColumn(OrdersStrings.GetText(@"PriceAfterDiscount"), typeof(string))); dt.Columns.Add(new System.Data.DataColumn(SuppliersStrings.GetText(@"Precent"), typeof(string))); dt.Columns.Add(new System.Data.DataColumn(OrdersStrings.GetText(@"PaymentForSupplier"), typeof(string))); dt.Columns.Add(new System.Data.DataColumn(OrdersStrings.GetText(@"IsSendReceived"), typeof(string))); dt.Columns.Add(new System.Data.DataColumn(OrdersStrings.GetText(@"OrderDate"), typeof(string))); dt.Columns.Add(new System.Data.DataColumn(OrdersStrings.GetText(@"TransactionStatus"), typeof(string))); dt.Columns.Add(new System.Data.DataColumn(OrdersStrings.GetText(@"PaySupplierStatus"), typeof(string))); dt.Columns.Add(new System.Data.DataColumn(OrdersStrings.GetText(@"Remarks"), typeof(string))); DateTime from, to = new DateTime(); if (DateTime.TryParse(datepickerFrom.Value.ToString(), out from)) { TimeSpan tsFrom = new TimeSpan(TimeSelectorFrom.Hour, TimeSelectorFrom.Minute, 0); from = from.Date + tsFrom; } if (DateTime.TryParse(datepickerTo.Value.ToString(), out to)) { TimeSpan tsTo = new TimeSpan(TimeSelectorTo.Hour, TimeSelectorTo.Minute, 0); to = to.Date + tsTo; } List <Int64> SuppliersIdList = FillSupplierList(); List <bool> IsReceivedSendDate = FillIsSendReceived(); List <int> StatusIdList = FillStatusList(); List <int> StatusPayementIdList = FillPayementStatusList(); string SearchBid = "%" + txtSearchBid.Text.Trim() + "%"; List <OrderUI> orders = OrderController.GetAllOrders(from, to, SuppliersIdList, IsReceivedSendDate, StatusIdList, StatusPayementIdList, SearchBid); foreach (OrderUI order in orders) { System.Data.DataRow row = dt.NewRow(); row[0] = order.SupplierId; row[1] = order.SupplierName; row[2] = order.BidId; row[3] = "\"" + order.BidEndDate + "\""; row[4] = order.DonationPrice; row[5] = order.TotalPrice; row[6] = order.PrecentDiscount + "%"; row[7] = order.PriceAfterDiscount; row[8] = order.Precent + "%"; row[9] = order.PaymentForSupplier; row[10] = GlobalStrings.GetYesNo(order.IsSendReceived); row[11] = "\"" + order.OrderDate + "\""; row[12] = OrdersStrings.GetText(Enum.GetName(typeof(OrderStatus), order.TransactionStatus)); row[13] = OrdersStrings.GetText(Enum.GetName(typeof(PaymentStatus), order.PaySupplierStatus));; row[14] = order.Remarks; dt.Rows.Add(row); } System.Data.DataRow sumRow = dt.NewRow(); dt.Rows.Add(sumRow); System.Data.DataRow sumRowTotalPrice = dt.NewRow(); sumRowTotalPrice[0] = OrdersStrings.GetText(@"SumTotalPrice") + " " + orders.Sum(o => o.TotalPrice); dt.Rows.Add(sumRowTotalPrice); System.Data.DataRow sumRowPriceAfterDiscount = dt.NewRow(); sumRowPriceAfterDiscount[0] = OrdersStrings.GetText(@"SumPriceAfterDiscount") + " " + orders.Sum(o => o.PriceAfterDiscount); dt.Rows.Add(sumRowPriceAfterDiscount); System.Data.DataRow sumRowSumPaymentForSupplier = dt.NewRow(); sumRowSumPaymentForSupplier[0] = OrdersStrings.GetText(@"SumPaymentForSupplier") + " " + orders.Sum(o => o.PaymentForSupplier); dt.Rows.Add(sumRowSumPaymentForSupplier); System.Data.DataRow sumRowSumDonation = dt.NewRow(); sumRowSumDonation[0] = OrdersStrings.GetText(@"SumDonation") + " " + orders.Sum(o => o.DonationPrice); dt.Rows.Add(sumRowSumDonation); SpreadsheetWriter ex = SpreadsheetWriter.FromDataTable(dt, false, true); Response.Clear(); Response.AddHeader(@"content-disposition", @"attachment;filename=OrdersExport_" + 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(); }