design and code changes to the application

This commit is contained in:
Ismail 2017-08-02 22:36:24 +02:00
parent 7a720ca87f
commit a4d3fc2d08
6 changed files with 259 additions and 167 deletions

View File

@ -32,34 +32,33 @@
this.LocationTextBox = new System.Windows.Forms.TextBox();
this.LocationLabel = new System.Windows.Forms.Label();
this.LocationSearchButton = new System.Windows.Forms.Button();
this.LocationInputLabel = new System.Windows.Forms.Label();
this.StreetnameInsertBox = new System.Windows.Forms.TextBox();
this.LocationCapacityInputBox = new System.Windows.Forms.TextBox();
this.LocationNameInputBox = new System.Windows.Forms.TextBox();
this.LocationInsertButton = new System.Windows.Forms.Button();
this.NameLabel = new System.Windows.Forms.Label();
this.CapacityLabel = new System.Windows.Forms.Label();
this.StreetLabel = new System.Windows.Forms.Label();
this.RentDateLabel = new System.Windows.Forms.Label();
this.PaymentDateLabel = new System.Windows.Forms.Label();
this.RentInsertButton = new System.Windows.Forms.Button();
this.RentInputLabel = new System.Windows.Forms.Label();
this.RentDateTimePicker = new System.Windows.Forms.DateTimePicker();
this.PaymentDateTimePicker2 = new System.Windows.Forms.DateTimePicker();
this.ADDLocationListBox = new System.Windows.Forms.ListBox();
this.ADDLocationLabel = new System.Windows.Forms.Label();
this.ADDLocationButton = new System.Windows.Forms.Button();
this.UserDisplaylistBox = new System.Windows.Forms.ListBox();
this.UserDisplayLabel = new System.Windows.Forms.Label();
this.ShowRentListBox = new System.Windows.Forms.ListBox();
this.ShowRentLabel = new System.Windows.Forms.Label();
this.ShowRentButton = new System.Windows.Forms.Button();
this.RentedTextBox = new System.Windows.Forms.TextBox();
this.SuspendLayout();
//
// LocationListBox
//
this.LocationListBox.FormattingEnabled = true;
this.LocationListBox.ItemHeight = 16;
this.LocationListBox.Location = new System.Drawing.Point(12, 91);
this.LocationListBox.Location = new System.Drawing.Point(12, 145);
this.LocationListBox.Name = "LocationListBox";
this.LocationListBox.Size = new System.Drawing.Size(196, 244);
this.LocationListBox.TabIndex = 0;
//
// LocationTextBox
//
this.LocationTextBox.Location = new System.Drawing.Point(12, 50);
this.LocationTextBox.Location = new System.Drawing.Point(12, 93);
this.LocationTextBox.Name = "LocationTextBox";
this.LocationTextBox.Size = new System.Drawing.Size(100, 22);
this.LocationTextBox.TabIndex = 1;
@ -67,15 +66,15 @@
// LocationLabel
//
this.LocationLabel.AutoSize = true;
this.LocationLabel.Location = new System.Drawing.Point(12, 13);
this.LocationLabel.Location = new System.Drawing.Point(12, 53);
this.LocationLabel.Name = "LocationLabel";
this.LocationLabel.Size = new System.Drawing.Size(112, 17);
this.LocationLabel.Size = new System.Drawing.Size(135, 17);
this.LocationLabel.TabIndex = 2;
this.LocationLabel.Text = "Location-Search";
this.LocationLabel.Text = "Locations-Searched";
//
// LocationSearchButton
//
this.LocationSearchButton.Location = new System.Drawing.Point(133, 50);
this.LocationSearchButton.Location = new System.Drawing.Point(118, 92);
this.LocationSearchButton.Name = "LocationSearchButton";
this.LocationSearchButton.Size = new System.Drawing.Size(75, 23);
this.LocationSearchButton.TabIndex = 3;
@ -83,77 +82,10 @@
this.LocationSearchButton.UseVisualStyleBackColor = true;
this.LocationSearchButton.Click += new System.EventHandler(this.LocationSearchButton_Click);
//
// LocationInputLabel
//
this.LocationInputLabel.AutoSize = true;
this.LocationInputLabel.Location = new System.Drawing.Point(266, 13);
this.LocationInputLabel.Name = "LocationInputLabel";
this.LocationInputLabel.Size = new System.Drawing.Size(98, 17);
this.LocationInputLabel.TabIndex = 4;
this.LocationInputLabel.Text = "Location-Input";
//
// StreetnameInsertBox
//
this.StreetnameInsertBox.Location = new System.Drawing.Point(369, 53);
this.StreetnameInsertBox.Name = "StreetnameInsertBox";
this.StreetnameInsertBox.Size = new System.Drawing.Size(100, 22);
this.StreetnameInsertBox.TabIndex = 5;
//
// LocationCapacityInputBox
//
this.LocationCapacityInputBox.Location = new System.Drawing.Point(369, 105);
this.LocationCapacityInputBox.Name = "LocationCapacityInputBox";
this.LocationCapacityInputBox.Size = new System.Drawing.Size(100, 22);
this.LocationCapacityInputBox.TabIndex = 6;
//
// LocationNameInputBox
//
this.LocationNameInputBox.Location = new System.Drawing.Point(369, 158);
this.LocationNameInputBox.Name = "LocationNameInputBox";
this.LocationNameInputBox.Size = new System.Drawing.Size(100, 22);
this.LocationNameInputBox.TabIndex = 7;
//
// LocationInsertButton
//
this.LocationInsertButton.Location = new System.Drawing.Point(369, 210);
this.LocationInsertButton.Name = "LocationInsertButton";
this.LocationInsertButton.Size = new System.Drawing.Size(75, 23);
this.LocationInsertButton.TabIndex = 9;
this.LocationInsertButton.Text = "Insert";
this.LocationInsertButton.UseVisualStyleBackColor = true;
this.LocationInsertButton.Click += new System.EventHandler(this.LocationInsertButton_Click);
//
// NameLabel
//
this.NameLabel.AutoSize = true;
this.NameLabel.Location = new System.Drawing.Point(266, 158);
this.NameLabel.Name = "NameLabel";
this.NameLabel.Size = new System.Drawing.Size(97, 17);
this.NameLabel.TabIndex = 10;
this.NameLabel.Text = "Locationname";
//
// CapacityLabel
//
this.CapacityLabel.AutoSize = true;
this.CapacityLabel.Location = new System.Drawing.Point(266, 105);
this.CapacityLabel.Name = "CapacityLabel";
this.CapacityLabel.Size = new System.Drawing.Size(62, 17);
this.CapacityLabel.TabIndex = 11;
this.CapacityLabel.Text = "Capacity";
//
// StreetLabel
//
this.StreetLabel.AutoSize = true;
this.StreetLabel.Location = new System.Drawing.Point(266, 53);
this.StreetLabel.Name = "StreetLabel";
this.StreetLabel.Size = new System.Drawing.Size(81, 17);
this.StreetLabel.TabIndex = 12;
this.StreetLabel.Text = "Streetname";
//
// RentDateLabel
//
this.RentDateLabel.AutoSize = true;
this.RentDateLabel.Location = new System.Drawing.Point(529, 56);
this.RentDateLabel.Location = new System.Drawing.Point(250, 98);
this.RentDateLabel.Name = "RentDateLabel";
this.RentDateLabel.Size = new System.Drawing.Size(73, 17);
this.RentDateLabel.TabIndex = 20;
@ -162,70 +94,134 @@
// PaymentDateLabel
//
this.PaymentDateLabel.AutoSize = true;
this.PaymentDateLabel.Location = new System.Drawing.Point(528, 110);
this.PaymentDateLabel.Location = new System.Drawing.Point(500, 258);
this.PaymentDateLabel.Name = "PaymentDateLabel";
this.PaymentDateLabel.Size = new System.Drawing.Size(101, 17);
this.PaymentDateLabel.Size = new System.Drawing.Size(0, 17);
this.PaymentDateLabel.TabIndex = 18;
this.PaymentDateLabel.Text = "Payment_Date";
//
// RentInsertButton
//
this.RentInsertButton.Location = new System.Drawing.Point(649, 210);
this.RentInsertButton.Location = new System.Drawing.Point(470, 395);
this.RentInsertButton.Name = "RentInsertButton";
this.RentInsertButton.Size = new System.Drawing.Size(75, 23);
this.RentInsertButton.Size = new System.Drawing.Size(101, 23);
this.RentInsertButton.TabIndex = 17;
this.RentInsertButton.Text = "Insert";
this.RentInsertButton.Text = "Rent";
this.RentInsertButton.UseVisualStyleBackColor = true;
this.RentInsertButton.Click += new System.EventHandler(this.RentInsertButton_Click);
//
// RentInputLabel
//
this.RentInputLabel.AutoSize = true;
this.RentInputLabel.Location = new System.Drawing.Point(528, 13);
this.RentInputLabel.Name = "RentInputLabel";
this.RentInputLabel.Size = new System.Drawing.Size(74, 17);
this.RentInputLabel.TabIndex = 13;
this.RentInputLabel.Text = "Rent-Input";
//
// RentDateTimePicker
//
this.RentDateTimePicker.Location = new System.Drawing.Point(649, 53);
this.RentDateTimePicker.Location = new System.Drawing.Point(329, 94);
this.RentDateTimePicker.Name = "RentDateTimePicker";
this.RentDateTimePicker.Size = new System.Drawing.Size(200, 22);
this.RentDateTimePicker.Size = new System.Drawing.Size(242, 22);
this.RentDateTimePicker.TabIndex = 21;
//
// PaymentDateTimePicker2
// ADDLocationListBox
//
this.PaymentDateTimePicker2.Location = new System.Drawing.Point(649, 110);
this.PaymentDateTimePicker2.Name = "PaymentDateTimePicker2";
this.PaymentDateTimePicker2.Size = new System.Drawing.Size(200, 22);
this.PaymentDateTimePicker2.TabIndex = 22;
this.ADDLocationListBox.FormattingEnabled = true;
this.ADDLocationListBox.ItemHeight = 16;
this.ADDLocationListBox.Location = new System.Drawing.Point(329, 145);
this.ADDLocationListBox.Name = "ADDLocationListBox";
this.ADDLocationListBox.Size = new System.Drawing.Size(242, 244);
this.ADDLocationListBox.TabIndex = 23;
//
// ADDLocationLabel
//
this.ADDLocationLabel.AutoSize = true;
this.ADDLocationLabel.Location = new System.Drawing.Point(326, 53);
this.ADDLocationLabel.Name = "ADDLocationLabel";
this.ADDLocationLabel.Size = new System.Drawing.Size(115, 17);
this.ADDLocationLabel.TabIndex = 24;
this.ADDLocationLabel.Text = "Locations-Added";
//
// ADDLocationButton
//
this.ADDLocationButton.Location = new System.Drawing.Point(228, 183);
this.ADDLocationButton.Name = "ADDLocationButton";
this.ADDLocationButton.Size = new System.Drawing.Size(75, 23);
this.ADDLocationButton.TabIndex = 25;
this.ADDLocationButton.Text = "ADD";
this.ADDLocationButton.UseVisualStyleBackColor = true;
this.ADDLocationButton.Click += new System.EventHandler(this.ADDLocationButton_Click);
//
// UserDisplaylistBox
//
this.UserDisplaylistBox.FormattingEnabled = true;
this.UserDisplaylistBox.ItemHeight = 16;
this.UserDisplaylistBox.Location = new System.Drawing.Point(133, 13);
this.UserDisplaylistBox.Name = "UserDisplaylistBox";
this.UserDisplaylistBox.Size = new System.Drawing.Size(257, 20);
this.UserDisplaylistBox.TabIndex = 26;
//
// UserDisplayLabel
//
this.UserDisplayLabel.AutoSize = true;
this.UserDisplayLabel.Location = new System.Drawing.Point(12, 13);
this.UserDisplayLabel.Name = "UserDisplayLabel";
this.UserDisplayLabel.Size = new System.Drawing.Size(94, 17);
this.UserDisplayLabel.TabIndex = 27;
this.UserDisplayLabel.Text = "Logged in as:";
//
// ShowRentListBox
//
this.ShowRentListBox.FormattingEnabled = true;
this.ShowRentListBox.ItemHeight = 16;
this.ShowRentListBox.Location = new System.Drawing.Point(675, 145);
this.ShowRentListBox.Name = "ShowRentListBox";
this.ShowRentListBox.Size = new System.Drawing.Size(629, 244);
this.ShowRentListBox.TabIndex = 28;
//
// ShowRentLabel
//
this.ShowRentLabel.AutoSize = true;
this.ShowRentLabel.Location = new System.Drawing.Point(672, 53);
this.ShowRentLabel.Name = "ShowRentLabel";
this.ShowRentLabel.Size = new System.Drawing.Size(120, 17);
this.ShowRentLabel.TabIndex = 29;
this.ShowRentLabel.Text = "Rented-Locations";
//
// ShowRentButton
//
this.ShowRentButton.Location = new System.Drawing.Point(781, 92);
this.ShowRentButton.Name = "ShowRentButton";
this.ShowRentButton.Size = new System.Drawing.Size(75, 23);
this.ShowRentButton.TabIndex = 30;
this.ShowRentButton.Text = "Show";
this.ShowRentButton.UseVisualStyleBackColor = true;
this.ShowRentButton.Click += new System.EventHandler(this.ShowRentButton_Click);
//
// RentedTextBox
//
this.RentedTextBox.Location = new System.Drawing.Point(675, 93);
this.RentedTextBox.Name = "RentedTextBox";
this.RentedTextBox.Size = new System.Drawing.Size(100, 22);
this.RentedTextBox.TabIndex = 31;
//
// Dashboard
//
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(861, 366);
this.Controls.Add(this.PaymentDateTimePicker2);
this.ClientSize = new System.Drawing.Size(1465, 483);
this.Controls.Add(this.RentedTextBox);
this.Controls.Add(this.ShowRentButton);
this.Controls.Add(this.ShowRentLabel);
this.Controls.Add(this.ShowRentListBox);
this.Controls.Add(this.UserDisplayLabel);
this.Controls.Add(this.UserDisplaylistBox);
this.Controls.Add(this.ADDLocationButton);
this.Controls.Add(this.ADDLocationLabel);
this.Controls.Add(this.ADDLocationListBox);
this.Controls.Add(this.RentDateTimePicker);
this.Controls.Add(this.RentDateLabel);
this.Controls.Add(this.PaymentDateLabel);
this.Controls.Add(this.RentInsertButton);
this.Controls.Add(this.RentInputLabel);
this.Controls.Add(this.StreetLabel);
this.Controls.Add(this.CapacityLabel);
this.Controls.Add(this.NameLabel);
this.Controls.Add(this.LocationInsertButton);
this.Controls.Add(this.LocationNameInputBox);
this.Controls.Add(this.LocationCapacityInputBox);
this.Controls.Add(this.StreetnameInsertBox);
this.Controls.Add(this.LocationInputLabel);
this.Controls.Add(this.LocationSearchButton);
this.Controls.Add(this.LocationLabel);
this.Controls.Add(this.LocationTextBox);
this.Controls.Add(this.LocationListBox);
this.Name = "Dashboard";
this.Text = "Dashboard";
this.Load += new System.EventHandler(this.Dashboard_Load);
this.ResumeLayout(false);
this.PerformLayout();
@ -237,19 +233,18 @@
private System.Windows.Forms.TextBox LocationTextBox;
private System.Windows.Forms.Label LocationLabel;
private System.Windows.Forms.Button LocationSearchButton;
private System.Windows.Forms.Label LocationInputLabel;
private System.Windows.Forms.TextBox StreetnameInsertBox;
private System.Windows.Forms.TextBox LocationCapacityInputBox;
private System.Windows.Forms.TextBox LocationNameInputBox;
private System.Windows.Forms.Button LocationInsertButton;
private System.Windows.Forms.Label NameLabel;
private System.Windows.Forms.Label CapacityLabel;
private System.Windows.Forms.Label StreetLabel;
private System.Windows.Forms.Label RentDateLabel;
private System.Windows.Forms.Label PaymentDateLabel;
private System.Windows.Forms.Button RentInsertButton;
private System.Windows.Forms.Label RentInputLabel;
private System.Windows.Forms.DateTimePicker RentDateTimePicker;
private System.Windows.Forms.DateTimePicker PaymentDateTimePicker2;
private System.Windows.Forms.ListBox ADDLocationListBox;
private System.Windows.Forms.Label ADDLocationLabel;
private System.Windows.Forms.Button ADDLocationButton;
private System.Windows.Forms.ListBox UserDisplaylistBox;
private System.Windows.Forms.Label UserDisplayLabel;
private System.Windows.Forms.ListBox ShowRentListBox;
private System.Windows.Forms.Label ShowRentLabel;
private System.Windows.Forms.Button ShowRentButton;
private System.Windows.Forms.TextBox RentedTextBox;
}
}

