public ActionResult Add(ProductCategoryModel pcm) { CommonDataService cds = new CommonDataService(); CommonModel cm = new CommonModel(); cm = cds.GenerateCommonModel(); Session["FaceBook"] = cm.FaceBook; Session["Twitter"] = cm.Twitter; Session["Youtube"] = cm.Youtube; Session["Instagram"] = cm.Instagram; Session["PhoneNumber"] = cm.PhoneNumber; Session["Email"] = cm.Email; Session["ShoppingHours"] = cm.ShoppingHours; PriceDataService dataService = new PriceDataService(); try { dataService.InsertProductCategory(pcm); return RedirectToAction("Edit", "Price"); } catch (Exception ex) { throw ex; } finally { dataService = null; } }
public ActionResult AddHeader(string tableHeader, int productCategoryId) { CommonDataService cds = new CommonDataService(); CommonModel cm = new CommonModel(); cm = cds.GenerateCommonModel(); Session["FaceBook"] = cm.FaceBook; Session["Twitter"] = cm.Twitter; Session["Youtube"] = cm.Youtube; Session["Instagram"] = cm.Instagram; Session["PhoneNumber"] = cm.PhoneNumber; Session["Email"] = cm.Email; Session["ShoppingHours"] = cm.ShoppingHours; PriceDataService dataService = new PriceDataService(); ProductHeaderModel model = new ProductHeaderModel(); try { model.ProductCategoryId = productCategoryId; model.ProductTableTitleDescription = tableHeader; dataService.InsertProductHeader(model); return RedirectToAction("Edit", "Price"); } catch (Exception ex) { throw ex; } finally { dataService = null; } }
// GET: Price public ActionResult Index() { CommonDataService cds = new CommonDataService(); CommonModel cm = new CommonModel(); cm = cds.GenerateCommonModel(); Session["FaceBook"] = cm.FaceBook; Session["Twitter"] = cm.Twitter; Session["Youtube"] = cm.Youtube; Session["Instagram"] = cm.Instagram; Session["PhoneNumber"] = cm.PhoneNumber; Session["Email"] = cm.Email; Session["ShoppingHours"] = cm.ShoppingHours; List<ProductCategoryModel> viewModel = new List<ProductCategoryModel>(); PriceDataService dataService = new PriceDataService(); try { viewModel = dataService.GenerateProductCategoryModel(); return View(viewModel); } catch (Exception ex) { throw ex; } finally { dataService = null; } }
public ActionResult EditPrice(PriceListModel plm) { CommonDataService cds = new CommonDataService(); CommonModel cm = new CommonModel(); cm = cds.GenerateCommonModel(); Session["FaceBook"] = cm.FaceBook; Session["Twitter"] = cm.Twitter; Session["Youtube"] = cm.Youtube; Session["Instagram"] = cm.Instagram; Session["PhoneNumber"] = cm.PhoneNumber; Session["Email"] = cm.Email; Session["ShoppingHours"] = cm.ShoppingHours; PriceDataService dataService = new PriceDataService(); PriceListModel model = new PriceListModel(); try { if (ModelState.IsValid) { model.PriceListId = plm.PriceListId; model.ProductName = plm.ProductName; model.ProductDescription = plm.ProductDescription; model.Price = plm.Price; dataService.UpdatePriceList(model); return RedirectToAction("Edit", "Price"); } else { return View(plm); } } catch (Exception ex) { throw ex; } finally { dataService = null; } }
public ActionResult EditPrice(int priceListId) { CommonDataService cds = new CommonDataService(); CommonModel cm = new CommonModel(); cm = cds.GenerateCommonModel(); Session["FaceBook"] = cm.FaceBook; Session["Twitter"] = cm.Twitter; Session["Youtube"] = cm.Youtube; Session["Instagram"] = cm.Instagram; Session["PhoneNumber"] = cm.PhoneNumber; Session["Email"] = cm.Email; Session["ShoppingHours"] = cm.ShoppingHours; PriceDataService dataService = new PriceDataService(); PriceListModel model = new PriceListModel(); try { model = dataService.GetPriceListById(priceListId); return View(model); } catch (Exception ex) { throw ex; } finally { dataService = null; } }
// GET: Forms public ActionResult Index() { PriceDataService dataService = new PriceDataService(); //dataService.CreateOrderForm(); List<ProductCategoryModel> modelList = new List<ProductCategoryModel>(); modelList = dataService.GenerateProductCategoryModel(); Response.ClearContent(); Response.Buffer = true; Response.AddHeader("content-disposition", "attachment; filename=OrderForm.doc"); Response.ContentType = "application/vnd.ms-word "; Response.Charset = string.Empty; StringWriter sw = new StringWriter(); StringBuilder sb = new StringBuilder(); sb.AppendLine("<h1>ORDER FORM</h1>"); sb.AppendLine("<h2> FREE DELIVERY 20KG MINIMUM</h2>"); sb.AppendLine("<h2>NAME :</h2>"); sb.AppendLine("<h2>COMPANY:</h2>"); sb.AppendLine("<h2>ADDRESS:</h2>"); sb.AppendLine("<h2>CONTACT NO.</h2>"); sb.AppendLine("<style>table, th, td {border: 1px solid black;}</style><div class=row>"); foreach (var item in modelList) { sb.AppendLine("<div class=col-lg-12>"); sb.AppendLine("<h2>" + item.ProductCategory + "</h2>"); sb.AppendLine("</div>"); sb.AppendLine("<table width=100%>"); sb.AppendLine("<thead>"); sb.AppendLine("<tr><th>Product Name</th><th>Product Description</th><th>Price</th><th>Quantity</th></tr></thead><tbody>"); if (item.PriceListModel.Count > 0) { foreach (var item3 in item.PriceListModel) { sb.AppendLine("<tr>"); sb.AppendLine("<td>" + item3.ProductName + "</td>"); sb.AppendLine("<td>" + item3.ProductDescription + "</td>"); sb.AppendLine("<td>" + item3.Price + "</td>"); sb.AppendLine("<td></td>"); sb.AppendLine("</tr>"); } } sb.AppendLine("</tbody>"); sb.AppendLine("</table>"); } sb.AppendLine("</div>"); sb.AppendLine("<h2>TOTAL ORDER AMOUNT =</h2>"); //HtmlTextWriter htw = new HtmlTextWriter(sw); //gv.RenderControl(htw); Response.Output.Write(sb.ToString()); Response.Flush(); Response.End(); return RedirectToAction("Index", "Products"); //return new FilePathResult("~/DownloadableForms/OrderForm.docx", System.Net.Mime.MediaTypeNames.Application.Octet); //return File("/DownloadableForms/OrderForm.doc", System.Net.Mime.MediaTypeNames.Application.Octet); }