private void ThucHienKiemTraNguoiDatDia() { 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(); if (bindingDSTilte[grvDSTieuDe.GetSelectedRows()[0]] is TitleOrder == false) { return; } //Kiểm tra tiêu đề đang được chọn int tieude = ((TitleOrder)bindingDSTilte[grvDSTieuDe.GetSelectedRows()[0]]).IdTitle; //Danh sách đặt là gì int idDsDat = (int)db.Find(x => x.t.IdTitle == tieude).dtd.dt.IdListTitlePreOrder; var DsDat = dbListPreOrder.GetListTitlePreOrder(idDsDat); //Lấy khách hàng var customer = dbCustomer.GetCustomer((int)DsDat.IdCustomer); txt_DiaChi.Text = customer.Address; txt_SoDienThoai.Text = customer.PhoneNumber; txt_TenKhachHang.Text = customer.CustomerName; // lay ra danh sach cua nhung thang nao la khach hang var lstPreOrderOfCustomer = dbListPreOrder.GetListTitlePreOrders().Where(x => x.IdCustomer == customer.IdCustomer).ToList(); // lay danh sach nhung thang nao thuoc lst id vua lay var lstOfCus = db.Where(d => lstPreOrderOfCustomer.Find(x => x.IdListTitlePreOrder == d.dtd.dt.IdListTitlePreOrder) != null && d.dtd.dt.Accepted == false).Select(x => new MyDeTailOrder { IdDetailPreOrder = x.dtd.dt.IdDetailPreOrder, IdDisk = x.dtd.d.IdDisk, Title = x.t.NameTitle }).ToList(); bindingDSDatTruoc.DataSource = lstOfCus; }
private void LoadDanhSachDatTruoc() { // Load những list nào đang imcomplete và những list nào complete nhưng id list vẫn còn ở dưới detail var data = dbListTitlePre.GetListTitlePreOrders().Where(x => x.StatusProcess.Equals(STATUS_INCOMPLETED) || dbDetailPre.GetDetailPreOrders().Find(d => d.IdListTitlePreOrder == x.IdListTitlePreOrder) != null) .Join(dbTitle.GetTitles(), dt => dt.IdTitle, t => t.IdTitle, (dt, t) => new { dt, t }) .Join(dbCus.GetCustomers(), dtt => dtt.dt.IdCustomer, c => c.IdCustomer, (dtt, c) => new MyListTitlePreOrder { IdCustomer = c.IdCustomer, IdListPreOrder = dtt.dt.IdListTitlePreOrder, NameCustomer = c.CustomerName, NameTitle = dtt.t.NameTitle }); bindingDSDatTruoc.DataSource = data; dbListTitlePre = new ListTitlePreOrderBUL(); dbCus = new CustomerBUL(); dbTitle = new TitleBUL(); dbDetailPre = new DetailPreOrderBUL(); }
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); }