From 146c030a44d46c21d7d4b2b72f45dfcdec5f6f20 Mon Sep 17 00:00:00 2001 From: Antonia Lewis Date: Tue, 24 Nov 2015 14:15:46 -0500 Subject: [PATCH] Registration Page Updated --- .../TeamDBAwesome/SqlService/MySqlService.cs | 43 ++--- TeamDBAwesome/TeamDBAwesome/index.html | 3 +- .../TeamDBAwesome/js/homeController.js | 162 +++++++++++------- .../TeamDBAwesome/pages/partial-register.html | 69 +++++++- 4 files changed, 190 insertions(+), 87 deletions(-) diff --git a/TeamDBAwesome/TeamDBAwesome/SqlService/MySqlService.cs b/TeamDBAwesome/TeamDBAwesome/SqlService/MySqlService.cs index e98970e..39fc76c 100644 --- a/TeamDBAwesome/TeamDBAwesome/SqlService/MySqlService.cs +++ b/TeamDBAwesome/TeamDBAwesome/SqlService/MySqlService.cs @@ -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); @@ -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 + "\")"; } @@ -135,7 +135,7 @@ namespace TeamDBAwesome.SqlService return 0; } - + } /// @@ -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); @@ -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 @@ -264,7 +264,7 @@ namespace TeamDBAwesome.SqlService //declare the cmd and the reader //MySqlCommand cmd; - + foreach (var key in queries) { @@ -272,11 +272,11 @@ namespace TeamDBAwesome.SqlService 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 { @@ -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 { @@ -314,7 +314,7 @@ namespace TeamDBAwesome.SqlService AlbumTitle = GetDBString("albumtitle", reader), MediaType = GetDBString("mediatype", reader), Genre = GetDBString("genre", reader) - }); + }); } else if (key.Key == "Composer") { @@ -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 { @@ -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 " @@ -388,7 +388,7 @@ namespace TeamDBAwesome.SqlService track.AlbumTitle = GetDBString("albumtitle", reader); track.MediaType = GetDBString("mediatype", reader); track.Genre = GetDBString("genre", reader); - + } } else @@ -417,5 +417,6 @@ namespace TeamDBAwesome.SqlService { return 1; } - } + } + } // ADL: I added this ending paren. } \ No newline at end of file diff --git a/TeamDBAwesome/TeamDBAwesome/index.html b/TeamDBAwesome/TeamDBAwesome/index.html index 9bf1a9e..dc26659 100644 --- a/TeamDBAwesome/TeamDBAwesome/index.html +++ b/TeamDBAwesome/TeamDBAwesome/index.html @@ -28,6 +28,7 @@ + @@ -40,8 +41,6 @@ - - diff --git a/TeamDBAwesome/TeamDBAwesome/js/homeController.js b/TeamDBAwesome/TeamDBAwesome/js/homeController.js index d8752f4..5b39a10 100644 --- a/TeamDBAwesome/TeamDBAwesome/js/homeController.js +++ b/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 */ }); \ No newline at end of file diff --git a/TeamDBAwesome/TeamDBAwesome/pages/partial-register.html b/TeamDBAwesome/TeamDBAwesome/pages/partial-register.html index e74b74a..ebae0c0 100644 --- a/TeamDBAwesome/TeamDBAwesome/pages/partial-register.html +++ b/TeamDBAwesome/TeamDBAwesome/pages/partial-register.html @@ -1,5 +1,68 @@
-
-

Register Shit will go here

+
+

Register

{{user}} +
{{message}}
+
+
+ + + First name is required +
+
+ + + Last name is required +
+
+ + + Address is required +
+
+ + + City is required +
+
+ + + State is required +
+
+ + + Country is required +
+
+ + + Postal is required +
+
+ + + Phone number is required +
+
+ + + Fax number is required +
+
+ + + Email is required +
+
+ + +
+
+ +
+
-
\ No newline at end of file +
+ + -NEED: first and Last name, addr, city, state, country, postal, phone, fax, email + -OPT: company name \ No newline at end of file