Exemplo n.º 1
0
        public eDia_LoaiDia_TieuDe layPhiTraMuon(string madia)
        {
            var query = from PhieuThue in db.PhieuThues
                        join Dia in db.Dias
                        on PhieuThue.MaDia equals Dia.MaDia
                        join TieuDe in db.TieuDes
                        on Dia.MaTieuDe equals TieuDe.MaTieuDe
                        join LoaiDia in db.LoaiDias
                        on TieuDe.MaLoaiDia equals LoaiDia.MaLoaiDia
                        where (PhieuThue.MaDia == madia)
                        select new
            {
                madianew    = Dia.MaDia,
                matieudenew = TieuDe.MaTieuDe,
                maloainew   = LoaiDia.MaLoaiDia,
                giaphatnew  = LoaiDia.GiaPhat
            };
            eDia_LoaiDia_TieuDe dulieulay = new eDia_LoaiDia_TieuDe();

            foreach (var item in query)
            {
                dulieulay.Madia     = item.madianew;
                dulieulay.Maloaidia = item.maloainew;
                dulieulay.Matieude  = item.matieudenew;
                dulieulay.Giaphat   = item.giaphatnew;
            }
            return(dulieulay);
        }
Exemplo n.º 2
0
        public List <eDia_LoaiDia_TieuDe> layDanhSachDiaTheoLoaiVaTheoTrangThai(string maLoai, string trangthai)
        {
            var query = from LoaiDia in db.LoaiDias
                        join TieuDe in db.TieuDes
                        on LoaiDia.MaLoaiDia equals TieuDe.MaLoaiDia
                        join Dia in db.Dias
                        on TieuDe.MaTieuDe equals Dia.MaTieuDe
                        where LoaiDia.MaLoaiDia == maLoai && Dia.TrangThaiDia == trangthai
                        select new
            {
                madianew        = Dia.MaDia,
                tenloaidianew   = LoaiDia.TenLoaiDia,
                tentieudenew    = TieuDe.TenTieuDe,
                tendianew       = Dia.TenDia,
                trangthaidianew = Dia.TrangThaiDia,
            };
            List <eDia_LoaiDia_TieuDe> l = new List <eDia_LoaiDia_TieuDe>();

            foreach (var item in query)
            {
                eDia_LoaiDia_TieuDe dulieulay = new eDia_LoaiDia_TieuDe();
                dulieulay.Madia     = item.madianew;
                dulieulay.Tenloai   = item.tenloaidianew;
                dulieulay.Tentieude = item.tentieudenew;
                dulieulay.Tendia    = item.tendianew;
                dulieulay.Trangthai = item.trangthaidianew;
                l.Add(dulieulay);
            }
            return(l);
        }
