예제 #1
0
        private void btnXoa_Click(object sender, EventArgs e)
        {
            int r = dgvQLNXB.CurrentCell.RowIndex;

            int          rSelected = (int)dgvQLNXB.Rows[r].Cells[0].Value;
            DialogResult traloi;

            traloi = MessageBox.Show("Ban co muon xoa mau tin nay ko?", "Tra loi"
                                     , MessageBoxButtons.YesNo, MessageBoxIcon.Question);
            if (traloi == DialogResult.Yes)
            {
                db.Configuration.LazyLoadingEnabled = false;
                int MaNXB = int.Parse(txtNXB.Text);
                db.sp_Delete_Publisher(MaNXB);
                //using (var db = new Model1())
                //{
                //    db.Configuration.LazyLoadingEnabled = false;
                //    var query = from d in db.NXBs
                //                where d.MANXB == rSelected
                //                select d;
                //    foreach (var MANXB in query)
                //    {
                //        db.NXBs.Remove(MANXB);
                //    }
                //    db.SaveChanges();
                //}
                db.SaveChanges();
                LoadData();
                MessageBox.Show("Da Xoa Xong!");
            }
            ClearData();
        }
예제 #2
0
        private void btnLuu_Click(object sender, EventArgs e)
        {
            if (Them == true)
            {
                if (checkThem == true)
                {
                    //int MaUser = int.Parse(txtMaUser.Text.ToString());

                    string TenUser  = txtTenUser.Text.ToString();
                    string Username = txtUsername.Text.ToString();
                    string Password = txtPassword.Text.ToString();
                    string Diachi   = txtDiaChi.Text.ToString();
                    string SDT      = txtSDT.Text.ToString();
                    MessageBox.Show(Username);
                    db.sp_Create_User(Username, Password, Diachi, SDT, TenUser);
                    db.SaveChanges();
                    LoadData();
                    MessageBox.Show("Da them xong");
                    btnLuu.Enabled     = false;
                    btnCapNhat.Enabled = true;
                    btnXoa.Enabled     = true;
                    Them = false;
                    DisableComponent();
                    ClearClickedData();
                }
            }
            else if (CapNhat == true)
            {
                try
                {
                    db.Configuration.LazyLoadingEnabled = false;

                    var userID      = int.Parse(txtMaUser.Text);
                    var userFounded = db.USERS.Where(x => x.MAUSER == userID).ToList().FirstOrDefault();
                    userFounded.USERNAME = txtUsername.Text.ToString();
                    userFounded.MATKHAU  = txtPassword.Text.ToString();
                    userFounded.DIACHI   = txtDiaChi.Text.ToString();
                    userFounded.SDT      = txtSDT.Text.ToString();
                    userFounded.TEN      = txtTenUser.Text.ToString();

                    db.SaveChanges();
                    LoadData();
                    DisableComponent();
                    MessageBox.Show("Đã cập nhật xong !!!");
                }
                catch
                {
                    MessageBox.Show("Không cập nhật được. Lỗi rồi!");
                }
                btnHuy.Enabled     = false;
                btnLuu.Enabled     = false;
                btnThem.Enabled    = true;
                btnXoa.Enabled     = true;
                btnCapNhat.Enabled = true;
            }
        }
예제 #3
0
        public bool XoaThacDauSach(string MaSach)
        {
            QLThuVienEntities qltvEntity = new QLThuVienEntities();
            DauSach           ds         = new DauSach();

            ds.MaSach = MaSach;
            qltvEntity.DauSaches.Attach(ds);
            qltvEntity.DauSaches.Remove(ds);
            foreach (TacGia tg in qltvEntity.TacGias)
            {
                if (tg.MaSach == MaSach)
                {
                    qltvEntity.TacGias.Attach(tg);
                    qltvEntity.TacGias.Remove(tg);
                }
            }
            foreach (CuonSach cs in qltvEntity.CuonSaches)
            {
                if (cs.MaSach == MaSach)
                {
                    qltvEntity.CuonSaches.Attach(cs);
                    qltvEntity.CuonSaches.Remove(cs);
                    foreach (MuonTra mt in qltvEntity.MuonTras)
                    {
                        if (mt.MaCuon == cs.MaCuon)
                        {
                            qltvEntity.MuonTras.Attach(mt);
                            qltvEntity.MuonTras.Remove(mt);
                        }
                    }
                }
            }
            qltvEntity.SaveChanges();
            return(true);
        }
 public bool ThemKeSach(KeSach keSach)
 {
     using (var ThuVienDS = new QLThuVienEntities())
     {
         ThuVienDS.KeSaches.Add(keSach);
         ThuVienDS.SaveChanges();
     }
     return(true);
 }
