Пример #1
0
        //全选按钮
        protected void btnSelect_All_Click(object sender, EventArgs e)
        {
            Grid_Contract.SelectAllRows();
            int[] select = Grid_Contract.SelectedRowIndexArray;
            int   m;
            //取整数(不是四舍五入,全舍)
            int Pages = (int)Math.Floor(Convert.ToDouble(Grid_Contract.RecordCount / this.Grid_Contract.PageSize));

            if (Grid_Contract.PageIndex == Pages)
            {
                m = (Grid_Contract.RecordCount - this.Grid_Contract.PageSize * Grid_Contract.PageIndex);
            }
            else
            {
                m = this.Grid_Contract.PageSize;
            }
            bool isCheck = false;

            for (int i = 0; i < m; i++)
            {
                if (BoxSelect_Contract.GetCheckedState(i) == false)
                {
                    isCheck = true;
                }
            }
            if (isCheck)
            {
                foreach (int item in select)
                {
                    BoxSelect_Contract.SetCheckedState(item, true);
                }
                btnDelete.Enabled  = true;
                btnSelect_All.Text = "取消全选";
            }
            else
            {
                foreach (int item in select)
                {
                    BoxSelect_Contract.SetCheckedState(item, false);
                }
                btnDelete.Enabled  = false;
                btnSelect_All.Text = "全选";
            }
        }
Пример #2
0
        protected void Grid_Contract_RowCommand(object sender, GridCommandEventArgs e)
        {
            string strs   = Session["LoginName"].ToString();
            string Person = Grid_Contract.Rows[e.RowIndex].Values[2].ToString();

            if (Person != strs && Convert.ToInt32(Session["SecrecyLevel"]) != 5)
            {
                string str = "您无对此行操作的权限!此行信息为" + Person + "录入,请与管理员联系!";
                BoxSelect_Contract.SetCheckedState(e.RowIndex, false);
                Alert.ShowInTop(str);
            }
            int m;
            //取整数(不是四舍五入,全舍)
            int Pages = (int)Math.Floor(Convert.ToDouble(Grid_Contract.RecordCount / this.Grid_Contract.PageSize));

            if (Grid_Contract.PageIndex == Pages)
            {
                m = (Grid_Contract.RecordCount - this.Grid_Contract.PageSize * Grid_Contract.PageIndex);
            }
            else
            {
                m = this.Grid_Contract.PageSize;
            }
            List <int> selections = new List <int>();

            for (int i = 0; i < m; i++)
            {
                if (BoxSelect_Contract.GetCheckedState(i))
                {
                    selections.Add(i);
                }
            }
            if (selections.Count == 0)
            {
                btnDelete.Enabled = false;
                //Alert.ShowInTop("请至少选择一项!");
                return;
            }
            else
            {
                btnDelete.Enabled = true;
            }
        }