Exemplo n.º 3
0
        public List <eDia_LoaiDia_TieuDe> layTatCaDia()
        {
            var query = (from LoaiDia in db.LoaiDias
                         join TieuDe in db.TieuDes
                         on LoaiDia.MaLoaiDia equals TieuDe.MaLoaiDia
                         join Dia in db.Dias
                         on TieuDe.MaTieuDe equals Dia.MaTieuDe
                         select new
            {
                madianew = Dia.MaDia,
                tenloaidianew = LoaiDia.TenLoaiDia,
                tentieudenew = TieuDe.TenTieuDe,
                tendianew = Dia.TenDia,
                trangthaidianew = Dia.TrangThaiDia,
            }).ToList();
            List <eDia_LoaiDia_TieuDe> l = new List <eDia_LoaiDia_TieuDe>();

            foreach (var item in query)
            {
                eDia_LoaiDia_TieuDe dulieulay = new eDia_LoaiDia_TieuDe();
                dulieulay.Madia     = item.madianew;
                dulieulay.Tenloai   = item.tenloaidianew;
                dulieulay.Tentieude = item.tentieudenew;
                dulieulay.Tendia    = item.tendianew;
                dulieulay.Trangthai = item.trangthaidianew;
                l.Add(dulieulay);
            }
            return(l);
        }
 private void btnXemDia_Click(object sender, EventArgs e)
 {
     ResetData();
     if (String.IsNullOrWhiteSpace(tbxMaDia.Text.ToString()))
     {
         MessageBox.Show("Vui lòng nhập mã đĩa cần trả");
     }
     else
     {
         ePT = busPT.layPhieuThueTheoDiaDangThue(tbxMaDia.Text.ToString());
         if (ePT == null)
         {
             MessageBox.Show("Thông tin chưa chính xác, vui lòng kiểm tra lại");
         }
         else
         {
             btnThanhToan.Enabled = true;
             eKhachHang thongtinkhachhang = new eKhachHang();
             lstPhiChuaThanhToan = new List <ePhieuThue>();
             thongtinkhachhang   = busPT.layThongTinKhachHangTheoPhieu(ePT.Makhachhang);
             lstPhiChuaThanhToan = busPT.layDanhSachPhiMuonChuaThanhToanTheoKhachHang(thongtinkhachhang.Makh);
             if (lstPhiChuaThanhToan.Count == 0)
             {
                 lblRong.Text = "Không có phiếu thuê chưa thanh toán";
             }
             LoadDataDataGridView(dataGridViewX1, lstPhiChuaThanhToan);
             lblTongPhi.Text     = lstPhiChuaThanhToan.Sum(x => x.Phitramuon).ToString();
             tbxTenKH.Text       = thongtinkhachhang.Tenkh;
             tbxDiaChi.Text      = thongtinkhachhang.Diachi;
             tbxSoDienThoai.Text = thongtinkhachhang.Sodt;
             tbxMaPhieu.Text     = ePT.Maphieuthue;
             tbxNgayThue.Text    = String.Format("{0:dd/MM/yyyy}", ePT.Ngaymuon);
             tbxNgayTra.Text     = String.Format("{0:dd/MM/yyyy}", DateTime.Today);;
             tbxNgayHenTra.Text  = String.Format("{0:dd/MM/yyyy}", ePT.Ngayhentra);
             if (DateTime.Today > ePT.Ngayhentra)
             {
                 eDia_LoaiDia_TieuDe loaidiatheomadia = new eDia_LoaiDia_TieuDe();
                 loaidiatheomadia = busPT.layPhiTraMuon(tbxMaDia.Text.ToString());
                 tbxPhiMuon.Text  = loaidiatheomadia.Giaphat.ToString();
             }
             else
             {
                 tbxPhiMuon.Text = "0";
             }
             if (tbxPhiMuon.Text == "0")
             {
                 checkBox1.Enabled = false;
                 checkBox1.Checked = true;
             }
         }
     }
 }
 private void checkBox1_CheckedChanged(object sender, EventArgs e)
 {
     if (checkBox1.Checked == true)
     {
         eDia_LoaiDia_TieuDe loaidiatheoma = new eDia_LoaiDia_TieuDe();
         loaidiatheoma = busPT.layPhiTraMuon(tbxMaDia.Text.ToString());
         thanhtoan     = thanhtoan + Double.Parse(tbxPhiMuon.Text.ToString());
     }
     else
     {
         eDia_LoaiDia_TieuDe loaidiatheoma = new eDia_LoaiDia_TieuDe();
         loaidiatheoma = busPT.layPhiTraMuon(tbxMaDia.Text.ToString());
         thanhtoan     = thanhtoan - Double.Parse(tbxPhiMuon.Text.ToString());
     }
     lblTienThanhToan.Text = thanhtoan.ToString();
 }
Exemplo n.º 6
0
        public List <eDia_LoaiDia_TieuDe> chiTietTraMuon(string makh)
        {
            var query = from PhieuThue in db.PhieuThues
                        join Dia in db.Dias
                        on PhieuThue.MaDia equals Dia.MaDia
                        join TieuDe in db.TieuDes
                        on Dia.MaTieuDe equals TieuDe.MaTieuDe
                        join LoaiDia in db.LoaiDias
                        on TieuDe.MaLoaiDia equals LoaiDia.MaLoaiDia
                        where (PhieuThue.MaKhachHang == makh && PhieuThue.TrangThaiPhi.Equals("Chưa trả"))
                        select new
            {
                maphieunew    = PhieuThue.MaThue,
                tentieudenew  = TieuDe.TenTieuDe,
                tendianew     = Dia.TenDia,
                ngaythuenew   = PhieuThue.NgayMuon,
                ngayhentranew = PhieuThue.NgayHenTra,
                ngaytranew    = PhieuThue.NgayTra,
                giaphatnew    = PhieuThue.PhiTraMuon
            };
            List <eDia_LoaiDia_TieuDe> lstChiTiet = new List <eDia_LoaiDia_TieuDe>();

            foreach (var item in query)
            {
                eDia_LoaiDia_TieuDe chitiet = new eDia_LoaiDia_TieuDe();
                chitiet.Maphieu    = item.maphieunew;
                chitiet.Tentieude  = item.tentieudenew;
                chitiet.Tendia     = item.tendianew;
                chitiet.Ngaythue   = item.ngaythuenew;
                chitiet.Ngayhentra = item.ngayhentranew;
                chitiet.NgayTra    = DateTime.Parse(item.ngaytranew.ToString());
                chitiet.Giaphat    = Double.Parse(item.giaphatnew.ToString());
                lstChiTiet.Add(chitiet);
            }
            return(lstChiTiet);
        }