public PipeIncomeRecord(int key, string code, BusinessCheckNotice notice, Account creator, DateTime dateCreated) : base(key) { if (notice == null) { throw new ArgumentNullException("notice"); } if (notice.DeliverNotice == null) { throw new InvalidOperationException("数据有误,来料通知单不能为空"); } this.Code = code; this.Creator = creator; this.DateCreated = dateCreated; this.BusinessCheckNotice = notice; this.Company = notice.DetectionCompany; this.CompanyContract = notice.DeliverNotice.CompanyContract; this.PipeQualityCertification = RepositoryFactory.GetRepository<IPipeQualityCertificationRepository, PipeQualityCertification>().FindBy(notice.DeliverNotice); this.PipeType = notice.PipeType; this.Producer = notice.DeliverNotice.Producer; this.ReciveDate = notice.LastReciveDate; this.SendDate = notice.DeliverNotice.DateDelivering; this.Supplier = notice.DeliverNotice.Supplier; }
public PipeBCRecord(string key, BusinessCheckNotice notice, Pipe pipe) : base(key) { this.BusinessCheckNotice = notice; this.Pipe = pipe; }
public ActionResult CreatePropose() { IDeliverWaggonRepository waggonReppository = RepositoryFactory.GetRepository<IDeliverWaggonRepository, DeliverWaggon>(unitOfWork); #region Get deliver notice string strDeliverNoticeId = Request.QueryString["delivernotice"]; int dnId; if (!int.TryParse(strDeliverNoticeId, out dnId)) { throw new HttpException(404, "未指定来料单"); } DeliverNotice deliverNotice = RepositoryFactory.GetRepository<IDeliverNoticeRepository, DeliverNotice>().FindBy(dnId); if (deliverNotice == null) { throw new HttpException(404, "未指定来料单"); } deliverNotice.Waggons = waggonReppository.FindBy(deliverNotice); #endregion #region Get selected waggons List<DeliverWaggon> selectedWaggons = new List<DeliverWaggon>(); List<long> waggonIds = new List<long>(); if (string.IsNullOrEmpty(Request.Form["WaggonIds"])) { TempData["HintMessage"] = new PDCPMS.Application.HintMessage { Content = "未选择车皮信息", Type = Application.HintMessageType.Error }; return RedirectToAction("AddPropose", new { delivernotice = dnId }); } string[] strWaggonId = Request.Form["WaggonIds"].Split(','); foreach (string strId in strWaggonId) { long wid; if (long.TryParse(strId, out wid)) { waggonIds.Add(wid); } } if (waggonIds.Count == 0) { TempData["HintMessage"] = new PDCPMS.Application.HintMessage { Content = "未选择车皮信息", Type = Application.HintMessageType.Error }; return RedirectToAction("AddPropose", new { delivernotice = dnId }); } waggonIds.ForEach<long>(delegate(long wid) { DeliverWaggon waggon = deliverNotice.Waggons.FirstOrDefault(w => (long)w.Key == wid && w.ActualNO.HasValue && w.BusinessCheckNotice == null); if (waggon != null && selectedWaggons.Where(w => w.Key == waggon.Key).Count() == 0) { selectedWaggons.Add(waggon); } }); if (selectedWaggons.Count == 0) { TempData["HintMessage"] = new PDCPMS.Application.HintMessage { Content = "未选择车皮信息", Type = Application.HintMessageType.Error }; return RedirectToAction("AddPropose", new { delivernotice = dnId }); } #endregion #region Get input data String code = Request.Form["Code"]; if (string.IsNullOrEmpty(code)) { TempData["HintMessage"] = new PDCPMS.Application.HintMessage { Content = "未输入编号", Type = Application.HintMessageType.Error }; return RedirectToAction("AddPropose", new { delivernotice = dnId }); } code = deliverNotice.Company.Code.ToUpper() + code.ToUpper().Trim(); string docProvided = Request.Form["DocProvided"]; if (repository.FindByCode(code) != null) { TempData["HintMessage"] = new PDCPMS.Application.HintMessage { Content = string.Format("编号{0}已存在", code), Type = Application.HintMessageType.Error }; return RedirectToAction("AddPropose", new { delivernotice = dnId }); } String contractNumber = Request.Form["ContractNumber"]; DateTime firstReceiveDate = selectedWaggons.OrderBy(w => w.ReceiveTime.Value).First().ReceiveTime.Value; DateTime lastreceiveDate = selectedWaggons.OrderByDescending(w => w.ReceiveTime.Value).First().ReceiveTime.Value; Account account = UserSession.OnlineAccount; #endregion #region Create Notice And Update Waggon's BusinessCheckNotice BusinessCheckNotice notice = new BusinessCheckNotice(0, deliverNotice, UserSession.OnlineAccount, DateTime.Now, UserSession.OnlineAccount, firstReceiveDate, lastreceiveDate, selectedWaggons.Sum(w => w.ActualNO.Value)); notice.Code = code; notice.DocProvided = docProvided; notice.ContractNumber = contractNumber; repository.Add(notice); selectedWaggons.ForEach(delegate(DeliverWaggon w) { w.BusinessCheckNotice = notice; waggonReppository[w.Key] = w; }); #endregion unitOfWork.Commit(); #region Update Deliver notice state deliverNotice.Waggons = waggonReppository.FindBy(deliverNotice); if (deliverNotice.Waggons.Where(w => w.BusinessCheckNotice == null).Count() == 0) { IDeliverNoticeRepository deliverNoticeRepository = RepositoryFactory.GetRepository<IDeliverNoticeRepository, DeliverNotice>(unitOfWork); deliverNotice.State = DeliverNoticeState.Done; deliverNoticeRepository[deliverNotice.Key] = deliverNotice; unitOfWork.Commit(); } #endregion TempData["HintMessage"] = new PDCPMS.Application.HintMessage { Content = "成功创建提检单" }; return RedirectToAction("ProposeIndex"); }