Пример #1
0
        async private void SelectAllUser()
        {
            this.dataSource.Clear();

            var dt = (await serviceClient.GetAllUserInfoAsync()).Tables[0];

            if (dt.Rows.Count < 1)
            {
                return;
            }
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                var username   = dt.Rows[i][0].ToString();
                var userrole   = dt.Rows[i][1].ToString();
                var updateDate = dt.Rows[i][3].ToString();
                if (userrole == ((int)UserTypeEnum.superAdmin).ToString())
                {
                    userrole = "超级管理员";
                }
                else if (userrole == ((int)UserTypeEnum.admin).ToString())
                {
                    userrole = "管理员";
                }
                else if (userrole == ((int)UserTypeEnum.controler).ToString())
                {
                    userrole = "操作员";
                }
                else if (userrole == ((int)UserTypeEnum.teamLeader).ToString())
                {
                    userrole = "班组长";
                }
                else if (userrole == ((int)UserTypeEnum.worker).ToString())
                {
                    userrole = "工人";
                }
                DataRow dr = dataSource.NewRow();
                dr[USER_ID]     = i + 1;
                dr[USER_NAME]   = username;
                dr[USER_ROLE]   = userrole;
                dr[UPDATE_DATE] = updateDate;
                this.dataSource.Rows.Add(dr);
            }

            this.radGridView1.DataSource = this.dataSource;
        }
Пример #2
0
        async private void Init()
        {
            this.tbx_pwd.PasswordChar = '*';
            mesService = new MesService.MesServiceClient();
            if (!TestCommunication())
            {
                return;
            }
            //设置单行
            //tbx_username.Multiline = false;
            tbx_pwd.Multiline = false;
            DataSet ds = await mesService.GetAllUserInfoAsync();

            if (ds == null)
            {
                MessageBox.Show("连接数据库服务异常!", "ERR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            var dt = ds.Tables[0];

            if (dt.Rows.Count > 0)
            {
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    //tbx_username.Items.Add(dt.Rows[i][0].ToString());
                }
            }
            else
            {
                //添加默认用户
                mesService.Register("superAdminMES", "superAdminMES", 0);
            }
            tbx_username.Text = "";
            configPath        = AppDomain.CurrentDomain.BaseDirectory + INI_CONFIG_NAME;
            ReadLastCfg();
        }