change the GetMembers class to a static class
This commit is contained in:
parent
918aca0b0e
commit
eb17e67e19
|
@ -100,11 +100,10 @@ namespace db_AI_4
|
|||
int RentPriceID;
|
||||
RentPriceID = 1;
|
||||
|
||||
int MemberID;
|
||||
MemberID = 1;
|
||||
//int MemberID;
|
||||
//MemberID = 1;
|
||||
|
||||
|
||||
db.InsertRent(RentDateTimePicker.Value.Date.ToString("yyyyMMdd"), RentPriceID, MemberID);
|
||||
db.InsertRent(RentDateTimePicker.Value.Date.ToString("yyyyMMdd"), GetMembers.member_id, RentPriceID);
|
||||
|
||||
RentDateTimePicker.Text = "";
|
||||
|
||||
|
|
|
@ -25,17 +25,17 @@ namespace db_AI_4
|
|||
|
||||
}
|
||||
}
|
||||
// im moment nicht benötigt (sollte die id des momentanen members herauslesen)
|
||||
public List<GetMembers> DisplayUser(string Email_address)
|
||||
|
||||
public void CurrentUser(string input_mail)
|
||||
{
|
||||
List<int> QueryResult = new List<int>();
|
||||
using (IDbConnection connection = new System.Data.SqlClient.SqlConnection(Helper.CnnVal("marketdb")))
|
||||
{
|
||||
var outputUser = connection.Query<GetMembers>($"SELECT member_id FROM dbo.members WHERE email_address = '{Email_address}'").ToList();
|
||||
return outputUser;
|
||||
var command = "SELECT member_id FROM dbo.members WHERE members.email_address = @Email_Adress";
|
||||
QueryResult = connection.Query<int>(command, new { Email_Adress = input_mail }).ToList();
|
||||
GetMembers.member_id = Convert.ToInt32(QueryResult[0]);
|
||||
}
|
||||
}
|
||||
//Read locations from the Database function end
|
||||
|
||||
|
||||
|
||||
// Insert Locations into Database start
|
||||
|
@ -62,7 +62,7 @@ namespace db_AI_4
|
|||
{
|
||||
List<GetRents> rents = new List<GetRents>();
|
||||
|
||||
rents.Add(new GetRents { rent_date = RentDate, member_id = 1, rent_price_id = RentPriceID, location_id = 1});
|
||||
rents.Add(new GetRents { rent_date = RentDate, member_id = GetMembers.member_id, rent_price_id = RentPriceID, location_id = 1});
|
||||
|
||||
connection.Execute("INSERT INTO dbo.rents (rent_date, member_id, rent_price_id, location_id)" +
|
||||
" VALUES (@rent_date, @member_id, @rent_price_id, @location_id )", rents);
|
||||
|
@ -73,17 +73,12 @@ namespace db_AI_4
|
|||
|
||||
|
||||
//Registration function start
|
||||
public void InsertMember(string Email_address, string Password)
|
||||
public void InsertMember(string input_mail, string input_pw)
|
||||
{
|
||||
using (IDbConnection connection = new System.Data.SqlClient.SqlConnection(Helper.CnnVal("marketdb")))
|
||||
{
|
||||
|
||||
List<GetMembers> members = new List<GetMembers>();
|
||||
|
||||
members.Add(new GetMembers { email_address = Email_address, password = Password });
|
||||
|
||||
connection.Execute("INSERT INTO dbo.members ( email_address, password)" +
|
||||
" VALUES (@Email_address, @Password) ", members);
|
||||
var command = "INSERT INTO dbo.members (email_address, password) VALUES ( @Email_address, @Password)";
|
||||
connection.Execute(command, new { Email_address = input_mail, Password = input_pw });
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -123,7 +118,7 @@ namespace db_AI_4
|
|||
|
||||
if (count == 1)
|
||||
{
|
||||
MessageBox.Show("It Worked");
|
||||
CurrentUser(GetMembers.email_address);
|
||||
Dashboard dashboard = new Dashboard();
|
||||
dashboard.Show();
|
||||
}
|
||||
|
|
|
@ -6,17 +6,15 @@ using System.Threading.Tasks;
|
|||
|
||||
namespace db_AI_4
|
||||
{
|
||||
public class GetMembers
|
||||
public static class GetMembers
|
||||
{
|
||||
public int member_id { get; set; }
|
||||
public string email_address { get; set; }
|
||||
public string password { get; set; }
|
||||
public int member_status_id { get; set; }
|
||||
public static int member_id { get; set; }
|
||||
public static string email_address { get; set; }
|
||||
public static string password { get; set; }
|
||||
public static int member_status_id { get; set; }
|
||||
|
||||
|
||||
|
||||
|
||||
public string MemberInfo
|
||||
public static string MemberInfo
|
||||
{
|
||||
get
|
||||
{
|
||||
|
@ -25,7 +23,7 @@ namespace db_AI_4
|
|||
|
||||
}
|
||||
|
||||
public string MemberID
|
||||
public static string MemberID
|
||||
{
|
||||
get
|
||||
{
|
||||
|
|
|
@ -22,18 +22,19 @@ namespace db_AI_4
|
|||
private void RegistrationButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
DataAccess db = new DataAccess();
|
||||
|
||||
db.InsertMember(EmailLoginBox.Text, PasswordLoginBox.Text);
|
||||
|
||||
EmailLoginBox.Text = "";
|
||||
PasswordLoginBox.Text = "";
|
||||
GetMembers.email_address = EmailLoginBox.Text;
|
||||
GetMembers.password = PasswordLoginBox.Text;
|
||||
db.InsertMember(GetMembers.email_address, GetMembers.password);
|
||||
MessageBox.Show("Member Registered.");
|
||||
}
|
||||
|
||||
private void LoginButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
DataAccess db = new DataAccess();
|
||||
|
||||
db.CheckLogin(EmailLoginBox.Text, PasswordLoginBox.Text);
|
||||
GetMembers.email_address = EmailLoginBox.Text;
|
||||
GetMembers.password = PasswordLoginBox.Text;
|
||||
db.CheckLogin(GetMembers.email_address, GetMembers.password);
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue