예제 #1
0
        public List<FullHouse> QueryFullHouse(QueryHouseServiceForm form)
        {
            List<FullHouse> list = new List<FullHouse>();
            ISqlMapper mapper = MapperHelper.GetMapper();

            HouseDao dao = new HouseDao(mapper);
            House_CustomerDao hcdao = new House_CustomerDao(mapper);
            CustomerDao customerdao = new CustomerDao(mapper);
            BuildingDao buildingdao = new BuildingDao(mapper);
            RentFeeDao rfdao = new RentFeeDao(mapper);
            House_OtherFeeDao hofdao = new House_OtherFeeDao(mapper);
            OtherFeeDao ofdao = new OtherFeeDao(mapper);
            var house = dao.QueryFullHouse(form);
            var houseids = (from h in house select h.ID).ToList();
            var hcs = hcdao.Query(new House_CustomerQueryForm { HouseOrRoomIDs = houseids });
            var customerids = (from ho in hcs select ho.CustomerID).Distinct().ToList();
            var customers = customerdao.Query(new CustomerQueryForm { IDs = customerids, Enabled = 1, IsDeleted = 0, });
            var buildingids = (from h in house select h.BuildingID).Distinct().ToList();
            var buidlings = buildingdao.Query(new BuildingQueryForm { IDs = buildingids });
            var rentfees = rfdao.Query(new RentFeeQueryForm { HouseOrRoomIDs = houseids, Enabled = 1, IsDeleted = 0 });
            var rentfeeids = (from rf in rentfees select rf.ID).ToList();
            var hos = hofdao.Query(new House_OtherFeeQueryForm { HouseOrRoomIDs = houseids });
            var otherfeeids = (from ho in hos select ho.OtherFeeID).Distinct().ToList();
            var ofs = ofdao.Query(new OtherFeeQueryForm { IDs = otherfeeids });
            foreach (var h in house)
            {
                FullHouse fh = new FullHouse
                {
                    House = h,
                    Customer = (from ho in hcs
                                join c in customers on ho.CustomerID equals c.ID
                                where ho.HouseOrRoomID.Equals(h.ID) && c.Type == (int)CustomerType.业主
                                select c).FirstOrDefault(),
                    Building = buidlings.Find(t => t.ID.Equals(h.BuildingID)),
                    RentFee = rentfees.Find(t => t.HouseOrRoomID.Equals(h.ID)),
                    OtherFees = (from ho in hos
                                 join of in ofs on ho.OtherFeeID equals of.ID
                                 where ho.HouseOrRoomID.Equals(h.ID)
                                 select of).ToList(),
                    Renter = (from ho in hcs
                              join c in customers on ho.CustomerID equals c.ID
                              where ho.HouseOrRoomID.Equals(h.ID) && c.Type == (int)CustomerType.租客
                              select c).FirstOrDefault(),
                };
                list.Add(fh);
            }
            return list;
        }
예제 #2
0
 public List<House_OtherFee> Query(House_OtherFeeQueryForm form)
 {
     ISqlMapper mapper = MapperHelper.GetMapper();
     House_OtherFeeDao dao = new House_OtherFeeDao(mapper);
     return dao.Query(form);
 }
예제 #3
0
        public BillModel QuerySingle(string BillID)
        {
            ISqlMapper mapper = MapperHelper.GetMapper();
            BillDao dao = new BillDao(mapper);
            OtherFeeDao ofdao = new OtherFeeDao(mapper);
            House_OtherFeeDao hodao = new House_OtherFeeDao(mapper);
            OtherFeeBillDao ofbdao = new OtherFeeBillDao(mapper);

            var bill = dao.QueryFullBill(new QueryFullBillServiceForm { ID = BillID }).FirstOrDefault();
            BillModel model = new BillModel
            {
                Bill = bill,
            };
            if (bill == null) return model;
            var house_otherfees = hodao.Query(new House_OtherFeeQueryForm { HouseOrRoomID = bill.HouseOrRoomID });
            var otherfeeids = (from ho in house_otherfees select ho.OtherFeeID).ToList();
            var otherfeebills = ofbdao.Query(new OtherFeeBillQueryForm { BillID = bill.ID, });
            var otherfees = ofdao.Query(new OtherFeeQueryForm { IDs = otherfeeids });
            var fullotherfeebills = new List<FullOtherFeeBill>();
            foreach (var ho in house_otherfees)
            {
                FullOtherFeeBill ofb = new FullOtherFeeBill
                {
                    House_OtherFee = ho,
                    OtherFee = otherfees.Find(t => t.ID.Equals(ho.OtherFeeID)),
                    OtherFeeBill = otherfeebills.Find(t => t.OtherFeeID.Equals(ho.OtherFeeID)),
                };
                fullotherfeebills.Add(ofb);
            }
            model.OtherFeeBill = fullotherfeebills;
            return model;
        }