コード例 #1
0
        public void getUserInfor(User user)
        {
            lbUsername.Content = user.Username;
            lbName.Content     = user.Name;
            if (user.Gender == 1)
            {
                lbGender.Content = "男";
            }
            else
            {
                lbGender.Content = "女";
            }

            //获取部门名称

            DeptBLL bll = new DeptBLL();

            lbDep.Content      = bll.GetDepartmentsById(user.Deptid).Name;
            lbWorknum.Content  = Convert.ToString(user.Worknum);
            lbPhone.Content    = user.Phone;
            lbPosition.Content = user.Position;
            if (user.Control == 0)
            {
                lbControl.Content = "用户";
            }
            else
            {
                lbControl.Content = "管理员";
            }
        }
コード例 #2
0
        /// <summary>
        /// 从数据库获取所有意见列表
        /// </summary>
        /// <returns></returns>
        private List <Tuple <string, string, int, int, List <string> > > getAllListByDb()
        {
            var     comments  = GetAll();
            DeptBLL borganize = new DeptBLL();
            List <Tuple <string, string, int, int, List <string> > > list = new List <Tuple <string, string, int, int, List <string> > >();

            foreach (var comment in comments)
            {
                List <string> userList = new List <string>();
                if (!comment.MemberID.IsNullOrEmpty())
                {
                    var users = borganize.GetAllUsers(comment.MemberID);
                    foreach (var user in users)
                    {
                        userList.Add(user.ID);
                    }
                }

                Tuple <string, string, int, int, List <string> > tuple = new Tuple <string, string, int, int, List <string> >(
                    comment.ID,
                    comment.Comment,
                    comment.Type,
                    comment.Sort,
                    userList
                    );
                list.Add(tuple);
            }
            return(list);
        }
コード例 #3
0
        //函数
        #region 页面加载
        public FrmHisInOutStationHead()
        {
            InitializeComponent();

            label8.Text = HardwareName.Value(CorpsName.CodeSenderAddress) + ":";
            label4.Text = HardwareName.Value(CorpsName.StationSplace) + ":";
            label5.Text = HardwareName.Value(CorpsName.StaHeadSplace) + ":";

            dtEndTime.Text   = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
            dtStartTime.Text = DateTime.Today.ToString();


            #region 加载部门, 工种, 证书, 职务, 职务等级 信息
            if (!lhsh.LoadInfo(treeInfo, cmbWorkType, cmbCerType, cmbDutyName, cmbDutyClass, 1))
            {
                MessageBox.Show("对不起, 基本数据加载失败!");
                return;
            }
            #endregion

            #region 加载分站信息
            lhab.LoadInfo(cmb_Station, cmb_StaHead, false);
            #endregion

            treeInfo.ExpandAll();
            treeInfo.SelectedNode = treeInfo.Nodes[0];

            cbPSize.SelectedIndex = 0;

            // 加载设备类型,生产厂家
            DeptBLL deptbll = new DeptBLL();
            deptbll.getEquTYpeCmb(cmbEquType);             // 设备类型
            deptbll.getEquFactoryCmb(cmbFactory);          // 生产厂家
        }
コード例 #4
0
        public FrmHisInOutMine()
        {
            InitializeComponent();

            dtEndTime.Text   = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
            dtStartTime.Text = DateTime.Today.ToString("yyyy-MM-dd HH:mm:ss");
            #region 加载部门, 工种, 证书, 职务, 职务等级 信息
            if (!lhmb.LoadInfo(treeInfo, cmbWorkType, null, cmbDutyName, null, 1))
            {
                MessageBox.Show("对不起, 基本数据加载失败!");
                return;
            }
            #endregion

            treeInfo.ExpandAll();
            treeInfo.SelectedNode = treeInfo.Nodes[0];

            // 加载设备类型,生产厂家
            DeptBLL deptbll = new DeptBLL();
            deptbll.getEquTYpeCmb(cmbEquType);             // 设备类型
            deptbll.getEquFactoryCmb(cmbFactory);          // 生产厂家

            label8.Text = HardwareName.Value(CorpsName.CodeSenderAddress) + ":";
            dgValue.Columns[0].HeaderText = HardwareName.Value(CorpsName.CodeSenderAddress);
            this.SelectInfo();
        }
