Example #1
0
        private void btnAddUser_Click(object sender, EventArgs e)
        {
            if (VerifyUser())
            {
                UserInfo userInfo = new UserInfo
                {
                    UserSn = txtUserSn.Text.Trim(),
                    UserSim = txtUserSIM.Text.Trim(),
                    UserTime = DateTime.Now,
                    UserName = txtUserRealname.Text.Trim(),
                    UserPass = txtUserPass.Text.Trim(),
                    UserRole = AttributeExtend.GetEnumValue<UserRole>(cmbUserRole.SelectedItem.ToSafeString()),
                    UserType = AttributeExtend.GetEnumValue<UserType>(cmbUserType.SelectedItem.ToSafeString()),
                    Remark = txtRemark.Text.Trim()
                };

                try
                {

                    if (GSetting.DataServBusi.SaveUser(userInfo))
                    {
                        GSetting.WashObj.ShowStatusTips(this.txtUserSn.Text + "保存成功!", Color.Empty);
                        UserManager_Load(null, null);
                    }
                    else
                    {
                        GSetting.WashObj.ShowStatusTips(this.txtUserSn.Text + "保存失败!", Color.Empty);
                    }
                }
                catch (Exception)
                {
                    MessageBox.Show("保存失败");
                }
            }
        }
Example #2
0
        /// <summary>
        /// 删除用户信息
        /// </summary>
        /// <param name="userInfo">用户对象</param>
        /// <returns>
        /// 删除结果
        /// </returns>
        public bool Delete(UserInfo userInfo)
        {
            bool result = false;

            try
            {
                if (GSetting.DataServ.DeleteUser(userInfo.UserSn))
                {
                    result = true;
                }
            }
            catch (Exception ex)
            {
                Global.Log(ex);
            }

            return result;
        }
Example #3
0
 /// <summary>
 /// 修改用户
 /// </summary>
 /// <param name="userInfo">用户对象</param>
 /// <returns>
 /// 修改结果
 /// </returns>
 public bool ModifyUser(UserInfo userInfo)
 {
     return Global.DBProcess.ModifyUser(Global.UserInfo, userInfo);
 }
Example #4
0
        /// <summary>
        /// 插入用户
        /// </summary>
        /// <param name="tableName">表名</param>
        /// <param name="user">用户</param>
        /// <returns>是否成功</returns>
        public bool ModifyUser(string tableName, UserInfo user)
        {
            var selectsql = string.Format("select * from userInfo where userSn='{0}'", user.UserSn);
            object temp = SqlHelper.ExecuteScalar(Global.ConnStr, CommandType.Text, selectsql);
            SqlParameter[] paras =
            {
                    this.GetSqlParameter("@userSn",user.UserSn,DbType.String),
                    this.GetSqlParameter("@userSIM",user.UserSim,DbType.String),
                    this.GetSqlParameter("@userPass",user.UserPass,DbType.String),
                    this.GetSqlParameter("@userName",user.UserName,DbType.String),
                    this.GetSqlParameter("@userRole",user.UserRole,DbType.Int32),
                    this.GetSqlParameter("@userTime",DateTime.Now,DbType.DateTime),
                    this.GetSqlParameter("@userType",((int)user.UserType) == 1 ? 9 : 1,DbType.Int32),
                    this.GetSqlParameter("@remark",user.Remark,DbType.String)
            };

            try
            {
                if (temp == null)
                {
                    var insertsql = @"insert into userInfo (userSn,userSim,userPass,userName,userTime,userRole,userType,remark)
                                values (@userSn,@userSim,@userPass,@userName,@userTime,@userRole,@userType,@remark)";
                    int result = SqlHelper.ExecuteNonQuery(Global.ConnStr, CommandType.Text, insertsql, paras);

                    if (result > 0)
                    {
                        return true;
                    }
                }
                else
                {
                    var updateSql = string.Format(@"update userInfo set userSn=@userSn,userSim=@userSim , userPass=@userPass,userName=@userName,
                                    userTime=@userTime,userRole=@userRole,userType=@userType,remark=@remark where userSn='{0}'",
                                                                                                                                   user.UserSn);
                    int result = SqlHelper.ExecuteNonQuery(Global.ConnStr, CommandType.Text, updateSql, paras);

                    if (result > 0)
                    {
                        return true;
                    }
                }
            }
            catch (Exception ex)
            {
                Global.Log("更新用户数据失败", ex);
                throw new Exception("更新用户数据失败");
            }

            return false;
        }
