public ActionResult Edit(AgencyPackage agencyPackage, string actionlink = "") { agencyPackage.UpdatedBy = user.Staff.UserName; agencyPackage.UpdatedAt = DateTime.Now; if (ModelState.IsValid) { agencyPackage.AgencyId = user.Agency.Id; db.Entry(agencyPackage).State = EntityState.Modified; db.SaveChanges(); ViewBag.ShipmentId = agencyPackage.ShipmentId; if (actionlink != "") { return(Content(javasctipt_add("/AgencyPackageItem/Index/" + agencyPackage.Id, "Cập nhật dữ liệu thành công"))); } else { return(Content(javasctipt_add("/Shipment/Package/" + agencyPackage.ShipmentId, "Cập nhật dữ liệu thành công"))); } } ViewBag.SendHour = new SelectList(TimeUtils.TimeHours(), "Value", "Text", agencyPackage.SendHour); ViewBag.ReceivedHour = new SelectList(TimeUtils.TimeHours(), "Value", "Text", agencyPackage.ReceivedHour); ViewBag.AgencyId = new SelectList(db.Agencies.Where(n => n.Id == user.Agency.Id), "Id", "Name", agencyPackage.AgencyId); ViewBag.DeliveryId = new SelectList(db.DeliveryComs.Where(n => n.IsActive == true), "Id", "Name", agencyPackage.DeliveryId); ViewBag.StatusId = new SelectList(StatusUtils.GetStatus(1), "Value", "Text", agencyPackage.TrackingStatusId); if (actionlink != "") { return(Content(javasctipt_add("/AgencyPackageItem/Index/" + agencyPackage.Id, "Cập nhật dữ liệu thất bại"))); } else { return(Content(javasctipt_add("/Shipment/Package/" + agencyPackage.ShipmentId, "Cập nhật dữ liệu thất bại"))); } }
public List <AgencyPackage> getAgencyPackage(List <ShipmentImport> lst, Shipment shipment) { List <AgencyPackage> list = new List <AgencyPackage>(); foreach (var _item in lst) { var listPackage = lst.Where(n => n.TrackingNumber.Trim() == _item.TrackingNumber.Trim()); foreach (var pack in listPackage) { if (list.Where(n => n.TrackingCode == pack.TrackingNumber.Trim()).Count() > 0) { break; } var packId = Guid.NewGuid(); var delivery = getDevilery(pack.DeliveryName); AgencyPackage package = new AgencyPackage() { AgencyId = user.Agency.Id, CreatedAt = DateTime.Now, Id = packId, CreatedBy = user.Staff.UserName, DeliveryId = delivery.Id, DeliveryName = delivery.Name, IsDeclare = false, IsEdit = false, Notes = pack.Notes, ReceivedDate = pack.RecivedDate, ReceivedHour = pack.RecivedHour.Trim(), SentDate = pack.SendDate, SendHour = pack.RecivedHour.Trim(), ShipmentId = shipment.Id, StatusId = int.Parse(getStatus(pack.Status)), TrackingCode = pack.TrackingNumber.Trim(), TrackingStatusId = 2, Weigh = pack.Weigh, UpdatedAt = DateTime.Now, UpdatedBy = user.Staff.UserName }; list.Add(package); break; } } return(list); }
// GET: AgencyPackage/Edit/5 public ActionResult Edit(Guid?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } AgencyPackage agencyPackage = db.AgencyPackages.Find(id); if (agencyPackage == null) { return(HttpNotFound()); } ViewBag.SendHour = new SelectList(TimeUtils.TimeHours(), "Value", "Text", agencyPackage.SendHour); ViewBag.ReceivedHour = new SelectList(TimeUtils.TimeHours(), "Value", "Text", agencyPackage.ReceivedHour); ViewBag.AgencyId = new SelectList(db.Agencies.Where(n => n.Id == user.Agency.Id), "Id", "Name", agencyPackage.AgencyId); ViewBag.StatusId = new SelectList(StatusUtils.GetStatus(1), "Value", "Text", agencyPackage.TrackingStatusId); ViewBag.DeliveryId = new SelectList(db.DeliveryComs, "Id", "Name", agencyPackage.DeliveryId); return(View(agencyPackage)); }
public ActionResult Add(AgencyPackage agencyPackage) { agencyPackage.CreatedAt = agencyPackage.UpdatedAt = DateTime.Now; agencyPackage.CreatedBy = agencyPackage.UpdatedBy = user.Staff.UserName; if (ModelState.IsValid) { agencyPackage.Id = Guid.NewGuid(); //agencyPackage.StatusId = 2; agencyPackage.AgencyId = user.Agency.Id; db.AgencyPackages.Add(agencyPackage); db.SaveChanges(); ViewBag.ShipmentId = agencyPackage.ShipmentId; return(Content(javasctipt_add("/Shipment/Package/" + agencyPackage.ShipmentId, "Thêm dữ liệu thành công"))); } //ViewBag.SendHour = new SelectList(TimeUtils.TimeHours(), "Value", "Text", agencyPackage.SendHour); //ViewBag.ReceivedHour = new SelectList(TimeUtils.TimeHours(), "Value", "Text", agencyPackage.ReceivedHour); //ViewBag.AgencyId = new SelectList(db.Agencies.Where(n => n.Id == user.Agency.Id), "Id", "Name", agencyPackage.AgencyId); //ViewBag.DeliveryId = new SelectList(db.DeliveryComs.Where(n => n.IsActive == true), "Id", "Name", agencyPackage.DeliveryId); //ViewBag.StatusId = new SelectList(StatusUtils.GetStatus(1), "Value", "Text",agencyPackage.TrackingStatusId); return(Content(javasctipt_add("/Shipment/Package/" + agencyPackage.ShipmentId, "Thêm dữ liệu thất bại"))); }
public List <AgencyPackageItem> getAgencyPackageItems(List <ShipmentImport> lst, Shipment shipment, AgencyPackage package) { List <AgencyPackageItem> list = new List <AgencyPackageItem>(); var listPackage = lst.Where(n => n.TrackingNumber == package.TrackingCode); foreach (var pack in listPackage) { var packId = Guid.NewGuid(); var cate = getCategory(pack.ItemCategoryName); if (cate != null) { AgencyPackageItem item = new AgencyPackageItem() { AgencyPackageId = package.Id, CreatedAt = DateTime.Now, Id = packId, CreatedBy = user.Staff.UserName, UpdatedAt = DateTime.Now, UpdatedBy = user.Staff.UserName, CategoryId = cate.Id, ItemCategory = cate.NameEN, ItemCode = "", ItemName = pack.ItemName, ItemNotes = pack.ItemNotes, ItemQuantity = pack.ItemQuantity, ItemUrl = "", ItemImg = "" }; list.Add(item); } } return(list); }