I created two registration forms 1.User Registration 2.Company Registration (In one database)
I created a sign In page. How to retrieve the particular user from the tables.
class UserReg
{
[AutoIncrement, PrimaryKey]
public int UserID { get; set; }
public string Name { get; set; }
public string UserName { get; set; }
public string UserPassword { get; set; }
public string Gender { get; set; }
public string State { get; set; }
}
The above code is for user registration table
class FuelReg
{
[AutoIncrement,PrimaryKey]
public int FuelID { get; set; }
public string FuelName { get; set; }
public string FuelPassword { get; set; }
public string CompanyName { get; set; }
public string CompanyAddress { get; set; }
}
The above code is for company registration.
Now the user and company should login with the same login page. How to implement this.
I tried some code but I cannot compare the particular user. My main problem is if the user and company provides similar user and password that would be a failure. So how to change it. (No validations given in the project)
private async void Button_Click_1(object sender, RoutedEventArgs e)
{
var dbpath = ApplicationData.Current.LocalFolder.Path + "/Map.db";
var con = new SQLiteAsyncConnection(dbpath);
try
{
UserReg t = new UserReg();
string query = string.Format("select UserName,UserPassword,Gender,State,Name from UserReg where UserName='{0}' and UserPassword='{1}'", text_user.Text, text_pass.Password);
List<UserReg> mylist = await con.QueryAsync<UserReg>(query);
if (mylist.Count == 1)
{
t = mylist[0];
}
if (t.UserName == text_user.Text && t.UserPassword == text_pass.Password && t.Gender!=null && t.Name!=null && t.State!=null)
{
this.Frame.Navigate(typeof(MainPage));
}
else
{
FuelReg f = new FuelReg();
string query1 = string.Format("select FuelName,FuelPassword,CompanyName,CompanyAddress from FuelReg where FuelName='{0}' and FuelPassword='{1}'", text_user.Text, text_pass.Password);
List<FuelReg> mylist1 = await con.QueryAsync<FuelReg>(query1);
if (mylist1.Count == 1)
{
f = mylist1[0];
}
if (f.FuelName == text_user.Text && f.FuelPassword == text_pass.Password && f.CompanyName!=null && f.CompanyAddress!=null)
{
this.Frame.Navigate(typeof(NewPage));
}
}
}
catch(Exception ex)
{
var msd = new MessageDialog("" + ex).ShowAsync();
}
}
So how to fetch the exact data when the user inputs in the SignIn page from the two tables
Aucun commentaire:
Enregistrer un commentaire