コード例 #5
0
 public AddUser()
 {
     InitializeComponent();
     DeptBLL bll = new DeptBLL();
     List<Department> departments = new List<Department>();
     departments = bll.GetDepartmentsList();
     departments.Insert(0, new Department(0, "--请选择分类--"));
     depName.ItemsSource = departments;
     depName.DisplayMemberPath = "Name";
     depName.SelectedIndex = 0;
 }
コード例 #6
0
        // 加载下拉菜单信息
        private void LoadCmb()
        {
            DeptBLL deptbll = new DeptBLL();

            deptbll.getDutyNameCmb(cmbDutyName);    // 职务名称
            deptbll.getWorkTypeCmb(cmbWorkType);    // 工种
            deptbll.getCerTypeCmb(cmbCerType);      // 证书类别

            deptbll.getEquTYpeCmb(cmbEquType);      // 设备类型
            deptbll.getEquFactoryCmb(cmb);          // 生产厂家
        }
コード例 #7
0
        public AdmiEditUserInfor(User user)
        {
            user1 = user;
            InitializeComponent();
            DeptBLL           bll         = new DeptBLL();
            List <Department> departments = new List <Department>();

            departments = bll.GetDepartmentsList();
            departments.Insert(0, new Department(0, "--请选择部门-"));
            depName.ItemsSource       = departments;
            depName.DisplayMemberPath = "Name";
            depName.SelectedIndex     = user.Deptid;
            getUserInfor(user);
        }
コード例 #8
0
        private void BindCmd()
        {
            int iYear = DateTime.Now.Year;

            for (int i = iYear - 5; i < iYear + 5; i++)
            {
                cmbYear.Items.Add(i.ToString());
            }
            cmbYear.SelectedIndex = 5;

            //绑定部门、工种
            DeptBLL deptbll = new DeptBLL();

            deptbll.getWorkTypeCmb(cmbWorkType); // 工种
            deptbll.getDeptAddAll(cmbDept);      // 部门
        }
コード例 #9
0
        public ActionResult AddRole(FormCollection collection)
        {
            string name      = Request.Form["Name"];
            string note      = Request.Form["Note"];
            string useMember = Request.Form["UseMember"];
            Role   role      = new Role();

            if (collection != null)
            {
                using (System.Transactions.TransactionScope trans = new System.Transactions.TransactionScope())
                {
                    role.ID   = Guid.NewGuid().ToString();
                    role.Name = name.Trim();
                    if (!useMember.IsNullOrEmpty())
                    {
                        role.UseMember = useMember;
                        RoadFlow.Platform.UsersRole busersRole = new RoadFlow.Platform.UsersRole();
                        var users = new DeptBLL().GetAllUsers(useMember);
                        foreach (var user in users)
                        {
                            RoadFlow.Data.Model.UsersRole ur = new RoadFlow.Data.Model.UsersRole();
                            ur.IsDefault = true;
                            ur.MemberID  = user.ID;
                            ur.RoleID    = role.ID;
                            busersRole.Insert(ur);
                        }
                    }
                    if (!note.IsNullOrEmpty())
                    {
                        role.Note = note.Trim();
                    }
                    new RoleBLL().Insert(role);

                    //添加一个根应用
                    RoleApp roleApp = new RoleApp();
                    roleApp.ID     = Guid.NewGuid().ToString();
                    roleApp.PID    = string.Empty;
                    roleApp.RoleID = role.ID;
                    roleApp.Sort   = 1;
                    roleApp.Title  = "管理目录";
                    new RoleAppBLL().Insert(roleApp);
                    trans.Complete();
                    ViewBag.Script = "alert('添加成功!');new RoadUI.Window().reloadOpener();new RoadUI.Window().close();";
                }
            }
            return(View(role));
        }
