fix the id forwarding
This commit is contained in:
parent
607db6b494
commit
5840e64d27
|
@ -39,19 +39,19 @@
|
||||||
this.ADDLocationListBox = new System.Windows.Forms.ListBox();
|
this.ADDLocationListBox = new System.Windows.Forms.ListBox();
|
||||||
this.ADDLocationLabel = new System.Windows.Forms.Label();
|
this.ADDLocationLabel = new System.Windows.Forms.Label();
|
||||||
this.ADDLocationButton = new System.Windows.Forms.Button();
|
this.ADDLocationButton = new System.Windows.Forms.Button();
|
||||||
this.UserDisplaylistBox = new System.Windows.Forms.ListBox();
|
|
||||||
this.UserDisplayLabel = new System.Windows.Forms.Label();
|
this.UserDisplayLabel = new System.Windows.Forms.Label();
|
||||||
this.ShowRentListBox = new System.Windows.Forms.ListBox();
|
this.ShowRentListBox = new System.Windows.Forms.ListBox();
|
||||||
this.ShowRentLabel = new System.Windows.Forms.Label();
|
this.ShowRentLabel = new System.Windows.Forms.Label();
|
||||||
this.ShowRentButton = new System.Windows.Forms.Button();
|
this.ShowRentButton = new System.Windows.Forms.Button();
|
||||||
this.RentedTextBox = new System.Windows.Forms.TextBox();
|
this.RentedTextBox = new System.Windows.Forms.TextBox();
|
||||||
|
this.LoggedInUserLabel = new System.Windows.Forms.Label();
|
||||||
this.SuspendLayout();
|
this.SuspendLayout();
|
||||||
//
|
//
|
||||||
// LocationListBox
|
// LocationListBox
|
||||||
//
|
//
|
||||||
this.LocationListBox.FormattingEnabled = true;
|
this.LocationListBox.FormattingEnabled = true;
|
||||||
this.LocationListBox.Location = new System.Drawing.Point(9, 118);
|
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.Name = "LocationListBox";
|
||||||
this.LocationListBox.Size = new System.Drawing.Size(148, 199);
|
this.LocationListBox.Size = new System.Drawing.Size(148, 199);
|
||||||
this.LocationListBox.TabIndex = 0;
|
this.LocationListBox.TabIndex = 0;
|
||||||
|
@ -59,7 +59,7 @@
|
||||||
// LocationTextBox
|
// LocationTextBox
|
||||||
//
|
//
|
||||||
this.LocationTextBox.Location = new System.Drawing.Point(9, 76);
|
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.Name = "LocationTextBox";
|
||||||
this.LocationTextBox.Size = new System.Drawing.Size(76, 20);
|
this.LocationTextBox.Size = new System.Drawing.Size(76, 20);
|
||||||
this.LocationTextBox.TabIndex = 1;
|
this.LocationTextBox.TabIndex = 1;
|
||||||
|
@ -77,7 +77,7 @@
|
||||||
// LocationSearchButton
|
// LocationSearchButton
|
||||||
//
|
//
|
||||||
this.LocationSearchButton.Location = new System.Drawing.Point(88, 75);
|
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.Name = "LocationSearchButton";
|
||||||
this.LocationSearchButton.Size = new System.Drawing.Size(56, 19);
|
this.LocationSearchButton.Size = new System.Drawing.Size(56, 19);
|
||||||
this.LocationSearchButton.TabIndex = 3;
|
this.LocationSearchButton.TabIndex = 3;
|
||||||
|
@ -107,7 +107,7 @@
|
||||||
// RentInsertButton
|
// RentInsertButton
|
||||||
//
|
//
|
||||||
this.RentInsertButton.Location = new System.Drawing.Point(352, 321);
|
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.Name = "RentInsertButton";
|
||||||
this.RentInsertButton.Size = new System.Drawing.Size(76, 19);
|
this.RentInsertButton.Size = new System.Drawing.Size(76, 19);
|
||||||
this.RentInsertButton.TabIndex = 17;
|
this.RentInsertButton.TabIndex = 17;
|
||||||
|
@ -118,7 +118,7 @@
|
||||||
// RentDateTimePicker
|
// RentDateTimePicker
|
||||||
//
|
//
|
||||||
this.RentDateTimePicker.Location = new System.Drawing.Point(247, 76);
|
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.Name = "RentDateTimePicker";
|
||||||
this.RentDateTimePicker.Size = new System.Drawing.Size(182, 20);
|
this.RentDateTimePicker.Size = new System.Drawing.Size(182, 20);
|
||||||
this.RentDateTimePicker.TabIndex = 21;
|
this.RentDateTimePicker.TabIndex = 21;
|
||||||
|
@ -127,7 +127,7 @@
|
||||||
//
|
//
|
||||||
this.ADDLocationListBox.FormattingEnabled = true;
|
this.ADDLocationListBox.FormattingEnabled = true;
|
||||||
this.ADDLocationListBox.Location = new System.Drawing.Point(247, 118);
|
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.Name = "ADDLocationListBox";
|
||||||
this.ADDLocationListBox.Size = new System.Drawing.Size(182, 199);
|
this.ADDLocationListBox.Size = new System.Drawing.Size(182, 199);
|
||||||
this.ADDLocationListBox.TabIndex = 23;
|
this.ADDLocationListBox.TabIndex = 23;
|
||||||
|
@ -145,7 +145,7 @@
|
||||||
// ADDLocationButton
|
// ADDLocationButton
|
||||||
//
|
//
|
||||||
this.ADDLocationButton.Location = new System.Drawing.Point(171, 149);
|
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.Name = "ADDLocationButton";
|
||||||
this.ADDLocationButton.Size = new System.Drawing.Size(56, 19);
|
this.ADDLocationButton.Size = new System.Drawing.Size(56, 19);
|
||||||
this.ADDLocationButton.TabIndex = 25;
|
this.ADDLocationButton.TabIndex = 25;
|
||||||
|
@ -153,15 +153,6 @@
|
||||||
this.ADDLocationButton.UseVisualStyleBackColor = true;
|
this.ADDLocationButton.UseVisualStyleBackColor = true;
|
||||||
this.ADDLocationButton.Click += new System.EventHandler(this.ADDLocationButton_Click);
|
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
|
// UserDisplayLabel
|
||||||
//
|
//
|
||||||
this.UserDisplayLabel.AutoSize = true;
|
this.UserDisplayLabel.AutoSize = true;
|
||||||
|
@ -176,7 +167,7 @@
|
||||||
//
|
//
|
||||||
this.ShowRentListBox.FormattingEnabled = true;
|
this.ShowRentListBox.FormattingEnabled = true;
|
||||||
this.ShowRentListBox.Location = new System.Drawing.Point(473, 118);
|
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.Name = "ShowRentListBox";
|
||||||
this.ShowRentListBox.Size = new System.Drawing.Size(367, 199);
|
this.ShowRentListBox.Size = new System.Drawing.Size(367, 199);
|
||||||
this.ShowRentListBox.TabIndex = 28;
|
this.ShowRentListBox.TabIndex = 28;
|
||||||
|
@ -195,7 +186,7 @@
|
||||||
// ShowRentButton
|
// ShowRentButton
|
||||||
//
|
//
|
||||||
this.ShowRentButton.Location = new System.Drawing.Point(553, 77);
|
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.Name = "ShowRentButton";
|
||||||
this.ShowRentButton.Size = new System.Drawing.Size(56, 19);
|
this.ShowRentButton.Size = new System.Drawing.Size(56, 19);
|
||||||
this.ShowRentButton.TabIndex = 30;
|
this.ShowRentButton.TabIndex = 30;
|
||||||
|
@ -206,22 +197,32 @@
|
||||||
// RentedTextBox
|
// RentedTextBox
|
||||||
//
|
//
|
||||||
this.RentedTextBox.Location = new System.Drawing.Point(473, 77);
|
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.Name = "RentedTextBox";
|
||||||
this.RentedTextBox.Size = new System.Drawing.Size(76, 20);
|
this.RentedTextBox.Size = new System.Drawing.Size(76, 20);
|
||||||
this.RentedTextBox.TabIndex = 31;
|
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
|
// Dashboard
|
||||||
//
|
//
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
this.ClientSize = new System.Drawing.Size(858, 392);
|
this.ClientSize = new System.Drawing.Size(858, 392);
|
||||||
|
this.Controls.Add(this.LoggedInUserLabel);
|
||||||
this.Controls.Add(this.RentedTextBox);
|
this.Controls.Add(this.RentedTextBox);
|
||||||
this.Controls.Add(this.ShowRentButton);
|
this.Controls.Add(this.ShowRentButton);
|
||||||
this.Controls.Add(this.ShowRentLabel);
|
this.Controls.Add(this.ShowRentLabel);
|
||||||
this.Controls.Add(this.ShowRentListBox);
|
this.Controls.Add(this.ShowRentListBox);
|
||||||
this.Controls.Add(this.UserDisplayLabel);
|
this.Controls.Add(this.UserDisplayLabel);
|
||||||
this.Controls.Add(this.UserDisplaylistBox);
|
|
||||||
this.Controls.Add(this.ADDLocationButton);
|
this.Controls.Add(this.ADDLocationButton);
|
||||||
this.Controls.Add(this.ADDLocationLabel);
|
this.Controls.Add(this.ADDLocationLabel);
|
||||||
this.Controls.Add(this.ADDLocationListBox);
|
this.Controls.Add(this.ADDLocationListBox);
|
||||||
|
@ -233,7 +234,7 @@
|
||||||
this.Controls.Add(this.LocationLabel);
|
this.Controls.Add(this.LocationLabel);
|
||||||
this.Controls.Add(this.LocationTextBox);
|
this.Controls.Add(this.LocationTextBox);
|
||||||
this.Controls.Add(this.LocationListBox);
|
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.Name = "Dashboard";
|
||||||
this.Text = "Dashboard";
|
this.Text = "Dashboard";
|
||||||
this.Load += new System.EventHandler(this.Dashboard_Load);
|
this.Load += new System.EventHandler(this.Dashboard_Load);
|
||||||
|
@ -255,11 +256,11 @@
|
||||||
private System.Windows.Forms.ListBox ADDLocationListBox;
|
private System.Windows.Forms.ListBox ADDLocationListBox;
|
||||||
private System.Windows.Forms.Label ADDLocationLabel;
|
private System.Windows.Forms.Label ADDLocationLabel;
|
||||||
private System.Windows.Forms.Button ADDLocationButton;
|
private System.Windows.Forms.Button ADDLocationButton;
|
||||||
private System.Windows.Forms.ListBox UserDisplaylistBox;
|
|
||||||
private System.Windows.Forms.Label UserDisplayLabel;
|
private System.Windows.Forms.Label UserDisplayLabel;
|
||||||
private System.Windows.Forms.ListBox ShowRentListBox;
|
private System.Windows.Forms.ListBox ShowRentListBox;
|
||||||
private System.Windows.Forms.Label ShowRentLabel;
|
private System.Windows.Forms.Label ShowRentLabel;
|
||||||
private System.Windows.Forms.Button ShowRentButton;
|
private System.Windows.Forms.Button ShowRentButton;
|
||||||
private System.Windows.Forms.TextBox RentedTextBox;
|
private System.Windows.Forms.TextBox RentedTextBox;
|
||||||
|
private System.Windows.Forms.Label LoggedInUserLabel;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -17,8 +17,6 @@ namespace db_AI_4
|
||||||
List<GetLocations> rentlocation = new List<GetLocations>();
|
List<GetLocations> rentlocation = new List<GetLocations>();
|
||||||
List<GetRents> rentedlocations = new List<GetRents>();
|
List<GetRents> rentedlocations = new List<GetRents>();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
BindingSource locationBinding = new BindingSource();
|
BindingSource locationBinding = new BindingSource();
|
||||||
BindingSource addlocationBinding = new BindingSource();
|
BindingSource addlocationBinding = new BindingSource();
|
||||||
BindingSource showrentBinding = new BindingSource();
|
BindingSource showrentBinding = new BindingSource();
|
||||||
|
@ -27,6 +25,7 @@ namespace db_AI_4
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
UpdateBinding();
|
UpdateBinding();
|
||||||
|
LoggedInUserLabel.Text = GetMembers.email_address;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UpdateBinding()
|
private void UpdateBinding()
|
||||||
|
@ -53,7 +52,6 @@ namespace db_AI_4
|
||||||
showrentBinding.DataSource = rentedlocations;
|
showrentBinding.DataSource = rentedlocations;
|
||||||
ShowRentListBox.DataSource = showrentBinding;
|
ShowRentListBox.DataSource = showrentBinding;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -74,16 +72,18 @@ namespace db_AI_4
|
||||||
private void RentInsertButton_Click(object sender, EventArgs e)
|
private void RentInsertButton_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
DataAccess db = new DataAccess();
|
DataAccess db = new DataAccess();
|
||||||
|
try
|
||||||
int RentPriceID;
|
{
|
||||||
RentPriceID = 1;
|
GetLocations selectedItem = (GetLocations)ADDLocationListBox.SelectedItem;
|
||||||
|
//var command = "SELECT rent_price_id FROM dbo.locations WHERE locations.location_name = @Location_Name";
|
||||||
//int MemberID;
|
selectedItem = db.GetLocations(selectedItem.location_name)[0];
|
||||||
//MemberID = 1;
|
db.InsertRent(RentDateTimePicker.Value.Date.ToString("yyyyMMdd"), GetMembers.member_id, selectedItem.rent_price_id, selectedItem.location_id);
|
||||||
|
//RentDateTimePicker.Text = "";
|
||||||
db.InsertRent(RentDateTimePicker.Value.Date.ToString("yyyyMMdd"), GetMembers.member_id, RentPriceID);
|
}
|
||||||
|
catch
|
||||||
RentDateTimePicker.Text = "";
|
{
|
||||||
|
MessageBox.Show("Please select a location and a date.");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
// Insert Rent end
|
// Insert Rent end
|
||||||
|
@ -117,8 +117,14 @@ namespace db_AI_4
|
||||||
private void ShowRentListBox_SelectedIndexChanged(object sender, EventArgs e)
|
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
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,22 +30,22 @@ namespace db_AI_4
|
||||||
{
|
{
|
||||||
List<int> QueryResult = new List<int>();
|
List<int> QueryResult = new List<int>();
|
||||||
using (IDbConnection connection = new System.Data.SqlClient.SqlConnection(Helper.CnnVal("marketdb")))
|
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";
|
var command = "SELECT member_id FROM dbo.members WHERE members.email_address = @Email_Adress";
|
||||||
QueryResult = connection.Query<int>(command, new { Email_Adress = input_mail }).ToList();
|
QueryResult = connection.Query<int>(command, new { Email_Adress = input_mail }).ToList();
|
||||||
GetMembers.member_id = Convert.ToInt32(QueryResult[0]);
|
GetMembers.member_id = Convert.ToInt32(QueryResult[0]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Insert Rents into Database start
|
// 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")))
|
using (IDbConnection connection = new System.Data.SqlClient.SqlConnection(Helper.CnnVal("marketdb")))
|
||||||
{
|
{
|
||||||
List<GetRents> rents = new List<GetRents>();
|
List<GetRents> rents = new List<GetRents>();
|
||||||
|
|
||||||
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)" +
|
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);
|
" VALUES (@rent_date, @member_id, @rent_price_id, @location_id )", rents);
|
||||||
|
|
|
@ -12,7 +12,7 @@ namespace db_AI_4
|
||||||
public string streetname { get; set; }
|
public string streetname { get; set; }
|
||||||
public int location_capacity { get; set; }
|
public int location_capacity { get; set; }
|
||||||
public string location_name { get; set; }
|
public string location_name { get; set; }
|
||||||
|
public int rent_price_id { get; set; }
|
||||||
|
|
||||||
|
|
||||||
public string LocationInfo
|
public string LocationInfo
|
||||||
|
|
Binary file not shown.
Loading…
Reference in New Issue