diff --git a/IoT1/IoT1.csproj b/IoT1/IoT1.csproj
index e32fb6b..53e14b9 100644
--- a/IoT1/IoT1.csproj
+++ b/IoT1/IoT1.csproj
@@ -118,6 +118,12 @@
MSBuild:Compile
Designer
+
+ Location.xaml
+
+
+ RegisterPage.xaml
+
UserInputWindow.xaml
@@ -133,6 +139,10 @@
Designer
MSBuild:Compile
+
+ Designer
+ MSBuild:Compile
+
Designer
MSBuild:Compile
@@ -158,6 +168,10 @@
MainWindow.xaml
Code
+
+ Designer
+ MSBuild:Compile
+
Designer
MSBuild:Compile
diff --git a/IoT1/Location.xaml b/IoT1/Location.xaml
new file mode 100644
index 0000000..d0cc225
--- /dev/null
+++ b/IoT1/Location.xaml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
diff --git a/IoT1/Location.xaml.cs b/IoT1/Location.xaml.cs
new file mode 100644
index 0000000..45bb48a
--- /dev/null
+++ b/IoT1/Location.xaml.cs
@@ -0,0 +1,28 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Navigation;
+using System.Windows.Shapes;
+
+namespace IoT1
+{
+ ///
+ /// Interaction logic for Location.xaml
+ ///
+ public partial class Location : Page
+ {
+ public Location()
+ {
+ InitializeComponent();
+ }
+ }
+}
diff --git a/IoT1/LoginPage.xaml b/IoT1/LoginPage.xaml
index c01861e..655c846 100644
--- a/IoT1/LoginPage.xaml
+++ b/IoT1/LoginPage.xaml
@@ -7,21 +7,27 @@
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800"
Title="LoginPage"
- Background="Transparent">
+ Background="Beige">
-
-
+
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
diff --git a/IoT1/LoginPage.xaml.cs b/IoT1/LoginPage.xaml.cs
index 512061d..1601952 100644
--- a/IoT1/LoginPage.xaml.cs
+++ b/IoT1/LoginPage.xaml.cs
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
+using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
@@ -24,5 +25,58 @@ public LoginPage()
{
InitializeComponent();
}
+
+ private void btnSubmit_Click(object sender, RoutedEventArgs e)
+ {
+
+ // For Windows auth -
+ // @"Data Source=(MachineName)\InstanceName);Initial Catalog = (DBName); Integrated Security = True;"
+ // For SQL Server auth -
+ // @"Data Source=(MachineName)\InstanceName);Initial Catalog = (DBName); UserID = Username; Password = (Password);"
+ SqlConnection sqlCon = new SqlConnection(@"Data Source=(localdb)\Local; Database = LoginDB;Integrated Security = True;");
+
+ try
+ {
+ if (sqlCon.State == System.Data.ConnectionState.Closed)
+ sqlCon.Open();
+ String query = "SELECT COUNT(1) FROM tblUser WHERE Username = @Username AND Password =@Password";
+ SqlCommand sqlCmd = new SqlCommand(query, sqlCon);
+ sqlCmd.CommandType = System.Data.CommandType.Text;
+
+ sqlCmd.Parameters.AddWithValue("@Username", txtUsername.Text);
+ sqlCmd.Parameters.AddWithValue("@Password", txtPassword.Password);
+ int count = Convert.ToInt32(sqlCmd.ExecuteScalar());
+
+ if (count == 1)
+ {
+ MainWindow dashboard = new MainWindow();
+ dashboard.Show();
+ MessageBox.Show("Login Successful");
+ this.NavigationService.Navigate(null);
+ }
+
+ else
+ {
+ MessageBox.Show("Invalid Username/Password");
+ }
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message);
+
+ }
+
+ finally
+ {
+ sqlCon.Close();
+ }
+ }
+
+ private void Button_Click(object sender, RoutedEventArgs e)
+ {
+ RegisterPage registerPage = new RegisterPage();
+ this.NavigationService.Navigate(registerPage);
+
+ }
}
}
diff --git a/IoT1/RegisterPage.xaml b/IoT1/RegisterPage.xaml
new file mode 100644
index 0000000..3eeb77e
--- /dev/null
+++ b/IoT1/RegisterPage.xaml
@@ -0,0 +1,31 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/IoT1/RegisterPage.xaml.cs b/IoT1/RegisterPage.xaml.cs
new file mode 100644
index 0000000..909e72c
--- /dev/null
+++ b/IoT1/RegisterPage.xaml.cs
@@ -0,0 +1,55 @@
+using System;
+using System.Collections.Generic;
+using System.Data.SqlClient;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Navigation;
+using System.Windows.Shapes;
+
+namespace IoT1
+{
+ ///
+ /// Interaction logic for RegisterPage.xaml
+ ///
+ public partial class RegisterPage : Page
+ {
+ public RegisterPage()
+ {
+ InitializeComponent();
+ }
+
+ SqlConnection conn = new SqlConnection(@"Data Source=(localdb)\Local;Initial Catalog=LoginDB;Integrated Security=True");
+
+ private void Button_Click(object sender, RoutedEventArgs e)
+ {
+ try
+ {
+ SqlCommand cmd = new SqlCommand("INSERT INTO tblUser VALUES (@Username, @Password)", conn);
+ cmd.CommandType = System.Data.CommandType.Text;
+ cmd.Parameters.AddWithValue("@Username", txt_Username.Text);
+ cmd.Parameters.AddWithValue("@Password", txt_Password.Password);
+ conn.Open();
+ cmd.ExecuteNonQuery();
+ conn.Close();
+ MessageBox.Show("Registration Completed ");
+
+ }
+
+ catch (SqlException Ex)
+ {
+
+ MessageBox.Show(Ex.Message);
+
+ }
+
+ }
+ }
+}