Example #5
0
        /// <summary>
        /// 加载用户信息
        /// </summary>
        /// <returns>用户信息</returns>
        public List<UserInfo> LoadUsers()
        {
            var seletsql = "select * from userInfo";
            List<UserInfo> userinfos = null;

            using (SqlDataReader reader = SqlHelper.ExecuteReader(Global.ConnStr, CommandType.Text, seletsql))
            {
                if (!reader.HasRows)
                {
                    return userinfos;
                }

                userinfos = new List<UserInfo>();

                while (reader.Read())
                {
                    try
                    {
                        var userInfo = new UserInfo
                        {
                            UserSn = reader.SafeRead<string>("userSn"),
                            Id = reader.SafeRead<int>("id"),
                            UserName = reader.SafeRead<string>("userName"),
                            UserPass = reader.SafeRead<string>("userPass"),
                            UserSim = reader.SafeRead<string>("userSim"),
                            UserRole = reader.SafeRead<ClassLibrary.UserRole>("userRole"),
                            UserTime = reader.SafeRead<DateTime>("userTime"),
                            UserType = reader.SafeRead<ClassLibrary.UserType>("userType"),
                            Remark = reader.SafeRead<string>("remark")
                        };

                        userinfos.Add(userInfo);
                    }
                    catch (Exception ex)
                    {
                        Global.Log("加载用户信息失败", ex);
                    }
                }
            }

            return userinfos;
        }
Example #6
0
        /// <summary>
        /// 根据SIM获取用户
        /// </summary>
        /// <param name="userSim">The user sim.</param>
        /// <param name="table">The table.</param>
        /// <returns>
        /// 用户信息
        /// </returns>
        public UserInfo GetUserInfo(string userSim, string table)
        {
            UserInfo userinfo = null;
            var tempstr = "select * from userInfo where userSim=@userSim";
            SqlParameter[] paras =
            {
                this.GetSqlParameter("@userSim",userSim,DbType.String)
            };

            try
            {
                using (SqlDataReader reader = SqlHelper.ExecuteReader(Global.ConnStr, CommandType.Text, tempstr, paras))
                {
                    if (reader == null || !reader.HasRows)
                    {
                        return null;
                    }

                    while (reader.Read())
                    {
                        userinfo = new UserInfo
                        {
                            UserSn = reader.SafeRead<string>("userSn"),
                            UserName = reader.SafeRead<string>("userName")
                        };
                    }
                }
            }
            catch (Exception ex)
            {
                Global.Log("根据sim获取用户信息失败", ex);
                throw new Exception("根据sim获取用户信息失败");
            }

            return userinfo;
        }
Example #7
0
        /// <summary>
        /// 修改用户
        /// </summary>
        /// <param name="tableName">表名</param>
        /// <param name="userInfo">用户对象</param>
        /// <returns>
        /// 修改结果
        /// </returns>
        public bool ModifyUser(string tableName, UserInfo userInfo)
        {
            if (string.IsNullOrEmpty(tableName) || userInfo == null)
            {
                return false;
            }

            bool result = false;

            try
            {
                result = dataObject.ModifyUser(tableName, userInfo);
            }
            catch (Exception)
            {
                return false;
            }

            return result;
        }
Example #8
0
        /// <summary>
        /// 根据SIM卡号获取User或者Endoscope的信息
        /// </summary>
        /// <param name="sim">磁卡号</param>
        /// <returns>
        /// 用户/内镜信息
        /// </returns>
        public string[] GetUserEndoscopeMsg(string sim)
        {
            if (string.IsNullOrEmpty(sim))
            {
                return new string[0];
            }

            var tempStr = new string[3];
            var en = new EndoscopeInfo();

            try
            {
                en = dataObject.GetEndoscopeMsgBySIM(sim, Global.EndoscopeInfo);
            }
            catch (Exception)
            {
                return new string[0];
            }

            if (en != null)
            {
                tempStr[0] = "endoscope";
                tempStr[1] = en.EndoscopeSn;
            }
            else
            {
                var u = new UserInfo();

                try
                {
                    u = dataObject.GetUserInfo(sim, Global.UserInfo);
                }
                catch (Exception)
                {
                    return new string[0];
                }

                if (u.UserName.Length > 0)
                {
                    tempStr[0] = "user";
                    tempStr[1] = u.UserSn;
                    tempStr[2] = u.UserName;
                }
                else
                {
                    tempStr[0] = "no";
                }
            }

            return tempStr;
        }
Example #9
0
 public override object Use(UserInfo obj)
 {
     return(null);
 }