public ActionResult Detail(int id, string transactionType, string IndexType) { DispatchWaybillHeaderViewModel H = _DispatchWaybillHeaderService.GetDispatchWaybillHeaderViewModel(id); DispatchWaybillHeaderViewModelWithLog Header = Mapper.Map <DispatchWaybillHeaderViewModel, DispatchWaybillHeaderViewModelWithLog>(H); DispatchWaybillHeaderMasterDetailModel M = new DispatchWaybillHeaderMasterDetailModel(); M.DispatchWaybillHeaderId = id; M.DispatchWaybillHeaderViewModelWithLog = Header; ViewBag.transactionType = transactionType; ViewBag.IndexStatus = IndexType; if (String.IsNullOrEmpty(transactionType) || transactionType == "detail") { LogActivity.LogActivityDetail(LogVm.Map(new ActiivtyLogViewModel { DocTypeId = H.DocTypeId, DocId = H.DispatchWaybillHeaderId, ActivityType = (int)ActivityTypeContants.Detail, DocNo = H.DocNo, DocDate = H.DocDate, DocStatus = H.Status, })); } return(View(M)); }
public string DataValidation(DispatchWaybillHeaderViewModel svm) { string ValidationMsg = ""; if (svm.ConsigneeId == 0 || svm.ConsigneeId == null) { ValidationMsg = "Consignee is required."; return(ValidationMsg); } if (svm.SaleInvoiceHeaderId == 0 || svm.SaleInvoiceHeaderId == null) { ValidationMsg = "Invoice No is required."; return(ValidationMsg); } if (svm.TransporterId == 0 || svm.TransporterId == null) { ValidationMsg = "Transporter is required."; return(ValidationMsg); } if (svm.RouteId == 0 || svm.RouteId == null) { ValidationMsg = "Route is required."; return(ValidationMsg); } return(ValidationMsg); }
private void PrepareViewBag(DispatchWaybillHeaderViewModel s) { ViewBag.ShipMethodList = new ShipMethodService(_unitOfWork).GetShipMethodList().ToList(); List <SelectListItem> temp = new List <SelectListItem>(); temp.Add(new SelectListItem { Text = PaymentTypeConstants.ToPay, Value = PaymentTypeConstants.ToPay }); temp.Add(new SelectListItem { Text = PaymentTypeConstants.Paid, Value = PaymentTypeConstants.Paid }); temp.Add(new SelectListItem { Text = PaymentTypeConstants.TobeBilled, Value = PaymentTypeConstants.TobeBilled }); if (s == null) { ViewBag.PaymentType = new SelectList(temp, "Value", "Text"); } else { ViewBag.PaymentType = new SelectList(temp, "Value", "Text", s.PaymentType); } }
private ActionResult Edit(int id, string IndexType) { ViewBag.IndexStatus = IndexType; DispatchWaybillHeader s = _DispatchWaybillHeaderService.Find(id); if (s == null) { return(HttpNotFound()); } #region DocTypeTimeLineValidation try { TimePlanValidation = DocumentValidation.ValidateDocument(Mapper.Map <DocumentUniqueId>(s), DocumentTimePlanTypeConstants.Modify, User.Identity.Name, out ExceptionMsg, out Continue); } catch (Exception ex) { string message = _exception.HandleException(ex); TempData["CSEXC"] += message; TimePlanValidation = false; } if (!TimePlanValidation) { TempData["CSEXC"] += ExceptionMsg; } #endregion DispatchWaybillHeaderViewModel svm = new DispatchWaybillHeaderViewModel(); svm = Mapper.Map <DispatchWaybillHeader, DispatchWaybillHeaderViewModel>(s); if ((!TimePlanValidation && !Continue)) { return(RedirectToAction("DetailInformation", new { id = id, IndexType = IndexType })); } PrepareViewBag(svm); PrepareViewBag(s.DocTypeId); ViewBag.Mode = "Edit"; if (!(System.Web.HttpContext.Current.Request.UrlReferrer.PathAndQuery).Contains("Create")) { LogActivity.LogActivityDetail(LogVm.Map(new ActiivtyLogViewModel { DocTypeId = s.DocTypeId, DocId = s.DispatchWaybillHeaderId, ActivityType = (int)ActivityTypeContants.Detail, DocNo = s.DocNo, DocDate = s.DocDate, DocStatus = s.Status, })); } return(View("Create", svm)); }
// GET: /DispatchWaybillHeader/Create public ActionResult Create(int DocTypeId) { DispatchWaybillHeaderViewModel p = new DispatchWaybillHeaderViewModel(); p.CreatedDate = DateTime.Now; p.DocDate = DateTime.Now.Date; p.WaybillDate = DateTime.Now.Date; p.EstimatedDeliveryDate = DateTime.Now.Date; p.DivisionId = (int)System.Web.HttpContext.Current.Session["DivisionId"]; p.SiteId = (int)System.Web.HttpContext.Current.Session["SiteId"]; p.DocNo = _DispatchWaybillHeaderService.GetMaxDocNo(); p.DocTypeId = DocTypeId; PrepareViewBag(p); ViewBag.Mode = "Add"; PrepareViewBag(DocTypeId); return(View(p)); }
public DispatchWaybillHeaderViewModel GetDispatchWaybillHeaderViewModel(int id) { DispatchWaybillHeaderViewModel packingheaderlistpendingtoapprove = (from H in db.DispatchWaybillHeader join B in db.Persons on H.ConsigneeId equals B.PersonID into ConsigneeTable from ConsigneeTab in ConsigneeTable.DefaultIfEmpty() orderby H.DocDate descending, H.DocNo descending where H.DispatchWaybillHeaderId == id select new DispatchWaybillHeaderViewModel { DispatchWaybillHeaderId = H.DispatchWaybillHeaderId, DocDate = H.DocDate, DocNo = H.DocNo, ConsigneeName = ConsigneeTab.Name, RouteId = H.RouteId, Remark = H.Remark, Status = H.Status, ModifiedBy = H.ModifiedBy, }).FirstOrDefault(); return(packingheaderlistpendingtoapprove); }
public ActionResult Create(DispatchWaybillHeaderViewModel svm) { string DataValidationMsg = DataValidation(svm); if (DataValidationMsg != "") { PrepareViewBag(svm); PrepareViewBag(svm.DocTypeId); return(View(svm).Danger(DataValidationMsg)); } #region DocTypeTimeLineValidation try { if (svm.DispatchWaybillHeaderId <= 0) { TimePlanValidation = DocumentValidation.ValidateDocument(Mapper.Map <DocumentUniqueId>(svm), DocumentTimePlanTypeConstants.Create, User.Identity.Name, out ExceptionMsg, out Continue); } else { TimePlanValidation = DocumentValidation.ValidateDocument(Mapper.Map <DocumentUniqueId>(svm), DocumentTimePlanTypeConstants.Modify, User.Identity.Name, out ExceptionMsg, out Continue); } } catch (Exception ex) { string message = _exception.HandleException(ex); TempData["CSEXC"] += message; TimePlanValidation = false; } if (!TimePlanValidation) { TempData["CSEXC"] += ExceptionMsg; } #endregion if (ModelState.IsValid && (TimePlanValidation || Continue)) { #region CreateRecord if (svm.DispatchWaybillHeaderId == 0) { DispatchWaybillHeader DispatchWaybillHeader = Mapper.Map <DispatchWaybillHeaderViewModel, DispatchWaybillHeader>(svm); DispatchWaybillHeader.CreatedDate = DateTime.Now; DispatchWaybillHeader.ModifiedDate = DateTime.Now; DispatchWaybillHeader.CreatedBy = User.Identity.Name; DispatchWaybillHeader.ModifiedBy = User.Identity.Name; DispatchWaybillHeader.Status = (int)StatusConstants.Drafted; if (svm.DocTypeId == new DocumentTypeService(_unitOfWork).Find(TransactionDoctypeConstants.PreDispatchWaybill).DocumentTypeId) { DispatchWaybillHeader.IsPreCarriage = true; } else { DispatchWaybillHeader.IsPreCarriage = false; } _DispatchWaybillHeaderService.Create(DispatchWaybillHeader); var routecities = new RouteLineService(_unitOfWork).GetRouteLineListForIndex(svm.RouteId).ToList(); foreach (var item in routecities) { DispatchWaybillLine DispatchWaybillLine = new DispatchWaybillLine(); DispatchWaybillLine.CityId = item.CityId; DispatchWaybillLine.CreatedDate = DateTime.Now; DispatchWaybillLine.ModifiedDate = DateTime.Now; DispatchWaybillLine.CreatedBy = User.Identity.Name; DispatchWaybillLine.ModifiedBy = User.Identity.Name; new DispatchWaybillLineService(_unitOfWork).Create(DispatchWaybillLine); } try { _unitOfWork.Save(); } catch (Exception ex) { string message = _exception.HandleException(ex); TempData["CSEXC"] += message; PrepareViewBag(svm); ViewBag.Mode = "Add"; return(View("Create", svm)); } LogActivity.LogActivityDetail(LogVm.Map(new ActiivtyLogViewModel { DocTypeId = DispatchWaybillHeader.DocTypeId, DocId = DispatchWaybillHeader.DispatchWaybillHeaderId, ActivityType = (int)ActivityTypeContants.Added, DocNo = DispatchWaybillHeader.DocNo, DocDate = DispatchWaybillHeader.DocDate, DocStatus = DispatchWaybillHeader.Status, })); return(RedirectToAction("Modify", new { id = DispatchWaybillHeader.DispatchWaybillHeaderId }).Success("Data saved Successfully")); } #endregion #region EditRecord else { int routeid = _DispatchWaybillHeaderService.GetDispatchWaybillHeaderViewModel(svm.DispatchWaybillHeaderId).RouteId; DispatchWaybillHeader DispatchWaybillHeader = Mapper.Map <DispatchWaybillHeaderViewModel, DispatchWaybillHeader>(svm); int status = DispatchWaybillHeader.Status; if (DispatchWaybillHeader.Status != (int)StatusConstants.Drafted && DispatchWaybillHeader.Status != (int)StatusConstants.Import) { DispatchWaybillHeader.Status = (int)StatusConstants.Modified; } DispatchWaybillHeader.Status = (int)StatusConstants.Modified; DispatchWaybillHeader.ModifiedDate = DateTime.Now; DispatchWaybillHeader.ModifiedBy = User.Identity.Name; _DispatchWaybillHeaderService.Update(DispatchWaybillHeader); if (routeid != svm.RouteId) { var dispatchwaybillline = new DispatchWaybillLineService(_unitOfWork).GetDispatchWaybillLineForHeaderId(svm.DispatchWaybillHeaderId); foreach (var item in dispatchwaybillline) { new DispatchWaybillLineService(_unitOfWork).Delete(item.DispatchWaybillLineId); } var routecities = new RouteLineService(_unitOfWork).GetRouteLineListForIndex(svm.RouteId).ToList(); foreach (var item in routecities) { DispatchWaybillLine DispatchWaybillLine = new DispatchWaybillLine(); DispatchWaybillLine.DispatchWaybillHeaderId = DispatchWaybillHeader.DispatchWaybillHeaderId; DispatchWaybillLine.CityId = item.CityId; DispatchWaybillLine.CreatedDate = DateTime.Now; DispatchWaybillLine.ModifiedDate = DateTime.Now; DispatchWaybillLine.CreatedBy = User.Identity.Name; DispatchWaybillLine.ModifiedBy = User.Identity.Name; new DispatchWaybillLineService(_unitOfWork).Create(DispatchWaybillLine); } } try { _unitOfWork.Save(); } catch (Exception ex) { string message = _exception.HandleException(ex); TempData["CSEXC"] += message; ViewBag.Mode = "Edit"; return(View("Create", svm)); } LogActivity.LogActivityDetail(LogVm.Map(new ActiivtyLogViewModel { DocTypeId = DispatchWaybillHeader.DocTypeId, DocId = DispatchWaybillHeader.DispatchWaybillHeaderId, ActivityType = (int)ActivityTypeContants.Modified, DocNo = DispatchWaybillHeader.DocNo, DocDate = DispatchWaybillHeader.DocDate, DocStatus = DispatchWaybillHeader.Status, })); return(RedirectToAction("Index", new { id = svm.DocTypeId, IndexType = "" }).Success("Data saved successfully")); } #endregion } PrepareViewBag(svm); PrepareViewBag(svm.DocTypeId); ViewBag.Mode = "Add"; return(View("Create", svm)); }