View File

@ -12,25 +12,52 @@ namespace db_AI_4
{
public partial class Dashboard : Form
{
//Search Locations start
List<GetLocations> locations = new List<GetLocations>();
List<GetLocations> rentlocation = new List<GetLocations>();
List<GetRents> rentedlocations = new List<GetRents>();
BindingSource locationBinding = new BindingSource();
BindingSource addlocationBinding = new BindingSource();
BindingSource showrentBinding = new BindingSource();
public Dashboard()
{
InitializeComponent();
UpdateBinding();
}
private void UpdateBinding()
{
// Loading of the Searched Locations
LocationListBox.DataSource = locations;
LocationListBox.DisplayMember = "LocationInfo";
locationBinding.DataSource = locations;
LocationListBox.DataSource = locationBinding;
//Loading of the Selected Locations
ADDLocationListBox.DataSource = rentlocation;
ADDLocationListBox.DisplayMember = "LocationInfo";
addlocationBinding.DataSource = rentlocation;
ADDLocationListBox.DataSource = addlocationBinding;
// Rented Locations
ShowRentListBox.DataSource = rentedlocations;
ShowRentListBox.DisplayMember = "RentInfo";
showrentBinding.DataSource = rentedlocations;
ShowRentListBox.DataSource = showrentBinding;
}
private void LocationSearchButton_Click(object sender, EventArgs e)
{
DataAccess db = new DataAccess();
@ -42,6 +69,7 @@ namespace db_AI_4
}
// Search Locations end
/*
//Insert Locations start
private void LocationInsertButton_Click(object sender, EventArgs e)
{
@ -60,13 +88,15 @@ namespace db_AI_4
}
// Insert Locations end
*/
// Insert Rent start
private void RentInsertButton_Click(object sender, EventArgs e)
{
DataAccess db = new DataAccess();
int RentPriceID;
RentPriceID = 1;
@ -74,12 +104,39 @@ namespace db_AI_4
MemberID = 1;
db.InsertRent(RentDateTimePicker.Value.Date.ToString("yyyyMMdd"), PaymentDateTimePicker2.Value.Date.ToString("yyyyMMdd"), RentPriceID, MemberID);
db.InsertRent(RentDateTimePicker.Value.Date.ToString("yyyyMMdd"), RentPriceID, MemberID);
RentDateTimePicker.Text = "";
PaymentDateTimePicker2.Text = "";
}
// Insert Rent end
//Add Location to ADDBox start
private void ADDLocationButton_Click(object sender, EventArgs e)
{
GetLocations selectedItem = (GetLocations)LocationListBox.SelectedItem;
rentlocation.Add(selectedItem);
UpdateBinding();
}
private void Dashboard_Load(object sender, EventArgs e)
{
}
private void ShowRentButton_Click(object sender, EventArgs e)
{
DataAccess db = new DataAccess();
rentedlocations = db.GetRentedLocations(RentedTextBox.Text);
UpdateBinding();
}
//Add Location to ADDBox end
}
}

