示例#1
0
        protected void Del(object sender, EventArgs e)
        {
            var db = new LookUpDataContext();

            db.nguvan_lookups.DeleteOnSubmit(db.nguvan_lookups.First(i => i.ID == ((LinkButton)sender).CommandArgument.ToInt()));
            db.SubmitChanges();
            LoadData();
        }
示例#2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            var datacontext = new LookUpDataContext();
            var userId      = Request.QueryString["id"].ToInt();
            var c           = datacontext.nguvan_lookups.FirstOrDefault(i => i.ID == userId) ?? new nguvan_lookup();

            tbTitle.Text      = c.Title;
            tbInstroctor.Text = c.Instructor;
            tb_Author.Text    = c.Author;
            tbYear.Text       = c.Year;
            tbKey.InnerText   = c.Keys;
        }
示例#3
0
        protected void bt_Update_Click(object sender, EventArgs e)
        {
            var datacontext      = new LookUpDataContext();
            LookUpDataContext db = new LookUpDataContext();
            var           userId = Request.QueryString["id"].ToInt();
            nguvan_lookup c      = db.nguvan_lookups.Single(i => i.ID == userId);

            c.Title      = tbTitle.Text;
            c.Instructor = tbInstroctor.Text;
            c.Author     = tb_Author.Text;
            c.Year       = tbYear.Text;
            c.Keys       = tbKey.InnerText;
            c.TabID      = TabId;
            db.SubmitChanges();
            Response.Redirect(BuildUrl("LookUp"));
        }
示例#4
0
        protected void lbNext_Click(object sender, EventArgs e)
        {
            var             db      = new LookUpDataContext();
            PagedDataSource pgitems = new PagedDataSource();

            pgitems.DataSource = db.nguvan_lookups.OrderByDescending(i => i.ID).ToList();
            System.Collections.ArrayList pages = new System.Collections.ArrayList();
            for (int i = 0; i < pgitems.PageCount; i++)
            {
                pages.Add((i + 1).ToString());
            }
            if (PageNumber <= pages.Count)
            {
                PageNumber += 1;
            }
            LoadData();
        }
示例#5
0
        void LoadData()
        {
            var             db      = new LookUpDataContext();
            PagedDataSource pgitems = new PagedDataSource();

            pgitems.DataSource       = db.nguvan_lookups.OrderByDescending(i => i.ID).Where(i => i.TabID == TabId).ToList();
            pgitems.AllowPaging      = true;
            pgitems.PageSize         = 3;
            pgitems.CurrentPageIndex = PageNumber;
            if (pgitems.PageCount > 1)
            {
                lb_total.Text = "Trang hiện tại: " + (PageNumber + 1);
                //lb_Trang.Visible = true;
                lbPrevious.Visible = true;
                lbNext.Visible     = true;
                rptPages.Visible   = true;
                System.Collections.ArrayList pages = new System.Collections.ArrayList();
                for (int i = PageNumber; i < pgitems.PageCount; i++)
                {
                    if (pages.Count < 5)
                    {
                        pages.Add((i + 1).ToString());
                    }
                }
                rptLookUp.DataSource = pgitems;
                rptLookUp.DataBind();
                rptPages.DataSource = pages;
                rptPages.DataBind();
            }
            else
            {
                //lb_Trang.Visible = false;
                lbPrevious.Visible   = false;
                lbNext.Visible       = false;
                rptPages.Visible     = false;
                rptLookUp.DataSource = pgitems;
                rptLookUp.DataBind();
            }
        }
示例#6
0
        protected void bt_Search(object sender, EventArgs e)
        {
            var datacontext = new LookUpDataContext();
            var a           = search.Text.Trim();

            if (a != null)
            {
                if (drpSearch.SelectedValue == "1")
                {
                    rptLookUp.DataSource = datacontext.nguvan_lookups.Where(i => i.Title.Contains(a) && i.TabID == TabId).ToList();
                    rptLookUp.DataBind();
                }
                if (drpSearch.SelectedValue == "2")
                {
                    rptLookUp.DataSource = datacontext.nguvan_lookups.Where(i => i.Author.Contains(a) && i.TabID == TabId).ToList();
                    rptLookUp.DataBind();
                }
                if (drpSearch.SelectedValue == "3")
                {
                    rptLookUp.DataSource = datacontext.nguvan_lookups.Where(i => i.Year.Contains(a) && i.TabID == TabId).ToList();
                    rptLookUp.DataBind();
                }
                if (drpSearch.SelectedValue == "4")
                {
                    rptLookUp.DataSource = datacontext.nguvan_lookups.Where(i => i.LibraryID.Contains(a) && i.TabID == TabId).ToList();
                    rptLookUp.DataBind();
                }
                if (drpSearch.SelectedValue == "5")
                {
                    rptLookUp.DataSource = datacontext.nguvan_lookups.Where(i => i.Instructor.Contains(a) && i.TabID == TabId).ToList();
                    rptLookUp.DataBind();
                }
            }
            if (a == "")
            {
                LoadData();
            }
        }