public int getReceivingNoteCount(GetReceivingNoteRequest request)
    {
        DetachedCriteria criteria = DetachedCriteria.For<Receipt>().SetProjection(Projections.ProjectionList()
               .Add(Projections.Count("ReceiptNo")));

        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.customerPartyCode != null && request.customerPartyCode != string.Empty)
        {
            criteria.Add(Expression.Eq("PartyTo.Code", request.customerPartyCode));
        }

        if (request.customer != null && request.customer != string.Empty)
        {
            criteria.Add(Expression.Like("PartyTo.Name", request.customer));
        }

        if (request.receivingNo != null && request.receivingNo != string.Empty)
        {
            criteria.Add(Expression.Eq("ReceiptNo", request.receivingNo));
        }

        if (request.receiveDateFromSpecified)
        {
            criteria.Add(Expression.Ge("CreateDate", request.receiveDateFrom));
        }

        if (request.receiveDateToSpecified)
        {
            criteria.Add(Expression.Le("CreateDate", request.receiveDateTo));
        }

       IList list = TheCriteriaMgr.FindAll(criteria, request.beginRowIndex, request.beginRowIndex + request.rowSize);

        int count = 0;
        if (list != null && list.Count > 0)
        {
            if (list[0] is int)
            {
                count = int.Parse(list[0].ToString());
            }
        }
        return count;
    }
    public ReceivingNote[] getReceivingNote(GetReceivingNoteRequest request)
    {

        DetachedCriteria criteria = DetachedCriteria.For<Receipt>();
        criteria.AddOrder(Order.Desc("ReceiptNo"));

        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.customerPartyCode != null && request.customerPartyCode != string.Empty)
        {
            criteria.Add(Expression.Eq("PartyTo.Code", request.customerPartyCode));
        }

        if (request.customer != null && request.customer != string.Empty)
        {
            criteria.Add(Expression.Like("PartyTo.Name", request.customer));
        }

        if (request.receivingNo != null && request.receivingNo != string.Empty)
        {
            criteria.Add(Expression.Eq("ReceiptNo", request.receivingNo));
        }

        if (request.receiveDateFromSpecified)
        {
            criteria.Add(Expression.Ge("CreateDate", request.receiveDateFrom));
        }

        if (request.receiveDateToSpecified)
        {
            criteria.Add(Expression.Le("CreateDate", request.receiveDateTo));
        }


        IList<Receipt> receiptList = TheCriteriaMgr.FindAll<Receipt>(criteria);

        List<ReceivingNote> noteList = new List<ReceivingNote>();
        ReceivingNote note = new ReceivingNote();
        foreach (Receipt receipt in receiptList)
        {
            note.id = receipt.ReceiptNo;
            note.receivingNo = receipt.ReceiptNo;
            note.receiveDate = receipt.CreateDate;
            note.receiveDateSpecified = true;

            DeliveryOrder deliveryOrder = new DeliveryOrder();
            deliveryOrder.deliveryOrderNo = receipt.ReferenceIpNo;
            note.deliveryOrder = deliveryOrder;

            com.Sconit.Entity.Svp.Party partyFrom = new com.Sconit.Entity.Svp.Party();
            partyFrom.code = receipt.PartyFrom.Code;
            partyFrom.id = receipt.PartyFrom.Code;
            partyFrom.description = receipt.PartyFrom.Name;
            note.partyFrom = partyFrom;

            com.Sconit.Entity.Svp.Party partyTo = new com.Sconit.Entity.Svp.Party();
            partyTo.code = receipt.PartyTo.Code;
            partyTo.id = receipt.PartyTo.Code;
            partyTo.description = receipt.PartyTo.Name;
            note.partyTo = partyTo;

            com.Sconit.Entity.Svp.User receiveUser = new com.Sconit.Entity.Svp.User();
            receiveUser.id = receipt.CreateUser.Code;
            receiveUser.name = receipt.CreateUser.Name;
            note.receiveUser = receiveUser;

            noteList.Add(note);
        }

        return noteList.ToArray();

    }