public JsonResult clearsession(OrderPrint orderPrint, OrderDetailPrint orderDetailPrint) { var searchOrPrintId = _graphiczoneDBContext.OrderPrint.Where(x => x.OrPrintId == orderPrint.OrPrintId).FirstOrDefault(); if (searchOrPrintId != null) { var searchOrdPrintId = _graphiczoneDBContext.OrderDetailPrint.Where(y => y.OrPrintId == searchOrPrintId.OrPrintId).FirstOrDefault(); if (searchOrdPrintId != null) { var countOrdPrintId = _graphiczoneDBContext.OrderDetailPrint.Where(x => x.OrPrintId == searchOrdPrintId.OrPrintId).ToList(); for (int i = 1; i <= countOrdPrintId.Count; i++) { var searchdataforclear = _graphiczoneDBContext.OrderDetailPrint.Where(x => x.OrPrintId == searchOrPrintId.OrPrintId).FirstOrDefault(); _graphiczoneDBContext.Remove(searchdataforclear); _graphiczoneDBContext.SaveChanges(); } } _graphiczoneDBContext.Remove(searchOrPrintId); HttpContext.Session.Remove("Cart"); _graphiczoneDBContext.SaveChanges(); return(Json(1)); } else { return(Json(0)); } }
public async Task <IActionResult> uploadAsync(OrderPrint orderPrint, OrderDetailPrint orderDetailPrint, Print print, TypePrint typePrint) { orderDetailPrint.PrintId = orderDetailPrint.PrintId.Trim(); string wwwRootPath = _webHostEnvironment.WebRootPath; string fileName = Path.GetFileNameWithoutExtension(Uploadfile.FileName); string extension = Path.GetExtension(Uploadfile.FileName); if (extension == ".jpg" || extension == ".png" || extension == ".gif") { fileName = fileName + DateTime.Now.ToString("yymmssfff") + extension; orderDetailPrint.OrdPrintFile = "images/" + fileName; fileName = Path.Combine(wwwRootPath, "images", fileName); using (var fileStream = new FileStream(fileName, FileMode.Create)) { await Uploadfile.CopyToAsync(fileStream); } } var printid = _graphiczoneDBContext.Print.Where(x => x.PrintId == orderDetailPrint.PrintId).FirstOrDefault(); orderDetailPrint.OrdPrintPriceset = printid.PrintPrice; float area = (float)(orderDetailPrint.OrdPrintHeight * orderDetailPrint.OrdPrintWidth) / 10000; float printtotal = (float)(area * orderDetailPrint.OrdPrintPriceset * orderDetailPrint.OrdPrintNum); orderDetailPrint.OrdPrintTotal = printtotal; var genId = _graphiczoneDBContext.OrderDetailPrint.Count(); orderDetailPrint.OrdPrintId = DateTime.Now.ToString("yyMMddHHmmssf") + "0" + (genId + 1).ToString(); orderDetailPrint.OrPrintId = HttpContext.Session.GetString("Cart"); // เพิ่ม _graphiczoneDBContext.OrderDetailPrint.Add(orderDetailPrint); _graphiczoneDBContext.SaveChanges(); return(RedirectToAction("CreateOrder")); }
public IActionResult successbill(OrderDetailPrint orderDetailPrint, OrderPrint orderPrint) { var searchBill = _graphiczoneDBContext.OrderPrint.Where(x => x.OrPrintId == orderPrint.OrPrintId).FirstOrDefault(); if (searchBill != null) { orderPrint.OrPrintDate = DateTime.Now; searchBill.OrPrintDate = orderPrint.OrPrintDate; searchBill.OrPrintStatus = orderPrint.OrPrintStatus; searchBill.OrPrintTotal = orderPrint.OrPrintTotal; _graphiczoneDBContext.SaveChanges(); HttpContext.Session.Remove("Cart"); return(Json(1)); } else { return(Json(0)); } }
public async Task <IActionResult> edituploadAsync(OrderPrint orderPrint, ProofPayment proofPayment) { var searchData = _graphiczoneDBContext.OrderPrint.Where(x => x.OrPrintId == orderPrint.OrPrintId).FirstOrDefault(); if (searchData != null) { var searchData2 = _graphiczoneDBContext.ProofPayment.Where(x => x.OrPrintId == proofPayment.OrPrintId).FirstOrDefault(); if (searchData2 != null) { _graphiczoneDBContext.Remove(searchData2); } searchData.OrPrintStatus = orderPrint.OrPrintStatus; proofPayment.OrPrintId = orderPrint.OrPrintId; proofPayment.PrfPayDate = proofPayment.PrfPayDate; string wwwRootPath = _webHostEnvironment.WebRootPath; string fileName = Path.GetFileNameWithoutExtension(Uploadfile.FileName); string extension = Path.GetExtension(Uploadfile.FileName); if (extension == ".jpg" || extension == ".png" || extension == ".gif") { fileName = fileName + DateTime.Now.ToString("yymmssfff") + extension; proofPayment.PrfPayFile = "images/" + fileName; fileName = Path.Combine(wwwRootPath, "images", fileName); using (var fileStream = new FileStream(fileName, FileMode.Create)) { await Uploadfile.CopyToAsync(fileStream); } } _graphiczoneDBContext.ProofPayment.Add(proofPayment); _graphiczoneDBContext.SaveChanges(); var x = "คุณได้ทำการแจ้งหลักฐานการโอน รายการที่ : " + orderPrint.OrPrintId + "เรียบร้อยแล้ว"; return(RedirectToAction("ListProofPayment")); } return(Json("ไม่สำเร็จ")); }
public async Task <IActionResult> uploadAsync(OrderPrint orderPrint, Shipping shipping) { var searchData = _graphiczoneDBContext.OrderPrint.Where(x => x.OrPrintId == orderPrint.OrPrintId).FirstOrDefault(); if (searchData != null) { searchData.OrPrintStatus = orderPrint.OrPrintStatus; shipping.OrPrintId = orderPrint.OrPrintId; shipping.ShippingDate = shipping.ShippingDate.Value.AddYears(543); var sessionid = HttpContext.Session.GetString("UserUsername"); var getUserid = _graphiczoneDBContext.User.Where(x => x.UserUsername == sessionid).FirstOrDefault(); shipping.UserId = getUserid.UserId; string wwwRootPath = _webHostEnvironment.WebRootPath; string fileName = Path.GetFileNameWithoutExtension(Uploadfile.FileName); string extension = Path.GetExtension(Uploadfile.FileName); if (extension == ".jpg" || extension == ".png" || extension == ".gif") { fileName = fileName + DateTime.Now.ToString("yymmssfff") + extension; shipping.ShippingFile = "images/" + fileName; fileName = Path.Combine(wwwRootPath, "images", fileName); using (var fileStream = new FileStream(fileName, FileMode.Create)) { await Uploadfile.CopyToAsync(fileStream); } } _graphiczoneDBContext.Shipping.Add(shipping); _graphiczoneDBContext.SaveChanges(); var x = "คุณได้ทำการบันทึกการส่งมอบ รายการที่ : " + orderPrint.OrPrintId + "เรียบร้อยแล้ว"; return(RedirectToAction("ListWorkShipping")); } return(Json("ไม่สำเร็จ")); }
public IActionResult opbill(OrderPrint orderPrint, Customer customer) { var searchCus = _graphiczoneDBContext.Customer.Where(x => x.CusId == customer.CusId).FirstOrDefault(); if (searchCus != null) { var maxbill = _graphiczoneDBContext.OrderPrint.Count(); var getid = orderPrint.OrPrintId = DateTime.Now.ToString("yyMMddHHmmssf") + (maxbill + 1).ToString(); orderPrint.OrPrintId = getid; orderPrint.CusId = searchCus.CusId; orderPrint.OrPrintDate = orderPrint.OrPrintDate; var getorprintdate = orderPrint.OrPrintDate; HttpContext.Session.SetString("Cart", getid); HttpContext.Session.SetString("OrPrintDate", getorprintdate.ToString()); _graphiczoneDBContext.Add(orderPrint); _graphiczoneDBContext.SaveChanges(); return(Json(getid)); } else { return(Json(0)); } }
public async Task <JsonResult> updateAsync(OrderPrint orderPrint, Shipping shipping) { var searchData = _graphiczoneDBContext.OrderPrint.Where(x => x.OrPrintId == orderPrint.OrPrintId).FirstOrDefault(); if (searchData != null) { searchData.OrPrintStatus = orderPrint.OrPrintStatus; shipping.OrPrintId = orderPrint.OrPrintId; shipping.ShippingDate = shipping.ShippingDate.Value.AddYears(543); var sessionid = HttpContext.Session.GetString("UserUsername"); var getUserid = _graphiczoneDBContext.User.Where(x => x.UserUsername == sessionid).FirstOrDefault(); shipping.UserId = getUserid.UserId; string wwwRootPath = _webHostEnvironment.WebRootPath; string fileName = Path.GetFileNameWithoutExtension(shipping.ShippingFile); string extension = Path.GetExtension(shipping.ShippingFile); fileName = fileName + DateTime.Now.ToString("yymmssfff") + extension; shipping.ShippingFile = "images/" + fileName; fileName = Path.Combine(wwwRootPath, "images", fileName); using (var fileStream = new FileStream(fileName, FileMode.Create)) { } _graphiczoneDBContext.Shipping.Add(shipping); _graphiczoneDBContext.SaveChanges(); return(Json(1)); } else { return(Json(0)); } }