コード例 #10
0
        public void BindDept()
        {
            DeptBLL dbll = new DeptBLL();
            DataSet ds   = dbll.GetDeptInfo();
            DataRow dr   = ds.Tables[0].NewRow();

            dr["DeptID"]   = 0;
            dr["DeptName"] = "所有";
            ds.Tables[0].Rows.InsertAt(dr, 0);
            if (ds.Tables != null && ds.Tables.Count > 0)
            {
                cmbDeptList.DataSource    = ds.Tables[0];
                cmbDeptList.DisplayMember = "DeptName";
                cmbDeptList.ValueMember   = "DeptID";
            }
            cmbDeptList.Text = "所有";
        }
コード例 #11
0
        //获取发码器配置查询条件

        private string GetStrWhereSet()
        {
            string strWhere = string.Empty;
            string tmpStr   = cmbDeptList.SelectedValue.ToString();

            if (tmpStr == "0")
            {
                string[,] arr = new string[3, 4]
                {
                    { "发码器地址", "=", txtCodeSet.Text, "int" },
                    { "称呼", "=", txt.Text, "string" },
                    { "CsTypeID", "=", cmbConfigType.Text.ToString() == "所有"?"":cmbConfigType.SelectedValue.ToString(), "int" }
                };
                strWhere = rtbll.SelectWhere(arr, 1);
            }
            else
            {
                DeptBLL dbll = new DeptBLL();
                DataSet ds   = dbll.GetDeptInfoAll();
                strWhere = "DeptID = " + tmpStr;
                strWhere = dbll.GetDeptChildAll(ds, strWhere, int.Parse(tmpStr));

                string[,] arr = new string[3, 4]
                {
                    { "发码器地址", "=", txtCodeSet.Text, "int" },
                    { "称呼", "=", txt.Text, "string" },
                    { "CsTypeID", "=", cmbConfigType.Text.ToString() == "所有"?"":cmbConfigType.SelectedValue.ToString(), "int" }
                };
                string tmp = rtbll.SelectWhere(arr, 1);
                // 如果没查询条件

                if (tmp != "")
                {
                    strWhere  = "(" + strWhere;
                    strWhere += ") and " + tmp;
                }
            }
            return(strWhere);
        }
