//detail public ActionResult Detail(Guid?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ExportGood exportGood = db.ExportGoods.Find(id); //LIST KIEN JP var listjp = db.StorageJPs.Where(n => n.AgencyId == user.Agency.Id).Where(n => n.StatusId == 8).OrderByDescending(n => n.CreatedAt); List <TrackingDetail> lstDetail = new List <TrackingDetail>(); foreach (var item in listjp) { lstDetail.AddRange(item.TrackingDetails.Where(n => n.TrackingSubCode != "21")); } lstDetail = lstDetail.Where(n => PageUtils.IsExistExport(n.Id, user.Agency.Id) == false).OrderByDescending(n => n.CreatedAt).ToList(); var lstReturn = Pager <TrackingDetail> .CreatePagging(lstDetail.AsQueryable(), 1, 10); ViewBag.ListJP = lstReturn; ViewBag.ListVN = Pager <ExportGoodDetail> .CreatePagging(exportGood.ExportGoodDetails.OrderByDescending(n => n.CreatedAt).AsQueryable(), 1, 10); ViewBag.StatusId = new SelectList(StatusUtils.GetStatus(3), "Value", "Text", exportGood.StatusId); ViewBag.ExportGoodStatus = exportGood.StatusId; return(View(exportGood)); }
public ActionResult Add2New(string[] array, Guid FlightBookingId) { try { var FlightBooking = db.FlightBookings.Find(FlightBookingId); Guid id = Guid.NewGuid(); foreach (var item in array) { ExportGood ExportGood = db.ExportGoods.Find(Guid.Parse(item)); FlightGood FlightGood = new FlightGood() { CreatedAt = DateTime.Now, CreatedBy = user.Staff.UserName, ExportGoodId = ExportGood.Id, Id = id, FlightBookingId = FlightBookingId, UpdatedAt = DateTime.Now, UpdatedBy = user.Staff.UserName }; db.FlightGoods.Add(FlightGood); } FlightBooking.AutomaticTrackingCount = FlightBooking.FlightGoods.Sum(n => n.ExportGood.ExportGoodDetails.Count); FlightBooking.AutomaticWeigh = FlightBooking.FlightGoods.Sum(n => n.ExportGood.Weigh); db.SaveChanges(); return(Json(new { message = new { idNew = id, num = FlightBooking.FlightGoods.Sum(n => n.ExportGood.ExportGoodDetails.Count), kg = FlightBooking.FlightGoods.Sum(n => n.ExportGood.Weigh) }, status = true }, JsonRequestBehavior.AllowGet)); } catch { return(Json(new { message = "Đã xảy ra lỗi trong quá trình thêm dữ liệu", status = false }, JsonRequestBehavior.AllowGet)); } }
// GET: ExportGoods/Edit/5 public ActionResult Edit(Guid?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ExportGood exportGood = db.ExportGoods.Find(id); if (exportGood == null) { return(HttpNotFound()); } var size = db.SizeTables.OrderBy(n => n.NoOrder).Select(n => new SelectListItem() { Text = n.Name, Value = n.Id + "" }).ToList(); size.Insert(0, new SelectListItem() { Value = " ", Text = " " }); ViewBag.SizeTableId = new SelectList(size, "Value", "Text", exportGood.SizeTableId); ViewBag.StatusId = new SelectList(StatusUtils.GetStatus(3), "Value", "Text", exportGood.StatusId); //ViewBag.ExportHour = new SelectList(TimeUtils.TimeHours(), "Value", "Text", exportGood.ExportHour); return(View(exportGood)); }
//check update xuat kho public string IsUpdateExport(ExportGood export) { try { string s = ""; if (export.StatusId == 10) { if (export.Weigh == null || export.Weigh == 0) { s = "Vui lòng cập nhật khối lượng"; } if (export.SizeTableId == null && export.SizeInput == null) { s = (s == "" ? "Vui lòng cập nhật kích thước" : s + ",kích thước"); } if (export.ExportGoodDetails.Count == 0) { s = (s == "" ? "Nội dung kiện hàng đang trống." : s + ",nội dung kiện hàng"); } return(s); } else { return(""); } } catch { } return("Vui lòng cập nhật khối lượng, kích thước..."); }
//general xuat kho public GeneralExportGood GeneralExportGood(StorageJP model) { GeneralExportGood result = new Models.GeneralExportGood(); var details = model.TrackingDetails; var exports = db.ExportGoodDetails.Where(n => n.ExportGood.AgencyId == model.AgencyId); var export = new ExportGood(); bool flag = false; foreach (var item in details) { if (exports.Where(n => n.TrackingDetailId == item.Id).Count() > 0) { export = exports.Where(n => n.TrackingDetailId == item.Id).First().ExportGood; flag = true; break; } } if (flag) { result = new Models.GeneralExportGood() { ShippingMask = export.ShippingMarkVN, Size = DisplaySize(export.Weigh, export.SizeInput, export.SizeTableId, export.Size), Status = PackageStatus(export.StatusId.Value, 3), Weigh = export.Weigh == null ? 0 : export.Weigh.Value }; } return(result); }
public ActionResult IsCheckConfirm(Guid id, bool isCheck = false) { ExportGood item = db.ExportGoods.Find(id); List <ExportGoodDetail> details = db.ExportGoodDetails.Where(n => n.ExportGoodId == id).ToList(); try { foreach (var d in details) { d.StatusId = isCheck == true ? 1 : 0; db.SaveChanges(); } if (isCheck) { item.IsStaffConfirm = isCheck; item.StatusId = 10; // đã đóng gói(define=10) } else { item.IsStaffConfirm = isCheck; item.StatusId = 9; // đang đóng gói(define=9) } db.SaveChanges(); var PageUtils = new PageUtils(); return(Json(new { message = PageUtils.PackageStatus(item.StatusId.Value, 3), status = true }, JsonRequestBehavior.AllowGet)); } catch { return(Json(new { message = "Cập nhật liệu thất bại !", status = false }, JsonRequestBehavior.AllowGet)); } }
public bool AlowEditExportGood(ExportGood model) { try { if (db.ShippingHAWBDetails.Where(n => n.AgencyId == user.Agency.Id).Where(n => n.ExportGoodId == model.Id).Count() == 0) { return(true); } } catch { } return(false); }
public ActionResult Add(ExportGood exportGood) { exportGood.CreatedAt = exportGood.UpdatedAt = DateTime.Now; exportGood.CreatedBy = exportGood.UpdatedBy = user.Staff.UserName; exportGood.AgencyId = user.Agency.Id; exportGood.StaffId = user.Staff.UserName; if (ModelState.IsValid) { try { //var upImage = Request.Files["upImage"]; //if (upImage.ContentLength > 0 && upImage != null) //{ // string fileName = upImage.FileName.DoiTenHinh(); // upImage.SaveAs(Server.MapPath("~/images/ExportGoods/" + fileName)); // exportGood.Image = fileName; //} exportGood.Id = Guid.NewGuid(); db.ExportGoods.Add(exportGood); db.SaveChanges(); TempData["Message"] = "Thêm dữ liệu thành công"; return(Content(javasctipt_add("/ExportGoods", "Thêm dữ liệu thành công"))); } catch (Exception) { TempData["Message"] = "Có lỗi xảy ra, vui lòng kiểm tra lại dữ liệu"; ModelState.AddModelError("error", "Có lỗi xảy ra, vui lòng kiểm tra lại dữ liệu"); } } ViewBag.StatusId = new SelectList(StatusUtils.GetStatus(3), "Value", "Text", exportGood.StatusId); var size = db.SizeTables.OrderBy(n => n.NoOrder).Select(n => new SelectListItem() { Text = n.Name, Value = n.Id + "" }).ToList(); size.Insert(0, new SelectListItem() { Value = " ", Text = " " }); ViewBag.SizeTableId = new SelectList(size, "Value", "Text", exportGood.SizeTableId); //ViewBag.ExportHour = new SelectList(TimeUtils.TimeHours(), "Value", "Text", exportGood.ExportHour); TempData["Message"] = "Thêm dữ liệu thất bại"; return(Content(javasctipt_add("/ExportGoods", "Thêm dữ liệu thất bại"))); }
public ActionResult Edit(ExportGood exportGood, string actionlink = "") { if (PageUtils.IsUpdateExport(exportGood).Length > 0) { if (exportGood.ExportGoodDetails.Count() == 0) { return(Content(javasctipt_add("/ExportGoods", PageUtils.IsUpdateExport(exportGood)) + ", nội dung kiện hàng.")); } else { return(Content(javasctipt_add("/ExportGoods", PageUtils.IsUpdateExport(exportGood)))); } } else { exportGood.UpdatedAt = DateTime.Now; exportGood.UpdatedBy = user.Staff.UserName; exportGood.StaffId = user.Staff.UserName; exportGood.AgencyId = user.Agency.Id; if (ModelState.IsValid) { try { //var upImage = Request.Files["upImage"]; //if (upImage.ContentLength > 0 && upImage != null) //{ // string fileName = upImage.FileName.DoiTenHinh(); // upImage.SaveAs(Server.MapPath("~/images/ExportGoods/" + fileName)); // exportGood.Image = fileName; //} db.Entry(exportGood).State = EntityState.Modified; TempData["Message"] = "Cập nhật dữ liệu thành công"; db.SaveChanges(); if (actionlink != "") { return(Content(javasctipt_add("/ExportGoods/Detail/" + exportGood.Id, "Cập nhật dữ liệu thành công"))); } else { return(Content(javasctipt_add("/ExportGoods", "Cập nhật dữ liệu thành công"))); } } catch (Exception) { TempData["Message"] = "Có lỗi xảy ra, vui lòng kiểm tra lại dữ liệu"; ModelState.AddModelError("error", "Có lỗi xảy ra, vui lòng kiểm tra lại dữ liệu"); } } var size = db.SizeTables.OrderBy(n => n.NoOrder).Select(n => new SelectListItem() { Text = n.Name, Value = n.Id + "" }).ToList(); size.Insert(0, new SelectListItem() { Value = " ", Text = " " }); ViewBag.SizeTableId = new SelectList(size, "Value", "Text", exportGood.SizeTableId); ViewBag.StatusId = new SelectList(StatusUtils.GetStatus(3), "Value", "Text", exportGood.StatusId); //ViewBag.ExportHour = new SelectList(TimeUtils.TimeHours(), "Value", "Text", exportGood.ExportHour); if (actionlink != "") { return(Content(javasctipt_add("/ExportGoods/Detail/" + exportGood.Id, "Cập nhật dữ liệu thất bại"))); } else { return(Content(javasctipt_add("/ExportGoods", "Cập nhật dữ liệu thất bại"))); } } }