public JsonResult insertItem(string itemID, string quoteID, int quantity) { _itemservice.UserVM = UserVM; bool itemidstatus = true; bool itemExist = false; ItemContainerService _itemContainerSrv = new ItemContainerService(); if (_iItemListViewService.CheckItemInMas(itemID)) { itemExist = true; List <string> lstPreviewableItemIds = _itemContainerSrv.GetPreviewableItemIDs(); QuoteViewService _QuoteViewService = new QuoteViewService(); int quotetypeID = _QuoteViewService.getQuoteTypeId(Convert.ToInt32(quoteID)); if (quotetypeID == (int)QuoteTypeEnum.Preview) { itemidstatus = lstPreviewableItemIds.Contains(itemID); } if (itemidstatus) { _itemservice.selectedOptions(itemID, quoteID, WebSecurity.CurrentUserId, "", quantity); this.AssignUserVM(_itemservice.UserVM); } } ActiveQuoteService aqs = new ActiveQuoteService(); RapidEntryModel rem = aqs.getRapidEntry(Convert.ToInt32(quoteID)); rem.ItemStatus = itemidstatus; rem.ItemExist = itemExist; return(Json(rem)); }
//[OutputCache(CacheProfile = "Aggressive", VaryByHeader = "X-Requested-With", Location = OutputCacheLocation.Any, NoStore = true)] private ActionResult ItemContainer(string quoteID, string type) { IQuoteViewService _QuoteViewSrv = new QuoteViewService(); _QuoteViewSrv.UserVM = UserVM; _itemcontainerPartialSrv.UserVM = UserVM; if (type == "View") { ViewData["SearchCategory"] = _QuoteViewSrv.getQuoteTypeText(Convert.ToInt32(quoteID)); QuoteViewModel qVM = _QuoteViewSrv.GetQuoteView(Convert.ToInt32(quoteID)); UserVM.SearchCategory = string.Empty; this.AssignUserVM(qVM.UserVM); return(View("../TCPViews/QuoteView", qVM)); } ViewData["QuoteID"] = quoteID; if (type == "Category") { CategoriesItemContainerViewModel categoriesItemCVM = new CategoriesItemContainerViewModel(); categoriesItemCVM.UserVM = UserVM; string noofItemsPerPage = "60"; categoriesItemCVM = _itemcontainerPartialSrv.GetSelectedCollectionItem((int)GroupEnum.EntirePenworthyCollection, 1, noofItemsPerPage, Convert.ToInt32(quoteID), ""); this.AssignUserVM(categoriesItemCVM.UserVM); return(View("../TCPViews/CategoriesItemContainer", categoriesItemCVM)); } KPLItemConatinerViewModel ciCVM = new KPLItemConatinerViewModel(); ciCVM.UserVM = UserVM; ciCVM = _itemcontainerPartialSrv.FillItemDetails(quoteID, type); this.AssignUserVM(ciCVM.UserVM); return(View("../TCPViews/KPLItemContainer", ciCVM)); }
private ItemListViewModel GetDWItemsList(int iD, string type, string ddlSelectedValue, string pgno, string selectionStatus, bool IsSingleView = false) { IQuoteViewService _QuoteViewSrv = new QuoteViewService(); _QuoteViewSrv.UserVM = UserVM; if (type == "Group") { ViewData["GroupName"] = _iItemListViewService.getGroupName(Convert.ToInt32(iD)); ViewData["QuoteType"] = type; } else { ViewData["QuoteType"] = type; ViewData["GroupName"] = Resources.TCPResources.AllText; ViewData["QuoteTitle"] = _QuoteViewSrv.getQuoteTitleText(Convert.ToInt32(iD)); } ViewData["SelectedStatus"] = selectionStatus; _iItemListViewService.UserVM = UserVM; ItemListViewModel iListVM = _iItemListViewService.GetDWItemsList(iD, type, ddlSelectedValue, Convert.ToInt32(pgno), selectionStatus, IsSingleView); if (IsSingleView == false) { iListVM.IsListView = true; iListVM.KPLItemListVM.ToList().ForEach(t => t.IsListView = true); } this.AssignUserVM(iListVM.UserVM); return(iListVM); }
public ActionResult GetSelectedCollectionItemByName(string groupName = "") { IQuoteViewService _quoteViewServ = new QuoteViewService(); int groupId = _quoteViewServ.getGroupId(groupName); return(GetSelectedCollectionItem(groupId, 1, "60")); }
private CategoriesItemContainerViewModel FillCategoriesItemConatinerViewModel(int groupID, int currentPageIndex, string noofItemsPerPage, string selectedPackageIdsList = "", int quoteID = 0) { CategoriesItemContainerViewModel categoriesItemCVM = new CategoriesItemContainerViewModel(); categoriesItemCVM.UserVM = UserVM; _itemcontainerPartialSrv.UserVM = UserVM; quoteID = UserVM == null ? 0 : ViewBag.Title == "Search" || quoteID == 0 ? UserVM.CurrentQuoteID : quoteID; categoriesItemCVM = _itemcontainerPartialSrv.GetSelectedCollectionItem(groupID, currentPageIndex, noofItemsPerPage, quoteID, selectedPackageIdsList); IQuoteViewService _QuoteViewSrv = new QuoteViewService(); _QuoteViewSrv.UserVM = UserVM; if (selectedPackageIdsList != "") { ViewData["grpIds"] = selectedPackageIdsList; } if (UserVM != null && UserVM.CurrentQuoteID != 0) { ViewData["QuoteType"] = _QuoteViewSrv.getQuoteTypeText(UserVM.CurrentQuoteID); ViewData["QuoteID"] = UserVM.CurrentQuoteID; ViewData["QuoteTitle"] = _QuoteViewSrv.getQuoteTitleText(Convert.ToInt32(UserVM.CurrentQuoteID)); } this.AssignUserVM(categoriesItemCVM.UserVM); return(categoriesItemCVM); }
public JsonResult UpdateQuantityByQuoteId(int currentQuoteId, int quantity) { ViewData["QuoteType"] = new QuoteViewService().getQuoteTypeText(currentQuoteId); _shoppingCartSrv.UserVM = UserVM; this.AssignUserVM(_shoppingCartSrv.UserVM); return(Json(_shoppingCartSrv.UpdateQuantityByQuoteId(currentQuoteId, quantity))); }
public ActionResult ViewEditQuote(string quoteDWID, string type) { IQuoteViewService _QuoteViewSrv = new QuoteViewService(); ViewData["QuoteID"] = quoteDWID; ViewData["QuoteType"] = _QuoteViewSrv.getQuoteTypeText(Convert.ToInt32(quoteDWID)); ViewData["QuoteTitle"] = _QuoteViewSrv.getQuoteTitleText(Convert.ToInt32(quoteDWID)); return(ItemContainer(quoteDWID, type)); }
public ActionResult ItemContainerDetails(string quoteID, string quoteType, string type) { IQuoteViewService _QuoteViewSrv = new QuoteViewService(); ViewData["QuoteType"] = _QuoteViewSrv.getQuoteTypeText(Convert.ToInt32(quoteID)); ViewData["QuoteTitle"] = _QuoteViewSrv.getQuoteTitleText(Convert.ToInt32(quoteID)); ViewData["QuoteID"] = quoteID; ViewData["SearchCategory"] = ViewData["QuoteType"]; return(ItemContainer(quoteID, type)); }
public ActionResult UpdateDWinSingleItemDetailedView(int DWID, int Qdid, string Itemid) { KPLBasedCommonViewModel kpl = new KPLBasedCommonViewModel(); kpl.QuoteID = Qdid; kpl.ItemID = Itemid; kpl.DWSelectionStatus = Convert.ToString(DWID); IQuoteViewService _QuoteViewSrv = new QuoteViewService(); ViewData["QuoteTitle"] = _QuoteViewSrv.getQuoteTitleText(Convert.ToInt32(Qdid)); return(View("../TCPViews/SingleItemDetailedView", _itemservice.UpdateDWSingleItemDetails(kpl))); }
public ActionResult ViewSingleDetailedItem(string itemID, string QuoteID, string groupID) { IQuoteViewService _QuoteViewSrv = new QuoteViewService(); _QuoteViewSrv.UserVM = UserVM; if (Roles.IsUserInRole("Repo") || Roles.IsUserInRole("AdminRep")) { ViewData["GroupID"] = groupID; ViewData["GroupName"] = _iItemListViewService.getGroupName(Convert.ToInt32(groupID)); ViewData["QuoteType"] = _QuoteViewSrv.getQuoteTypeText(Convert.ToInt32(QuoteID)); } ViewData["QuoteTitle"] = _QuoteViewSrv.getQuoteTitleText(Convert.ToInt32(QuoteID)); return(View("../TCPViews/SingleItemDetailedView", _itemservice.GetSingleItemDetailsWithSets(itemID, QuoteID))); }
public ActionResult ViewQuoteandDecisionWizard(string quoteID, string quoteType) { IQuoteViewService _QuoteViewSrv = new QuoteViewService(); _QuoteViewSrv.UserVM = UserVM; ViewData["QuoteType"] = quoteType; ViewData["QuoteID"] = quoteID; ViewData["QuoteTitle"] = _QuoteViewSrv.getQuoteTitleText(Convert.ToInt32(quoteID)); IShoppingCartService _shoppingCartSrv = new ShoppingCartService(); _shoppingCartSrv.UserVM = UserVM; if (quoteType == @Resources.TCPResources.DecisionWizardliText) { UserVM.SearchCategory = string.Empty; ShoppingCartViewModel scVM = _shoppingCartSrv.GetDWByClientID(UserVM.CRMModelProperties.LoggedINCustomerUserID.ToString(), Convert.ToInt32(quoteID)); this.AssignUserVM(scVM.UserVM); return(View("../TCPViews/RepoDecisionWizard", scVM)); } if (quoteType == @Resources.TCPResources.ShoppingCartliText) { return(View("../TCPViews/ShoppingCart", _shoppingCartSrv.GetShoppingCartViewByClientID(UserVM.CRMModelProperties.LoggedINCustomerUserID))); } int quoteid = Convert.ToInt32(quoteID); if (quoteID != null) { UserVM.SearchCategory = string.Empty; this.AssignUserVM(_QuoteViewSrv.UserVM); return(View("../TCPViews/QuoteView", _QuoteViewSrv.GetQuoteView(quoteid))); } else { UserVM.SearchCategory = string.Empty; this.AssignUserVM(_QuoteViewSrv.UserVM); return(View("../TCPViews/QuoteView", _QuoteViewSrv.GetQuoteView(UserVM.CurrentQuoteID))); } }
public ActionResult GetProducts(int groupID, int currentPageIndex, string noofItemsPerPage, string selectedPackageIdsList = "", int quoteID = 0, string searchText = "") { if (groupID == 0) { ViewBag.Title = "Search"; } if (WebSecurity.IsAuthenticated && UserVM != null) { UserVM.SearchCategory = searchText; } if (WebSecurity.IsAuthenticated) { QuoteViewService qvs = new QuoteViewService(); qvs.UserVM = UserVM; quoteID = qvs.getCustomerSCQuoteID(); } CategoriesItemContainerViewModel categoriesItemCVM = FillCategoriesItemConatinerViewModel(groupID, currentPageIndex, noofItemsPerPage, selectedPackageIdsList, quoteID); categoriesItemCVM.UserVM = UserVM; return(View("../TCPViews/Partial/CategoriesItemViewPartial", categoriesItemCVM.CategoriesPVM)); }
public ActionResult GetItemListView(int iD, string type) { if (type == "DefaultDW") { if (UserVM != null) { if (UserVM.DWDetails.Count > 1) { return(RedirectToAction("GetProducts", "ItemContainerPartial", new { groupID = (int)GroupEnum.EntirePenworthyCollection, currentPageIndex = 1, noofItemsPerPage = 60, quoteID = 0 })); } else { UserVM.CurrentQuoteID = UserVM.DWDetails.FirstOrDefault().Key; } } } if (type == "Group") { ViewData["GroupName"] = _iItemListViewService.getGroupName(Convert.ToInt32(iD)); ViewData["QuoteType"] = type; } else { IQuoteViewService _QuoteViewSrv = new QuoteViewService(); _QuoteViewSrv.UserVM = UserVM; ViewData["QuoteType"] = type; ViewData["GroupName"] = Resources.TCPResources.AllText; ViewData["QuoteTitle"] = _QuoteViewSrv.getQuoteTitleText(Convert.ToInt32(iD)); } _iItemListViewService.UserVM = UserVM; ItemListViewModel ivm = _iItemListViewService.GetListOfItems(Convert.ToInt32(iD), type, "10", 1, "5"); ViewData["QuoteTitle"] = ivm.QuoteTitle; this.AssignUserVM(ivm.UserVM); return(View("../TCPViews/ItemListView", ivm)); }
public ActionResult ItemContainer(FormCollection activeQuoteVM) { IQuoteViewService _QuoteViewSrv = new QuoteViewService(); IShoppingCartService _shoppingCartSrv = new ShoppingCartService(); IItemListViewService _iItemListViewService = new ItemListViewService(); _QuoteViewSrv.UserVM = UserVM; string selectedQuoteID = string.Empty; string quotetypeText = ""; if (activeQuoteVM != null) { if (activeQuoteVM.GetValues("assignChkBx") != null) { selectedQuoteID = activeQuoteVM.GetValues("assignChkBx").FirstOrDefault().Split('%')[0]; quotetypeText = activeQuoteVM.GetValues("assignChkBx").FirstOrDefault().Split('%')[1]; string totalItems = activeQuoteVM.GetValues("assignChkBx").FirstOrDefault().Split('%')[2]; string price = activeQuoteVM.GetValues("assignChkBx").FirstOrDefault().Split('%')[3]; ViewData["QuoteType"] = quotetypeText; ViewData["QuoteTitle"] = _QuoteViewSrv.getQuoteTitleText(Convert.ToInt32(selectedQuoteID)); ViewData["QuoteID"] = selectedQuoteID; ViewData["SearchCategory"] = quotetypeText; } } //Added for Exception when no Quotes are present if (selectedQuoteID == string.Empty) { selectedQuoteID = activeQuoteVM["DWQuoteID"]; } //For Active Quote View if (activeQuoteVM["View"] != null) { return(ItemContainer(selectedQuoteID, "View")); } //For DW View if (activeQuoteVM["DWView"] != null) { _shoppingCartSrv.UserVM = UserVM; ShoppingCartViewModel scVM = _shoppingCartSrv.GetDWByClientID(UserVM.CRMModelProperties.LoggedINCustomerUserID.ToString(), Convert.ToInt32(selectedQuoteID)); UserVM.SearchCategory = string.Empty; this.AssignUserVM(scVM.UserVM); return(View("../TCPViews/RepoDecisionWizard", scVM)); } //For Dw//Active Quote Filter View if (activeQuoteVM["Category"] != null) { return(ItemContainer(selectedQuoteID, "Category")); } //For Preview of DW if (activeQuoteVM["DetailList"] == Resources.TCPResources.DetailList) { ViewData["GroupName"] = activeQuoteVM["DetailList"]; _iItemListViewService.UserVM = UserVM; _QuoteViewSrv.UserVM = UserVM; ItemListViewModel itmLstVM = _iItemListViewService.GetDWItemsList(Convert.ToInt32(ViewData["QuoteID"]), Resources.TCPResources.DetailList, "10", 0, ""); itmLstVM.KPLItemListVM.ForEach(t => t.IsListView = true); itmLstVM.IsListView = true; this.AssignUserVM(itmLstVM.UserVM); return(View("../TCPViews/CustDecisionWizardView", itmLstVM)); } //Default is for KPL-Item List return(ItemContainer(selectedQuoteID, "KPL")); }
public QuoteViewController(QuoteViewService QuoteViewSrv) { _QuoteViewSrv = QuoteViewSrv; _QuoteViewSrv.UserVM = UserVM; }
public void Export(int QuoteID) { IQuoteViewService _quoteviewservice = new QuoteViewService(); int Quotetypeid = _quoteviewservice.getQuoteTypeId(QuoteID); string userSelection = null; List <CartDWPdfModel> orderVM = new List <CartDWPdfModel>(); _shoppingCartSrv.UserVM = UserVM; orderVM.Add(_shoppingCartSrv.GetQuotePdfDetails(QuoteID)); int shpId = Convert.ToInt32(TPC.Common.Enumerations.QuoteTypeEnum.ShoppingCart); int DWId = Convert.ToInt32(TPC.Common.Enumerations.QuoteTypeEnum.DecisionWhizard); if (Quotetypeid == shpId) { userSelection = Resources.TCPResources.ShoppingCartuserSelection; } if (Quotetypeid == DWId) { userSelection = Resources.TCPResources.DWuserSelection; } if (Quotetypeid == Convert.ToInt32(TPC.Common.Enumerations.QuoteTypeEnum.Direct) || Quotetypeid == Convert.ToInt32(TPC.Common.Enumerations.QuoteTypeEnum.Preview) || Quotetypeid == Convert.ToInt32(TPC.Common.Enumerations.QuoteTypeEnum.Web)) { userSelection = Resources.TCPResources.QuoteuserSelection; } string[] preferences = string.IsNullOrEmpty(userSelection) ? null : userSelection.Split(','); var Controller = DependencyResolver.Current.GetService <DefaultController>(); System.Data.DataTable dt = new System.Data.DataTable(); if (preferences != null) { dt = Controller.ConvertToDataTable(orderVM.FirstOrDefault().CartListView, preferences); } StringBuilder sb = new StringBuilder(); string headerText = string.Format(Resources.TCPResources.QuoteEmailExcelHeaderTable, ConfigurationManager.AppSettings["imgLogoPath"], string.Format("{0:d}", DateTime.Today), UserVM.CurrentQuoteID, UserVM.CRMModelProperties.CustNO, UserVM.CRMModelProperties.RepName, UserVM.CRMModelProperties.custName, UserVM.CRMModelProperties.RepEmail, UserVM.CRMModelProperties.CustFirstName + ' ' + UserVM.CRMModelProperties.CustLastName); sb.Append(headerText); sb.Append("<table style=\"border-collapse:collapse;\">"); sb.Append("<tr>"); foreach (System.Data.DataColumn dc in dt.Columns) { if (dc.ToString().Trim() == "DwstatusID") { sb.Append("<td><b><font face=Arial size=2>" + "Sts" + "</font></b></td>"); } else if (dc.ToString().Trim() == "Price") { sb.Append("<td><b><font face=Arial size=2>" + "Total" + "</font></b></td>"); } else if (dc.ToString().ToLower().Trim() == "itemid") { sb.Append("<td style='width:10px;text-align: center;'><font face=Arial size=" + "14px" + ">" + "ItemID" + "</font></td>"); } else if (dc.ToString().ToLower().Trim() == "ar") { sb.Append("<td style='width:10px;text-align: center;'><font face=Arial size=" + "14px" + ">" + "AR" + "</font></td>"); } else if (dc.ToString().ToLower().Trim() == "lexile") { sb.Append("<td style='width:10px;text-align: center;'><font face=Arial size=" + "14px" + ">" + "Lexile" + "</font></td>"); } else if (dc.ColumnName.ToLower().Trim() != "type") { sb.Append("<td><b><font face=Arial size=2>" + dc.ColumnName + "</font></b></td>"); } } sb.Append("</tr>"); foreach (System.Data.DataRow dr in dt.Rows) { sb.Append("<tr>"); foreach (System.Data.DataColumn dc in dt.Columns) { if (dc.ToString().Trim() == "DwstatusID") { string DWstatus = Convert.ToInt32(dr[dc]) == (int)DecisionWhizardStatusEnum.New ? DecisionWhizardStatusEnum.New.ToString() : Convert.ToInt32(dr[dc]) == (int)DecisionWhizardStatusEnum.Yes ? DecisionWhizardStatusEnum.Yes.ToString() : Convert.ToInt32(dr[dc]) == (int)DecisionWhizardStatusEnum.No ? DecisionWhizardStatusEnum.No.ToString() : DecisionWhizardStatusEnum.MayBe.ToString(); sb.Append("<td><font face=Arial size=" + "14px" + ">" + DWstatus + "</font></td>"); } else if (dc.ToString().Trim() == "ISBN") { sb.Append("<td><font face=Arial size=2>" + dr[dc] + " </font></td>"); } else if (dc.ColumnName.ToLower().Trim() == "title" && dr["Type"] != "Catalog") { sb.Append("<td><b><font face=Arial size=" + "10px" + "><a href =" + ConfigurationManager.AppSettings["imgLogoPath"] + ">" + dr[dc] + "</a></font></b></td>"); } else if (dc.ToString().ToLower().Trim() == "price") { sb.Append("<td>" + String.Format("{0:C}", dr[dc]) + "</td>"); } else if (dc.ToString().ToLower().Trim() == "itemprice") { sb.Append("<td>" + String.Format("{0:C}", dr[dc]) + "</td>"); } else if (dc.ToString().ToLower().Trim() == "itemid" || dc.ToString().ToLower().Trim() == "ar" || dc.ToString().ToLower().Trim() == "lexile") { sb.Append("<td style='width:10px;text-align: center;'><font face=Arial size=" + "14px" + ">" + dr[dc].ToString() + "</font></td>"); } else if (dc.ColumnName.ToLower().Trim() != "type") { sb.Append("<td><font face=Arial size=" + "14px" + ">" + dr[dc].ToString() + "</font></td>"); } } sb.Append("</tr>"); } double totalPrice = orderVM.FirstOrDefault().CartListView.Sum(e => e.Price); double SalesTax = 0; if (orderVM.FirstOrDefault().SalesTax > 0) { SalesTax = (totalPrice * (double)orderVM.FirstOrDefault().SalesTax); } string footerText = string.Format(Resources.TCPResources.QuoteEmailExcelFooter, preferences.Length - 2, String.Format("{0:C}", SalesTax), String.Format("{0:C}", SalesTax + totalPrice)); sb.Append(footerText); sb.Append("</table>"); byte[] buffer = System.Text.Encoding.UTF8.GetBytes(sb.ToString()); Response.Clear(); Response.ClearHeaders(); Response.ClearContent(); Response.ContentType = "application/vnd.ms-excel"; Response.AddHeader("Content-Disposition", "attachment; filename=download.xls"); Response.BinaryWrite(buffer); Response.End(); Response.Close(); }
public ActionResult ExportItemListToExcel() { IQuoteViewService _QuoteViewSrv = new QuoteViewService(); _QuoteViewSrv.UserVM = UserVM; ViewData["QuoteType"] = _QuoteViewSrv.getQuoteTypeText(UserVM.CurrentQuoteID); KPLItemConatinerViewModel lstkplVM = new KPLItemConatinerViewModel(); lstkplVM.UserVM = UserVM; _itemcontainerPartialSrv.UserVM = UserVM; lstkplVM = _itemcontainerPartialSrv.FillItemDetails(UserVM.CurrentQuoteID.ToString(), _QuoteViewSrv.getQuoteTypeText(UserVM.CurrentQuoteID).ToString()); string userSelection = string.Empty; if (lstkplVM.UserVM.Preferences.Count() == 0) { lstkplVM.UserVM.Preferences.Add("TabularItemPartial", Resources.TCPResources.DefaultKPLValues); } foreach (KeyValuePair <string, string> item in lstkplVM.UserVM.Preferences) { userSelection = string.IsNullOrEmpty(item.Value) ? null : "IsChecked," + item.Value; } string[] preferences = string.IsNullOrEmpty(userSelection) ? null : userSelection.Split(','); var Controller = DependencyResolver.Current.GetService <TPC.Web.Controllers.TCPControllers.DefaultController>(); System.Data.DataTable dt = Controller.ConvertToDataTable(lstkplVM.KPLBasedVM, preferences); System.Text.StringBuilder sb = new System.Text.StringBuilder(); string headerText = string.Format(Resources.TCPResources.QuoteEmailExcelHeaderTable, ConfigurationManager.AppSettings["imgLogoPath"], string.Format("{0:d}", DateTime.Today), UserVM.CurrentQuoteID, UserVM.CRMModelProperties.CustNO, UserVM.CRMModelProperties.RepName, UserVM.CRMModelProperties.custName, UserVM.CRMModelProperties.RepEmail, UserVM.CRMModelProperties.CustFirstName + ' ' + UserVM.CRMModelProperties.CustLastName); sb.Append(headerText); sb.Append("<table style=\"border-collapse:collapse;\">"); //write column headings sb.Append("<tr>"); foreach (System.Data.DataColumn dc in dt.Columns) { if (dc.ColumnName.ToLower().Trim() == "series" || dc.ColumnName.ToLower().Trim() == "title" || dc.ColumnName.ToLower().Trim() == "primarycharacter") { sb.Append("<td><b><font face=Arial size=" + "10px" + ">" + "X " + "</font></b></td>"); } if (dc.ColumnName.ToLower().Trim() == "ischecked") { sb.Append("<td><font face=Arial size=" + "10px" + ">" + "Select" + "</font></td>"); } else { sb.Append("<td><b><font face=Arial size=" + "10px" + ">" + dc.ColumnName + "</font></b></td>"); } } sb.Append("</tr>"); //write table data foreach (System.Data.DataRow dr in dt.Rows) { sb.Append("<tr>"); foreach (System.Data.DataColumn dc in dt.Columns) { if (dc.ToString().ToLower().Trim() == "title") { if (lstkplVM.KPLBasedVM.Single(x => x.ItemID == dr["ItemId"].ToString()).IsInCustomerTitles) { sb.Append("<td><font face=Arial size=" + "10px" + ">" + "X" + "</font></td>"); } else { sb.Append("<td><font face=Arial size=" + "10px" + ">" + "" + "</font></td>"); } } else { //sb.Append("<td><font face=Arial size=" + "10px" + ">" + "" + "</font></td>"); if (dc.ToString().ToLower() == "primarycharacter") { if (lstkplVM.KPLBasedVM.Single(x => x.ItemID == dr["ItemId"].ToString()).CharecterBroughtBefore) { sb.Append("<td><font face=Arial size=" + "10px" + ">" + "X" + "</font></td>"); } else { sb.Append("<td><font face=Arial size=" + "10px" + ">" + "" + "</font></td>"); } } if (dc.ToString().ToLower().Trim() == "series") { if (lstkplVM.KPLBasedVM.Single(x => x.ItemID == dr["ItemId"].ToString()).SeriesBroughtBefore) { sb.Append("<td><font face=Arial size=" + "10px" + ">" + "X" + "</font></td>"); } else { sb.Append("<td><font face=Arial size=" + "10px" + ">" + "" + "</font></td>"); } } } if (dc.ToString().ToLower().Trim() == "ischecked") { if (dr[dc].ToString() == "checked") { sb.Append("<td><font face=Arial size=" + "10px" + ">" + "X" + "</font></td>"); } else { sb.Append("<td><font face=Arial size=" + "10px" + ">" + "" + "</font></td>"); } } else if (dc.ToString().ToLower().Trim() == "price") { sb.Append("<td>" + String.Format("{0:0.00}", dr[dc].ToString()) + "</td>"); } else { sb.Append("<td><font face=Arial size=" + "10px" + ">" + dr[dc].ToString() + " </font></td>"); } } sb.Append("</tr>"); } sb.Append("</table>"); this.Response.AddHeader("Content-Disposition", "attachment; filename=ItemList.xls"); this.Response.ContentType = "application/vnd.ms-excel"; byte[] buffer = System.Text.Encoding.UTF8.GetBytes(sb.ToString()); return(File(buffer, "application/vnd.ms-excel")); }