diff --git a/csharp/marketconnectionNET2.0/db_AI-4_V3/db_AI-4/Dashboard.Designer.cs b/csharp/marketconnectionNET2.0/db_AI-4_V3/db_AI-4/Dashboard.Designer.cs index 3ff5155..5ab64f0 100644 --- a/csharp/marketconnectionNET2.0/db_AI-4_V3/db_AI-4/Dashboard.Designer.cs +++ b/csharp/marketconnectionNET2.0/db_AI-4_V3/db_AI-4/Dashboard.Designer.cs @@ -39,19 +39,19 @@ 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.LoggedInUserLabel = new System.Windows.Forms.Label(); this.SuspendLayout(); // // LocationListBox // this.LocationListBox.FormattingEnabled = true; this.LocationListBox.Location = new System.Drawing.Point(9, 118); - this.LocationListBox.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); + this.LocationListBox.Margin = new System.Windows.Forms.Padding(2); this.LocationListBox.Name = "LocationListBox"; this.LocationListBox.Size = new System.Drawing.Size(148, 199); this.LocationListBox.TabIndex = 0; @@ -59,7 +59,7 @@ // LocationTextBox // this.LocationTextBox.Location = new System.Drawing.Point(9, 76); - this.LocationTextBox.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); + this.LocationTextBox.Margin = new System.Windows.Forms.Padding(2); this.LocationTextBox.Name = "LocationTextBox"; this.LocationTextBox.Size = new System.Drawing.Size(76, 20); this.LocationTextBox.TabIndex = 1; @@ -77,7 +77,7 @@ // LocationSearchButton // this.LocationSearchButton.Location = new System.Drawing.Point(88, 75); - this.LocationSearchButton.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); + this.LocationSearchButton.Margin = new System.Windows.Forms.Padding(2); this.LocationSearchButton.Name = "LocationSearchButton"; this.LocationSearchButton.Size = new System.Drawing.Size(56, 19); this.LocationSearchButton.TabIndex = 3; @@ -107,7 +107,7 @@ // RentInsertButton // this.RentInsertButton.Location = new System.Drawing.Point(352, 321); - this.RentInsertButton.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); + this.RentInsertButton.Margin = new System.Windows.Forms.Padding(2); this.RentInsertButton.Name = "RentInsertButton"; this.RentInsertButton.Size = new System.Drawing.Size(76, 19); this.RentInsertButton.TabIndex = 17; @@ -118,7 +118,7 @@ // RentDateTimePicker // this.RentDateTimePicker.Location = new System.Drawing.Point(247, 76); - this.RentDateTimePicker.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); + this.RentDateTimePicker.Margin = new System.Windows.Forms.Padding(2); this.RentDateTimePicker.Name = "RentDateTimePicker"; this.RentDateTimePicker.Size = new System.Drawing.Size(182, 20); this.RentDateTimePicker.TabIndex = 21; @@ -127,7 +127,7 @@ // this.ADDLocationListBox.FormattingEnabled = true; this.ADDLocationListBox.Location = new System.Drawing.Point(247, 118); - this.ADDLocationListBox.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); + this.ADDLocationListBox.Margin = new System.Windows.Forms.Padding(2); this.ADDLocationListBox.Name = "ADDLocationListBox"; this.ADDLocationListBox.Size = new System.Drawing.Size(182, 199); this.ADDLocationListBox.TabIndex = 23; @@ -145,7 +145,7 @@ // ADDLocationButton // this.ADDLocationButton.Location = new System.Drawing.Point(171, 149); - this.ADDLocationButton.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); + this.ADDLocationButton.Margin = new System.Windows.Forms.Padding(2); this.ADDLocationButton.Name = "ADDLocationButton"; this.ADDLocationButton.Size = new System.Drawing.Size(56, 19); this.ADDLocationButton.TabIndex = 25; @@ -153,15 +153,6 @@ this.ADDLocationButton.UseVisualStyleBackColor = true; this.ADDLocationButton.Click += new System.EventHandler(this.ADDLocationButton_Click); // - // UserDisplaylistBox - // - this.UserDisplaylistBox.FormattingEnabled = true; - this.UserDisplaylistBox.Location = new System.Drawing.Point(100, 11); - this.UserDisplaylistBox.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); - this.UserDisplaylistBox.Name = "UserDisplaylistBox"; - this.UserDisplaylistBox.Size = new System.Drawing.Size(194, 17); - this.UserDisplaylistBox.TabIndex = 26; - // // UserDisplayLabel // this.UserDisplayLabel.AutoSize = true; @@ -176,7 +167,7 @@ // this.ShowRentListBox.FormattingEnabled = true; this.ShowRentListBox.Location = new System.Drawing.Point(473, 118); - this.ShowRentListBox.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); + this.ShowRentListBox.Margin = new System.Windows.Forms.Padding(2); this.ShowRentListBox.Name = "ShowRentListBox"; this.ShowRentListBox.Size = new System.Drawing.Size(367, 199); this.ShowRentListBox.TabIndex = 28; @@ -195,7 +186,7 @@ // ShowRentButton // this.ShowRentButton.Location = new System.Drawing.Point(553, 77); - this.ShowRentButton.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); + this.ShowRentButton.Margin = new System.Windows.Forms.Padding(2); this.ShowRentButton.Name = "ShowRentButton"; this.ShowRentButton.Size = new System.Drawing.Size(56, 19); this.ShowRentButton.TabIndex = 30; @@ -206,22 +197,32 @@ // RentedTextBox // this.RentedTextBox.Location = new System.Drawing.Point(473, 77); - this.RentedTextBox.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); + this.RentedTextBox.Margin = new System.Windows.Forms.Padding(2); this.RentedTextBox.Name = "RentedTextBox"; this.RentedTextBox.Size = new System.Drawing.Size(76, 20); this.RentedTextBox.TabIndex = 31; // + // LoggedInUserLabel + // + this.LoggedInUserLabel.AutoSize = true; + this.LoggedInUserLabel.Location = new System.Drawing.Point(84, 11); + this.LoggedInUserLabel.Name = "LoggedInUserLabel"; + this.LoggedInUserLabel.Size = new System.Drawing.Size(100, 13); + this.LoggedInUserLabel.TabIndex = 32; + this.LoggedInUserLabel.Text = "LoggedInUserLabel"; + this.LoggedInUserLabel.Click += new System.EventHandler(this.label1_Click); + // // Dashboard // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(858, 392); + this.Controls.Add(this.LoggedInUserLabel); 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); @@ -233,7 +234,7 @@ this.Controls.Add(this.LocationLabel); this.Controls.Add(this.LocationTextBox); this.Controls.Add(this.LocationListBox); - this.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); + this.Margin = new System.Windows.Forms.Padding(2); this.Name = "Dashboard"; this.Text = "Dashboard"; this.Load += new System.EventHandler(this.Dashboard_Load); @@ -255,11 +256,11 @@ 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; + private System.Windows.Forms.Label LoggedInUserLabel; } } \ No newline at end of file diff --git a/csharp/marketconnectionNET2.0/db_AI-4_V3/db_AI-4/Dashboard.cs b/csharp/marketconnectionNET2.0/db_AI-4_V3/db_AI-4/Dashboard.cs index d2179b9..8edb2b4 100644 --- a/csharp/marketconnectionNET2.0/db_AI-4_V3/db_AI-4/Dashboard.cs +++ b/csharp/marketconnectionNET2.0/db_AI-4_V3/db_AI-4/Dashboard.cs @@ -17,8 +17,6 @@ namespace db_AI_4 List rentlocation = new List(); List rentedlocations = new List(); - - BindingSource locationBinding = new BindingSource(); BindingSource addlocationBinding = new BindingSource(); BindingSource showrentBinding = new BindingSource(); @@ -27,6 +25,7 @@ namespace db_AI_4 { InitializeComponent(); UpdateBinding(); + LoggedInUserLabel.Text = GetMembers.email_address; } private void UpdateBinding() @@ -53,7 +52,6 @@ namespace db_AI_4 showrentBinding.DataSource = rentedlocations; ShowRentListBox.DataSource = showrentBinding; - } @@ -74,16 +72,18 @@ namespace db_AI_4 private void RentInsertButton_Click(object sender, EventArgs e) { DataAccess db = new DataAccess(); - - int RentPriceID; - RentPriceID = 1; - - //int MemberID; - //MemberID = 1; - - db.InsertRent(RentDateTimePicker.Value.Date.ToString("yyyyMMdd"), GetMembers.member_id, RentPriceID); - - RentDateTimePicker.Text = ""; + try + { + GetLocations selectedItem = (GetLocations)ADDLocationListBox.SelectedItem; + //var command = "SELECT rent_price_id FROM dbo.locations WHERE locations.location_name = @Location_Name"; + selectedItem = db.GetLocations(selectedItem.location_name)[0]; + db.InsertRent(RentDateTimePicker.Value.Date.ToString("yyyyMMdd"), GetMembers.member_id, selectedItem.rent_price_id, selectedItem.location_id); + //RentDateTimePicker.Text = ""; + } + catch + { + MessageBox.Show("Please select a location and a date."); + } } // Insert Rent end @@ -117,8 +117,14 @@ namespace db_AI_4 private void ShowRentListBox_SelectedIndexChanged(object sender, EventArgs e) { - } - //Add Location to ADDBox end - + } + + private void label1_Click(object sender, EventArgs e) + { + + } + + //Add Location to ADDBox end + } } diff --git a/csharp/marketconnectionNET2.0/db_AI-4_V3/db_AI-4/DataAccess.cs b/csharp/marketconnectionNET2.0/db_AI-4_V3/db_AI-4/DataAccess.cs index 78eef89..128f7ff 100644 --- a/csharp/marketconnectionNET2.0/db_AI-4_V3/db_AI-4/DataAccess.cs +++ b/csharp/marketconnectionNET2.0/db_AI-4_V3/db_AI-4/DataAccess.cs @@ -30,22 +30,22 @@ namespace db_AI_4 { List QueryResult = new List(); using (IDbConnection connection = new System.Data.SqlClient.SqlConnection(Helper.CnnVal("marketdb"))) - { + { var command = "SELECT member_id FROM dbo.members WHERE members.email_address = @Email_Adress"; - QueryResult = connection.Query(command, new { Email_Adress = input_mail }).ToList(); + QueryResult = connection.Query(command, new { Email_Adress = input_mail }).ToList(); GetMembers.member_id = Convert.ToInt32(QueryResult[0]); } } // Insert Rents into Database start - public void InsertRent(string RentDate, int MemberID, int RentPriceID ) + public void InsertRent(string RentDate, int MemberID, int RentPriceID , int LocationID) { using (IDbConnection connection = new System.Data.SqlClient.SqlConnection(Helper.CnnVal("marketdb"))) { List rents = new List(); - rents.Add(new GetRents { rent_date = RentDate, member_id = GetMembers.member_id, 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 = LocationID}); 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); diff --git a/csharp/marketconnectionNET2.0/db_AI-4_V3/db_AI-4/GetLocations.cs b/csharp/marketconnectionNET2.0/db_AI-4_V3/db_AI-4/GetLocations.cs index 92c687d..f53de22 100644 --- a/csharp/marketconnectionNET2.0/db_AI-4_V3/db_AI-4/GetLocations.cs +++ b/csharp/marketconnectionNET2.0/db_AI-4_V3/db_AI-4/GetLocations.cs @@ -12,7 +12,7 @@ namespace db_AI_4 public string streetname { get; set; } public int location_capacity { get; set; } public string location_name { get; set; } - + public int rent_price_id { get; set; } public string LocationInfo diff --git a/sql/.vs/sql/v14/.ssms_suo b/sql/.vs/sql/v14/.ssms_suo index cd7333d..5f88eed 100644 Binary files a/sql/.vs/sql/v14/.ssms_suo and b/sql/.vs/sql/v14/.ssms_suo differ