コード例 #12
0
        public void ProcessRequest(HttpContext context)
        {
            try
            {
                LoginUser loginUser = new LoginUser(context, "User");
                if (!loginUser.Pass)//权限验证
                {
                    return;
                }

                //加载角色列表
                if (context.Request["action"] == "roleListLoad")
                {
                    RoleBLL bll = new RoleBLL(context, loginUser);
                    bll.Combobox();
                    return;
                }

                //加载部门列表
                if (context.Request["action"] == "deptListLoad")
                {
                    DeptBLL bll = new DeptBLL(context, loginUser);
                    bll.Combobox();
                    return;
                }

                //加载DataGrid
                if (context.Request["action"] == "gridLoad")
                {
                    UserBLL bll      = new UserBLL(context, loginUser);
                    int     page     = int.Parse(context.Request["page"]);
                    int     rows     = int.Parse(context.Request["rows"]);
                    string  deptId   = context.Request["deptId"];
                    string  userName = context.Request["userName"];
                    bll.LoadGrid(page, rows, deptId, userName);
                    return;
                }

                //加载信息
                if (context.Request["action"] == "load")
                {
                    UserBLL bll    = new UserBLL(context, loginUser);
                    string  userId = context.Request["userId"];//用户编号
                    bll.Load(userId);
                    return;
                }

                //增加
                if (context.Request["action"] == "add")
                {
                    UserBLL bll    = new UserBLL(context, loginUser);
                    TSUser  tsUser = new TSUser();
                    //tsUser.userId= context.Request["userId"];//用户编号
                    tsUser.userName  = context.Request["userName"];  //用户姓名
                    tsUser.userCode  = context.Request["userCode"];  //用户帐号
                    tsUser.userPwd   = tsUser.userCode;              //用户密码
                    tsUser.roleIds   = context.Request["roleIds"];   //角色编号
                    tsUser.deptId    = context.Request["deptId"];    //部门编号
                    tsUser.status    = context.Request["status"];    //使用状态
                    tsUser.post      = context.Request["post"];      //职务
                    tsUser.telephone = context.Request["telephone"]; //联系电话
                    bll.Add(tsUser);
                    return;
                }

                //修改
                if (context.Request["action"] == "edit")
                {
                    UserBLL bll    = new UserBLL(context, loginUser);
                    TSUser  tsUser = new TSUser();
                    tsUser.userId   = context.Request["userId"];     //用户编号
                    tsUser.userName = context.Request["userName"];   //用户姓名
                    tsUser.userCode = context.Request["userCode"];   //用户帐号
                    //tsUser.userPwd = context.Request["userPwd"];//用户密码
                    tsUser.roleIds   = context.Request["roleIds"];   //角色编号
                    tsUser.deptId    = context.Request["deptId"];    //部门编号
                    tsUser.status    = context.Request["status"];    //使用状态
                    tsUser.post      = context.Request["post"];      //职务
                    tsUser.telephone = context.Request["telephone"]; //联系电话
                    bll.Edit(tsUser);
                    return;
                }

                //删除
                if (context.Request["action"] == "delete")
                {
                    UserBLL bll    = new UserBLL(context, loginUser);
                    string  userId = context.Request["userId"];//用户编号
                    bll.Delete(userId);
                    return;
                }
            }
            catch (Exception e)
            {
                Message.error(context, e.Message);
            }
        }
コード例 #13
0
        /// <summary>
        /// 根据显示方式得到显示的字符串
        /// </summary>
        /// <param name="value"></param>
        /// <param name="displayModel"></param>
        /// <returns></returns>
        public string GetDisplayString(string value, string displayModel, string format = "", string dbconnID = "", string sql = "")
        {
            string value1 = string.Empty;

            switch ((displayModel ?? "").ToLower())
            {
            case "normal":
            default:
                value1 = value;
                break;

            case "dict_id_title":
                var dict = new DictBLL().FindByID(value.ToGuid());
                value1 = dict == null ? "" : dict.Title;
                break;

            case "dict_id_code":
                var dict1 = new DictBLL().FindByID(value.ToGuid());
                value1 = dict1 == null ? "" : dict1.Code;
                break;

            case "dict_id_value":
                var dict2 = new DictBLL().FindByID(value.ToGuid());
                value1 = dict2 == null ? "" : dict2.Value;
                break;

            case "dict_id_note":
                var dict3 = new DictBLL().FindByID(value.ToGuid());
                value1 = dict3 == null ? "" : dict3.Note;
                break;

            case "dict_id_other":
                var dict4 = new DictBLL().FindByID(value.ToGuid());
                value1 = dict4 == null ? "" : dict4.Other;
                break;

            case "dict_code_title":
                var dict5 = new DictBLL().GetByCode(value);
                value1 = dict5 == null ? "" : dict5.Title;
                break;

            case "dict_code_id":
                var dict6 = new DictBLL().GetByCode(value);
                value1 = dict6 == null ? "" : dict6.ID.ToString();
                break;

            case "dict_code_value":
                var dict7 = new DictBLL().GetByCode(value);
                value1 = dict7 == null ? "" : dict7.Value;
                break;

            case "dict_code_note":
                var dict8 = new DictBLL().GetByCode(value);
                value1 = dict8 == null ? "" : dict8.Note;
                break;

            case "dict_code_other":
                var dict9 = new DictBLL().GetByCode(value);
                value1 = dict9 == null ? "" : dict9.Other;
                break;

            case "organize_id_name":
                value1 = new DeptBLL().GetNames(value);
                break;

            case "files_link":
                string[]      files = value.Split('|');
                StringBuilder links = new StringBuilder();
                //links.Append("<div>");
                foreach (string file in files)
                {
                    links.AppendFormat("<a target=\"_blank\" class=\"blue\" href=\"{0}\">{1}</a><br/>", file, System.IO.Path.GetFileName(file));
                }
                //links.Append("</div>");
                value1 = links.ToString();
                break;

            case "files_img":
                string[]      files1 = value.Split('|');
                StringBuilder links1 = new StringBuilder();
                //links.Append("<div>");
                foreach (string file in files1)
                {
                    links1.AppendFormat("<img src=\"{0}\" />", file);
                }
                //links.Append("</div>");
                value1 = links1.ToString();
                break;

            case "datetime_format":
                value1 = value.ToDateTime().ToString(format ?? Utility.Config.DateFormat);
                break;

            case "number_format":
                value1 = value.ToDecimal().ToString(format);
                break;

            case "table_fieldvalue":
                DBConnectionBLL dbconn = new DBConnectionBLL();
                DataTable       dt     = dbconn.GetDataTable(dbconn.FindByID(dbconnID.ToGuid()), sql + "'" + value + "'");
                value1 = dt.Rows.Count > 0 && dt.Columns.Count > 0 ? dt.Rows[0][0].ToString() : "";
                break;
            }
            return(value1);
        }
