Ejemplo n.º 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)
                    {
                        //获取选择的一条数据
                        ModuleCatetory category = new ModuleCatetory();
                        category = _listModuleCategory[listSelected[0]];

                        FormModuleCategoryEdit formRoleEdit = new FormModuleCategoryEdit(FormOperation.Modify, category);
                        if (formRoleEdit.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);
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 ///  新增一个功能大类
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btnAdd_Click(object sender, EventArgs e)
 {
     try
     {
         FormModuleCategoryEdit formRoleEdit = new FormModuleCategoryEdit(FormOperation.Add);
         if (formRoleEdit.ShowDialog() == DialogResult.OK)
         {
             BindGrid();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
         Log.Error(ex);
     }
 }