public JsonResult GetCustomers(Customers item) { try { IList <Customers> listData = new List <Customers>(); CustomersData data = new CustomersData(); listData = data.Get(item); var jsonResult = Json(new { data = listData, success = true }, JsonRequestBehavior.AllowGet); jsonResult.MaxJsonLength = int.MaxValue; return(jsonResult); } catch (Exception ex) { return(Json(new { success = false, errMsg = ex.Message }, JsonRequestBehavior.AllowGet)); } }
// GET: /Customers/GetDataPurchaseData/:id public JsonResult GetDataPurchaseData(int id) { try { IList <Customers> listData = new List <Customers>(); CustomersData data = new CustomersData(); listData = data.Get(id); ProductData dataPro = new ProductData(); IList <Products> listProduct = new List <Products>(); listProduct = dataPro.GetListProduct(); IList <ProductSelect> listProductsSelect = new List <ProductSelect>(); listProductsSelect = dataPro.GetProductCustomer(id, 0); return(Json(new { data = listData, dataProduct = listProduct, dataProductSelect = listProductsSelect, success = true }, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { return(Json(new { success = false, errMsg = ex.Message }, JsonRequestBehavior.AllowGet)); } }
// POST: /Customers/ExportCard public FileResult ExportCard(int ContractID, int CustomerID) { IList <Customers> listData = new List <Customers>(); CustomersData data = new CustomersData(); listData = data.Get(CustomerID); try { string yourcode = CustomerID + ":" + ContractID; string firstText = listData[0].CustomerName; string secondText = "(" + listData[0].CustomerNickName + ")"; PointF firstLocation = new PointF(550f, 250f); PointF secondLocation = new PointF(550f, 300f); string imageFilePath = Server.MapPath("~/Content/bg_1.png"); Bitmap bitmap = new Bitmap(1800, 1400); bitmap = (Bitmap)Image.FromFile(imageFilePath);//load the image file //string imageFilePath1 = Server.MapPath("~/Content/qr1.png"); //Bitmap bitmap1 = new Bitmap(400, 400); //bitmap1 = (Bitmap)Image.FromFile(imageFilePath1.ToString());//load the image file QRCodeEncoder enc = new QRCodeEncoder(); enc.QRCodeScale = 5; Bitmap qrcode = enc.Encode(yourcode); using (Graphics graphics = Graphics.FromImage(bitmap)) { using (Font arialFont = new Font("Cordia New", 30)) { graphics.DrawString(firstText, arialFont, Brushes.White, firstLocation); graphics.DrawString(secondText, new Font("Cordia New", 30), Brushes.White, secondLocation); graphics.DrawImage(qrcode.Clone(new Rectangle(0, 0, qrcode.Width - 1, qrcode.Height - 1), qrcode.PixelFormat), new Point(200, 200)); } } MemoryStream ms = new MemoryStream(); bitmap.Save(ms, System.Drawing.Imaging.ImageFormat.Png); bitmap.Save(Server.MapPath("~/Content/img1.jpg"), System.Drawing.Imaging.ImageFormat.Png); return(File(Server.MapPath("~/Content/img1.jpg"), System.Net.Mime.MediaTypeNames.Application.Octet, "MEMBER" + (CustomerID * 1000) + ContractID + ".png")); } catch (Exception) { throw; } }
// GET: /Customers/GetContract?CustomerID=id&ContractID=id public JsonResult GetContract(int CustomerID, int ContractID) { try { IList <Contract> listContract = new List <Contract>(); ContractData cd = new ContractData(); listContract = cd.GetContract(CustomerID, ContractID); IList <Customers> listData = new List <Customers>(); CustomersData dataCus = new CustomersData(); listData = dataCus.Get(CustomerID); ProductData dataPro = new ProductData(); IList <ProductSelect> listProductsSelect = new List <ProductSelect>(); IList <Products> listProduct = new List <Products>(); listProduct = dataPro.GetListProduct(); List <ProductSelect> listProductsSelect1 = new List <ProductSelect>(); if (ContractID > 0) { listProductsSelect = dataPro.GetProductCustomer(CustomerID, ContractID); } double ContractPayment = 0; listProductsSelect1 = dataPro.ProductContractSummary(ref ContractPayment, listProductsSelect); return(Json(new { data = listContract, dataCustomers = listData, dataProduct = listProduct, dataProductSelect = listProductsSelect1, success = true }, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { return(Json(new { data = ex.Message, success = false }, JsonRequestBehavior.AllowGet)); } }
public ActionResult ExportPDF(Customers item) { IList <Customers> listData = new List <Customers>(); CustomersData data = new CustomersData(); listData = data.Get(item); Dictionary <string, object> param = new Dictionary <string, object>(); param.Add("pCondition", listData[0].CustomerFirstName + " " + listData[0].CustomerLastName); param.Add("pAddress", " 100 ต.ควนมะพร้าว อ.เมืองพัทลุง จ.พัทลุง 10000 เบอร์โทร 081-476-2091"); Utility.ExportPDF( "RedemptionReport_" + DateTime.Now.ToString("yyyyMMdd_HHmmss"), "~/Report/CustomerReport.rpt", listData, param ); return(View()); }
public CustomersController() { Customers = CustomersData.Get(); }