Esempio n. 1
0
 public FormModuleCategoryEdit(FormOperation formOperation, ModuleCatetory moduleCategory)
 {
     InitializeComponent();
     _Operation      = formOperation;
     _moduleCategory = moduleCategory;
     this.Text       = "功能模块大类修改";
 }
Esempio n. 2
0
 public FormModuleCategoryEdit(FormOperation formOperation)
 {
     InitializeComponent();
     _Operation      = formOperation;
     _moduleCategory = new ModuleCatetory();
     this.Text       = "功能模块大类新增";
 }
Esempio n. 3
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);
            }
        }
Esempio n. 4
0
        /// <summary>
        /// 选择功能类别删除操作
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnDelete_Click(object sender, EventArgs e)
        {
            try
            {
                List <int> listDeleted = 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)
                    {
                        listDeleted.Add(i);
                    }
                }
                if (listDeleted.Count > 0)
                {
                    if (MessageBox.Show("确定要删除" + listDeleted.Count + "条数据吗?", "系统提示", MessageBoxButtons.OKCancel) == System.Windows.Forms.DialogResult.Cancel)
                    {
                        return;
                    }

                    foreach (int i in listDeleted)
                    {
                        string         msg      = string.Empty;
                        ModuleCatetory category = _listModuleCategory[listDeleted[i]];
                        if (PharmacyDatabaseService.DeleteModuleCatetory(out msg, category.Id))
                        {
                            MessageBox.Show(string.Format("模块大类:{0}的记录删除失败", category.Name), "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            return;
                        }
                    }
                    BindGrid();
                    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);
            }
        }
Esempio n. 5
0
        /// <summary>
        /// 修改删除数据保存
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (_Operation != null)
            {
                try
                {
                    if (_Operation == FormOperation.Modify || _Operation == FormOperation.Add)
                    {
                        string msg = string.Empty;
                        if (_Operation == FormOperation.Modify)
                        {
                            _moduleCategory.Name        = txtModuleCategoryName.Text;
                            _moduleCategory.Description = rtbDesc.Text;
                            this.PharmacyDatabaseService.SaveModuleCatetory(out msg, _moduleCategory);
                        }
                        else
                        {
                            ModuleCatetory moduleCategory = new ModuleCatetory();
                            moduleCategory.Id          = moduleCategory.StoreId = Guid.NewGuid();
                            moduleCategory.Name        = txtModuleCategoryName.Text;
                            moduleCategory.Description = rtbDesc.Text;

                            this.PharmacyDatabaseService.AddModuleCatetory(out msg, moduleCategory);
                        }

                        if (msg.Length == 0)
                        {
                            MessageBox.Show("数据保存成功!", "系统信息");
                            DialogResult = DialogResult.OK;
                            this.Close();
                        }
                        else
                        {
                            MessageBox.Show("数据保存失败!", "系统信息");
                        }
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    Log.Error(ex);
                }
            }
        }
Esempio n. 6
0
 /// <summary>
 /// 根据角色,模块分类,要授权的模块编号位对角色进行模块授权
 /// </summary>
 /// <returns></returns>
 public bool AuthModuleWithRoleCatetoryAuthModuleIds(Role role, ModuleCatetory catetory, List <Guid> authModuleIds)
 {
     try
     {
         if (role == null)
         {
             throw new NullReferenceException("角色不可为空");
         }
         if (catetory == null)
         {
             throw new NullReferenceException("模块分类不可为空");
         }
         if (authModuleIds == null)
         {
             throw new NullReferenceException("要授权的模块编号不可为空");
         }
         var currentModuleWithRole =
             this.Fetch(mwr => mwr.RoleId == role.Id && mwr.Module.ModuleCatetoryId == catetory.Id)
             .ToList();
         foreach (var moduleWithRole in currentModuleWithRole)
         {
             this.Delete(moduleWithRole.Id);
         }
         this.Save();//提交变更
         foreach (var moduleId in authModuleIds)
         {
             this.Add(new ModuleWithRole
             {
                 ModuleId = moduleId
                 , RoleId = role.Id
             });
         }
         this.Save();//提交变更
         NotificationHandlerFactory.NotificationHandler.OnRoleAuthorityChanged();
         return(true);
     }
     catch (Exception ex)
     {
         return(this.HandleException <bool>("根据角色,模块分类,要授权的模块编号位对角色进行模块授权失败", ex));
     }
 }
Esempio n. 7
0
 /// <summary>
 ///  初始化Module Category information
 /// </summary>
 /// <param name="moduleCategory"></param>
 private void InitModuleCategory(ModuleCatetory moduleCategory)
 {
     this.txtModuleCategoryName.Text = moduleCategory.Name;
     this.rtbDesc.Text = moduleCategory.Description;
 }