예제 #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;
            }
        }
예제 #3
0
        //删除资料
        protected void btnDelete_Click(object sender, EventArgs e)
        {
            try
            {
                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 (Convert.ToInt32(Session["SecrecyLevel"]) == 5)
                {
                    for (int i = 0; i < selections.Count(); i++)
                    {
                        int ContractID = Convert.ToInt32(Grid_Contract.DataKeys[selections[i]][0].ToString());
                        //删除资料附件
                        int    AttactID = BLLContract.FindAttachmentID(ContractID);
                        string strPath;
                        if (AttactID != 0)
                        {
                            strPath = BLLAttachment.FindPath(AttactID);
                            if (strPath != "")
                            {
                                //删除附件文件
                                publicMethod.DeleteFile(AttactID, strPath);
                                //在附件表中删除附件数据
                                BLLAttachment.Delete(AttactID);
                            }
                        }
                        //删除资料借阅记录
                        List <int> listRecordID = BLLLibraryRecord.FindLibraryID(ContractID, "资料");
                        if (listRecordID != null)
                        {
                            for (int j = 0; j < listRecordID.Count(); j++)
                            {
                                BLLLibraryRecord.Delete(listRecordID[j]);
                            }
                        }
                        //删除资料
                        BLLContract.Delete(Convert.ToInt32(Grid_Contract.DataKeys[selections[i]][0].ToString()));
                    }
                    Alert.ShowInTop("删除成功!");
                    btnSelect_All.Text = "全选";
                }
                else
                {
                    for (int i = 0; i < selections.Count(); i++)
                    {
                        BLLContract.UpdateIsPass(Convert.ToInt32(Grid_Contract.DataKeys[selections[i]][0]), false);
                        List <int> listRecordID = BLLLibraryRecord.FindLibraryID(Convert.ToInt32(Grid_Contract.DataKeys[selections[i]][0]), "资料");
                        for (int j = 0; j < listRecordID.Count(); i++)
                        {
                            BLLLibraryRecord.UpdateIsPass(listRecordID[j], false);
                        }
                        //BLLUser.FindByLoginName(Session["LoginName"].ToString()).UserName
                        operate.LoginName        = Session["LoginName"].ToString();
                        operate.OperationTime    = DateTime.Now;
                        operate.LoginIP          = " ";
                        operate.OperationContent = "Contract";
                        operate.OperationType    = "删除";
                        operate.OperationDataID  = Convert.ToInt32(Grid_Contract.DataKeys[selections[i]][0]);
                        op.Insert(operate);
                        //BindData();
                        Alert.ShowInTop("操作已经提交,请等待管理员确认!");
                        btnSelect_All.Text = "全选";
                    }
                }
                btnDelete.Enabled = false;
                BindData();
                Grid_Contract.PageIndex = 0;
                Grid_Contract.PageSize  = 20;
                BindData();
            }
            catch (Exception ex)
            {
                BLCommon.PublicMethod pm = new BLCommon.PublicMethod();
                pm.SaveError(ex, this.Request);
            }
        }