Exemple #1
0
        /// <summary>
        /// 通过账号得到用户的姓名和昵称
        /// </summary>
        /// <param name="account">账号</param>
        /// <returns></returns>
        public IQueryable <user> FindNickName(string account)
        {
            userDal modifyDal  = new userDal();
            var     modifyInfo = modifyDal.FindNickName(account);

            return(modifyInfo);
        }
Exemple #2
0
        /// <summary>
        /// 检查用户是否注册成功
        /// </summary>
        /// <param name="account">账号</param>
        /// <param name="pwd">密码</param>
        /// <returns></returns>
        public IQueryable <user> CheckUserRegisterStatus(string account, string pwd)
        {
            userDal registerStatus = new userDal();
            var     status         = registerStatus.CheckUserRegisterStatus(account, pwd);

            return(status);
        }
Exemple #3
0
        /// <summary>
        /// 检查用户注册的账号是否已经存在
        /// </summary>
        /// <param name="account">账号</param>
        /// <returns></returns>
        public IQueryable <user> CheckAccount(string account)
        {
            DAL.userDal uAccount    = new userDal();
            var         userAccount = uAccount.CheckAccount(account);

            return(userAccount);
        }
        public void bindUser()
        {
            userDal studenDal = new userDal();

            user = studenDal.getUser();
            grdUser.DataSource = user;
        }
        private void btnSaveAndNew_Click(object sender, EventArgs e)
        {
            if (txtUserId.Text == "" || txtUserName.Text == "" || TxtPassword.Text == "" || ddlRoleId.SelectedIndex == 0)
            {
                MessageBox.Show("Please Fill all the fields", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtUserId.Focus();
                return;
            }
            if (!Regex.Match(txtUserId.Text, "^[0-9]*$").Success)
            {
                MessageBox.Show("Invalid userid!! Please enter correct id", "Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtUserId.Focus();
                return;
            }

            if (!Regex.Match(txtUserName.Text, "^[a-zA-Z][A-Za-z s]+$").Success)
            {
                MessageBox.Show("Invalid name!! Please enter alphabets only", "Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtUserName.Focus();
                return;
            }

            userDal           userDal = new userDal();
            List <userEntity> user    = userDal.getUser();

            if (user.Where(c => c.Userid == txtUserId.Text).Count() > 0)
            {
                MessageBox.Show("Duplicate UserId\n please enter unique userid", "Caution", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtUserId.Focus();
                return;
            }
            else
            {
                try
                {
                    con.Open();
                    SqlCommand cmd = new SqlCommand("usp_user_insert_update", con);
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.AddWithValue("@uid", ToInt32(lblid.Text));
                    cmd.Parameters.AddWithValue("@userid", txtUserId.Text);
                    cmd.Parameters.AddWithValue("@name", txtUserName.Text);
                    cmd.Parameters.AddWithValue("@password", TxtPassword.Text);
                    cmd.Parameters.AddWithValue("@roleid", ddlRoleId.SelectedValue);
                    cmd.ExecuteNonQuery();
                    // con.Close();
                    MessageBox.Show("details saved!!");
                    clear();
                    bindUser();
                }
                catch (Exception ex)
                { MessageBox.Show(ex.Message); }
                finally
                {
                    con.Close();
                }
            }
        }
        public static IuserDal GetuserDal()
        {
            IuserDal Data = CallContext.GetData("userDal") as IuserDal;

            if (Data == null)
            {
                Data = new userDal();
                CallContext.SetData("userDal", Data);
            }
            return(Data);
        }