public bool SaveDeliveryLine(int _deliveryID, DeliveryLine _deliveryLine) { IProductRepository ProdRepo = new ProductRepository(); ProdRepo.UpdateAmountInStock(_deliveryLine.Product, _deliveryLine.Amount); return(DeLictx.SaveDeliveryLine(_deliveryID, _deliveryLine)); }
public bool SaveDeliveryLine(int _deliveryID, DeliveryLine _deliveryLine) { string query = "INSERT INTO Delivery_Product(DeliveryID,ProductID,Amount) VALUES (@DeliveryID,@ProductID,@Amount)"; List <KeyValuePair <string, object> > parameterlist = new List <KeyValuePair <string, object> > { new KeyValuePair <string, object>("@DeliveryID", _deliveryID), new KeyValuePair <string, object>("@ProductID", _deliveryLine.Product.ID), new KeyValuePair <string, object>("@Amount", _deliveryLine.Amount) }; return(SQL_CRUD_Methods.SQLInsertBoolReturn(query, parameterlist)); }
public Delivery CreateDelivery(decimal deliveryPrice, long cardNumber, long userId, string description, List <ShoppingCart> shoppingCart, string deliveryAddress = null) { CreditCard card = CreditCardDao.FindByNumber(cardNumber); if (CreditCardDao.FindByUserId(userId) .Contains(card)) { Delivery delivery = new Delivery { deliveryDate = DateTime.Now, deliveryPrice = deliveryPrice, deliveryAddress = deliveryAddress ?? UserProfileDao.Find(userId).address, cardId = card.cardId, userId = userId, description = description }; DeliveryDao.Create(delivery); DeliveryLine deliveryLine; foreach (ShoppingCart item in shoppingCart) { deliveryLine = new DeliveryLine(); if (item.Product.productQuantity - item.Amount >= 0) { DecreaseProductStock(item.Product, item.Amount); deliveryLine.deliveryLineAmount = item.Amount; } else { throw new StockEmptyException(item.Product.productId, item.Product.productName); } deliveryLine.deliveryLinePrice = item.Product.productPrice; deliveryLine.productId = item.Product.productId; deliveryLine.deliveryId = delivery.deliveryId; DeliveryLineDao.Create(deliveryLine); } return(delivery); } else { throw new UnmatchingUserAndCardException(userId, cardNumber); } }
public void DAO_FindByDeliveryId() { int numberDeliveryLines = 3; List <DeliveryLine> createdDeliveryLines = new List <DeliveryLine>(numberDeliveryLines); for (int i = 0; i < numberDeliveryLines; i++) { deliveryLine = new DeliveryLine { deliveryLineAmount = deliveryLineAmount, deliveryLinePrice = deliveryLinePrice, deliveryId = delivery.deliveryId, productId = product.productId }; deliveryLineDao.Create(deliveryLine); createdDeliveryLines.Add(deliveryLine); deliveryLine = new DeliveryLine { deliveryLineAmount = deliveryLineAmount, deliveryLinePrice = deliveryLinePrice, deliveryId = delivery2.deliveryId, productId = product.productId }; deliveryLineDao.Create(deliveryLine); } List <DeliveryLine> totalRetrievedDeliveryLines = deliveryLineDao.FindByDeliveryId(delivery.deliveryId); Assert.AreEqual(numberDeliveryLines, totalRetrievedDeliveryLines.Count); for (int i = 0; i < numberDeliveryLines; i++) { Assert.AreEqual(totalRetrievedDeliveryLines[i], createdDeliveryLines[i]); } }
/// <summary> /// Get Lines for Delivery Document that will be added to Invoice Document /// </summary> /// <returns></returns> public List <DeliveryLine> GetDeliveryLines(string cardCode, string whsCode) { Recordset lObjRecordset = null; var parameters = new Dictionary <string, string>(); var lLstdeliveryLines = new List <DeliveryLine>(); try { string query = this.GetSQL("GetDeliveryLines"); parameters.Add("CardCode", cardCode); parameters.Add("WhsCode", whsCode); lObjRecordset = (Recordset)DIApplication.Company.GetBusinessObject(BoObjectTypes.BoRecordset); lObjRecordset.DoQuery(query.Inject(parameters)); if (lObjRecordset.RecordCount > 0) { for (int i = 0; i < lObjRecordset.RecordCount; i++) { var deliveryLine = new DeliveryLine(); Parallel.ForEach(lObjRecordset.Fields.OfType <SAPbobsCOM.Field>(), field => { deliveryLine.GetType().GetProperty(field.Name).SetValue(deliveryLine, field.Value); }); lLstdeliveryLines.Add(deliveryLine); lObjRecordset.MoveNext(); } } } catch (Exception ex) { HandleException(ex, "GetDeliveryLines"); } finally { MemoryUtility.ReleaseComObject(lObjRecordset); } return(lLstdeliveryLines); }
private DeliveryLine SaveObject() { var deliveryLine = new DeliveryLine { Id = ObjectId == 0 ? GetDeliveryLineId() : Id, BrandId = BrandId, CommodityTypeId = CommodityTypeId, SpecificationId = SpecificationId, CountryId = CountryId, GrossWeight = (GrossWeight ?? 0), NetWeight = (NetWeight ?? 0), VerifiedWeight = (VerifiedWeight ?? 0), IsVerified = IsVerified, DlvLineIsVerified=IsVerified, PackingQuantity = (PackingQuantity ?? 0), PBNo = PBNo, Comment = Comment, DeliveryStatus = (DeliveryStatus==1), FDPLineId = _fDPLineId, Country = CountryId == null ? null : GetCountryById((int) CountryId) }; if (DeliveryType == DeliveryType.InternalMDBOL || DeliveryType == DeliveryType.InternalMDWW || DeliveryType == DeliveryType.InternalTDBOL || DeliveryType == DeliveryType.InternalTDWW) { //内贸,有暂定价 deliveryLine.TempUnitPrice = TempUnitPrice; } if (BrandId.HasValue) deliveryLine.Brand = GetBrandById((int) BrandId); if (CommodityTypeId.HasValue) deliveryLine.CommodityType = GetCommodityTypeById((int) CommodityTypeId); if (SpecificationId.HasValue) deliveryLine.Specification = GetSpecificationById((int) SpecificationId); deliveryLine.CommodityType.Commodity = Commodity; if (CountryId.HasValue) { deliveryLine.Country = GetCountryById(CountryId.Value); } //提货人信息 deliveryLine.WarehouseOutDeliveryPersons.Clear(); foreach (WarehouseOutDeliveryPerson deliveryPerson in AllDeliveryPersonList) { deliveryLine.WarehouseOutDeliveryPersons.Add(deliveryPerson); } return deliveryLine; }
private void LoadDeliveryLine(DeliveryLine deliveryLine) { Id = deliveryLine.Id; CurrentDeliveryLine = deliveryLine; PBNo = deliveryLine.PBNo; NetWeight = deliveryLine.NetWeight; GrossWeight = deliveryLine.GrossWeight; VerifiedWeight = deliveryLine.VerifiedWeight; Country = deliveryLine.Country; CountryId = deliveryLine.CountryId; BrandId = deliveryLine.BrandId; CommodityTypeId = deliveryLine.CommodityTypeId; SpecificationId = deliveryLine.SpecificationId; PackingQuantity = deliveryLine.PackingQuantity; IsVerified = deliveryLine.IsVerified; DlvLineIsVerified = deliveryLine.IsVerified; Comment = deliveryLine.Comment; DeliveryStatus = deliveryLine.DeliveryStatus?1:0; _fDPLineId = deliveryLine.FDPLineId; AllDeliveryPersonList = deliveryLine.WarehouseOutDeliveryPersons.Where(c => c.IsDeleted == false).ToList(); if (DeliveryType == DeliveryType.InternalMDBOL || DeliveryType == DeliveryType.InternalMDWW || DeliveryType == DeliveryType.InternalTDBOL || DeliveryType == DeliveryType.InternalTDWW) { //内贸,有暂定价 TempUnitPrice = deliveryLine.TempUnitPrice; } }
public DeliveryLineVM(DeliveryLine deliveryLine, Commodity commodity) { AllDeliveryPersonList = new List<WarehouseOutDeliveryPerson>(); AddDeliveryPersonList = new List<WarehouseOutDeliveryPerson>(); UpdateDeliveryPersonList = new List<WarehouseOutDeliveryPerson>(); DeleteDeliveryPersonList = new List<WarehouseOutDeliveryPerson>(); Id = deliveryLine.Id; CurrentDeliveryLine = deliveryLine; Commodity = commodity; CommodityId = commodity.Id; PBNo = deliveryLine.PBNo; NetWeight = deliveryLine.NetWeight; GrossWeight = deliveryLine.GrossWeight; VerifiedWeight = deliveryLine.VerifiedWeight; CountryId = deliveryLine.CountryId; Country = deliveryLine.Country; BrandId = deliveryLine.BrandId; PackingQuantity = deliveryLine.PackingQuantity; IsVerified = deliveryLine.IsVerified; DlvLineIsVerified = deliveryLine.IsVerified; Comment = deliveryLine.Comment; DeliveryStatus = deliveryLine.DeliveryStatus?1:0; _fDPLineId = deliveryLine.FDPLineId; _startStatus = true; LoadCommodityType(); LoadBrandAndSpecification(); LoadCountry(); LoadStatus(); LoadDocumentLineEnableProperty(Id); PropertyChanged += OnPropertyChanged; }
public void GetExternalTDListByParameter() { using (var inventoryService = SvcClientManager.GetSvcClient<InventoryServiceClient>(SvcType.InventorySvc)) { ExternalTDList = inventoryService.GetExternalTDList(SelectedCommodityID, SelectedCustomerID, CurrentUser.Id); if(ExternalTDList != null && ExternalTDList.Count > 0) { decimal totalOnlyQty = ExternalTDList.Sum(c => c.OnlyQty ?? 0); decimal totalOnlyGrossWeight = ExternalTDList.Sum(c => c.OnlyGrossWeight ?? 0); var totalLine = new DeliveryLine { Id = 0, OnlyQty = totalOnlyQty, OnlyGrossWeight = totalOnlyGrossWeight }; ExternalTDList.Add(totalLine); } } }
/// <summary> /// 内贸提单/仓单 /// </summary> public void GetInternalTDByParameter() { using (var inventoryService = SvcClientManager.GetSvcClient<InventoryServiceClient>(SvcType.InventorySvc)) { InternalTDList = inventoryService.GetInternalTDList(SelectedCommodityID, SelectedCustomerID, CurrentUser.Id); if(InternalTDList != null && InternalTDList.Count > 0) { decimal totalOnlyQty = InternalTDList.Sum(c => c.OnlyQty ?? 0); decimal totalOnlyVerifiedQty = InternalTDList.Sum(c => c.OnlyVerfiedQty ?? 0); var totalLine = new DeliveryLine { Id = 0, OnlyQty = totalOnlyQty, OnlyVerfiedQty = totalOnlyVerifiedQty }; InternalTDList.Add(totalLine); } } }
public DeliveryLineViewModel(DeliveryLine _deliveryLine) { Product = new ProductViewModel(_deliveryLine.Product); Amount = _deliveryLine.Amount; }