Ejemplo n.º 1
0
        /// <summary>
        /// 初始化人员
        /// </summary>
        private void InitCreateUser()
        {
            //获取所有用户
            BLL.ManagerBll         mBll  = new BLL.ManagerBll();
            List <Model.UserModel> users = mBll.GetModelList(1000, " isLock = 0 ", " RoleType desc ");

            if (users != null && users.Count > 0)
            {
                bool isHaveUser = false;
                foreach (var item in users)
                {
                    string showText = string.Format("{0}({1})", item.UserName, item.RealName);
                    this.skinComboBox_createUser.Items.Add(new ListItem(showText, item));
                    if (this.file != null && !string.IsNullOrEmpty(this.file.UserName) && item.UserName == this.file.UserName)
                    {
                        this.skinComboBox_createUser.SelectedItem = new ListItem(showText, item);
                        isHaveUser = true;
                    }
                }
                if (!isHaveUser)
                {
                    this.skinComboBox_createUser.SelectedIndex = 0;
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 初始化界面展示
        /// </summary>
        private void InitUiData()
        {
            if (userId <= 0)
            {
                this.skinTextBox_addTime.SkinTxt.Text = DateTime.Now.ToString();
                return;
            }
            if (userId > 0)
            {
                BLL.ManagerBll  managerBll = new BLL.ManagerBll();
                Model.UserModel userModel  = managerBll.GetModel(userId);
                if (userModel == null)
                {
                    this.skinTextBox_addTime.SkinTxt.Text = DateTime.Now.ToString();
                    return;
                }

                if (userModel != null)
                {
                    this.skinTextBox_userName.SkinTxt.Text = userModel.UserName;
                    this.skinTextBox_realName.SkinTxt.Text = userModel.RealName;
                    this.skinTextBox_addTime.SkinTxt.Text  = userModel.AddTime.ToString();
                    this.skinRadioButton_lock.Checked      = userModel.IsLock == 1;
                    this.skinRadioButton_unLock.Checked    = userModel.IsLock == 0;
                    this.skinComboBox_role.SelectedIndex   = userModel.RoleType;

                    //工程初始化
                    if (userModel.Projects != null && userModel.Projects.Count > 0)
                    {
                        foreach (var item in userModel.Projects)
                        {
                            int             index   = this.skinDataGridView_projects.Rows.Add(1);
                            DataGridViewRow gridRow = this.skinDataGridView_projects.Rows[index];
                            gridRow.Cells[0].Value = item.ID;
                            gridRow.Cells[1].Value = item.ProjectName;
                            gridRow.Cells[2].Value = item.MonitoringSoftwareName;
                            gridRow.Cells[3].Value = item.MonitoringPath;
                            //gridRow.Cells[4].Value = item.UserName;
                            //gridRow.Cells[5].Value = item.IsLock;
                            //gridRow.Cells[6].Value = item.ClientIp;
                            //gridRow.Cells[7].Value = item.AddTime;
                            gridRow.Tag = item;
                        }

                        #region 暂时删除
                        //DataTable dt = new DataTable();
                        //dt.Columns.Add("ID");
                        //dt.Columns.Add("ProjectName");
                        //dt.Columns.Add("MonitoringSoftwareName");
                        //dt.Columns.Add("MonitoringPath");
                        //dt.Columns.Add("UserName");
                        //dt.Columns.Add("IsLock");
                        //dt.Columns.Add("ClientIp");
                        //dt.Columns.Add("AddTime");

                        //foreach (var item in userModel.Projects)
                        //{
                        //    DataRow row = dt.NewRow();
                        //    row[0] = item.ID;
                        //    row[1] = item.ProjectName;
                        //    row[2] = item.MonitoringSoftwareName;
                        //    row[3] = item.MonitoringPath;
                        //    row[4] = item.UserName;
                        //    row[5] = item.IsLock;
                        //    row[6] = item.ClientIp;
                        //    row[7] = item.AddTime;
                        //    dt.Rows.Add(row);

                        //    int index = this.skinDataGridView_projects.Rows.Add(1);
                        //    DataGridViewRow gridRow = this.skinDataGridView_projects.Rows[index];
                        //    gridRow.Cells[0].Value = item.ID;
                        //    gridRow.Cells[1].Value = item.ProjectName;
                        //    gridRow.Cells[2].Value = item.MonitoringSoftwareName;
                        //    gridRow.Cells[3].Value = item.MonitoringPath;
                        //    gridRow.Cells[4].Value = item.UserName;
                        //    gridRow.Cells[5].Value = item.IsLock;
                        //    gridRow.Cells[6].Value = item.ClientIp;
                        //    gridRow.Cells[7].Value = item.AddTime;
                        //    gridRow.Tag = item;
                        //}
                        //this.skinDataGridView_projects.DataSource = dt;
                        //this.skinDataGridView_projects.DataSource = userModel.Projects;

                        #endregion
                    }
                }
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 确定
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btn_ok_Click(object sender, EventArgs e)
        {
            Model.UserModel user       = new Model.UserModel();
            BLL.ManagerBll  managerBll = new BLL.ManagerBll();

            try
            {
                #region 信息校验

                //校验
                int    isLock     = this.skinRadioButton_lock.Checked ? 1 : 0;;
                string userName   = this.skinTextBox_userName.SkinTxt.Text;
                string realName   = this.skinTextBox_realName.SkinTxt.Text;
                int    roleType   = this.skinComboBox_role.SelectedIndex;
                string addTimeStr = this.skinTextBox_addTime.SkinTxt.Text.Trim();

                DateTime addTime = DateTime.Now;
                if (string.IsNullOrEmpty(userName))
                {
                    MessageBoxEx.Show("账号不能为空!");
                    return;
                }

                if (string.IsNullOrEmpty(realName))
                {
                    MessageBoxEx.Show("姓名不能为空!");
                    return;
                }

                if (roleType != 0 && roleType != 1)
                {
                    MessageBoxEx.Show("请联系管理员,用户角色有异常!");
                    return;
                }

                if (string.IsNullOrEmpty(addTimeStr) || !DateTime.TryParse(addTimeStr, out addTime))
                {
                    MessageBoxEx.Show("添加时间不正确!");
                    return;
                }

                //新增用户校验用户是否存在
                if (userId <= 0)
                {
                    bool isExidted = managerBll.Exists(userName);
                    if (isExidted)
                    {
                        MessageBoxEx.Show(string.Format("账号: {0}已经存在!", userName));
                        return;
                    }
                    //开始修改值
                }

                //修改用户
                if (userId > 0)
                {
                    user = managerBll.GetModel(userId);
                    //开始修改值
                }

                #endregion

                #region  构建信息
                user.IsLock   = isLock;
                user.UserName = userName;
                user.RealName = realName;
                user.RoleType = roleType;
                user.RoleName = this.skinComboBox_role.SelectedItem.ToString();;
                user.AddTime  = addTime;

                //工程信息构建
                user.Projects = new List <Model.UserProjectModel>();
                foreach (DataGridViewRow item in this.skinDataGridView_projects.Rows)
                {
                    Model.UserProjectModel projectModel = (Model.UserProjectModel)item.Tag;
                    if (projectModel == null)
                    {
                        continue;
                    }
                    user.Projects.Add(projectModel);
                }

                #endregion

                #region 添加域账号判断
                // 域账号验证
                if (!AuthDomin(realName, userName))
                {
                    return;
                }
                #endregion

                //修改用户
                if (userId > 0)
                {
                    if (managerBll.Update(user))
                    {
                        this.DialogResult = System.Windows.Forms.DialogResult.OK;
                    }
                    else
                    {
                        MessageBoxEx.Show("更新用户信息异常!");
                    }
                }
                else
                {
                    if (managerBll.Add(user) > 0)
                    {
                        this.DialogResult = System.Windows.Forms.DialogResult.OK;
                    }
                    else
                    {
                        MessageBoxEx.Show("新增用户信息异常!");
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBoxEx.Show("更新用户信息异常!" + ex.Message);
            }
        }
Ejemplo n.º 4
0
 private void btn_ok_Click(object sender, EventArgs e)
 {
     isLock = this.skinRadioButton_lock.Checked ? 1 : 0;
     BLL.ManagerBll managerBll = new BLL.ManagerBll();
     managerBll.UpdateField(userId, " IsLock = " + isLock);
 }