コード例 #1
0
 /// <summary>
 ///  功能模块修改
 /// </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)
             {
                 Module         module         = _lstModule[listSelected[0]];
                 FormModuleEdit formModuleEdit = new FormModuleEdit(FormOperation.Modify, module);
                 if (formModuleEdit.ShowDialog() == DialogResult.OK)
                 {
                     BindGrid();
                 }
             }
             else
             {
                 MessageBox.Show("修改操作每次只能选择一条,请重新选择!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
             }
         }
         else
         {
             MessageBox.Show("没有可以修改的记录,请至少选择一条记录!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
         Log.Error(ex);
     }
 }
コード例 #2
0
 /// <summary>
 /// 功能模块新增操作
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btnAdd_Click(object sender, EventArgs e)
 {
     try
     {
         FormModuleEdit formModuleEdit = new FormModuleEdit(FormOperation.Add);
         if (formModuleEdit.ShowDialog() == DialogResult.OK)
         {
             BindGrid();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
         Log.Error(ex);
     }
 }