本文整理汇总了C#中POSServer.DataLayer.Implement.ObjectCriteria.Add方法的典型用法代码示例。如果您正苦于以下问题:C# ObjectCriteria.Add方法的具体用法?C# ObjectCriteria.Add怎么用?C# ObjectCriteria.Add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类POSServer.DataLayer.Implement.ObjectCriteria
的用法示例。
在下文中一共展示了ObjectCriteria.Add方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FindInventoryChecking
public IList<DepartmentInventoryChecking> FindInventoryChecking(DateTime fromDate, DateTime toDate)
{
ObjectCriteria<DepartmentInventoryChecking> criteria = new ObjectCriteria<DepartmentInventoryChecking>();
criteria.Add(a => a.CreateDate >= fromDate);
criteria.Add(a => a.CreateDate <= toDate);
criteria.Add(a => a.Fixed == 0);
criteria.Add(a => a.ExFld2 == 0);
return DepartmentInventoryCheckingDao.FindAll(criteria);
}
示例2: FindByProductId
public MainStock FindByProductId(string productId)
{
ObjectCriteria<MainStock> objectCriteria = new ObjectCriteria<MainStock>();
objectCriteria.Add(mstk => mstk.Product.ProductId == productId);
return (MainStock)MainStockDao.FindFirst(objectCriteria);
}
示例3: Update
public void Update(StockOut data)
{
long definitionStatusId = data.DefinitionStatus.DefectStatusId;
if (definitionStatusId == DefinitionStatus.TEMP_STOCKOUT
|| definitionStatusId == DefinitionStatus.PROTOTYPE) return;
foreach (StockOutDetail outDetail in data.StockOutDetails)
{
string productId = outDetail.Product.ProductId;
ObjectCriteria<MainStock> findStock = new ObjectCriteria<MainStock>();
findStock.Add(stk => stk.Product.ProductId == productId);
MainStock currentStock = MainStockDao.FindFirst(findStock) as MainStock;
/*MainStock currentStock = (MainStock)MainStockDao.ExecuteExposedSession(delegate(ISession session)
{
var query =
session.QueryOver<MainStock>()
.Where(
stk =>
stk.Product.ProductId ==
productId);
return query.SingleOrDefault();
});*/
if (currentStock == null) // create new stock
{
throw new DataIntegrityViolationException("Could not find the product id in stock");
}
else // update current stock
{
// * ---- CHUA CO PHAN XUAT HANG HU LOI HONG MAT O DAY --------
currentStock.Quantity -= outDetail.Quantity;
currentStock.GoodQuantity -= outDetail.Quantity;
currentStock.ExclusiveKey += 1;
if (currentStock.Quantity < 0 || currentStock.GoodQuantity < 0)
throw new DataIntegrityViolationException("Stock quantity of " + currentStock.Product.ProductId + " is zero.");
MainStockDao.Update(currentStock);
}
}
}
示例4: Add
public StockIn Add(StockIn data)
{
IDictionary<string,MainPrice> prices = new Dictionary<string, MainPrice>();
var maxIdResult = StockInDao.SelectSpecificType(null, Projections.Max("StockInId"));
long nextStockInId = maxIdResult != null ? Int64.Parse(maxIdResult.ToString()) + 1 : 1;
// add or update stock
var maxStockIdResult = MainStockDao.SelectSpecificType(null, Projections.Max("StockId"));
long nextStockId = maxStockIdResult != null ? Int64.Parse(maxStockIdResult.ToString()) + 1 : 1;
data.StockInId = nextStockInId.ToString();
StockInDao.Add(data);
foreach (StockInDetail inDetail in data.StockInDetails)
{
inDetail.StockInDetailPK.StockInId = nextStockInId.ToString();
Product current = ProductDao.FindById(inDetail.Product.ProductId);
if (current != null)
{
inDetail.Product = current;
}
else
{
ProductDao.Add(inDetail.Product);
}
StockInDetailDao.Add(inDetail);
ObjectCriteria<MainStock> findStock = new ObjectCriteria<MainStock>();
string productId = inDetail.Product.ProductId;
findStock.Add(stk => stk.Product.ProductId==productId);
MainStock currentStock = MainStockDao.FindFirst(findStock) as MainStock;
if(currentStock == null) // create new stock
{
MainStock newStock = new MainStock
{
StockId = nextStockId++,
CreateDate = DateTime.Now,
UpdateDate = DateTime.Now,
CreateId = "admin",
UpdateId = "admin",
DelFlg = 0,
ExclusiveKey = 1,
Product = inDetail.Product,
ProductMaster = inDetail.ProductMaster,
Quantity = inDetail.Quantity,
GoodQuantity = inDetail.Quantity
};
MainStockDao.Add(newStock);
}
else // update current stock
{
currentStock.Quantity += inDetail.Quantity;
currentStock.GoodQuantity += inDetail.Quantity;
currentStock.ExclusiveKey += 1;
MainStockDao.Update(currentStock);
}
// add price for update later
prices[inDetail.MainPrice.MainPricePK.ProductMasterId] = inDetail.MainPrice;
}
// update price if have
foreach (KeyValuePair<string, MainPrice> mainPrice in prices)
{
ObjectCriteria<MainPrice> findPrice = new ObjectCriteria<MainPrice>();
string productMasterId = mainPrice.Key;
findPrice.Add(
price => price.MainPricePK.ProductMasterId == productMasterId);
MainPrice currentPrice = MainPriceDao.FindFirst(findPrice) as MainPrice;
if (currentPrice == null)
{
MainPriceDao.Add(mainPrice.Value);
}
else
{
currentPrice.Price = mainPrice.Value.Price;
currentPrice.WholeSalePrice = mainPrice.Value.WholeSalePrice;
MainPriceDao.Update(currentPrice);
}
}
// color and size
// the updating informs that specialized object has been used in stock in so it can not be deleted.
IList<ExProductColor> colors = data.StockInDetails.Select(x => x.Product.ProductColor).Distinct().ToList();
foreach (ExProductColor exProductColor in colors)
{
if(exProductColor.ExFld1 == 1) continue;
exProductColor.ExFld1 = 1;
ExProductColorDao.Update(exProductColor);
}
IList<ExProductSize> sizes = data.StockInDetails.Select(x => x.Product.ProductSize).Distinct().ToList();
foreach (ExProductSize exProductSize in sizes)
{
if(exProductSize.ExFld1 == 1) continue;
exProductSize.ExFld1 = 1;
ExProductSizeDao.Update(exProductSize);
}
return data;
}