本文整理汇总了C#中Inventory.CopyPropertiesFrom方法的典型用法代码示例。如果您正苦于以下问题:C# Inventory.CopyPropertiesFrom方法的具体用法?C# Inventory.CopyPropertiesFrom怎么用?C# Inventory.CopyPropertiesFrom使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Inventory
的用法示例。
在下文中一共展示了Inventory.CopyPropertiesFrom方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: btnSave_Click
protected void btnSave_Click(object sender, EventArgs e)
{
inventoryManager = new InventoryManager(this);
Inventory inventory = new Inventory();
original_Inventory = inventoryManager.GetInventory(Company.CompanyId, Convert.ToInt32(Page.ViewState["ProductId"]), Convert.ToInt32(Page.ViewState["DepositId"]));
if (original_Inventory == null)
return;
inventory.CopyPropertiesFrom(original_Inventory);
inventory.FiscalNumber = txtFiscalNumber.Text;
inventory.SupplierId = Convert.ToInt32(cboSupplier.SelectedValue);
inventory.MinimumRequired = ucCurrFieldMinimunRequired.IntValue;
inventory.Localization = txtLocalization.Text;
inventory.RealCost = uctxtRealCost.CurrencyValue.Value;
inventory.Profit = uctxtProfit.CurrencyValue.Value;
inventory.UnitPrice = uctxtUnitPrice1.CurrencyValue.Value;
if (!String.IsNullOrEmpty(cboCurrencyRate.SelectedValue))
inventory.CurrencyRateId = Convert.ToInt32(cboCurrencyRate.SelectedValue);
if (uctxtUnitPrice2.CurrencyValue.HasValue)
inventory.UnitPrice2 = uctxtUnitPrice2.CurrencyValue.Value;
if (uctxtUnitPrice3.CurrencyValue.HasValue)
inventory.UnitPrice3 = uctxtUnitPrice3.CurrencyValue.Value;
if (uctxtUnitPrice4.CurrencyValue.HasValue)
inventory.UnitPrice4 = uctxtUnitPrice4.CurrencyValue.Value;
if (uctxtUnitPrice5.CurrencyValue.HasValue)
inventory.UnitPrice5 = uctxtUnitPrice5.CurrencyValue.Value;
inventoryManager.Update(original_Inventory, inventory);
Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "", "parent.location='Inventories.aspx';", true);
}
示例2: TransferStockDeposit
/// <summary>
/// this method transfer a product Between two deposit
/// </summary>
/// <param name="moviment"></param>
public void TransferStockDeposit(InventoryMoviment moviment, Int32 userId)
{
//company Source Inventory Moviment
InventoryMoviment sourceInventoryMoviment = RetrievePendingTransfers(moviment.InventoryMovementId);
//company Souce Inventory
Inventory sourceInventory = GetProductInventory(moviment.CompanyId, moviment.ProductId, moviment.DepositId);
//company targeting Inventory
Inventory destinationInventory = GetProductInventory(moviment.CompanyId, moviment.ProductId,
moviment.DepositDestinationId);
//insert Inventory History
var history = new InventoryHistory();
history.Quantity = sourceInventory.Quantity;
history.CurrencyRateId = sourceInventory.CurrencyRateId;
history.FiscalNumber = sourceInventory.FiscalNumber;
history.Localization = sourceInventory.Localization;
history.MinimumRequired = sourceInventory.MinimumRequired;
history.ProductId = sourceInventory.ProductId;
history.Profit = sourceInventory.Profit;
history.RealCost = sourceInventory.RealCost;
history.SupplierId = sourceInventory.SupplierId;
history.UnitPrice = sourceInventory.UnitPrice;
history.CompanyId = moviment.CompanyId;
history.DepositId = sourceInventory.DepositId;
history.DestinationDepositId = moviment.DepositDestinationId;
history.InventoryEntryTypeId = (int)EntryType.Transfer;
history.LogDate = DateTime.Now;
history.UserId = userId;
//insert History
InsertHistory(history);
if (destinationInventory != null)
{
//set the new AverageCost
destinationInventory.AverageCosts =
((destinationInventory.Quantity * destinationInventory.UnitPrice
+ sourceInventoryMoviment.Quantity * sourceInventory.UnitPrice) /
(sourceInventoryMoviment.Quantity + destinationInventory.Quantity));
//set the new Quantity
destinationInventory.Quantity += sourceInventoryMoviment.Quantity;
}
else
{
//insert a Inventory if the product not exists in the target inventory
//set the new depositId and companyId
var newInventory = new Inventory();
newInventory.CopyPropertiesFrom(sourceInventory);
newInventory.DepositId = moviment.DepositDestinationId;
newInventory.CompanyId = moviment.CompanyId;
Insert(newInventory);
}
//delete Moviment
DeleteMovement(moviment);
//submit changes
DbContext.SubmitChanges();
}