﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using CraneAlert.Service;
using System.Collections;

namespace CraneAlert.videoDevMange
{
    public partial class manage : System.Web.UI.Page
    {

        videoDevService service = new videoDevService();
        protected void Page_Load(object sender, EventArgs e)
        {

            this.AspNetPager1.CurrentPageIndex = 1;
            this.AspNetPager1.PageSize = 10;

            if (!Page.IsPostBack)
            {
                if ("delete".Equals(Request.QueryString["action"]))
                {
                    delete();
                }
                this.AspNetPager1.RecordCount = service.totalVideoDevInfoCount(this.DevNo.Text);

                dataBind();
            }
        }


        protected void search(object sender, EventArgs e)
        {

            this.AspNetPager1.RecordCount = service.totalVideoDevInfoCount(this.DevNo.Text);
            dataBind();

        }

        public void dataBind()
        {
            IList list = service.getVideoDevInfoList(this.AspNetPager1.CurrentPageIndex, this.AspNetPager1.PageSize, this.DevNo.Text);
            Repeater1.DataSource = list;
            Repeater1.DataBind();
        }

        protected void AspNetPager1_PageChanging(object src, Wuqi.Webdiyer.PageChangingEventArgs e)
        {

            this.AspNetPager1.CurrentPageIndex = e.NewPageIndex;
            this.dataBind();
        }

        protected void delete()
        {

            string userNo = Request.QueryString["id"];
            List<string> List = new List<string>();
            List.Add(userNo);
            service.deleteVideoDevInfo(List);
            Page.RegisterStartupScript("starup", "<script language = 'javascript'>alert('删除成功')</script>");
        }

    }
}