Ejemplo n.º 1
0
 /// <summary>
 ///  Modify User Information
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btnModify_Click(object sender, EventArgs e)
 {
     try
     {
         List <int> listSelected = new List <int>();
         for (int i = 0; i < dgvData.Rows.Count; i++)
         {
             //判断是否被选中
             bool isChecked = false;
             if (dgvData.Rows[i].Cells[0].Value != null)
             {
                 isChecked = Convert.ToBoolean(dgvData.Rows[i].Cells[0].Value.ToString());
             }
             else
             {
                 isChecked = false;
             }
             if (isChecked)
             {
                 listSelected.Add(i);
             }
         }
         int selectCount = listSelected.Count;
         if (selectCount > 0)
         {
             if (selectCount == 1)
             {
                 User updateUser = new User();
                 updateUser = _lstUser[listSelected[0]];
                 FormUserEdit formUserEdit = new FormUserEdit(FormOperation.Modify, updateUser);
                 if (formUserEdit.ShowDialog() == DialogResult.OK)
                 {
                     BindGrid();
                 }
             }
             else
             {
                 MessageBox.Show("修改操作每次只能选择一条,请重新选择!", "系统提示");
             }
         }
         else
         {
             MessageBox.Show("没有可以修改的记录,请至少选择一条记录!", "系统提示");
         }
     }
     catch (Exception ex)
     {
         Log.Error(ex);
         MessageBox.Show(ex.Message, "系统错误");
     }
 }
Ejemplo n.º 2
0
 private void btnAdd_Click(object sender, EventArgs e)
 {
     try
     {
         FormUserEdit formUserEdit = new FormUserEdit(FormOperation.Add);
         if (formUserEdit.ShowDialog() == DialogResult.OK)
         {
             BindGrid();
         }
     }
     catch (Exception ex)
     {
         Log.Error(ex);
         MessageBox.Show("角色管理窗口启动失败!", "系统错误");
     }
 }