예제 #5
0
 public bool ThemTheLoai(TheLoai theLoai)
 {
     using (QLThuVienEntities ThuVienDS = new QLThuVienEntities())
     {
         ThuVienDS.TheLoais.Add(theLoai);
         ThuVienDS.SaveChanges();
     }
     return(true);
 }
 public bool ThemTacGia(TacGia tacGia)
 {
     using (QLThuVienEntities ThuVienDS = new QLThuVienEntities())
     {
         ThuVienDS.TacGias.Add(tacGia);
         ThuVienDS.SaveChanges();
     }
     return(true);
 }
 public bool ThemPhieuMuon(PhieuMuonSach phieuMuon)
 {
     using (QLThuVienEntities ThuVienDS = new QLThuVienEntities())
     {
         ThuVienDS.PhieuMuonSaches.Add(phieuMuon);
         ThuVienDS.SaveChanges();
     }
     return(true);
 }
 public bool ThemSach(Sach sach)
 {
     using (QLThuVienEntities ThuVienDS = new QLThuVienEntities())
     {
         ThuVienDS.Saches.Add(sach);
         ThuVienDS.SaveChanges();
     }
     return(true);
 }
예제 #9
0
 public bool ThemDocGia(DocGia docGia)
 {
     using (QLThuVienEntities ThuVienDS = new QLThuVienEntities())
     {
         ThuVienDS.DocGias.Add(docGia);
         ThuVienDS.SaveChanges();
     }
     return(true);
 }
예제 #10
0
 public bool ThemThuThu(ThuThu thuThu)
 {
     using (QLThuVienEntities ThuVienDS = new QLThuVienEntities())
     {
         ThuVienDS.ThuThus.Add(thuThu);
         ThuVienDS.SaveChanges();
     }
     return(true);
 }
예제 #11
0
 public bool CapNhatBanSao(BanSao banSao)
 {
     using (QLThuVienEntities ThuVienDS = new QLThuVienEntities())
     {
         var bSao = ThuVienDS.BanSaos.Find(banSao.MaBanSao);
         bSao = banSao;
         ThuVienDS.SaveChanges();
     }
     return(true);
 }
 public bool XoaPhieuMuon(string maPhieuMuon)
 {
     using (QLThuVienEntities ThuVienDs = new QLThuVienEntities())
     {
         var pMuon = ThuVienDs.PhieuMuonSaches.Find(maPhieuMuon);
         ThuVienDs.PhieuMuonSaches.Remove(pMuon);
         ThuVienDs.SaveChanges();
     }
     return(true);
 }
 public bool CapNhatPhieuMuon(PhieuMuonSach phieuMuon)
 {
     using (QLThuVienEntities ThuVienDS = new QLThuVienEntities())
     {
         var pMuon = ThuVienDS.PhieuMuonSaches.Find(phieuMuon.MaPhieuMuon);
         pMuon = phieuMuon;
         ThuVienDS.SaveChanges();
     }
     return(true);
 }
 public bool XoaTacGia(string maTacGia)
 {
     using (QLThuVienEntities ThuVienDs = new QLThuVienEntities())
     {
         var tGia = ThuVienDs.TacGias.Find(maTacGia);
         ThuVienDs.TacGias.Remove(tGia);
         ThuVienDs.SaveChanges();
     }
     return(true);
 }
예제 #15
0
 public bool CapNhatDocGia(DocGia docGia)
 {
     using (QLThuVienEntities ThuVienDS = new QLThuVienEntities())
     {
         var dGia = ThuVienDS.DocGias.Find(docGia.MaDocGia);
         dGia = docGia;
         ThuVienDS.SaveChanges();
     }
     return(true);
 }
예제 #16
0
 public bool XoaBanSao(string maBanSao)
 {
     using (QLThuVienEntities ThuVienDs = new QLThuVienEntities())
     {
         var bSao = ThuVienDs.BanSaos.Find(maBanSao);
         ThuVienDs.BanSaos.Remove(bSao);
         ThuVienDs.SaveChanges();
     }
     return(true);
 }
예제 #17
0
 public bool CapNhatSach(Sach sach)
 {
     using (QLThuVienEntities ThuVienDS = new QLThuVienEntities())
     {
         var phieu = ThuVienDS.Saches.Find(sach.MaSach);
         phieu = sach;
         ThuVienDS.SaveChanges();
     }
     return(true);
 }
 public bool CapNhatKeSach(KeSach keSach)
 {
     using (QLThuVienEntities ThuVienDS = new QLThuVienEntities())
     {
         var ke = ThuVienDS.KeSaches.Find(keSach.MaKeSach);
         ke = keSach;
         ThuVienDS.SaveChanges();
     }
     return(true);
 }
