示例#1
0
        /// <summary>
        /// 模拟数据库分页
        /// </summary>
        /// <returns></returns>
        private DataTable GetPagedDataTable1()
        {
            Demo.BLL.tb_JC_Department bll = new Demo.BLL.tb_JC_Department();

            int pageIndex = Grid1.PageIndex;
            int pageSize  = Grid1.PageSize;

            string sortField     = Grid1.SortField;
            string sortDirection = Grid1.SortDirection;

            DataTable table3 = bll.GetList("").Tables[0];

            DataView view3 = table3.DefaultView;

            view3.Sort = String.Format("{0} {1}", sortField, sortDirection);

            DataTable table = view3.ToTable();

            DataTable paged = table.Clone();

            int rowbegin = pageIndex * pageSize;
            int rowend   = (pageIndex + 1) * pageSize;

            if (rowend > table.Rows.Count)
            {
                rowend = table.Rows.Count;
            }

            for (int i = rowbegin; i < rowend; i++)
            {
                paged.ImportRow(table.Rows[i]);
            }

            return(paged);
        }
示例#2
0
        public void BindGrid(string id)
        {
            Demo.BLL.tb_JC_Department   bll  = new Demo.BLL.tb_JC_Department();
            Demo.Model.tb_JC_Department dept = new Demo.Model.tb_JC_Department();

            dept = bll.GetModel(id);

            DeptmentId.Text     = dept.ID;
            DepartmentNO.Text   = dept.DepartmentNO;
            DepartmentName.Text = dept.DepartmentName;
        }
示例#3
0
        protected void ttbSearch1_Trigger2Click(object sender, EventArgs e)
        {
            //search
            Demo.BLL.tb_JC_Department   bll   = new Demo.BLL.tb_JC_Department();
            Demo.Model.tb_JC_Department model = new Demo.Model.tb_JC_Department();
            string deptname = ttbSearch1.Text.Trim();

            model = bll.GetModelList("DepartmentName = '" + deptname + "'")[0];

            if (model.DepartmentNO == null)
            {
                Alert.ShowInTop("未找到改部门!");
            }
            else
            {
                PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("~/Web/JC/deptment/listdeptmodify.aspx?id={0}&deptno={1}", model.ID, model.DepartmentNO), "编辑"));
            }
        }
示例#4
0
        /// <summary>
        /// 点击删除按钮
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnDelete1_Click(object sender, EventArgs e)
        {
            if (Grid1.SelectedRowIndexArray.Length == 0)
            {
                Alert.ShowInTop("请至少选择一条记录!");
                return;
            }

            Demo.BLL.tb_JC_Department bll = new Demo.BLL.tb_JC_Department();

            foreach (int n in Grid1.SelectedRowIndexArray)
            {
                object[] keys = Grid1.DataKeys[n];
                string   id   = keys[0].ToString();
                bll.Delete(id);
            }

            PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
            Alert.ShowInTop("删除选中的 " + Grid1.SelectedRowIndexArray.Length + " 项纪录!");
        }
示例#5
0
        protected void btnDelete1_Click(object sender, EventArgs e)
        {
            if (Grid1.SelectedRowIndexArray.Length == 0)
            {
                Alert.ShowInTop("请至少选择一条记录!");
                return;
            }

            Demo.BLL.tb_JC_Department bll = new Demo.BLL.tb_JC_Department();

            foreach (int n in Grid1.SelectedRowIndexArray)
            {
                object[] keys = Grid1.DataKeys[n];
                string   id   = keys[0].ToString();
                bll.Delete(id);
            }

            BindGrid1();

            Alert.ShowInTop("删除成功");
        }
示例#6
0
        /// <summary>
        /// 模拟数据库分页
        /// </summary>
        /// <returns></returns>
        private DataTable GetPagedDataTable(int pageIndex, int pageSize)
        {
            Demo.BLL.tb_JC_Department bll = new Demo.BLL.tb_JC_Department();
            DataTable source = bll.GetList("").Tables[0];

            DataTable paged = source.Clone();

            int rowbegin = pageIndex * pageSize;
            int rowend   = (pageIndex + 1) * pageSize;

            if (rowend > source.Rows.Count)
            {
                rowend = source.Rows.Count;
            }

            for (int i = rowbegin; i < rowend; i++)
            {
                paged.ImportRow(source.Rows[i]);
            }

            return(paged);
        }
示例#7
0
        private void BindDataTableToDropDownList()
        {
            List <CustomClass> myList = new List <CustomClass>();

            Demo.BLL.tb_JC_Department bll = new Demo.BLL.tb_JC_Department();

            //泛型
            List <Demo.Model.tb_JC_Department> model = new List <Demo.Model.tb_JC_Department>();

            model = bll.GetModelList("");

            foreach (Demo.Model.tb_JC_Department temp in model)
            {
                myList.Add(new CustomClass(temp.DepartmentNO, temp.DepartmentName));
            }


            DropDownList1.DataTextField  = "Name";
            DropDownList1.DataValueField = "ID";
            DropDownList1.DataSource     = myList;
            DropDownList1.DataBind();
        }
示例#8
0
        protected void btnSaveRefresh_Click(object sender, EventArgs e)
        {
            // 1. 这里放置保存窗体中数据的逻辑

            Demo.BLL.tb_JC_Department   bll  = new Demo.BLL.tb_JC_Department();
            Demo.Model.tb_JC_Department dept = new Demo.Model.tb_JC_Department();

            dept.ID             = Guid.NewGuid().ToString();
            dept.DepartmentNO   = DepartmentNO.Text.Trim();
            dept.DepartmentName = DepartmentName.Text.Trim();

            if (bll.Add(dept))
            {
                Alert.ShowInTop("添加成功");
            }
            else
            {
                Alert.ShowInTop("添加失败");
            }

            // 2. 关闭本窗体,然后刷新父窗体
            PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
        }
示例#9
0
        private void dept()
        {
            List <CustomClass> myList1 = new List <CustomClass>();

            Demo.BLL.tb_JC_Department bll = new Demo.BLL.tb_JC_Department();

            //泛型
            List <Demo.Model.tb_JC_Department> model = new List <Demo.Model.tb_JC_Department>();

            model = bll.GetModelList("");
            foreach (Demo.Model.tb_JC_Department temp in model)
            {
                myList1.Add(new CustomClass(temp.DepartmentNO, temp.DepartmentName));
            }

            DropDownList1.DataTextField  = "Name";
            DropDownList1.DataValueField = "ID";
            DropDownList1.DataSource     = myList1;
            DropDownList1.DataBind();

            DropDownList1.Items.Insert(0, new ListItem("请选择部门", "-1"));
            DropDownList1.SelectedValue = "-1";
        }
示例#10
0
 /// <summary>
 /// 模拟返回总项数
 /// </summary>
 /// <returns></returns>
 private int GetTotalCount()
 {
     Demo.BLL.tb_JC_Department bll = new Demo.BLL.tb_JC_Department();
     return(bll.GetList("").Tables[0].Rows.Count);
 }