예제 #1
0
파일: UserForm.cs 프로젝트: liwei5946/CEMS
 /// <summary>
 /// 删除按钮
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void delButton_Click(object sender, EventArgs e)
 {
     DialogResult dr;
     Boolean flag = false;
     if (grid1[grid1.Selection.ActivePosition.Row, 0] != null)
     {
         dr = MessageBox.Show("您确认删除用户\"" + grid1[grid1.Selection.ActivePosition.Row, 0].ToString() + "\"?", "请确认", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
         if (dr == DialogResult.Yes)
         {
             Account acc = new Account();
             //flag = acc.deleteFaultById(grid1[grid1.Selection.ActivePosition.Row, 0].ToString());
             //flag = acc.deleteKnowledgeById(grid1[grid1.Selection.ActivePosition.Row, 0].ToString());
             flag = acc.deleteUserByUsername(grid1[grid1.Selection.ActivePosition.Row, 0].ToString());
             if (flag)
             {
                 MessageBox.Show("删除成功!");
                 DataSet ds = acc.queryUsers();
                 BindSourceGrid(grid1, ds.Tables[0]);
                 grid1.Selection.SelectRow(1, true);
                 grid1.Selection.FocusFirstCell(true);
             }
             else
             {
                 MessageBox.Show("删除失败!");
             }
         }
     }
 }