add department sql join query, alter person model to fit department data
This commit is contained in:
@@ -16,13 +16,13 @@ namespace it_projekt
|
|||||||
{
|
{
|
||||||
connection.Open();
|
connection.Open();
|
||||||
|
|
||||||
string sql = "SELECT * FROM stammdaten";
|
string sql = "SELECT stammdaten.id, stammdaten.firstname, stammdaten.lastname, stammdaten.creationdate, abteilung.kuerzel, abteilung.name FROM `stammdaten` JOIN abteilung GROUP BY stammdaten.id; ";
|
||||||
MySqlCommand cmd = new MySqlCommand(sql, connection);
|
MySqlCommand cmd = new MySqlCommand(sql, connection);
|
||||||
MySqlDataReader rdr = cmd.ExecuteReader();
|
MySqlDataReader rdr = cmd.ExecuteReader();
|
||||||
Persons = new List<Person>();
|
Persons = new List<Person>();
|
||||||
while (rdr.Read())
|
while (rdr.Read())
|
||||||
{
|
{
|
||||||
Person p = new Person(rdr[0].ToString(), rdr[1].ToString(), rdr[2].ToString(), DateTime.Parse(rdr[3].ToString()));
|
Person p = new Person(rdr[0].ToString(), rdr[1].ToString(), rdr[2].ToString(), DateTime.Parse(rdr[3].ToString()), rdr[4].ToString(), rdr[5].ToString());
|
||||||
Persons.Add(p);
|
Persons.Add(p);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
98
Form1.Designer.cs
generated
98
Form1.Designer.cs
generated
@@ -1,34 +1,34 @@
|
|||||||
|
|
||||||
namespace it_projekt
|
namespace it_projekt
|
||||||
{
|
{
|
||||||
partial class Form1
|
partial class Form1
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Required designer variable.
|
/// Required designer variable.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private System.ComponentModel.IContainer components = null;
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Clean up any resources being used.
|
/// Clean up any resources being used.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||||
protected override void Dispose(bool disposing)
|
protected override void Dispose(bool disposing)
|
||||||
{
|
{
|
||||||
if (disposing && (components != null))
|
if (disposing && (components != null))
|
||||||
{
|
{
|
||||||
components.Dispose();
|
components.Dispose();
|
||||||
}
|
}
|
||||||
base.Dispose(disposing);
|
base.Dispose(disposing);
|
||||||
}
|
}
|
||||||
|
|
||||||
#region Windows Form Designer generated code
|
#region Windows Form Designer generated code
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Required method for Designer support - do not modify
|
/// Required method for Designer support - do not modify
|
||||||
/// the contents of this method with the code editor.
|
/// the contents of this method with the code editor.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private void InitializeComponent()
|
private void InitializeComponent()
|
||||||
{
|
{
|
||||||
this.loginBtn = new System.Windows.Forms.Button();
|
this.loginBtn = new System.Windows.Forms.Button();
|
||||||
this.exportBtn = new System.Windows.Forms.Button();
|
this.exportBtn = new System.Windows.Forms.Button();
|
||||||
this.label1 = new System.Windows.Forms.Label();
|
this.label1 = new System.Windows.Forms.Label();
|
||||||
@@ -189,24 +189,24 @@ namespace it_projekt
|
|||||||
this.ResumeLayout(false);
|
this.ResumeLayout(false);
|
||||||
this.PerformLayout();
|
this.PerformLayout();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
private System.Windows.Forms.Button loginBtn;
|
private System.Windows.Forms.Button loginBtn;
|
||||||
private System.Windows.Forms.Button exportBtn;
|
private System.Windows.Forms.Button exportBtn;
|
||||||
private System.Windows.Forms.Label label1;
|
private System.Windows.Forms.Label label1;
|
||||||
private System.Windows.Forms.Label label2;
|
private System.Windows.Forms.Label label2;
|
||||||
private System.Windows.Forms.TextBox userTxt;
|
private System.Windows.Forms.TextBox userTxt;
|
||||||
private System.Windows.Forms.TextBox passTxt;
|
private System.Windows.Forms.TextBox passTxt;
|
||||||
private System.Windows.Forms.DataGridView dataGrid;
|
private System.Windows.Forms.DataGridView dataGrid;
|
||||||
private System.Windows.Forms.DataGridViewTextBoxColumn Id;
|
private System.Windows.Forms.DataGridViewTextBoxColumn Id;
|
||||||
private System.Windows.Forms.DataGridViewTextBoxColumn firstname;
|
private System.Windows.Forms.DataGridViewTextBoxColumn firstname;
|
||||||
private System.Windows.Forms.DataGridViewTextBoxColumn lastname;
|
private System.Windows.Forms.DataGridViewTextBoxColumn lastname;
|
||||||
private System.Windows.Forms.DataGridViewTextBoxColumn creationDate;
|
private System.Windows.Forms.DataGridViewTextBoxColumn creationDate;
|
||||||
private System.Windows.Forms.DataGridViewCheckBoxColumn markItem;
|
private System.Windows.Forms.DataGridViewCheckBoxColumn markItem;
|
||||||
private System.Windows.Forms.RadioButton jsonRBtn;
|
private System.Windows.Forms.RadioButton jsonRBtn;
|
||||||
private System.Windows.Forms.RadioButton xmlRBtn;
|
private System.Windows.Forms.RadioButton xmlRBtn;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
2
Form1.cs
2
Form1.cs
@@ -41,7 +41,7 @@ namespace it_projekt
|
|||||||
}
|
}
|
||||||
foreach (Person person in db.Persons)
|
foreach (Person person in db.Persons)
|
||||||
{
|
{
|
||||||
this.dataGrid.Rows.Add(person.Id, person.Firstname, person.Lastname, person.CreationDate, false);
|
this.dataGrid.Rows.Add(person.Id, person.Firstname, person.Lastname, person.department_short, person.department_long, person.CreationDate, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,17 +12,21 @@ namespace it_projekt
|
|||||||
public string Lastname { get; set; }
|
public string Lastname { get; set; }
|
||||||
public string Firstname { get; set; }
|
public string Firstname { get; set; }
|
||||||
public DateTime CreationDate { get; set; }
|
public DateTime CreationDate { get; set; }
|
||||||
|
public string department_short { get; set; }
|
||||||
|
public string department_long { get; set; }
|
||||||
|
|
||||||
public Person()
|
public Person()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
public Person(string Id, string Lastname, string Firstname, DateTime CreationDate)
|
public Person(string Id, string Lastname, string Firstname, DateTime CreationDate, string department_short, string department_long)
|
||||||
{
|
{
|
||||||
this.Id = Id;
|
this.Id = Id;
|
||||||
this.Lastname = Lastname;
|
this.Lastname = Lastname;
|
||||||
this.Firstname = Firstname;
|
this.Firstname = Firstname;
|
||||||
this.CreationDate = CreationDate;
|
this.CreationDate = CreationDate;
|
||||||
|
this.department_short = department_short;
|
||||||
|
this.department_long = department_long;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user