protected void btnXoa_Click(object sender, EventArgs e)
        {
            string   id  = Page.RouteData.Values["ID"].ToString().Trim();
            NhomSach _ns = tbl_ns.GetByID(id);

            tbl_ns.Delete(_ns);
            Response.Redirect("/QuanLyNhomSach/Nhom");
        }
        protected void btnCapNhat_Click(object sender, EventArgs e)
        {
            string   id  = Page.RouteData.Values["ID"].ToString().Trim();
            NhomSach _ns = tbl_ns.GetByID(id);

            _ns.TenNhom = txtTenNhom.Text.Trim();
            tbl_ns.Update(_ns);
            Response.Redirect("/QuanLyNhomSach/Nhom");
        }
        protected void btnThem_Click(object sender, EventArgs e)
        {
            NhomSach _ns = new NhomSach();

            _ns.MaNhom  = CreateKey();
            _ns.TenNhom = txtTenNhom.Text.Trim();
            tbl_ns.Insert(_ns);

            Response.Redirect("/QuanLyNhomSach/Nhom");
        }
        public void DatalistPaging()
        {
            PagedDataSource PD = new PagedDataSource();
            string          id = Page.RouteData.Values["modul"].ToString().Trim();
            NhomSach        ns = tbl_ns.GetByID(id);

            PD.DataSource = tbl_sach.GroupBook(ns.TenNhom);

            PD.PageSize         = 21;
            PD.AllowPaging      = true;
            PD.CurrentPageIndex = CurrentPage;

            if (PD.PageCount > 1)
            {
                Repeater1.Visible = true;
                System.Collections.ArrayList pages = new System.Collections.ArrayList();

                int cout = 0;
                for (int i = CurrentPage - 5; i <= CurrentPage + 10; i++)
                {
                    if (i > PD.PageCount)
                    {
                        break;
                    }

                    if (i > 0)
                    {
                        if (cout < 10)
                        {
                            cout++;
                            pages.Add(i.ToString());
                        }
                        else
                        {
                            break;
                        }
                    }
                }


                Repeater1.DataSource = pages;
                Repeater1.DataBind();
            }
            else
            {
                Repeater1.Visible = false;
            }

            DataList1.DataSource = PD;
            DataList1.DataBind();
        }
        private void ThemNhomSach(string ten)
        {
            NhomSach _ns = tbl_nhomsach.GetByName(ten);

            if (_ns == null)
            {
                if (ten.Trim() != "")
                {
                    _ns         = new NhomSach();
                    _ns.MaNhom  = QL_Nhom.CreateKey();
                    _ns.TenNhom = ten;
                    tbl_nhomsach.Insert(_ns);
                }
            }
        }
        //Hiển Thị Form Input
        private void ShowFormInput()
        {
            if (Page.RouteData.Values["ID"] != null)
            {
                btnThem.Visible    = false;
                btnCapNhat.Visible = true;
                btnXoa.Visible     = true;

                string   id  = Page.RouteData.Values["ID"].ToString().Trim();
                NhomSach _ns = tbl_ns.GetByID(id);

                txtTenNhom.Text = _ns.TenNhom;
            }
            else
            {
                btnThem.Visible    = true;
                btnCapNhat.Visible = false;
                btnXoa.Visible     = false;
            }
        }
Exemplo n.º 7
0
 //xoa du lieu
 public void Delete(NhomSach obj)
 {
     db.NhomSaches.Attach(obj);
     db.NhomSaches.Remove(obj);
     db.SaveChanges();
 }
Exemplo n.º 8
0
 //Cap nhap du lieu
 public void Update(NhomSach obj)
 {
     db.NhomSaches.Attach(obj);
     db.Entry(obj).State = System.Data.Entity.EntityState.Modified;
     db.SaveChanges();
 }
Exemplo n.º 9
0
 //Them du lieu
 public NhomSach Insert(NhomSach obj)
 {
     db.NhomSaches.Add(obj);
     db.SaveChanges();
     return(obj);
 }