コード例 #14
0
        public void ProcessRequest(HttpContext context)
        {
            try
            {
                LoginUser loginUser = new LoginUser(context, "Dept");
                if (!loginUser.Pass)//权限验证
                {
                    return;
                }

                //加载DataGrid
                if (context.Request["action"] == "gridLoad")
                {
                    DeptBLL bll  = new DeptBLL(context, loginUser);
                    int     page = int.Parse(context.Request["page"]);
                    int     rows = int.Parse(context.Request["rows"]);
                    bll.LoadGrid(page, rows);
                    return;
                }

                //加载信息
                if (context.Request["action"] == "load")
                {
                    DeptBLL bll    = new DeptBLL(context, loginUser);
                    string  deptId = context.Request["deptId"];//部门编号
                    bll.Load(deptId);
                    return;
                }

                //增加
                if (context.Request["action"] == "add")
                {
                    DeptBLL bll    = new DeptBLL(context, loginUser);
                    TSDept  tsDept = new TSDept();
                    //tsDept.deptId= context.Request["deptId"];//部门编号
                    tsDept.status    = context.Request["status"];    //使用状态
                    tsDept.deptName  = context.Request["deptName"];  //部门名称
                    tsDept.telephone = context.Request["telephone"]; //联系电话
                    bll.Add(tsDept);
                    return;
                }

                //修改
                if (context.Request["action"] == "edit")
                {
                    DeptBLL bll    = new DeptBLL(context, loginUser);
                    TSDept  tsDept = new TSDept();
                    tsDept.deptId    = context.Request["deptId"];    //部门编号
                    tsDept.status    = context.Request["status"];    //使用状态
                    tsDept.deptName  = context.Request["deptName"];  //部门名称
                    tsDept.telephone = context.Request["telephone"]; //联系电话
                    bll.Edit(tsDept);
                    return;
                }

                //删除
                if (context.Request["action"] == "delete")
                {
                    DeptBLL bll    = new DeptBLL(context, loginUser);
                    string  deptId = context.Request["deptId"];//部门编号
                    bll.Delete(deptId);
                    return;
                }
            }
            catch (Exception e)
            {
                Message.error(context, e.Message);
            }
        }
