Beispiel #1
0
        public ActionResult LoginInfo(UsersInput input)
        {
            var result = _userService.GetUserByName(input);

            if (result != null)
            {
                var model = new UsersOutput()
                {
                    UserName = result.UserName,
                    PassWord = result.PassWord,
                    Id       = result.Id,
                    State    = result.State
                };
                Session["QQLOGIN"] = result;
            }
            return(Json(result));
        }
Beispiel #2
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            Users users = new Users();

            users.username = txtUsername.Text.Trim();
            users.password = txtPassword.Text.Trim();

            UsersOutput usersOutput = new UsersOutput();

            usersOutput.responsecode = ResponseCodes.Fail;

            UsersManager usersManager = new UsersManager();

            usersManager.Login(users, ref usersOutput);

            lblmessage.Text = usersOutput.message;
        }
Beispiel #3
0
        public void Login(Users users, ref UsersOutput usersOutput)
        {
            try
            {
                using (OleDbConnection conn = new OleDbConnection {
                    ConnectionString = fileName.BuildConnectionString()
                })
                {
                    using (OleDbCommand cmd = new OleDbCommand {
                        Connection = conn
                    })
                    {
                        cmd.CommandText = "SELECT * FROM tblUsers WHERE username = @username AND password = @password";
                        cmd.Parameters.AddWithValue("@username", users.username);
                        cmd.Parameters.AddWithValue("@password", users.password);

                        DataTable dataTable = new DataTable();
                        conn.Open();
                        dataTable.Load(cmd.ExecuteReader());

                        if (dataTable.Rows.Count > 0)
                        {
                            DataRow row = dataTable.Rows[0];
                            usersOutput.status       = row["status"].ToString().Trim();
                            usersOutput.message      = "Success";
                            usersOutput.responsecode = ResponseCodes.Success;
                        }
                        else
                        {
                            usersOutput.message = "Invalid Username/Password";
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                usersOutput.message      = ex.Message;
                usersOutput.responsecode = ResponseCodes.Fail;
            }
        }
        public DataTransferObject GetUsers(string pageIndex = "1", string pageSize = "20")
        {
            try
            {
                if (!Int32.TryParse(pageIndex, out int nPageIndex) || nPageIndex <= 0)
                {
                    return(new DataTransferObject {
                        Status = 0, Message = "pageIndex必须为数字且大于0"
                    });
                }

                if (!Int32.TryParse(pageSize, out int nPageSize) || nPageSize <= 0)
                {
                    return(new DataTransferObject {
                        Status = 0, Message = "pageSize必须为数字且大于0"
                    });
                }

                var tupleResult = _userService.GetUsers(nPageIndex, nPageSize);
                var result      = new UsersOutput
                {
                    PageIndex = nPageIndex,
                    PageSize  = nPageSize,
                    Count     = tupleResult.Item1,
                    Users     = tupleResult.Item2
                };
                return(new DataTransferObject {
                    Status = 1, Result = result
                });
            }
            catch (Exception ex)
            {
                return(new DataTransferObject {
                    Status = 0, Message = ex.Message + "\r\n" + ex.StackTrace
                });
            }
        }