예제 #1
0
        public List <Permission> GetAllPermissions()
        {
            List <Permission> perms = new List <Permission>();
            string            sql   = "select * from TF_Permission";
            DataTable         dt    = sqlHelper.Query(sql);

            if (dt != null && dt.Rows.Count > 0)
            {
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    Permission perm = new Permission();
                    perm.ID        = Convert.ToInt32(dt.Rows[i]["ID"]);
                    perm.Name      = dt.Rows[i]["Name"].ToString();
                    perm.TheModule = ModuleLogic.GetInstance().GetModule(Convert.ToInt32(dt.Rows[i]["TheModule"]));
                    perm.TheAction = ActionLogic.GetInstance().GetAction(Convert.ToInt32(dt.Rows[i]["TheAction"]));
                    if (dt.Rows[i]["Remark"] != null && dt.Rows[i]["Remark"] != DBNull.Value)
                    {
                        perm.Remark = dt.Rows[i]["Remark"].ToString();
                    }
                    else
                    {
                        perm.Remark = "";
                    }
                    perms.Add(perm);
                }
            }
            return(perms);
        }
예제 #2
0
        internal bool UpgradeArchitectureToRemote(out Exception ex)
        {
            ex = null;
            int errCount = 0;

            try
            {
                Architecture      a     = this.CurrentArchitecture;
                List <Action>     atcs  = a.Acts;
                List <Department> deps  = a.Deps;
                List <Module>     mods  = a.Mods;
                List <Permission> perms = a.Pers;
                List <Role>       roles = a.Roles;
                List <UserGroup>  ugrps = a.Ugroups;
                List <User>       users = a.Users;
                ActionLogic.GetInstance().UpgradeList(atcs);
                DepartmentLogic.GetInstance().UpgradeList(deps);
                ModuleLogic.GetInstance().UpgradeList(mods);
                PermissionLogic.GetInstance().UpgradeList(perms);
                RoleLogic.GetInstance().UpgradeList(roles);
                UserGroupLogic.GetInstance().UpgradeList(ugrps);
                UserLogic.GetInstance().UpgradeList(users);
            }
            catch (Exception e)
            {
                errCount++;
                ex = e;
            }
            return(errCount == 0);
        }
예제 #3
0
        public Permission GetPermission(int id)
        {
            string    sql = "select * from TF_Permission where ID=" + id;
            DataTable dt  = sqlHelper.Query(sql);

            if (dt != null && dt.Rows.Count > 0)
            {
                Permission perm = new Permission();
                perm.ID        = id;
                perm.Name      = dt.Rows[0]["Name"].ToString();
                perm.IsExcept  = Convert.ToBoolean(dt.Rows[0]["IsExcept"]);
                perm.TheModule = ModuleLogic.GetInstance().GetModule(Convert.ToInt32(dt.Rows[0]["TheModule"]));
                perm.TheAction = ActionLogic.GetInstance().GetAction(Convert.ToInt32(dt.Rows[0]["TheAction"]));
                if (dt.Rows[0]["Remark"] != null && dt.Rows[0]["Remark"] != DBNull.Value)
                {
                    perm.Remark = dt.Rows[0]["Remark"].ToString();
                }
                else
                {
                    perm.Remark = "";
                }
                return(perm);
            }
            return(null);
        }
예제 #4
0
        public static ActionLogic GetInstance()
        {
            if (instance == null)
            {
                instance = new ActionLogic();
            }

            return(instance);
        }
예제 #5
0
        private static Architecture GetRemoteArchitecture()
        {
            Architecture a = Architecture.Empty;

            a.Deps    = DepartmentLogic.GetInstance().GetAllDepartments();
            a.Ugroups = UserGroupLogic.GetInstance().GetAllUserGroups();
            a.Users   = UserLogic.GetInstance().GetAllUsers();
            a.Mods    = ModuleLogic.GetInstance().GetAllModules();
            a.Acts    = ActionLogic.GetInstance().GetAllActions();
            a.Pers    = PermissionLogic.GetInstance().GetAllPermissions();
            a.Roles   = RoleLogic.GetInstance().GetAllRoles();
            return(a);
        }
