📄 inventory.cs
字号:
using System;
using System.IO;
namespace HardwareDistributor.Business
{
public class Inventory : DataObject
{
#region Constants
public const string BIN_COLUMN = "Bin";
public const string DISTRIBUTIONCENTER_COLUMN = "DistributionCenter";
public const string INSTOCK_COLUMN = "InStock";
public const string INVENTORYID_COLUMN = "InventoryId";
public const string NAME_COLUMN = "Name";
public const string PICTURE_COLUMN = "Picture";
public const string PRICE_COLUMN = "Price";
#endregion
#region Fields
private Nullable<int> _bin = null;
private Nullable<int> _distributionCenter = null;
private Nullable<int> _inStock = null;
private Nullable<int> _inventoryId = null;
private string _name = string.Empty;
private byte[] _picture = null;
private Nullable<decimal> _price = null;
#endregion
#region Constructor(s) & Dispose
/// <summary>
/// Create a new Inventory item
/// </summary>
public Inventory() : base()
{
}
/// <summary>
/// Create an unmodified Inventory item
/// </summary>
/// <param name="inventoryId">Id of the inventory item</param>
/// <param name="inventoryName">Name of the inventory item</param>
/// <param name="picture">Picture of the inventory item</param>
/// <param name="price">Price of the inventory item</param>
/// <param name="inStock">
/// Quantity of the inventory item in stock
/// </param>
/// <param name="distributionCenter">
/// Distribution center where the inventory item is stored
/// </param>
/// <param name="bin">bin where the inventory item is stored</param>
public Inventory(Nullable<int> inventoryId,
string inventoryName,
byte[] picture,
Nullable<decimal> price,
Nullable<int> inStock,
Nullable<int> distributionCenter,
Nullable<int> bin) : base()
{
_bin = bin;
_distributionCenter = distributionCenter;
_inStock = inStock;
_inventoryId = inventoryId;
_name = inventoryName;
_picture = picture;
_price = price;
_objectState= ObjectState.Unchanged;
}
#endregion
#region Properties
/// <summary>
/// Id of warehouse bin where Inventory items are found
/// </summary>
public Nullable<int> Bin
{
get
{
return _bin;
}
set
{
// If needed put additional editing before the change value.
_bin = ChangeValue<Nullable<int>>(_bin, value, BIN_COLUMN);
}
}
/// <summary>
/// Id of Distribution Center
/// </summary>
public Nullable<int> DistributionCenter
{
get
{
return _distributionCenter;
}
set
{
// If needed put additional editing before the change value.
_distributionCenter = ChangeValue<Nullable<int>>(_distributionCenter,
value,
DISTRIBUTIONCENTER_COLUMN);
}
}
/// <summary>
/// Number of Inventory Items in stock
/// </summary>
public Nullable<int> InStock
{
get
{
return _inStock;
}
set
{
// If needed put additional editing before the change value.
_inStock = ChangeValue<Nullable<int>>(_inStock, value,
INSTOCK_COLUMN);
}
}
/// <summary>
/// Unique Inventory Id
/// </summary>
public Nullable<int> InventoryId
{
get
{
return _inventoryId;
}
set
{
_inventoryId = ChangeKey<Nullable<int>>(_inventoryId, value,
INVENTORYID_COLUMN);
}
}
/// <summary>
/// Name of the Inventory Item
/// </summary>
public string InventoryName
{
get
{
return _name;
}
set
{
// If needed put additional editing before the change value.
_name = ChangeValue<string>(_name, value, NAME_COLUMN);
}
}
/// <summary>
/// Byte Array to hold the Inventory image
/// </summary>
public byte[] Picture
{
get
{
return _picture;
}
set
{
// If needed put additional editing before the change value.
_picture = ChangeValue<byte[]>(_picture, value, PICTURE_COLUMN);
}
}
/// <summary>
/// Returns the Picture byte array as a MemoryStream that can be
/// displayed in a PictureBox
/// </summary>
public MemoryStream PictureAsStream
{
get
{
MemoryStream _ms = new MemoryStream(Picture);
return _ms;
}
}
/// <summary>
/// Price of the Inventory item
/// </summary>
public Nullable<decimal> Price
{
get
{
return _price;
}
set
{
// If needed put additional editing before the change value.
_price = ChangeValue<Nullable<decimal>>(_price, value, PRICE_COLUMN);
}
}
#endregion
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -