Beispiel #1
0
        private void toolStripButton_Del_Click(object sender, EventArgs e)
        {
            if (this.dgvMain.CurrentRow == null)
            {
                return;
            }
            if (this.dgvMain.CurrentRow.Index >= 0)
            {
                if (this.dgvMain.CurrentRow.Cells["colGroupName"].Value.ToString() != "admin")
                {
                    if (DialogResult.Yes == MessageBox.Show("您确定要删除此用户组吗?", "询问", MessageBoxButtons.YesNo, MessageBoxIcon.Question))
                    {
                        int membercount = (int)bll.ExecScalar("Security.SelectGroupMemberCount", new DataParameter[] { new DataParameter("@GroupID", Convert.ToInt32((this.dgvMain.CurrentRow.DataBoundItem as DataRowView).Row["GroupID"]).ToString()) });
                        if (membercount > 0)
                        {
                            Logger.Info("用户组还有用户存在,请调整后再删除!");
                            return;
                        }

                        bll.ExecNonQuery("Security.DeleteGroup", new DataParameter[] { new DataParameter("{0}", (this.dgvMain.CurrentRow.DataBoundItem as DataRowView).Row["GroupID"].ToString()) });
                        this.BindData();
                    }
                }
                else
                {
                    Logger.Info("管理用户组不能删除!");
                    return;
                }
            }
        }
Beispiel #2
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)
                        {
                            WMS.App_Code.JScript.Instance.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)
            {
                WMS.App_Code.JScript.Instance.ShowMessage(this.UpdatePanel1, exp.Message);
            }
        }