예제 #19
0
 public bool XoaThuThu(string maThuThu)
 {
     using (QLThuVienEntities ThuVienDs = new QLThuVienEntities())
     {
         var tThu = ThuVienDs.ThuThus.Find(maThuThu);
         ThuVienDs.ThuThus.Remove(tThu);
         ThuVienDs.SaveChanges();
     }
     return(true);
 }
예제 #20
0
 public bool CapNhatThuThu(ThuThu thuThu)
 {
     using (QLThuVienEntities ThuVienDS = new QLThuVienEntities())
     {
         var tThu = ThuVienDS.ThuThus.Find(thuThu.MaThuThu);
         tThu = thuThu;
         ThuVienDS.SaveChanges();
     }
     return(true);
 }
 public bool XoaKeSach(string maKeSach)
 {
     using (QLThuVienEntities ThuVienDs = new QLThuVienEntities())
     {
         var ke = ThuVienDs.KeSaches.Find(maKeSach);
         ThuVienDs.KeSaches.Remove(ke);
         ThuVienDs.SaveChanges();
     }
     return(true);
 }
예제 #22
0
 public bool XoaTheLoai(string maTheLoai)
 {
     using (QLThuVienEntities ThuVienDs = new QLThuVienEntities())
     {
         var tLoai = ThuVienDs.TheLoais.Find(maTheLoai);
         ThuVienDs.TheLoais.Remove(tLoai);
         ThuVienDs.SaveChanges();
     }
     return(true);
 }
 public bool CapNhatTacGia(TacGia tacGia)
 {
     using (QLThuVienEntities ThuVienDS = new QLThuVienEntities())
     {
         var tGia = ThuVienDS.TacGias.Find(tacGia.MaTacGia);
         tGia = tacGia;
         ThuVienDS.SaveChanges();
     }
     return(true);
 }
예제 #24
0
 public bool CapNhatTheLoai(TheLoai theLoai)
 {
     using (QLThuVienEntities ThuVienDS = new QLThuVienEntities())
     {
         var tLoai = ThuVienDS.TheLoais.Find(theLoai.MaTheLoai);
         tLoai = theLoai;
         ThuVienDS.SaveChanges();
     }
     return(true);
 }
예제 #25
0
        public bool XoaDocGia(string MaThe)
        {
            QLThuVienEntities qltvEntity = new QLThuVienEntities();
            DocGia            dg         = new DocGia();

            dg.MaThe = MaThe;
            qltvEntity.DocGias.Attach(dg);
            qltvEntity.DocGias.Remove(dg);
            qltvEntity.SaveChanges();
            return(true);
        }
예제 #26
0
        public bool XoaNhanVien(string MaNV)
        {
            QLThuVienEntities qltvEntity = new QLThuVienEntities();
            NhanVien          nv         = new NhanVien();

            nv.MaNV = MaNV;
            qltvEntity.NhanViens.Attach(nv);
            qltvEntity.NhanViens.Remove(nv);
            qltvEntity.SaveChanges();
            return(true);
        }
예제 #27
0
        public bool XoaCuonSach(string MaCuon)
        {
            QLThuVienEntities qltvEntity = new QLThuVienEntities();
            CuonSach          cs         = new CuonSach();

            cs.MaCuon = MaCuon;
            qltvEntity.CuonSaches.Attach(cs);
            qltvEntity.CuonSaches.Remove(cs);
            qltvEntity.SaveChanges();
            return(true);
        }
예제 #28
0
        public bool XoaNXB(string MaNXB)
        {
            QLThuVienEntities qltvEntity = new QLThuVienEntities();
            NXB nxb = new NXB();

            nxb.MaNXB = MaNXB;
            qltvEntity.NXBs.Attach(nxb);
            qltvEntity.NXBs.Remove(nxb);
            qltvEntity.SaveChanges();
            return(true);
        }
예제 #29
0
        public bool XoaTaiKhoan(string ID)
        {
            QLThuVienEntities qltvEntity = new QLThuVienEntities();
            Login             lg         = new Login();

            lg.ID = ID;
            qltvEntity.Logins.Attach(lg);
            qltvEntity.Logins.Remove(lg);
            qltvEntity.SaveChanges();
            return(true);
        }
예제 #30
0
        public bool XoaDauSach(string MaSach)
        {
            QLThuVienEntities qltvEntity = new QLThuVienEntities();
            DauSach           ds         = new DauSach();

            ds.MaSach = MaSach;
            qltvEntity.DauSaches.Attach(ds);
            qltvEntity.DauSaches.Remove(ds);
            qltvEntity.SaveChanges();
            return(true);
        }