public RequisitionOrder[] getRequisitionOrder(GetRequisitionOrderRequest request) { DetachedCriteria criteria = DetachedCriteria.For <OrderHead>(); if (request.orderby != null) { RequestOrderByHelper.ConverToCriteria(request.orderby, orderbyFiledsMapping, criteria); } if (request.requisitionOrderNo != null && request.requisitionOrderNo != string.Empty) { criteria.Add(Expression.Eq("OrderNo", request.requisitionOrderNo)); request.rowSize = 1; } else { if (request.requisitionOrderStatus != null && request.requisitionOrderStatus.Length > 0) { for (int i = 0; i < request.requisitionOrderStatus.Count(); i++) { if (request.requisitionOrderStatus[i] == "In_Process") { request.requisitionOrderStatus[i] = BusinessConstants.CODE_MASTER_STATUS_VALUE_INPROCESS; } } criteria.Add(Expression.In("Status", request.requisitionOrderStatus)); } else { criteria.Add(Expression.Not(Expression.Eq("Status", BusinessConstants.CODE_MASTER_STATUS_VALUE_CREATE))); } } if (request.supplier != null && request.supplier != string.Empty) { criteria.Add(Expression.Like("PartyFrom.Name", request.supplier)); } if (request.supplierPartyCode != null && request.supplierPartyCode != string.Empty) { criteria.Add(Expression.Eq("PartyFrom.Code", request.supplierPartyCode)); } if (request.customer != null && request.customer != string.Empty) { criteria.Add(Expression.Like("PartyTo.Name", request.supplierPartyCode)); } if (request.customerPartyCode != null && request.customerPartyCode != string.Empty) { criteria.Add(Expression.Eq("PartyTo.Code", request.customerPartyCode)); } if (request.effectiveDateFromSpecified) { criteria.Add(Expression.Ge("ReleaseDate", request.effectiveDateFrom)); } if (request.effectiveDateToSpecified) { criteria.Add(Expression.Le("ReleaseDate", request.effectiveDateTo)); } IList <OrderHead> orderHeadList = TheCriteriaMgr.FindAll <OrderHead>(criteria, request.beginRowIndex, request.beginRowIndex + request.rowSize); List <RequisitionOrder> orderList = new List <RequisitionOrder>(); foreach (OrderHead orderHead in orderHeadList) { RequisitionOrder requisitionOrder = fillOrderHead(orderHead); foreach (OrderDetail orderDetail in orderHead.OrderDetails) { RequisitionOrderItem requisitionOrderItem = fillOrderDetail(orderDetail); requisitionOrder.addRequisitionOrderItem(requisitionOrderItem); } orderList.Add(requisitionOrder); } return(orderList.ToArray()); }
public int getRequisitionOrderCount(GetRequisitionOrderRequest request) { DetachedCriteria criteria = DetachedCriteria.For <OrderHead>().SetProjection(Projections.ProjectionList() .Add(Projections.Count("OrderNo"))); if (request.requisitionOrderNo != null && request.requisitionOrderNo != string.Empty) { criteria.Add(Expression.Eq("OrderNo", request.requisitionOrderNo)); } if (request.supplier != null && request.supplier != string.Empty) { criteria.Add(Expression.Like("PartyFrom.Name", request.supplier)); } if (request.supplierPartyCode != null && request.supplierPartyCode != string.Empty) { criteria.Add(Expression.Eq("PartyFrom.Code", request.supplierPartyCode)); } if (request.customer != null && request.customer != string.Empty) { criteria.Add(Expression.Like("PartyTo.Name", request.supplierPartyCode)); } if (request.customerPartyCode != null && request.customerPartyCode != string.Empty) { criteria.Add(Expression.Eq("PartyTo.Code", request.customerPartyCode)); } if (request.effectiveDateFromSpecified) { criteria.Add(Expression.Ge("StartTime", request.effectiveDateFrom)); } if (request.effectiveDateToSpecified) { criteria.Add(Expression.Le("StartTime", request.effectiveDateTo)); } if (request.requisitionOrderStatus != null && request.requisitionOrderStatus.Length > 0) { criteria.Add(Expression.In("Status", request.requisitionOrderStatus)); } else { criteria.Add(Expression.Not(Expression.Eq("Status", BusinessConstants.CODE_MASTER_STATUS_VALUE_CREATE))); } IList list = TheCriteriaMgr.FindAll(criteria); int count = 0; if (list != null && list.Count > 0) { if (list[0] is int) { count = int.Parse(list[0].ToString()); } } return(count); }