コード例 #15
0
        public SelectGroupUser(MainWindow m)
        {
            InitializeComponent();
            double workHeight = SystemParameters.WorkArea.Height;
            double workWidth  = SystemParameters.WorkArea.Width;

            this.Top     = (workHeight - this.Height) / 2;
            this.Left    = (workWidth - this.Width) / 2;
            this.user    = m.user;
            selfusername = m.user.Username;
            DeptBLL deptbll = new DeptBLL();

            DepartmentsList = deptbll.GetDepartmentsList();
            UserBLL userbll = new UserBLL();

            UserList = userbll.GetUsersList();
            foreach (Department d in DepartmentsList)
            {
                TreeViewItem item = new TreeViewItem();
                item.Header = d.Name;
                foreach (User u in UserList)
                {
                    if (u.Deptid != d.Id || u.Id == m.user.Id)
                    {
                        continue;
                    }
                    CheckBox   check  = new CheckBox();
                    StackPanel stack1 = new StackPanel();
                    Image      image  = new Image();
                    StackPanel stack2 = new StackPanel();
                    Label      label1 = new Label();
                    Label      label2 = new Label();
                    label1.Content    = u.Name;
                    label2.Content    = u.State == 1 ? "在线" : "离线";
                    label1.FontSize   = 20;
                    label2.FontSize   = 20;
                    label1.Foreground = Brushes.Black;
                    label2.Foreground = Brushes.Black;
                    stack2.Children.Add(label1);
                    stack2.Children.Add(label2);
                    stack2.VerticalAlignment = VerticalAlignment.Center;
                    MemoryStream ms     = new MemoryStream(u.Avatar);
                    BitmapImage  bitmap = new BitmapImage();
                    bitmap.BeginInit();
                    bitmap.StreamSource = ms;
                    bitmap.CacheOption  = BitmapCacheOption.OnLoad;
                    bitmap.EndInit();
                    ms.Dispose();
                    image.Source    = bitmap;
                    image.MaxHeight = 80;
                    image.MaxWidth  = 80;
                    stack1.Children.Add(image);
                    stack1.Children.Add(stack2);
                    stack1.Orientation = Orientation.Horizontal;
                    check.Content      = stack1;
                    check.Name         = u.Username;
                    check.MinWidth     = 60;
                    check.Margin       = new Thickness(5);
                    item.Items.Add(check);
                }
                departmentTree.Items.Add(item);
            }
        }
コード例 #16
0
        public string TreeRefresh()
        {
            string id       = Request.QueryString["refreshid"];
            string showtype = Request.QueryString["showtype"];

            System.Text.StringBuilder json = new System.Text.StringBuilder("[", 1000);

            string orgID;

            if (string.IsNullOrEmpty(id))
            {
                json.Append("]");
                Response.Write(json.ToString());
            }
            else
            {
                orgID = id;
            }

            DeptBLL deptBll = BLLFactory <DeptBLL> .Instance;

            var childOrgs = deptBll.GetChilds(id);

            int count = childOrgs.Count;
            int i     = 0;

            foreach (var org in childOrgs)
            {
                json.Append("{");
                json.AppendFormat("\"id\":\"{0}\",", org.ID);
                json.AppendFormat("\"parentID\":\"{0}\",", id);
                json.AppendFormat("\"title\":\"{0}\",", org.Name);
                json.AppendFormat("\"ico\":\"{0}\",", "");
                json.AppendFormat("\"link\":\"{0}\",", "");
                json.AppendFormat("\"type\":\"{0}\",", 2);
                json.AppendFormat("\"hasChilds\":\"{0}\",", 1);
                json.Append("\"childs\":[");
                json.Append("]");
                json.Append("}");
                if (i++ < count - 1)
                {
                    json.Append(",");
                }
            }

            UserBLL busers = BLLFactory <UserBLL> .Instance;
            var     users  = busers.Find("DeptID='" + id + "'");//.GetUsersByDept(id);
            int     count1 = users.Count;

            if (count1 > 0 && count > 0)
            {
                json.Append(",");
            }
            int j = 0;

            foreach (var user in users)
            {
                json.Append("{");
                json.AppendFormat("\"id\":\"{0}\",", user.ID);
                json.AppendFormat("\"parentID\":\"{0}\",", id);
                json.AppendFormat("\"title\":\"{0}\",", user.FullName);//, ur != null && ur.IsMain == 0 ? "<span style='color:#999;'>[兼职]</span>" : "");
                json.AppendFormat("\"ico\":\"{0}\",", Url.Content("~/Assets/WorkFlow/images/ico/contact_grey.png"));
                json.AppendFormat("\"link\":\"{0}\",", "");
                json.AppendFormat("\"type\":\"{0}\",", "4");
                json.AppendFormat("\"hasChilds\":\"{0}\",", "0");
                json.Append("\"childs\":[");
                json.Append("]");
                json.Append("}");
                if (j++ < count1 - 1)
                {
                    json.Append(",");
                }
            }
            json.Append("]");
            return(json.ToString());
        }
