Ejemplo n.º 1
0
        private void tsbSave_Click(object sender, EventArgs e)
        {
            try
            {
                if (!MyLove.PermissionsBalidation(this.Text, "04"))
                {
                    return;
                }
                if (this.tvType.SelectedNode == null)
                {
                    MsgForm.ShowFrom("请先选择操作员组");
                    return;
                }

                sa_t_oper_type oper_type = this.tvType.SelectedNode.Tag as sa_t_oper_type;

                if (oper_type.oper_type.Equals("1000"))
                {
                    MsgForm.ShowFrom("系统管理员权限不可修改");
                    return;
                }

                List <sa_t_oper_grant> grantlis = new List <sa_t_oper_grant>();
                var list = tn_dic.Where(d => d.Value.Checked).Select(d => d.Key).ToList();

                list.ForEach(t =>
                {
                    string[] strs = t.Split('_');

                    var item = grantlis.SingleOrDefault(g => g.func_id.Equals(strs[0]));

                    if (item == null)
                    {
                        grantlis.Add(new sa_t_oper_grant()
                        {
                            func_id      = strs[0],
                            grant_string = strs[1] + ";",
                            oper_id      = oper_type.oper_type,
                            update_time  = DateTime.Now,
                        });
                    }
                    else
                    {
                        item.grant_string += strs[1] + ";";
                    }
                });

                IBLL.ISys bll = new BLL.SysBLL();
                bll.SaveGrant(grantlis);

                MsgForm.ShowFrom("保存成功");
            }
            catch (Exception ex)
            {
                MsgForm.ShowFrom(ex);
            }
        }