Example #1
0
        public int AddRole(Role role)
        {
            string sql = "insert into [Role] (Name, Permissions, Flag, Remark) values ('" + role.Name + "', '" + Common.GetPermissionsStr(role.Permissions) + "', " + (role.Flag ? "1" : "0") + ", '" + role.Remark + "'); select SCOPE_IDENTITY()";
            object obj = sqlHelper.ExecuteSqlReturn(sql);
            int    R;

            if (obj != null && obj != DBNull.Value && int.TryParse(obj.ToString(), out R))
            {
                return(R);
            }
            else
            {
                return(0);
            }
        }
Example #2
0
        public int AddModule(Module module)
        {
            string sql = "insert into Module (Name, FormName, ControlName, Remark) values ('" + module.Name + "', '" + module.FormName + "', '" + module.ControlName + "', '" + module.Remark + "'); select SCOPE_IDENTITY()";
            object obj = sqlHelper.ExecuteSqlReturn(sql);
            int    R;

            if (obj != null && obj != DBNull.Value && int.TryParse(obj.ToString(), out R))
            {
                return(R);
            }
            else
            {
                return(0);
            }
        }
Example #3
0
        public int AddUserGroup(UserGroup ug)
        {
            string sql = "insert into UserGroup (Name, Remark) values ('" + ug.Name + "', '" + ug.Remark + "'); select SCOPE_IDENTITY()";
            object obj = sqlHelper.ExecuteSqlReturn(sql);
            int    R;

            if (obj != null && obj != DBNull.Value && int.TryParse(obj.ToString(), out R))
            {
                return(R);
            }
            else
            {
                return(0);
            }
        }
Example #4
0
        public int AddUser(User user)
        {
            string sql = "insert into [User] (Username, Password, Depart, Flag, Remark) values ('" + user.Username + "', '" + user.Password + "', '" + Common.GetDepartmentsStr(user.Departments) + "'," + user.Flag + ", '" + user.Remark + "'); select SCOPE_IDENTITY()";
            object obj = sqlHelper.ExecuteSqlReturn(sql);
            int    R;

            if (obj != null && obj != DBNull.Value && int.TryParse(obj.ToString(), out R))
            {
                return(R);
            }
            else
            {
                return(0);
            }
        }
Example #5
0
        public int AddDepartment(Department dep)
        {
            //string parent = "0";
            //if (dep.Parent != null)
            //    parent = dep.Parent.ID.ToString();
            string sql = "insert into Depart (Name, Manager, Parent, Remark) values ('" + dep.Name + "','" + dep.Manager + "', " + dep.ParentID + ", '" + dep.Remark + "'); select SCOPE_IDENTITY()";
            object obj = sqlHelper.ExecuteSqlReturn(sql);
            int    R;

            if (obj != null && obj != DBNull.Value && int.TryParse(obj.ToString(), out R))
            {
                return(R);
            }
            else
            {
                return(0);
            }
        }
Example #6
0
        public int AddPermission(Permission perm)
        {
            string sql = "";

            if (perm.TheAction != null)
            {
                sql = "insert into Permission (Name, IsExcept, TheModule, TheAction, Remark) values ('" + perm.Name + "'," + (perm.IsExcept ? "1" : "0") + ", " + perm.TheModule.ID + ", " + perm.TheAction.ID + ", '" + perm.Remark + "'); select SCOPE_IDENTITY()";
            }
            else
            {
                sql = "insert into Permission (Name, IsExcept, TheModule, Remark) values ('" + perm.Name + "', " + (perm.IsExcept ? "1" : "0") + ", " + perm.TheModule.ID + ", '" + perm.Remark + "'); select SCOPE_IDENTITY()";
            }
            object obj = sqlHelper.ExecuteSqlReturn(sql);
            int    R;

            if (obj != null && obj != DBNull.Value && int.TryParse(obj.ToString(), out R))
            {
                return(R);
            }
            else
            {
                return(0);
            }
        }