From 5840e64d27630aa409ddc5c5fff4d33263e8512b Mon Sep 17 00:00:00 2001 From: Andreas Zweili Date: Wed, 30 Aug 2017 19:55:25 +0200 Subject: [PATCH] fix the id forwarding --- .../db_AI-4_V3/db_AI-4/Dashboard.Designer.cs | 47 +++++++++--------- .../db_AI-4_V3/db_AI-4/Dashboard.cs | 38 ++++++++------ .../db_AI-4_V3/db_AI-4/DataAccess.cs | 8 +-- .../db_AI-4_V3/db_AI-4/GetLocations.cs | 2 +- sql/.vs/sql/v14/.ssms_suo | Bin 18432 -> 23040 bytes 5 files changed, 51 insertions(+), 44 deletions(-) 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 cd7333df8e2f88fa80491ca6f0104fccf0553845..5f88eede0a96907881fb22ddc0acf05af97a036b 100644 GIT binary patch delta 2502 zcmb_c-)mb{96#sArXk7N*y?OzX_GBW@9mQ9=65pJc+%dabj&tw=Gs9eO`AI?%UVs+ zDOn*w1@TSut+0oIqW{3Q^g$3tg+2Hn$WVOoN%2vAvLG_7-+PsM}cz~7y5 zYK5ro74vB{45HMZv!i|n1>tVcik<j~BKo#sc-h znz2N^u#JCDb!|vPIgO@To&_^Do_A*2^kDS_K83s>2hE{ZD@^;>3Wo~_t78manHr7B~vo0jlU z21Q1>jskZK{k!~$6-R;2!J4B)XJH%vS9kd{7?Ho>-f8uz`ao2$3vR3=?WFQ)S_$z0w0$vg~A3ziX)lMXp{ZMvmD=kjl5 ztu8B{U0q6Nh56+4<=9+eCYDT|yP3}2kPDebD?d9i>ADIY+No+V^iSSS!?E@CsIw3a)PdOzV zD%C5CPQYW(EudR}fT?;1NM;cOCGMIZDp7>!jxvs3s+EYl zPFBM}D$TUnJdn&bt*LaCUl5K0IlDKK4#qs+zJ{8^Qax8_?`uK3(pyaf=s2^(_Y`vn z@2Yc0aq++5N;PWsMDBzJ2P#nWh@q*~>0bF$HLd*zWv)IYA<4?hP|h>}NN= zY+n0}lgsclWgTslaqO-{9mhF++IEaH;?9AOoU8mqH|s$k(tC&nS%CFn-j5!DKZr4m zSp?oe*Z>P58b+j#9cOWP!mz_ELJQ7=ry^iA&z@99+1*XoT_*b8?RCYlOOVB|zl0tG z1RDuEi$2J@#r|}~9i=zg{iDl#=&*!7-xuzeBFk3BL{Uv_wdPMK`AbUvrRb`Xk7@J&5CBp2kQJg1Z`SM*A*ddA7q@Waw{SJ_+Oekyu3 z?xQNKw^D2}a>E3xsQ%8D6aA1V4pP04C=43_;RxnJz8=hDy37$o*2V3w2|0`x62%a! zP=XDTKB=QG}<+}Tfk}W9dkz8t1k{Ve0rb?xG zsn!Bwe8kja3#EtU-riZP6Vv%>TP3XX)z9@~lQy%VtN*2}_P^KWA*$<4$K_;3sr&QL zc9XK#F5cr1v_ad2Qs=+-moCQlv<94b&1dxNkA$=hq0H940d>+F&dC;Drb|{reR40E wPrF)zk`yeh->E21{9~