/// <summary> /// Join and return a db DiskRent /// </summary> /// <returns></returns> public static List<DiskInfoRent> DBDiskRent() { DiskTypeBUL dbDiskType= new DiskTypeBUL(); TitleBUL dbTitle = new TitleBUL(); DiskBUL dbDisk = new DiskBUL(); List<DiskInfoRent> lst = new List<DiskInfoRent>(); List<Disk> disks = dbDisk.GetDisks(); List<DiskType> diskTypes = dbDiskType.GetDiskTypes(); List<Title> titles = dbTitle.GetTitles(); var db = dbDisk.GetDisks() .Join(dbTitle.GetTitles(), d => d.IdTitle, t => t.IdTitle, (d, t) => new { d, t }) .Join(dbDiskType.GetDiskTypes(), dt => dt.t.IdDiskType, ty => ty.IdDiskType, (dt, ty) => new { dt, ty }) .Select(x => new { IdDisk = x.dt.d.IdDisk, Title = x.dt.t.NameTitle, TypeName = x.ty.TypeName, TimeRented = x.ty.TimeRented, LateFee = x.ty.LateFee, Price = x.ty.Price, DiskRentalStatus = x.dt.d.DiskRentalStatus }).ToList(); foreach (var item in db) lst.Add(new DiskInfoRent { IdDisk = item.IdDisk, LateFee = (int)item.LateFee, Price = (int)item.Price, TimeRented = (int)item.TimeRented, Title = item.Title, TypeName = item.TypeName, DiskRentalStatus = item.DiskRentalStatus }); return lst; }
private void LoadNhungTieuDeDangChoAccept() { //Load những cái tiêu đề nào có đĩa đang chờ được accept var db = dbDetail.GetDetailPreOrders().Where(x => x.Accepted == false) .Join(dbDisk.GetDisks(), dt => dt.IdDisk, d => d.IdDisk, (dt, d) => new { dt, d }) .Join(dbTitle.GetTitles(), dtd => dtd.d.IdTitle, t => t.IdTitle, (dtd, t) => new { dtd, t }).ToList(); var lstTitle = dbTitle.GetTitles().Where(x => db.Find(k => k.t.IdTitle == x.IdTitle) != null).ToList() .Join(dbDiskType.GetDiskTypes(), t => t.IdDiskType, dt => dt.IdDiskType, (t, dt) => new TitleOrder { IdTitle = t.IdTitle, NameTitle = t.NameTitle, TitleType = dt.TypeName }); bindingDSTilte.DataSource = lstTitle; dbDetail = new DetailPreOrderBUL(); dbDisk = new DiskBUL(); dbTitle = new TitleBUL(); }
private void ReportTitle() { var dbBSThueCuaTitle = (from d in dbDisk.GetDisks() group d by d.IdTitle into titleGroup select new { Title = titleGroup.Key, SoLuongThue = titleGroup.Where(x => x.DiskRentalStatus.Equals(STATUS_RENTED)).Count(), SoLuongBSDatTruoc = titleGroup.Where(x => x.DiskRentalStatus.Equals(STATUS_ONHOLD)).Count(), }) .Join(dbTitle.GetTitles(), bs => bs.Title, t => t.IdTitle, (bs, t) => new { idTitle = t.IdTitle, TitleName = t.NameTitle, SoLuongTrenKe = t.TotalDiskOnShelf, SoLuongThue = bs.SoLuongThue, SoLuongBSDatTruoc = bs.SoLuongBSDatTruoc }); var dbDSDatTruoc = from pre in dbListPre.GetListTitlePreOrders().Where(x => x.StatusProcess.Equals(STATUS_INCOMPLETE)) group pre by pre.IdTitle into preListGroup select new { idTitle = preListGroup.Key, TongDatTruoc = preListGroup.Sum(x => x.NumberOfDisk) }; var db = dbBSThueCuaTitle .GroupJoin(dbDSDatTruoc, bss => bss.idTitle, dt => dt.idTitle, (bss, dt) => new { bss, dt }) .SelectMany(temp => temp.dt.DefaultIfEmpty(), (bs, temp) => new { bs = bs, dt = temp }); List <ReportTitle> lst = new List <ReportTitle>(); foreach (var item in db) { int?tongsodattruoc = 0; if (item.dt != null) { tongsodattruoc = item.dt.TongDatTruoc; } lst.Add(new ReportTitle { TitleName = item.bs.bss.TitleName, TongSoBanSao = item.bs.bss.SoLuongThue + item.bs.bss.SoLuongTrenKe + item.bs.bss.SoLuongBSDatTruoc, TongSoBanSaoDuocDatTruoc = tongsodattruoc, TongSoBanSaoDuocThue = item.bs.bss.SoLuongThue, TongSoBanSaoTrongKho = item.bs.bss.SoLuongTrenKe, TongSoDatTruocDangXuLi = item.bs.bss.SoLuongBSDatTruoc }); } bindingTitle.DataSource = lst; ExpressionMethod.LoadGridControl(grcTieuDe, grvTieuDe, bindingTitle); }
/// <summary> /// Trả về cái list có return db join từ 3 bảng và thông tin của khách hahgnf đó /// </summary> /// <returns></returns> public static List<DiskInfoReturn> DBDiskReturn() { List<DiskInfoReturn> lst = new List<DiskInfoReturn>(); CustomerBUL dbCustomer = new CustomerBUL(); TitleBUL dbTitle = new TitleBUL(); DiskBUL dbDisk = new DiskBUL(); ListRentedBUL dbRented = new ListRentedBUL(); var db = dbRented.GetListRenteds().Where(x => x.StatusOnBill == null) .Join(dbDisk.GetDisks(), rt => rt.IdDisk, d => d.IdDisk, (rt, d) => new { rt, d }) .Join(dbTitle.GetTitles(), rtd => rtd.d.IdTitle, t => t.IdTitle, (rtd, t) => new { rtd, t }) .Join(dbCustomer.GetCustomers(), rtdt => rtdt.rtd.rt.IdCustomer, c => c.IdCustomer, (rtdt, c) => new { rtdt, c }); foreach (var item in db) { lst.Add(new DiskInfoReturn { Address = item.c.Address, CustomerName = item.c.CustomerName, ExpectedDate = (DateTime)item.rtdt.rtd.rt.ExpectedReturnDate, IdCustomer = (int)item.rtdt.rtd.rt.IdCustomer, IdDisk = (int)item.rtdt.rtd.rt.IdDisk, PhoneNumber = item.c.PhoneNumber, RentedDate = (DateTime)item.rtdt.rtd.rt.RentalDate, Title = item.rtdt.t.NameTitle,IdListRented=item.rtdt.rtd.rt.IdListRented }); } return lst; }
private void LoadView() { binding.DataSource = db.GetDisks(); ExpressionMethod.LoadGridControl(grdc_CD, grv_CD, binding); }