コード例 #17
0
        public string Tree1()
        {
            string  rootid   = Request.QueryString["rootid"];
            string  showtype = Request.QueryString["showtype"];
            DeptBLL deptBll  = BLLFactory <DeptBLL> .Instance;

            System.Text.StringBuilder json = new System.Text.StringBuilder("[", 1000);

            string rootID;
            Dept   root;

            if (!string.IsNullOrEmpty(rootid))
            {
                root = deptBll.FindByID(rootid);
            }
            else
            {
                root = deptBll.GetTopGroup();
            }

            List <User> users = new List <User>();

            UserBLL busers = BLLFactory <UserBLL> .Instance;

            users = busers.Find("DeptID='" + root.ID + "'"); //busers.GetUsersByDept(root.ID);

            json.Append("{");
            json.AppendFormat("\"id\":\"{0}\",", root.ID);
            json.AppendFormat("\"parentID\":\"{0}\",", root.PID);
            json.AppendFormat("\"title\":\"{0}\",", root.Name);
            json.AppendFormat("\"ico\":\"{0}\",", Url.Content("~/Assets/WorkFlow/images/ico/icon_site.gif"));
            json.AppendFormat("\"link\":\"{0}\",", "");
            json.AppendFormat("\"type\":\"{0}\",", 2);
            json.AppendFormat("\"hasChilds\":\"{0}\",", 1);
            json.Append("\"childs\":[");

            var orgs  = deptBll.GetChilds(root.ID);
            int count = orgs.Count;

            int i = 0;

            foreach (var org in orgs)
            {
                json.Append("{");
                json.AppendFormat("\"id\":\"{0}\",", org.ID);
                json.AppendFormat("\"parentID\":\"{0}\",", org.PID);
                json.AppendFormat("\"title\":\"{0}\",", org.Name);
                json.AppendFormat("\"ico\":\"{0}\",", "");
                json.AppendFormat("\"link\":\"{0}\",", "");
                json.AppendFormat("\"type\":\"{0}\",", 2);
                json.AppendFormat("\"hasChilds\":\"{0}\",", 1);
                json.Append("\"childs\":[");
                json.Append("]");
                json.Append("}");
                if (i++ < count - 1 || users.Count > 0)
                {
                    json.Append(",");
                }
            }

            if (users.Count > 0)
            {
                //var userRelations = new RoadFlow.Platform.UsersRelation().GetAllByOrganizeID(root.ID);
                //var userList
                int count1 = users.Count;
                int j      = 0;
                foreach (var user in users)
                {
                    //var ur = userRelations.Find(p => p.UserID == user.ID);
                    json.Append("{");
                    json.AppendFormat("\"id\":\"{0}\",", user.ID);
                    json.AppendFormat("\"parentID\":\"{0}\",", root.ID);
                    json.AppendFormat("\"title\":\"{0}\",", user.FullName);//, ur != null && ur.IsMain == 0 ? "<span style='color:#999;'>[兼职]</span>" : "");
                    json.AppendFormat("\"ico\":\"{0}\",", "");
                    json.AppendFormat("\"link\":\"{0}\",", "");
                    json.AppendFormat("\"type\":\"{0}\",", "4");
                    json.AppendFormat("\"hasChilds\":\"{0}\",", "0");
                    json.Append("\"childs\":[");
                    json.Append("]");
                    json.Append("}");
                    if (j++ < count1 - 1)
                    {
                        json.Append(",");
                    }
                }
            }


            json.Append("]");
            json.Append("}");
            json.Append("]");

            return(json.ToString());
        }