예제 #6
0
 private void btn_Actn_Click(object sender, EventArgs e)
 {
     if (comboBox1.SelectedIndex > -1)
     {
         Action action = new Action();
         action.ID          = data[comboBox1.SelectedIndex].ID;
         action.Name        = textBox1.Text.Trim();
         action.FormName    = textBox3.Text.Trim();
         action.ControlName = textBox4.Text.Trim();
         action.Remark      = textBox2.Text;
         ActionLogic al = ActionLogic.GetInstance();
         if (al.ExistsNameOther(action.Name, action.ID))
         {
             if (MessageBox.Show("系统中已经存在该名称,确定还要继续保存么?", "重名提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.OK)
             {
                 if (al.UpdateAction(action))
                 {
                     data[comboBox1.SelectedIndex].Name        = action.Name;
                     data[comboBox1.SelectedIndex].FormName    = action.FormName;
                     data[comboBox1.SelectedIndex].ControlName = action.ControlName;
                     data[comboBox1.SelectedIndex].Remark      = action.Remark;
                     RefreshInfo();
                     MessageBox.Show("修改成功!");
                 }
             }
             else
             {
                 textBox1.Focus();
                 textBox1.SelectAll();
             }
         }
         else
         {
             if (al.UpdateAction(action))
             {
                 data[comboBox1.SelectedIndex].Name        = action.Name;
                 data[comboBox1.SelectedIndex].FormName    = action.FormName;
                 data[comboBox1.SelectedIndex].ControlName = action.ControlName;
                 data[comboBox1.SelectedIndex].Remark      = action.Remark;
                 RefreshInfo();
                 MessageBox.Show("修改成功!");
             }
         }
     }
     else
     {
         MessageBox.Show("先选定要修改的项目!");
     }
 }
예제 #7
0
 private void button1_Click(object sender, EventArgs e)
 {
     if (comboBox1.SelectedIndex > -1)
     {
         if (MessageBox.Show("确定要删除该项目?", "删除提醒", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.OK)
         {
             Action action = data[comboBox1.SelectedIndex];
             if (ActionLogic.GetInstance().DeleteAction(action))
             {
                 data.RemoveAt(comboBox1.SelectedIndex);
                 RefreshInfo();
             }
         }
     }
     else
     {
         MessageBox.Show("先选定要删除的项目!");
     }
 }
예제 #8
0
        private void button19_Click(object sender, EventArgs e)
        {
            Action action = new Action();

            action.Name        = textBox1.Text.Trim();
            action.FormName    = textBox3.Text.Trim();
            action.ControlName = textBox4.Text.Trim();
            action.Remark      = textBox2.Text;
            ActionLogic al = ActionLogic.GetInstance();

            if (al.ExistsName(action.Name))
            {
                if (MessageBox.Show("系统中已经存在该名称,确定还要继续保存么?", "重名提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.OK)
                {
                    int id = al.AddAction(action);
                    if (id > 0)
                    {
                        action.ID = id;
                        data.Add(action);
                        RefreshInfo();
                        MessageBox.Show("添加成功!");
                    }
                }
                else
                {
                    textBox1.Focus();
                    textBox1.SelectAll();
                }
            }
            else
            {
                int id = al.AddAction(action);
                if (id > 0)
                {
                    action.ID = id;
                    data.Add(action);
                    RefreshInfo();
                    MessageBox.Show("添加成功!");
                }
            }
        }
예제 #9
0
        public Tuple <bool, Tuple <string, string>, Tuple <string, string> > GetExcModAct(int id)
        {
            string    sql = "select IsExcept, TheModule, TheAction from TF_Permission where ID=" + id;
            DataTable dt  = sqlHelper.Query(sql);

            if (dt != null && dt.Rows.Count > 0)
            {
                Tuple <bool, Tuple <string, string>, Tuple <string, string> > result = new Tuple <bool, Tuple <string, string>, Tuple <string, string> >(Convert.ToBoolean(dt.Rows[0]["IsExcept"]), ModuleLogic.GetInstance().GetFormNameAndControlName(Convert.ToInt32(dt.Rows[0]["TheModule"])), ActionLogic.GetInstance().GetFormNameAndControlName(Convert.ToInt32(dt.Rows[0]["TheAction"])));
                return(result);
            }
            return(null);
        }