Exemplo n.º 1
0
 /// <summary>
 /// ɾ��
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void btnDel_Click(object sender, EventArgs e)
 {
     PRoleBB roleBB = new PRoleBB();
     PUserRoleBB userRoleBB = new PUserRoleBB();
     PRolePermissionsBB rolePermissionsBB = new PRolePermissionsBB();
     //��ȡѡ�е�����Id
     try
     {
         foreach (GridViewRow gvrow in this.grid.Rows)
         {
             CheckBox chkId = (CheckBox)gvrow.FindControl("chkId");
             int id = Convert.ToInt32(this.grid.DataKeys[gvrow.RowIndex]["id"]);
             if (chkId.Checked == true)
             {
                 PRoleData roleData = new PRoleData();
                 roleData = roleBB.GetModel(id);
                 if (roleData.isSys)
                 {
                     this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert(\"����λΪϵͳ��λ�����޷�ɾ����\");", true);
                     return;
                 }
                 else
                 {
                     //ɾ����ɫ��ͬʱ��ɾ����Ա��ɫ����ɫȨ��
                     roleBB.DeleteRecord(id);
                     userRoleBB.DeleteRecordByRole(id);
                     rolePermissionsBB.DeleteRecordByRole(id, 2);
                 }
             }
         }
     }
     catch (Exception ex)
     {
         this.ClientScript.RegisterStartupScript(this.GetType(), "ShowErr", "ShowErr(\"" + Server.UrlEncode(ex.Message) + "\",3);", true);
         return;
     }
     finally
     {
         roleBB.Dispose();
         userRoleBB.Dispose();
         rolePermissionsBB.Dispose();
     }
     this.BindGrid();
 }