コード例 #1
0
ファイル: ConfigClient.cs プロジェクト: zanderzhg/TopFashion
        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);
        }
コード例 #2
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);
        }
コード例 #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
ファイル: ModuleLogic.cs プロジェクト: zanderzhg/TopFashion
        public static ModuleLogic GetInstance()
        {
            if (instance == null)
            {
                instance = new ModuleLogic();
            }

            return(instance);
        }
コード例 #5
0
ファイル: ConfigClient.cs プロジェクト: zanderzhg/TopFashion
        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_Modu_Click(object sender, EventArgs e)
 {
     if (comboBox1.SelectedIndex > -1)
     {
         Module module = new Module();
         module.ID          = data[comboBox1.SelectedIndex].ID;
         module.Name        = textBox1.Text.Trim();
         module.FormName    = textBox3.Text.Trim();
         module.ControlName = textBox4.Text.Trim();
         module.Remark      = textBox2.Text;
         ModuleLogic ml = ModuleLogic.GetInstance();
         if (ml.ExistsNameOther(module.Name, module.ID))
         {
             if (MessageBox.Show("系统中已经存在该名称,确定还要继续保存么?", "重名提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.OK)
             {
                 if (ml.UpdateModule(module))
                 {
                     data[comboBox1.SelectedIndex].Name        = module.Name;
                     data[comboBox1.SelectedIndex].FormName    = module.FormName;
                     data[comboBox1.SelectedIndex].ControlName = module.ControlName;
                     data[comboBox1.SelectedIndex].Remark      = module.Remark;
                     RefreshInfo();
                     MessageBox.Show("修改成功!");
                 }
             }
             else
             {
                 textBox1.Focus();
                 textBox1.SelectAll();
             }
         }
         else
         {
             if (ml.UpdateModule(module))
             {
                 data[comboBox1.SelectedIndex].Name        = module.Name;
                 data[comboBox1.SelectedIndex].FormName    = module.FormName;
                 data[comboBox1.SelectedIndex].ControlName = module.ControlName;
                 data[comboBox1.SelectedIndex].Remark      = module.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)
         {
             Module module = data[comboBox1.SelectedIndex];
             if (ModuleLogic.GetInstance().DeleteModule(module))
             {
                 data.RemoveAt(comboBox1.SelectedIndex);
                 RefreshInfo();
             }
         }
     }
     else
     {
         MessageBox.Show("先选定要删除的项目!");
     }
 }
コード例 #8
0
        private void button18_Click(object sender, EventArgs e)
        {
            Module module = new Module();

            module.Name        = textBox1.Text.Trim();
            module.FormName    = textBox3.Text.Trim();
            module.ControlName = textBox4.Text.Trim();
            module.Remark      = textBox2.Text;
            ModuleLogic ml = ModuleLogic.GetInstance();

            if (ml.ExistsName(module.Name))
            {
                if (MessageBox.Show("系统中已经存在该名称,确定还要继续保存么?", "重名提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.OK)
                {
                    int id = ml.AddModule(module);
                    if (id > 0)
                    {
                        module.ID = id;
                        data.Add(module);
                        RefreshInfo();
                        MessageBox.Show("添加成功!");
                    }
                }
                else
                {
                    textBox1.Focus();
                    textBox1.SelectAll();
                }
            }
            else
            {
                int id = ml.AddModule(module);
                if (id > 0)
                {
                    module.ID = id;
                    data.Add(module);
                    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);
        }