Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Registration Page Updated
  • Loading branch information
adl13006 committed Nov 24, 2015
1 parent c06d810 commit 146c030
Show file tree
Hide file tree
Showing 4 changed files with 190 additions and 87 deletions.
43 changes: 22 additions & 21 deletions TeamDBAwesome/TeamDBAwesome/SqlService/MySqlService.cs
Expand Up @@ -86,12 +86,12 @@ namespace TeamDBAwesome.SqlService
{
bool open = this.OpenConnection();

if(open == true)
if (open == true)
{

//do the update into person
string update = "INSERT into chinook.Person(LastName,FirstName,Address,City,State,PostalCode,Country,Phone,Fax,Email)" +
" VALUES (\""+newCust.LName+ "\",\"" + newCust.FName + "\",\"" + newCust.Address + "\",\"" + newCust.City + "\",\"" + newCust.State +
" VALUES (\"" + newCust.LName + "\",\"" + newCust.FName + "\",\"" + newCust.Address + "\",\"" + newCust.City + "\",\"" + newCust.State +
"\",\"" + newCust.Post + "\",\"" + newCust.Country + "\",\"" + newCust.Phone + "\",\"" + newCust.Fax + "\",\"" + newCust.Email + "\");";

MySqlCommand command = new MySqlCommand(update, SqlConn);
Expand All @@ -108,11 +108,11 @@ namespace TeamDBAwesome.SqlService
string nextCustIDstring = command.ExecuteScalar() + "";
int next_custID_int = int.Parse(nextCustIDstring);
next_custID_int = next_custID_int + 1;
nextCustIDstring = next_custID_int.ToString();
nextCustIDstring = next_custID_int.ToString();

//now we can put into Customer
if (newCust.Company=="" || newCust.Company == null)
{
if (newCust.Company == "" || newCust.Company == null)
{
update = "INSERT INTO chinook.Customer(CustomerID,Company,SupportRepID,PersonID) VALUES (" + nextCustIDstring + ",\"" + newCust.Company + "\",\"" + newCust.SupportRepId +
"\",\"" + newPersonID + "\")";
}
Expand All @@ -135,7 +135,7 @@ namespace TeamDBAwesome.SqlService
return 0;
}


}

/// <summary>
Expand Down Expand Up @@ -187,14 +187,14 @@ namespace TeamDBAwesome.SqlService
bool open = this.OpenConnection();
Customer customer = new Customer();

if(open == true)
if (open == true)
{
string customer_query = "select * from `person` left join `customer` on person.PersonId=customer.PersonID where Customer.CustomerID = "+PersonID.ToString();
string customer_query = "select * from `person` left join `customer` on person.PersonId=customer.PersonID where Customer.CustomerID = " + PersonID.ToString();
MySqlCommand cmd = new MySqlCommand(customer_query, SqlConn);

MySqlDataReader reader = cmd.ExecuteReader();

while(reader.Read())
while (reader.Read())
{
customer.FName = GetDBString("FirstName", reader);
customer.LName = GetDBString("LastName", reader);
Expand Down Expand Up @@ -232,7 +232,7 @@ namespace TeamDBAwesome.SqlService
bool open = this.OpenConnection();
SearchResult searchresult = new SearchResult();

if(open == true)
if (open == true)
{
//media / album / artist / track / composer / genre

Expand Down Expand Up @@ -264,19 +264,19 @@ namespace TeamDBAwesome.SqlService

//declare the cmd and the reader
//MySqlCommand cmd;


foreach (var key in queries)
{
MySqlCommand cmd = new MySqlCommand(key.Value, SqlConn);
MySqlDataReader reader;
reader = cmd.ExecuteReader();

while(reader.Read())
while (reader.Read())
{
if(search.GetType().GetProperty(key.Key).GetValue(search).ToString() != "")
if (search.GetType().GetProperty(key.Key).GetValue(search).ToString() != "")
{
if(key.Key == "Media")
if (key.Key == "Media")
{
searchresult.Media.Add(new Media
{
Expand All @@ -293,7 +293,7 @@ namespace TeamDBAwesome.SqlService
Title = GetDBString("Title", reader)
});
}
else if( key.Key == "Artist")
else if (key.Key == "Artist")
{
searchresult.Artist.Add(new Artist
{
Expand All @@ -314,7 +314,7 @@ namespace TeamDBAwesome.SqlService
AlbumTitle = GetDBString("albumtitle", reader),
MediaType = GetDBString("mediatype", reader),
Genre = GetDBString("genre", reader)
});
});
}
else if (key.Key == "Composer")
{
Expand All @@ -331,7 +331,7 @@ namespace TeamDBAwesome.SqlService
Genre = GetDBString("genre", reader)
});
}
else if(key.Key == "Genre")
else if (key.Key == "Genre")
{
searchresult.Genre.Add(new Genre
{
Expand Down Expand Up @@ -366,7 +366,7 @@ namespace TeamDBAwesome.SqlService
Track track = new Track();
bool open = this.OpenConnection();

if(open == true)
if (open == true)
{
string query = "select track.TrackId as trackid,track.Name as trackname,track.Composer as trackcomposer,track.Milliseconds,track.Bytes,track.UnitPrice,"
+ "Album.Title as albumtitle,MediaType.Name as mediatype,Genre.Name as genre "
Expand All @@ -388,7 +388,7 @@ namespace TeamDBAwesome.SqlService
track.AlbumTitle = GetDBString("albumtitle", reader);
track.MediaType = GetDBString("mediatype", reader);
track.Genre = GetDBString("genre", reader);

}
}
else
Expand Down Expand Up @@ -417,5 +417,6 @@ namespace TeamDBAwesome.SqlService
{
return 1;
}
}
}
} // ADL: I added this ending paren.
}
3 changes: 1 addition & 2 deletions TeamDBAwesome/TeamDBAwesome/index.html
Expand Up @@ -28,6 +28,7 @@
<script src="js/homeController.js"></script>
<script src="js/services/factories.js"></script>
<script src="js/services/httpRequestInjector.js"></script>
<script src="js/HolderService.js"></script>
<script src="scripts/ui-bootstrap-tpls-0.13.0.js"></script>
<script src="scripts/select.js"></script>

Expand All @@ -40,8 +41,6 @@
<script src="http://ui-grid.info/docs/grunt-scripts/pdfmake.js"></script>
<script src="http://ui-grid.info/docs/grunt-scripts/vfs_fonts.js"></script>
<script src="http://ui-grid.info/release/ui-grid-unstable.js"></script>

<link rel="stylesheet" type="text/css" href="description.json">
</head>

<!-- apply our angular app to our site -->
Expand Down
162 changes: 101 additions & 61 deletions TeamDBAwesome/TeamDBAwesome/js/homeController.js
@@ -1,73 +1,113 @@
angular.module('routerApp').controller('homeController', function($scope, $http,urlService,$q,$state,$cookies,$rootScope) {
angular.module('routerApp').controller('homeController', function ($scope, $http, urlService, $q, $state, $cookies, $rootScope) {

/* BEGIN FUNCTIONS FUNCTIONS */
/* BEGIN FUNCTIONS FUNCTIONS */

$scope.authenticateAdmin = function(id,pass){
return $q(function(resolve,reject){
var param = id + " " + pass;
var promise = $http.post(url + "/authenticateAdmin",param)
.success(function(data) {
if (data.STATUS == 555) {
$scope.authenticated = false;
resolve('We did it');
} else {
$scope.authenticated = true;
resolve('We did it');
}
})
.error(function(data, status, headers, config) {
$scope.messages = 'There was a network error. Try again later.';
reject('We did not do it');
});
})
}
$scope.authenticateAdmin = function (id, pass) {
return $q(function (resolve, reject) {
var param = id + " " + pass;
var promise = $http.post(url + "/authenticateAdmin", param)
.success(function (data) {
if (data.STATUS == 555) {
$scope.authenticated = false;
resolve('We did it');
} else {
$scope.authenticated = true;
resolve('We did it');
}
})
.error(function (data, status, headers, config) {
$scope.messages = 'There was a network error. Try again later.';
reject('We did not do it');
});
})
}

$scope.toAdminPage = function (user) {
//$cookies.put('LOGIN','ADMIN ' + $cookies.get('DEPID') + ' ' + $cookies.get('PWD') )
//var promise = $scope.authenticateAdmin(user.username,user.password);
//promise.then(function(){
// if($scope.authenticated == true){
// $cookies.put('ADMIN',user.username);
// Function to register new users.
$scope.createUser = function (newUser) {
// TODO: Make Service fit into things.
var sub = {
FName: null,
LName: null,
Address: null,
City: null,
State: null,
Post: null,
Country: null,
Phone: null,
Fax: null,
Email: null,
Company: null,
//SUPPORT REP ID SHOULD BE 0 for NEW customer
SupportRepID: null,
PersonID: null,
CustomerID: null
};

if (newUser.company == null) {
newUser.company = null;
}

sub.FName = newUser.firstName;
sub.LName = newUser.lastName;
sub.Address = newUser.addr;
sub.City = newUser.city;
sub.State = newUser.state;
sub.Post = newUser.postal;
sub.Country = newUser.country;
sub.Phone = newUser.phone;
sub.Fax = newUser.fax;
sub.Email = newUser.email;
sub.Company = newUser.company;
sub.SupportRepID = 0;

console.log(sub);
//Unsure of how to handle local host for now
$http.post(localhost/api/newCustomer,sub)
.success(function (data, status, headers, config) {
$scope.messages = 'You are now registered!';

})
.error(function (data, status, headers, config) {
$scope.messages = 'There was a network error. Try again later.';
$log.error(status);
});
}

$scope.toAdminPage = function (user) {
//$cookies.put('LOGIN','ADMIN ' + $cookies.get('DEPID') + ' ' + $cookies.get('PWD') )
//var promise = $scope.authenticateAdmin(user.username,user.password);
//promise.then(function(){
// if($scope.authenticated == true){
// $cookies.put('ADMIN',user.username);
//$cookies.put('PWD',user.password);
// $scope.messages = null;
// $scope.messages = null;
$state.go('admin-home');
//}
// else if ($scope.authenticated == false){
// $scope.messages = 'Incorrect Login Information.';
// }
// });
}
//}
// else if ($scope.authenticated == false){
// $scope.messages = 'Incorrect Login Information.';
// }
// });
}

$scope.toUserPage = function (user) {
//$cookies.put('LOGIN','ADMIN ' + $cookies.get('DEPID') + ' ' + $cookies.get('PWD') )
//var promise = $scope.authenticateAdmin(user.username,user.password);
//promise.then(function(){
// if($scope.authenticated == true){
// $cookies.put('ADMIN',user.username);
//$cookies.put('LOGIN','ADMIN ' + $cookies.get('DEPID') + ' ' + $cookies.get('PWD') )
//var promise = $scope.authenticateAdmin(user.username,user.password);
//promise.then(function(){
// if($scope.authenticated == true){
// $cookies.put('ADMIN',user.username);
//$cookies.put('PWD',user.password);
// $scope.messages = null;
// $scope.messages = null;
$state.go('user-home');
//}
// else if ($scope.authenticated == false){
// $scope.messages = 'Incorrect Login Information.';
// }
// });
}
//}
// else if ($scope.authenticated == false){
// $scope.messages = 'Incorrect Login Information.';
// }
// });
}

/* BEGIN LOGIC */
var url = urlService.web;

/* BEGIN LOGIC */
var url = urlService.web;
$scope.myInterval = 5000;
$scope.noWrapSlides = false;
var slides = $scope.slides = [{image: '../../images/C1.JPG', text: 'Hello'},{image: '../../images/C2.JPG', text: 'Hello'},{image: '../../images/C3.JPG', text: 'Hello'},
{image: '../../images/C4.JPG', text: 'Hello'},{image: '../../images/C5.JPG', text: 'Hello'}];
$scope.addSlide = function() {
var newWidth = 600 + slides.length + 1;
slides.push({
image: '//placekitten.com/' + newWidth + '/300',
text: ['More','Extra','Lots of','Surplus'][slides.length % 4] + ' ' +
['Cats', 'Kittys', 'Felines', 'Cutes'][slides.length % 4]
});
};
/* END LOGIC */
/* END LOGIC */

});

0 comments on commit 146c030

Please sign in to comment.