database now defined as singleton
This commit is contained in:
15
Form1.cs
15
Form1.cs
@@ -15,6 +15,7 @@ namespace it_projekt
|
||||
public Form1()
|
||||
{
|
||||
InitializeComponent();
|
||||
this.exportBtn.Enabled = false;
|
||||
}
|
||||
|
||||
|
||||
@@ -29,19 +30,23 @@ namespace it_projekt
|
||||
private void loginBtn_Click(object sender, EventArgs e)
|
||||
{
|
||||
LoadUsersFromTable(this.userTxt.Text, this.passTxt.Text);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void LoadUsersFromTable(string user, string password)
|
||||
{
|
||||
if (db == null)
|
||||
db = Database.getDatabase(user, password);
|
||||
if (db.Persons == null)
|
||||
{
|
||||
db = new Database(user, password);
|
||||
MessageBox.Show("Connection to Database failed! \nPlease Try again.", "Database Error!");
|
||||
}
|
||||
foreach (Person person in db.Persons)
|
||||
{
|
||||
this.dataGrid.Rows.Add(person.Id, person.Firstname, person.Lastname, person.department_short, person.department_long, person.CreationDate, false);
|
||||
else {
|
||||
foreach (Person person in db.Persons)
|
||||
{
|
||||
this.dataGrid.Rows.Add(person.Id, person.Firstname, person.Lastname, person.department_short, person.department_long, person.CreationDate, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user