コード例 #18
0
        public ActionResult EditRole(FormCollection collection)
        {
            RoleBLL brole  = new RoleBLL();
            Role    role   = null;
            string  roleID = Request.QueryString["roleid"];
            string  roleGID;
            string  name      = string.Empty;
            string  useMember = string.Empty;
            string  note      = string.Empty;

            if (roleID.IsGuid(out roleGID))
            {
                role = brole.FindByID(roleGID);
            }

            if (!Request.Form["Copy"].IsNullOrEmpty())
            {
                string tpl = Request.Form["ToTpl"];
                if (tpl.IsGuid())
                {
                    new RoleAppBLL().CopyRoleApp(roleGID, tpl.ToGuid());
                    //RoadFlow.Platform.Log.Add("复制了模板应用", "源:" + roleID + "复制给:" + tpl, RoadFlow.Platform.Log.Types.角色应用);
                    ViewBag.Script = "alert('复制成功!');";
                }
            }

            if (!Request.Form["Save"].IsNullOrEmpty() && role != null)
            {
                User_Role busersRole = new User_Role();
                using (System.Transactions.TransactionScope scope = new System.Transactions.TransactionScope())
                {
                    name      = Request.Form["Name"];
                    useMember = Request.Form["UseMember"];
                    note      = Request.Form["Note"];

                    role.Name   = name.Trim();
                    role.Note   = note.IsNullOrEmpty() ? null : note.Trim();
                    role.UserID = useMember.IsNullOrEmpty() ? null : useMember;
                    brole.Update(role);
                    busersRole.DeleteByRoleID(role.ID);
                    if (!useMember.IsNullOrEmpty())
                    {
                        busersRole.DeleteByRoleID(role.ID);
                        var users = new DeptBLL().GetAllUsers(useMember);
                        foreach (var user in users)
                        {
                            RoadFlow.Data.Model.UsersRole ur = new RoadFlow.Data.Model.UsersRole();
                            ur.IsDefault = true;
                            ur.MemberID  = user.ID;
                            ur.RoleID    = role.ID;
                            busersRole.Insert(ur);
                        }
                    }
                    scope.Complete();
                }
                ViewBag.Script = "alert('保存成功!');new RoadUI.Window().reloadOpener();new RoadUI.Window().close();";
            }

            if (!Request.Form["Delete"].IsNullOrEmpty())
            {
                using (System.Transactions.TransactionScope scope = new System.Transactions.TransactionScope())
                {
                    brole.Delete(roleGID);
                    new RoleAppBLL().DeleteByRoleID(roleGID);
                    new UsersRoleBLL().DeleteByRoleID(roleGID);
                    scope.Complete();
                }
                //RoadFlow.Platform.Log.Add("删除的角色其及相关数据", roleID, RoadFlow.Platform.Log.Types.角色应用);
                ViewBag.Script = "new RoadUI.Window().reloadOpener();new RoadUI.Window().close();";
            }
            ViewBag.RoleOptions = brole.GetRoleOptions("", roleID);
            return(View(role));
        }