View File

@ -25,8 +25,53 @@ namespace db_AI_4
}
}
// im moment nicht benötigt (sollte die id des momentanen members herauslesen)
public List<GetMembers> DisplayUser(string Email_address)
{
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;
}
}
//Read locations from the Database function end
// Insert Locations into Database start
public void InsertLocations(string StreetName, int LocationCapacity, string LocationName)
{
using (IDbConnection connection = new System.Data.SqlClient.SqlConnection(Helper.CnnVal("marketdb")))
{
List<GetLocations> locations = new List<GetLocations>();
locations.Add(new GetLocations { streetname = StreetName, location_capacity = LocationCapacity, location_name = LocationName });
connection.Execute("INSERT INTO dbo.locations (streetname, location_capacity, location_name)" +
" VALUES (@streetName, @location_capacity, @location_name)", locations);
}
}
// Insert Locations into Database end
// Insert Rents into Database start
public void InsertRent(string RentDate, int MemberID, int RentPriceID )
{
using (IDbConnection connection = new System.Data.SqlClient.SqlConnection(Helper.CnnVal("marketdb")))
{
List<GetRents> rents = new List<GetRents>();
rents.Add(new GetRents { rent_date = RentDate, member_id = MemberID, rent_price_id = RentPriceID, });
connection.Execute("INSERT INTO dbo.rents (rent_date, member_id, rent_price_id)" +
" VALUES (@rent_date, @member_id, @rent_price_id )", rents);
}
}
// Insert Rents into Database end
//Registration function start
public void InsertMember(string Email_address, string Password)
{
@ -42,39 +87,22 @@ namespace db_AI_4
}
}
internal List<GetRents> GetRentedLocations(string LocationName)
{
using (IDbConnection connection = new System.Data.SqlClient.SqlConnection(Helper.CnnVal("marketdb")))
{
var rentoutput = connection.Query<GetRents>( $"SELECT * FROM [RentedLocations] WHERE location_name like '%{ LocationName }%' ORDER BY rent_date ASC ").ToList();
return rentoutput;
}
}
//Registration function end
// Insert Locations into Database start
public void InsertLocations(string StreetName, int LocationCapacity, string LocationName)
{
using (IDbConnection connection = new System.Data.SqlClient.SqlConnection(Helper.CnnVal("marketdb")))
{
List<GetLocations> locations = new List<GetLocations>();
locations.Add(new GetLocations { streetname = StreetName, location_capacity = LocationCapacity, location_name = LocationName });
connection.Execute("INSERT INTO dbo.locations (streetname, location_capacity, location_name)" +
" VALUES (@streetName, @location_capacity, @location_name)", locations);
}
}
// Insert Locations into Database end
// Insert Rents into Database start
public void InsertRent(string RentDate, string PaymentDate, int MemberID, int RentPriceID )
{
using (IDbConnection connection = new System.Data.SqlClient.SqlConnection(Helper.CnnVal("marketdb")))
{
List<GetRents> rents = new List<GetRents>();
rents.Add(new GetRents { rent_date = RentDate, payment_date = PaymentDate, member_id = MemberID, rent_price_id = RentPriceID, });
connection.Execute("INSERT INTO dbo.rents (rent_date, payment_date, member_id, rent_price_id)" +
" VALUES (@rent_date, @payment_date, @member_id, @rent_price_id )", rents);
}
}
// Insert Rents into Database end
//CheckLogin function start
public void CheckLogin(string Email_address, string Password)

View File

@ -20,10 +20,18 @@ namespace db_AI_4
{
get
{
return $" ({email_address}) {password} ";
return $" {member_id} ({email_address}) {password} ";
}
}
public string MemberID
{
get
{
return $"({email_address}) {member_id}";
}
}
}
}

View File

@ -14,7 +14,10 @@ namespace db_AI_4
public int member_id { get; set; }
public int rent_price_id { get; set; }
public int location_id { get; set; }
public string streetname { get; set; }
public int location_capacity { get; set; }
public string location_name { get; set; }
@ -23,7 +26,7 @@ namespace db_AI_4
{
get
{
return $"{ rent_date } { payment_date } {member_id} {rent_price_id} ";
return $"{location_name} {streetname} {location_capacity} { rent_date } {member_id} {rent_price_id} ";
}
}

View File

@ -12,6 +12,7 @@ namespace db_AI_4
{
public partial class LoginForm : Form
{
public LoginForm()
{
InitializeComponent();