Пример #1
0
 private void btnThem_Click(object sender, EventArgs e)
 {
     using (var db = new ThuVien())
     {
         db.Sach.Add(Current);
         db.SaveChanges();
     }
     LoadGrid();
 }
Пример #2
0
 private void simpleButton1_Click(object sender, EventArgs e)
 {
     using (var db = new ThuVien())
     {
         db.TacGia.Add(new TacGia {
             matacgia = txtID.Text, tentacgia = txtName.Text, gioithieu = txtGioiThieu.Text
         });
         db.SaveChanges();
     }
     UpdateGridView();
 }
Пример #3
0
 private void simpleButton1_Click(object sender, EventArgs e)
 {
     using (var db = new ThuVien())
     {
         db.DocGia.Add(new DocGia {
             madocgia = txtID.Text, hoten = txtName.Text, diachi = txtAddr.Text, sodienthoai = txtSDT.Text
         });
         db.SaveChanges();
     }
     UpdateGridView();
 }
Пример #4
0
 private void barButtonItem1_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
 {
     // Them
     using (var db = new ThuVien()) {
         db.PhieuMuon.Add(new PhieuMuon {
             maphieumuon = txtMaPhieu.Text, nguoimuon = luDocGia.EditValue as string, ngaymuon = (DateTime)calendar.EditValue
         });
         db.SaveChanges();
     }
     LoadGridView();
 }
Пример #5
0
 private void simpleButton1_Click(object sender, EventArgs e)
 {
     using (var db = new ThuVien())
     {
         db.TheLoai.Add(new TheLoai {
             matheloai = txtID.Text, tentheloai = txtName.Text
         });
         db.SaveChanges();
     }
     UpdateGridView();
 }
Пример #6
0
 private void btnXoa_Click(object sender, EventArgs e)
 {
     if (gridView1.GetFocusedRow() != null)
     {
         using (var db = new ThuVien())
         {
             var id = (int)gridView1.GetFocusedRowCellValue("masach");
             db.Sach.Remove(db.Sach.First(s => s.masach == id));
             db.SaveChanges();
         }
         LoadGrid();
     }
 }
Пример #7
0
        private void simpleButton1_Click(object sender, EventArgs e)
        {
            if (listMuon.SelectedValue == null)
            {
                return;
            }
            var selected = (int)listMuon.SelectedValue;

            using (var db = new ThuVien())
            {
                var phieu = db.PhieuMuon.First(pm => pm.maphieumuon == id);
                phieu.Sach.Remove(db.Sach.First(s => s.masach == selected));
                db.SaveChanges();
            }
            LoadData();
        }
Пример #8
0
 private void btnSua_Click(object sender, EventArgs e)
 {
     if (gridView1.GetFocusedRow() != null)
     {
         using (var db = new ThuVien())
         {
             var id = (int)gridView1.GetFocusedRowCellValue("masach");
             var s  = Current;
             s.masach = id;
             db.Sach.Attach(s);
             db.Entry(s).State = System.Data.Entity.EntityState.Modified;
             db.SaveChanges();
         }
         LoadGrid();
     }
 }
Пример #9
0
        private void simpleButton3_Click(object sender, EventArgs e)
        {
            GridView gridView = gridControl.MainView as GridView;

            if (gridView.GetFocusedRow() == null)
            {
                return;
            }
            string id = (gridView.GetFocusedRow() as TacGia).matacgia;

            using (var db = new ThuVien())
            {
                db.TacGia.Remove(db.TacGia.First(x => x.matacgia == id));
                db.SaveChanges();
            }
            UpdateGridView();
        }
Пример #10
0
        private void barButtonItem3_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            // Xoa
            var gridview = (GridView)gridControl.MainView;
            var id       = gridview.GetFocusedRowCellValue("maphieumuon") as string;

            if (id == null)
            {
                return;
            }
            using (var db = new ThuVien())
            {
                var phieumuon = db.PhieuMuon.First(pm => pm.maphieumuon == id);
                db.PhieuMuon.Remove(phieumuon);
                db.SaveChanges();
            }
            LoadGridView();
        }
Пример #11
0
        private void simpleButton2_Click(object sender, EventArgs e)
        {
            GridView gridView = gridControl.MainView as GridView;

            if (gridView.GetFocusedRow() == null)
            {
                return;
            }
            string id = (gridView.GetFocusedRow() as TheLoai).matheloai;

            using (var db = new ThuVien())
            {
                var tl = db.TheLoai.First(x => x.matheloai == id);
                tl.tentheloai = txtName.Text;
                db.SaveChanges();
            }
            UpdateGridView();
        }
Пример #12
0
        private void simpleButton2_Click(object sender, EventArgs e)
        {
            GridView gridView = gridControl.MainView as GridView;

            if (gridView.GetFocusedRow() == null)
            {
                return;
            }
            string id = (gridView.GetFocusedRow() as TacGia).matacgia;

            using (var db = new ThuVien())
            {
                var tg = db.TacGia.First(x => x.matacgia == id);
                tg.tentacgia = txtName.Text;
                tg.gioithieu = txtGioiThieu.Text;
                db.SaveChanges();
            }
            UpdateGridView();
        }
Пример #13
0
        private void simpleButton2_Click(object sender, EventArgs e)
        {
            GridView gridView = gridControl.MainView as GridView;

            if (gridView.GetFocusedRow() == null)
            {
                return;
            }
            string id = (gridView.GetFocusedRow() as DocGia).madocgia;

            using (var db = new ThuVien())
            {
                var dg = db.DocGia.First(x => x.madocgia == id);
                dg.hoten       = txtName.Text;
                dg.sodienthoai = txtSDT.Text;
                dg.diachi      = txtAddr.Text;
                db.SaveChanges();
            }
            UpdateGridView();
        }
Пример #14
0
        private void barButtonItem2_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            // Cap nhat
            var gridview = (GridView)gridControl.MainView;
            var id       = gridview.GetFocusedRowCellValue("maphieumuon") as string;

            if (id == null)
            {
                return;
            }

            using (var db = new ThuVien())
            {
                var phieumuon = db.PhieuMuon.First(pm => pm.maphieumuon == id);
                phieumuon.ngaymuon  = (DateTime)calendar.EditValue;
                phieumuon.nguoimuon = (string)luDocGia.EditValue;
                db.SaveChanges();
            }
            LoadGridView();
        }
Пример #15
0
        private void simpleButton1_Click(object sender, EventArgs e)
        {
            string s1 = txt1.EditValue as string;
            string s2 = txt1.EditValue as string;

            if (!s1.Equals(s2))
            {
                XtraMessageBox.Show(this, "Mật khẩu nhập lại không chính xác!", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }
            else if (s1.Length < 6)
            {
                XtraMessageBox.Show(this, "Mật khẩu tối thiểu 6 ký tự!", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            using (var db = new ThuVien())
            {
                db.User.First(u => u.id == userID).password = s1;
                db.SaveChanges();
                XtraMessageBox.Show(this, "Đổi mật khẩu thành công", "Succes", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }