Add rent function
This commit is contained in:
parent
fef89ba4bd
commit
06d4e0afe2
|
@ -40,6 +40,12 @@
|
|||
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.SuspendLayout();
|
||||
//
|
||||
// LocationListBox
|
||||
|
@ -144,11 +150,68 @@
|
|||
this.StreetLabel.TabIndex = 12;
|
||||
this.StreetLabel.Text = "Streetname";
|
||||
//
|
||||
// RentDateLabel
|
||||
//
|
||||
this.RentDateLabel.AutoSize = true;
|
||||
this.RentDateLabel.Location = new System.Drawing.Point(529, 56);
|
||||
this.RentDateLabel.Name = "RentDateLabel";
|
||||
this.RentDateLabel.Size = new System.Drawing.Size(73, 17);
|
||||
this.RentDateLabel.TabIndex = 20;
|
||||
this.RentDateLabel.Text = "Rent-Date";
|
||||
//
|
||||
// PaymentDateLabel
|
||||
//
|
||||
this.PaymentDateLabel.AutoSize = true;
|
||||
this.PaymentDateLabel.Location = new System.Drawing.Point(528, 110);
|
||||
this.PaymentDateLabel.Name = "PaymentDateLabel";
|
||||
this.PaymentDateLabel.Size = new System.Drawing.Size(101, 17);
|
||||
this.PaymentDateLabel.TabIndex = 18;
|
||||
this.PaymentDateLabel.Text = "Payment_Date";
|
||||
//
|
||||
// RentInsertButton
|
||||
//
|
||||
this.RentInsertButton.Location = new System.Drawing.Point(649, 210);
|
||||
this.RentInsertButton.Name = "RentInsertButton";
|
||||
this.RentInsertButton.Size = new System.Drawing.Size(75, 23);
|
||||
this.RentInsertButton.TabIndex = 17;
|
||||
this.RentInsertButton.Text = "Insert";
|
||||
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.Name = "RentDateTimePicker";
|
||||
this.RentDateTimePicker.Size = new System.Drawing.Size(200, 22);
|
||||
this.RentDateTimePicker.TabIndex = 21;
|
||||
//
|
||||
// PaymentDateTimePicker2
|
||||
//
|
||||
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;
|
||||
//
|
||||
// Dashboard
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(656, 366);
|
||||
this.ClientSize = new System.Drawing.Size(861, 366);
|
||||
this.Controls.Add(this.PaymentDateTimePicker2);
|
||||
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);
|
||||
|
@ -182,5 +245,11 @@
|
|||
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;
|
||||
}
|
||||
}
|
|
@ -61,5 +61,25 @@ 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;
|
||||
|
||||
int MemberID;
|
||||
MemberID = 1;
|
||||
|
||||
|
||||
db.InsertRent(RentDateTimePicker.Value.Date.ToString("yyyyMMdd"), PaymentDateTimePicker2.Value.Date.ToString("yyyyMMdd"), RentPriceID, MemberID);
|
||||
|
||||
RentDateTimePicker.Text = "";
|
||||
PaymentDateTimePicker2.Text = "";
|
||||
}
|
||||
// Insert Rent end
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -46,7 +46,7 @@ namespace db_AI_4
|
|||
|
||||
// Insert Locations into Database start
|
||||
|
||||
internal void InsertLocations(string StreetName, int LocationCapacity, string LocationName)
|
||||
public void InsertLocations(string StreetName, int LocationCapacity, string LocationName)
|
||||
{
|
||||
using (IDbConnection connection = new System.Data.SqlClient.SqlConnection(Helper.CnnVal("marketdb")))
|
||||
{
|
||||
|
@ -55,11 +55,26 @@ namespace db_AI_4
|
|||
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, @LocationCapacity, @LocationName)", locations);
|
||||
" 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 Locations into Database end
|
||||
// Insert Rents into Database end
|
||||
|
||||
//CheckLogin function start
|
||||
public void CheckLogin(string Email_address, string Password)
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace db_AI_4
|
||||
{
|
||||
public class GetRents
|
||||
{
|
||||
public int rent_id { get; set; }
|
||||
public string rent_date { get; set; }
|
||||
public string payment_date { get; set; }
|
||||
public int member_id { get; set; }
|
||||
public int rent_price_id { get; set; }
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public string RentInfo
|
||||
{
|
||||
get
|
||||
{
|
||||
return $"{ rent_date } { payment_date } {member_id} {rent_price_id} ";
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
|
@ -58,6 +58,7 @@
|
|||
<Compile Include="DataAccess.cs" />
|
||||
<Compile Include="GetLocations.cs" />
|
||||
<Compile Include="GetMembers.cs" />
|
||||
<Compile Include="GetRents.cs" />
|
||||
<Compile Include="Helper.cs" />
|
||||
<Compile Include="LoginForm.cs">
|
||||
<SubType>Form</SubType>
|
||||
|
|
Loading…
Reference in New Issue