Exemplo n.º 1
0
        public PhieuMuon getPhieuMuonById(int id)
        {
            String sql = @"SELECT [MaPhieu]
                              ,[MaDG]
                              ,[NgayMuon]
                              ,[MaNV]
                          FROM [dbo].[PhieuMuon] WHERE [MaPhieu]=" + id;
            DataTable table = dbcnn.getdata(sql);
            PhieuMuon newPhieuMuon = new PhieuMuon();
            if (table.Rows.Count == 1)
            {
                newPhieuMuon.MaPhieu = (int)table.Rows[0]["MaPhieu"];
                //đổ dữ liệu vào độc giả
                newPhieuMuon.docGia.MaDG = (int)table.Rows[0]["MaDG"];
                DocGiaDAL dgDAL = new DocGiaDAL();
                newPhieuMuon.docGia = dgDAL.getDocGiaById(newPhieuMuon.docGia.MaDG);

                newPhieuMuon.NgayMuon = (DateTime)table.Rows[0]["NgayMuon"];
                //đổ dữ liệu vào nhân viên
                newPhieuMuon.nhanVien.MaNV = (int)table.Rows[0]["MaNV"];
                NhanVienDAL nvDAL = new NhanVienDAL();
                newPhieuMuon.nhanVien = nvDAL.getNhanVienByID(newPhieuMuon.nhanVien.MaNV);
                //đổ dữ liệu vào sách
            }
            return newPhieuMuon;
        }
Exemplo n.º 2
0
        public List<PhieuMuon> getListPhieuMuon()
        {
            String sql = @"SELECT [MaPhieu]
                              ,[MaDG]
                              ,[NgayMuon]
                              ,[MaNV]
                          FROM [dbo].[PhieuMuon]";
            DataTable table = dbcnn.getdata(sql);
            List<PhieuMuon> listDG = new List<PhieuMuon>();
            foreach (DataRow row in table.Rows)
            {
                PhieuMuon newPhieuMuon = new PhieuMuon();
                newPhieuMuon.MaPhieu = (int)row["MaPhieu"];
                //đổ dữ liệu vào độc giả
                newPhieuMuon.docGia.MaDG = (int)row["MaDG"];
                DocGiaDAL dgDAL = new DocGiaDAL();
                newPhieuMuon.docGia = dgDAL.getDocGiaById(newPhieuMuon.docGia.MaDG);

                newPhieuMuon.NgayMuon = (DateTime)row["NgayMuon"];
                //đổ dữ liệu vào nhân viên
                newPhieuMuon.nhanVien.MaNV = (int)row["MaNV"];
                NhanVienDAL nvDAL = new NhanVienDAL();
                newPhieuMuon.nhanVien = nvDAL.getNhanVienByID(newPhieuMuon.nhanVien.MaNV);

                listDG.Add(newPhieuMuon);
            }
            return listDG;
        }
Exemplo n.º 3
0
        /// <summary>
        /// ham cho muon sach. neu cho muon thanh cong tra ve true. nguoc lai la false
        /// </summary>
        /// <param name="maSach">Mã Sách</param>
        /// <param name="maDocGia">Mã Độc Giả</param>
        /// <returns></returns>
        public bool choMuon(int maSach,int maDocGia,int maNV)
        {
            ctPhieuDAL = new CT_PhieuMuonDAL();
            phieuMuonDAL = new PhieuMuonDAL();
            //đổ dữ liệu vào mã phiếu mượn
            phieuMuon = new PhieuMuon();
            phieuMuon.docGia.MaDG = maDocGia;
            phieuMuon.NgayMuon = DateTime.Now;
            phieuMuon.nhanVien.MaNV = maNV;
            if (!phieuMuonDAL.insertPhieuMuon(phieuMuon)) return false;

            ctPhieu = new CT_PhieuMuon();
            ctPhieu.phieuMuon = phieuMuonDAL.getPhieuMuonVuaNhap();
            ctPhieu.sach.MaSach = maSach;
            ctPhieu.HanTra = DateTime.Now.AddDays(30);
            if (!ctPhieuDAL.insertCT_PhieuMuon(ctPhieu)) return false;
            return true;
        }
Exemplo n.º 4
0
 public bool deletePhieuMuon(PhieuMuon phieu)
 {
     String sql = @"DELETE FROM [dbo].[PhieuMuon]
                  WHERE [MaPhieu]=" + phieu.MaPhieu;
     return dbcnn.ThucThiSQL(sql);
 }
Exemplo n.º 5
0
 public bool updatePhieuMuon(PhieuMuon phieu)
 {
     String sql = @"UPDATE [dbo].[PhieuMuon]
                    SET [MaDG] = " + phieu.docGia.MaDG + @"
                       ,[NgayMuon] = N'" + phieu.NgayMuon + @"'
                       ,[MaNV] = " + phieu.nhanVien.MaNV + @"
                  WHERE [MaPhieu]=" + phieu.MaPhieu;
     return dbcnn.ThucThiSQL(sql);
 }
Exemplo n.º 6
0
 public bool insertPhieuMuon(PhieuMuon phieu)
 {
     String sql = @"INSERT INTO [dbo].[PhieuMuon]
                        ([MaDG]
                        ,[NgayMuon]
                        ,[MaNV])
                  VALUES
                        (" + phieu.docGia.MaDG + @"
                        ,N'"+phieu.NgayMuon+@"'
                        ," + phieu.nhanVien.MaNV + @")";
     return dbcnn.ThucThiSQL(sql);
 }
Exemplo n.º 7
0
 public CT_PhieuMuon()
 {
     sach = new Sach();
     phieuMuon = new PhieuMuon();
 }
Exemplo n.º 8
0
 //public virtual NhanVien NhanVien { get; set; }
 public TraSach()
 {
     phieuMuon = new PhieuMuon();
     nhanVien = new NhanVien();
 }