Example #1
0
    protected void btnDelete_Click(object sender, EventArgs e)
    {
        try
        {
            string strGroupID = "-1,";
            for (int i = 0; i < gvMain.Rows.Count; i++)
            {
                CheckBox chk = (CheckBox)gvMain.Rows[i].Cells[0].Controls[0];
                if (chk.Enabled && chk.Checked)
                {
                    int membercount = (int)bll.ExecScalar("Security.SelectGroupMemberCount", new DataParameter[] { new DataParameter("@GroupID", Convert.ToInt32(dtGroup.Rows[i]["GroupID"])) });
                    if (membercount > 0)
                    {
                        JScript.ShowMessage(this.UpdatePanel1, gvMain.Rows[i].Cells[1].Text + "用户组还有用户存在,请调整后再删除!");
                        return;
                    }

                    strGroupID += dtGroup.Rows[i]["GroupID"].ToString() + ",";
                }
            }
            strGroupID += "-1";


            bll.ExecNonQuery("Security.DeleteGroup", new DataParameter[] { new DataParameter("{0}", strGroupID) });
            AddOperateLog("用户管理", "删除用户信息");
            SetBtnEnabled(int.Parse(ViewState["CurrentPage"].ToString()), SqlCmd, ViewState["filter"].ToString(), pageSize, gvMain, btnFirst, btnPre, btnNext, btnLast, btnToPage, lblCurrentPage, this.UpdatePanel1);
        }
        catch (Exception exp)
        {
            JScript.ShowMessage(this.UpdatePanel1, exp.Message);
        }
    }