本文整理汇总了C#中ObjectCriteria.AddOrder方法的典型用法代码示例。如果您正苦于以下问题:C# ObjectCriteria.AddOrder方法的具体用法?C# ObjectCriteria.AddOrder怎么用?C# ObjectCriteria.AddOrder使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ObjectCriteria
的用法示例。
在下文中一共展示了ObjectCriteria.AddOrder方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnInitialize
/// <summary>
/// Initializes this instance.
/// </summary>
protected override void OnInitialize()
{
ObjectCriteria<Department> crit = new ObjectCriteria<Department>();
crit.AddOrder(m => m.DepartmentId, Order.Asc);
IList<Department> departments = DepartmentLogic.FindAll(crit);
Departments = departments as IList;
SelectedDepartment = departments[0];
StockInventoryList = new ArrayList();
CheckSelectedDepartment = true;
Barcode = "";
IList list = new ArrayList();
}
示例2: Add
public void Add(DepartmentStockIn data)
{
string deptStr = string.Format("{0:000}", data.DepartmentId);
string dateStr = data.StockInDate.ToString("yyMMdd");
var criteria = new ObjectCriteria();
criteria.AddGreaterCriteria("StockoutId", (long)0);
var maxId = StockOutDAO.SelectSpecificType(criteria, Projections.Max("StockoutId"));
var stockOutId = maxId == null ? 1 : Int64.Parse(maxId.ToString()) + 1;
//var stockInPk = new DepartmentStockInPK { DepartmentId = data.DepartmentId, StockInId = stockOutId + "" };
//data.DepartmentStockInPK = stockInPk;
data.CreateDate = DateTime.Now;
data.UpdateDate = DateTime.Now;
data.UpdateId = ClientInfo.getInstance().LoggedUser.Name;
data.CreateId = ClientInfo.getInstance().LoggedUser.Name;
StockOut stockOut = new StockOut();
stockOut.StockoutId = stockOutId;
stockOut.CreateDate = DateTime.Now;
stockOut.UpdateDate = DateTime.Now;
stockOut.StockOutDate = DateTime.Now;
stockOut.UpdateId = ClientInfo.getInstance().LoggedUser.Name;
stockOut.CreateId = ClientInfo.getInstance().LoggedUser.Name;
stockOut.NotUpdateMainStock = false;
stockOut.DefectStatus = new StockDefectStatus { DefectStatusId = 0};
stockOut.DelFlg = 0;
stockOut.DepartmentId = data.DepartmentId;
// we will get the stock to get the data
IList productMasterIds = new ArrayList();
foreach (DepartmentStockInDetail stockInDetail in data.DepartmentStockInDetails)
{
productMasterIds.Add(stockInDetail.Product.ProductMaster.ProductMasterId);
}
IList productIds = new ArrayList();
foreach (DepartmentStockInDetail stockInDetail in data.DepartmentStockInDetails)
{
productIds.Add(stockInDetail.Product.ProductId);
}
criteria = new ObjectCriteria();
criteria.AddEqCriteria("DelFlg", CommonConstants.DEL_FLG_NO);
criteria.AddGreaterCriteria("Quantity", (long)0);
//criteria.AddSearchInCriteria("ProductMaster.ProductMasterId", productMasterIds);
criteria.AddSearchInCriteria("Product.ProductId", productIds);
//criteria.AddOrder("ProductMaster.ProductMasterId", true);
criteria.AddOrder("Product.ProductId", true);
IList stockList = StockDAO.FindAll(criteria);
IList updateStockList = new ArrayList();
IList stockOutDetailList = new ArrayList();
var maxSODetailId = StockOutDetailDAO.SelectSpecificType(new ObjectCriteria(), Projections.Max("StockOutDetailId"));
long stockOutDetailId = (maxSODetailId == null ? 1 : Int64.Parse(maxSODetailId.ToString()) + 1);
foreach (DepartmentStockInDetail stockInDetail in data.DepartmentStockInDetails)
{
long quantity = stockInDetail.Quantity;
foreach (Stock stock in stockList)
{
long stockInQty = 0;
//if (stock.ProductMaster.ProductMasterId.Equals(stockInDetail.Product.ProductMaster.ProductMasterId) && stock.Quantity > 0)
if (stock.Product.ProductId.Equals(stockInDetail.Product.ProductId) && stock.Quantity > 0)
{
if (quantity > stock.GoodQuantity)
{
throw new BusinessException("Mặt hàng: " + stock.ProductMaster.ProductName
+ " - mã vạch: " + stock.Product.ProductId
+ " không đủ hàng! Tồn: " + stockInDetail.StockQuantity + " , cần xuất: " + quantity);
stockInQty = stock.GoodQuantity;
quantity -= stock.GoodQuantity;
stock.GoodQuantity = 0;
}
else
{
stockInQty = quantity;
stock.GoodQuantity -= quantity;
quantity = 0;
}
stock.Quantity = stock.GoodQuantity + stock.ErrorQuantity + stock.DamageQuantity +
stock.LostQuantity + stock.UnconfirmQuantity;
stock.UpdateDate = DateTime.Now;
stock.UpdateId = ClientInfo.getInstance().LoggedUser.Name;
updateStockList.Add(stock);
/*var pk = new StockOutDetailPK
{
//DepartmentId = data.DepartmentId,
ProductId = stock.Product.ProductId,
StockOutId = stockOutId
};*/
var detail = new StockOutDetail
{
//StockOutDetailPK = pk,
StockOutDetailId = stockOutDetailId++,
StockOutId = stockOutId,
//.........这里部分代码省略.........
示例3: AddStockInBack
public void AddStockInBack(DepartmentStockIn data)
{
long deptId = data.DepartmentStockInPK.DepartmentId;
string deptStr = "000";
if (deptId > 9999)
{
deptStr = deptId.ToString();
}
else
{
deptStr = string.Format("{0:000}", data.DepartmentStockInPK.DepartmentId);
}
string dateStr = data.StockInDate.ToString("yyMMdd");
var criteria = new ObjectCriteria();
string extraZero = "00000";
if(deptId > 9999)
{
extraZero = "000";
}
criteria.AddGreaterCriteria("DepartmentStockInPK.StockInId", dateStr + deptStr + extraZero);
var maxId = DepartmentStockInDAO.SelectSpecificType(criteria,
Projections.Max("DepartmentStockInPK.StockInId"));
string startNum = "00001";
if(deptId > 9999)
{
startNum = "001";
}
var stockInId = maxId == null
? dateStr + deptStr + startNum
: string.Format("{0:00000000000000}", (Int64.Parse(maxId.ToString()) + 1));
var stockInPk = new DepartmentStockInPK {DepartmentId = deptId, StockInId = stockInId + ""};
data.DepartmentStockInPK = stockInPk;
data.CreateDate = DateTime.Now;
data.UpdateDate = DateTime.Now;
data.UpdateId = ClientInfo.getInstance().LoggedUser.Name;
data.CreateId = ClientInfo.getInstance().LoggedUser.Name;
DepartmentStockInDAO.Add(data);
// we will get the stock to get the data
IList productMasterIds = new ArrayList();
IList productIds = new ArrayList();
foreach (DepartmentStockInDetail stockInDetail in data.DepartmentStockInDetails)
{
productIds.Add(stockInDetail.Product.ProductId);
}
criteria = new ObjectCriteria();
criteria.AddEqCriteria("DelFlg", CommonConstants.DEL_FLG_NO);
criteria.AddSearchInCriteria("DepartmentStockPK.ProductId", productIds);
criteria.AddOrder("Product.ProductId", true);
IList stockList = DepartmentStockDAO.FindAll(criteria);
IList updateStockList = new ArrayList();
IList stockInDetailList = new ArrayList();
foreach (DepartmentStockInDetail stockInDetail in data.DepartmentStockInDetails)
{
long quantity = stockInDetail.Quantity;
DepartmentStockPK stockPk = new DepartmentStockPK
{
DepartmentId = deptId,
ProductId = stockInDetail.Product.ProductId
};
DepartmentStock departmentStock = DepartmentStockDAO.FindById(stockPk);
if (departmentStock.DepartmentStockPK.ProductId.Equals(stockInDetail.Product.ProductId))
{
departmentStock.GoodQuantity += stockInDetail.Quantity;
departmentStock.Quantity += stockInDetail.Quantity;
departmentStock.UpdateDate = DateTime.Now;
departmentStock.UpdateId = ClientInfo.getInstance().LoggedUser.Name;
DepartmentStockDAO.Update(departmentStock);
var pk = new DepartmentStockInDetailPK
{
DepartmentId = data.DepartmentStockInPK.DepartmentId,
ProductId = departmentStock.Product.ProductId,
StockInId = stockInId
};
stockInDetail.DepartmentStockInDetailPK = pk;
DepartmentStockInDetailDAO.Add(stockInDetail);
}
}
}
示例4: Add
public DepartmentStockIn Add(DepartmentStockIn data)
{
string deptStr = "";
if(ClientSetting.IsSubStock())
{
deptStr = string.Format("{0:00000}", data.DepartmentStockInPK.DepartmentId);
}
else
{
deptStr = string.Format("{0:000}", data.DepartmentStockInPK.DepartmentId);
}
string dateStr = data.StockInDate.ToString("yyMMdd");
var criteria = new ObjectCriteria();
if(ClientSetting.IsSubStock())
{
criteria.AddGreaterCriteria("DepartmentStockInPK.StockInId", dateStr + deptStr + "000");
}
else
{
criteria.AddGreaterCriteria("DepartmentStockInPK.StockInId", dateStr + deptStr + "00000");
}
var maxId = DepartmentStockInDAO.SelectSpecificType(criteria, Projections.Max("DepartmentStockInPK.StockInId"));
string stockInId = "";
if(ClientSetting.IsSubStock())
{
stockInId = maxId == null ? dateStr + deptStr + "001" : string.Format("{0:00000000000000}", (Int64.Parse(maxId.ToString()) + 1));
}
else
{
stockInId = maxId == null ? dateStr + deptStr + "00001" : string.Format("{0:00000000000000}", (Int64.Parse(maxId.ToString()) + 1));
}
var stockInPk = new DepartmentStockInPK {DepartmentId = data.DepartmentId, StockInId = stockInId + ""};
data.DepartmentStockInPK = stockInPk;
data.CreateDate = DateTime.Now;
data.UpdateDate = DateTime.Now;
data.UpdateId = ClientInfo.getInstance().LoggedUser.Name;
data.CreateId = ClientInfo.getInstance().LoggedUser.Name;
DepartmentStockInDAO.Add(data);
// we will get the stock to get the data
IList productMasterIds = new ArrayList();
foreach (DepartmentStockInDetail stockInDetail in data.DepartmentStockInDetails)
{
productMasterIds.Add(stockInDetail.Product.ProductMaster.ProductMasterId);
}
criteria = new ObjectCriteria();
criteria.AddEqCriteria("DelFlg", CommonConstants.DEL_FLG_NO);
criteria.AddGreaterCriteria("Quantity", (long)0);
criteria.AddSearchInCriteria("ProductMaster.ProductMasterId", productMasterIds);
criteria.AddOrder("ProductMaster.ProductMasterId", true);
criteria.AddOrder("Product.ProductId", true);
IList stockList = DepartmentStockDAO.FindAll(criteria);
IList updateStockList = new ArrayList();
IList stockInDetailList = new ArrayList();
foreach (DepartmentStockInDetail stockInDetail in data.DepartmentStockInDetails)
{
long quantity = stockInDetail.Quantity;
foreach (DepartmentStock stock in stockList)
{
long stockInQty = 0;
if (stock.Product.ProductId.Equals(stockInDetail.ProductId) && stock.Quantity >= 0)
{
/*if (quantity >= stock.Quantity)
{
stockInQty = stock.Quantity;
quantity -= stock.Quantity;
stock.Quantity = 0;
}
else
{
stockInQty = quantity;
stock.Quantity -= quantity;
quantity = 0;
}*/
if (quantity >= stock.GoodQuantity)
{
stockInQty = stock.GoodQuantity;
quantity -= stock.GoodQuantity;
stock.GoodQuantity = 0;
}
else
{
stockInQty = quantity;
stock.GoodQuantity -= quantity;
quantity = 0;
}
stock.Quantity = stock.GoodQuantity + stock.ErrorQuantity + stock.DamageQuantity +
stock.LostQuantity + stock.UnconfirmQuantity;
stock.UpdateDate = DateTime.Now;
stock.UpdateId = ClientInfo.getInstance().LoggedUser.Name;
updateStockList.Add(stock);
var pk = new DepartmentStockInDetailPK
{
DepartmentId = data.DepartmentId,
//.........这里部分代码省略.........
示例5: Add
public EmployeeInfo Add(EmployeeInfo employeeInfo)
{
ObjectCriteria crit = new ObjectCriteria();
crit.AddOrder("Barcode", false);
crit.MaxResult = 3;
IList list = EmployeeDetailDAO.FindAll(crit);
string barCode = "NV000001";
if(list!=null && list.Count > 0 )
{
EmployeeInfo info = (EmployeeInfo) list[0];
barCode = "NV" + string.Format("{0:000000}",Int32.Parse(info.Barcode.Substring(2))+1);
}
if (employeeInfo.Employee==null) // create new
{
string employeeId = ConvertEmployeeNameToId(employeeInfo.EmployeeName);
//employeeInfo.EmployeePK.DepartmentId = departmentId;
var employeePK = new EmployeePK { DepartmentId = 0, EmployeeId = employeeId };
employeeInfo.EmployeePK = employeePK;
//employeeInfo.EmployeeId = employeeId;
if(employeeInfo.Employee == null)
{
employeeInfo.Employee = new Employee();
}
employeeInfo.Employee.EmployeePK = employeePK;
employeeInfo.Employee.CreateDate = DateTime.Now;
employeeInfo.Employee.CreateId = ClientInfo.getInstance().LoggedUser.Name;
employeeInfo.DelFlg = 0;
employeeInfo.ExclusiveKey = 1;
employeeInfo.Employee.DelFlg = 0;
employeeInfo.Employee.ExclusiveKey = 1;
employeeInfo.Employee.Department = new Department {DepartmentId = 0};
employeeInfo.Department = new Department{DepartmentId = 0};
/*employeeInfo.Employee.EmployeeId = employeeId;
employeeInfo.Employee.DepartmentId = departmentId;*/
employeeInfo.CreateDate = DateTime.Now;
employeeInfo.CreateId = ClientInfo.getInstance().LoggedUser.Name;
employeeInfo.Barcode = barCode;
employeeInfo.Employee.CreateDate = DateTime.Now;
employeeInfo.Employee.CreateId = ClientInfo.getInstance().LoggedUser.Name;
EmployeeDAO.Add(employeeInfo.Employee);
EmployeeDetailDAO.Add(employeeInfo);
}
else // update
{
employeeInfo.UpdateDate = DateTime.Now;
employeeInfo.UpdateId = ClientInfo.getInstance().LoggedUser.Name;
employeeInfo.Employee.UpdateDate = DateTime.Now;
employeeInfo.Employee.UpdateId = ClientInfo.getInstance().LoggedUser.Name;
EmployeeDetailDAO.Update(employeeInfo);
//EmployeeDAO.Update(employeeInfo.Employee);
}
//EmployeeDetailDAO.Add(data);
return employeeInfo;
}
示例6: ProcessPeriod
public void ProcessPeriod(bool isSubmitPeriod)
{
// Save the end of period
// select 5 day nearest
//IList departmentTimelineList = new ArrayList();
ObjectCriteria crit = new ObjectCriteria();
crit.AddOrder("EndTime", false);
crit.MaxResult = 5;
IList list = DepartmentTimelineDAO.FindAll(crit);
DateTime startTime = DateUtility.ZeroTime(DateTime.Now);
if (list != null && list.Count > 0)
{
// update end time of nearest 5 timeline for sure transparency
DepartmentTimeline departmentTimeline = (DepartmentTimeline) list[0];
DateTime lastSubmitEndTime = departmentTimeline.EndTime;
// get days which customer do not submit period
TimeSpan timeSpan = DateUtility.ZeroTime(DateTime.Now).Subtract(DateUtility.ZeroTime(lastSubmitEndTime));
// fix those days in order we can sync for today.
startTime = lastSubmitEndTime.AddSeconds(1);
for (int i = 0; i < timeSpan.Days - 1; i++)
{
DateTime nextDateTime = lastSubmitEndTime.AddDays(i + 1);
DepartmentTimeline fixTimeline = new DepartmentTimeline();
fixTimeline.WorkingDay = DateUtility.ZeroTime(nextDateTime);
fixTimeline.CreateDate = DateUtility.MaxTime(nextDateTime);
fixTimeline.UpdateDate = DateUtility.MaxTime(nextDateTime);
fixTimeline.CreateId = ClientInfo.getInstance().LoggedUser.Name;
fixTimeline.UpdateId = ClientInfo.getInstance().LoggedUser.Name;
fixTimeline.StartTime = startTime;
fixTimeline.EndTime = DateUtility.MaxTime(nextDateTime);
DepartmentTimelinePK fixTimelinePK = new DepartmentTimelinePK
{
DepartmentId = CurrentDepartment.Get().DepartmentId,
Period = nextDateTime.DayOfYear
};
fixTimeline.DepartmentTimelinePK = fixTimelinePK;
DepartmentTimelineDAO.Add(fixTimeline);
startTime = fixTimeline.EndTime.AddSeconds(1);
}
}
// If submit period ( ket so ) then we ' ket so '
DepartmentTimeline timeline = null;
if (isSubmitPeriod)
{
timeline = new DepartmentTimeline();
timeline.WorkingDay = DateUtility.ZeroTime(DateTime.Now);
timeline.CreateDate = DateTime.Now;
timeline.UpdateDate = DateTime.Now;
timeline.CreateId = ClientInfo.getInstance().LoggedUser.Name;
timeline.UpdateId = ClientInfo.getInstance().LoggedUser.Name;
timeline.StartTime = startTime;
timeline.EndTime = DateTime.Now;
DepartmentTimelinePK timelinePK = new DepartmentTimelinePK
{
DepartmentId = CurrentDepartment.Get().DepartmentId,
Period = DateTime.Now.DayOfYear
};
var dbTimeline = DepartmentTimelineDAO.FindById(timelinePK);
if (dbTimeline != null)
{
throw new BusinessException("Ngày hôm nay đã kết sổ");
}
timeline.DepartmentTimelinePK = timelinePK;
DepartmentTimelineDAO.Add(timeline);
//departmentTimelineList.Add(timeline);
}
}
示例7: Add
public void Add(DepartmentStockIn data)
{
string deptStr = string.Format("{0:000}", data.DepartmentId);
string dateStr = data.StockInDate.ToString("yyMMdd");
var criteria = new ObjectCriteria();
criteria.AddGreaterCriteria("StockoutId", (long)0);
var maxId = StockOutDAO.SelectSpecificType(criteria, Projections.Max("StockoutId"));
var stockOutId = maxId == null ? 1 : Int64.Parse(maxId.ToString()) + 1;
//var stockInPk = new DepartmentStockInPK { DepartmentId = data.DepartmentId, StockInId = stockOutId + "" };
//data.DepartmentStockInPK = stockInPk;
data.CreateDate = DateTime.Now;
data.UpdateDate = DateTime.Now;
data.UpdateId = ClientInfo.getInstance().LoggedUser.Name;
data.CreateId = ClientInfo.getInstance().LoggedUser.Name;
StockOut stockOut = new StockOut();
stockOut.StockoutId = stockOutId;
stockOut.CreateDate = DateTime.Now;
stockOut.UpdateDate = DateTime.Now;
stockOut.StockOutDate = DateTime.Now;
stockOut.UpdateId = ClientInfo.getInstance().LoggedUser.Name;
stockOut.CreateId = ClientInfo.getInstance().LoggedUser.Name;
stockOut.NotUpdateMainStock = false;
stockOut.DefectStatus = new StockDefectStatus { DefectStatusId = 0};
stockOut.DelFlg = 0;
stockOut.DepartmentId = data.DepartmentId;
// we will get the stock to get the data
IList productMasterIds = new ArrayList();
foreach (DepartmentStockInDetail stockInDetail in data.DepartmentStockInDetails)
{
productMasterIds.Add(stockInDetail.Product.ProductMaster.ProductMasterId);
}
criteria = new ObjectCriteria();
criteria.AddEqCriteria("DelFlg", CommonConstants.DEL_FLG_NO);
criteria.AddGreaterCriteria("Quantity", (long)0);
criteria.AddSearchInCriteria("ProductMaster.ProductMasterId", productMasterIds);
criteria.AddOrder("ProductMaster.ProductMasterId", true);
criteria.AddOrder("Product.ProductId", true);
IList stockList = StockDAO.FindAll(criteria);
IList updateStockList = new ArrayList();
IList stockOutDetailList = new ArrayList();
var maxSODetailId = StockOutDetailDAO.SelectSpecificType(new ObjectCriteria(), Projections.Max("StockOutDetailId"));
long stockOutDetailId = (maxSODetailId == null ? 1 : Int64.Parse(maxSODetailId.ToString()) + 1);
/*if(stockOutIds!= null && ((long)stockOutIds) > 0)
{
stockOutDetailId = (long) stockOutIds + 1;
}
MessageBox.Show(stockOutDetailId)*/
/*if (stockOutIds != null && 1 == ((IList)stockOutIds).Count)
{
stockOutDetailId = (long)((IList)stockOutIds)[0] + 1;
}*/
foreach (DepartmentStockInDetail stockInDetail in data.DepartmentStockInDetails)
{
long quantity = stockInDetail.Quantity;
foreach (Stock stock in stockList)
{
long stockInQty = 0;
if (stock.ProductMaster.ProductMasterId.Equals(stockInDetail.Product.ProductMaster.ProductMasterId) && stock.Quantity > 0)
{
if (quantity >= stock.GoodQuantity)
{
stockInQty = stock.GoodQuantity;
quantity -= stock.GoodQuantity;
stock.GoodQuantity = 0;
}
else
{
stockInQty = quantity;
stock.GoodQuantity -= quantity;
quantity = 0;
}
stock.Quantity = stock.GoodQuantity + stock.ErrorQuantity + stock.DamageQuantity +
stock.LostQuantity + stock.UnconfirmQuantity;
stock.UpdateDate = DateTime.Now;
stock.UpdateId = ClientInfo.getInstance().LoggedUser.Name;
updateStockList.Add(stock);
/*var pk = new StockOutDetailPK
{
//DepartmentId = data.DepartmentId,
ProductId = stock.Product.ProductId,
StockOutId = stockOutId
};*/
var detail = new StockOutDetail
{
//StockOutDetailPK = pk,
StockOutDetailId = stockOutDetailId++,
StockOutId = stockOutId,
StockOut = stockOut,
//.........这里部分代码省略.........