db_AI-4/csharp/db_AI-4/Dashboard.cs

115 lines
3.2 KiB
C#
Raw Normal View History

2017-07-26 18:18:37 +02:00
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
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();
2017-07-26 18:18:37 +02:00
public Dashboard()
{
InitializeComponent();
UpdateBinding();
2017-08-30 19:55:25 +02:00
LoggedInUserLabel.Text = GetMembers.email_address;
2017-07-26 18:18:37 +02:00
}
private void UpdateBinding()
{
// Loading of the Searched Locations
2017-07-26 18:18:37 +02:00
LocationListBox.DataSource = locations;
LocationListBox.DisplayMember = "LocationInfo";
locationBinding.DataSource = locations;
LocationListBox.DataSource = locationBinding;
//Loading of the Selected Locations
// Rented Locations
ShowRentListBox.DataSource = rentedlocations;
ShowRentListBox.DisplayMember = "RentInfo";
showrentBinding.DataSource = rentedlocations;
ShowRentListBox.DataSource = showrentBinding;
2017-07-26 18:18:37 +02:00
}
2017-07-26 18:18:37 +02:00
private void LocationSearchButton_Click(object sender, EventArgs e)
{
DataAccess db = new DataAccess();
locations = db.GetLocations(LocationTextBox.Text);
UpdateBinding();
}
// Search Locations end
2017-07-26 20:20:14 +02:00
// Insert Rent start
private void RentInsertButton_Click(object sender, EventArgs e)
{
DataAccess db = new DataAccess();
2017-08-30 19:55:25 +02:00
try
{
2017-08-30 20:10:55 +02:00
GetLocations selectedItem = (GetLocations)LocationListBox.SelectedItem;
2017-08-30 19:55:25 +02:00
//var command = "SELECT rent_price_id FROM dbo.locations WHERE locations.location_name = @Location_Name";
selectedItem = db.GetLocations(selectedItem.location_name)[0];
2017-08-30 20:10:55 +02:00
db.InsertRent(RentDateTimePicker.Value.Date.ToString("yyyyMMdd"), GetMembers.member_id, selectedItem.rent_price_id, selectedItem.location_id);
2017-08-30 19:55:25 +02:00
//RentDateTimePicker.Text = "";
}
catch
2017-08-30 20:10:55 +02:00
{
2017-08-30 19:55:25 +02:00
MessageBox.Show("Please select a location and a date.");
}
2017-07-26 20:20:14 +02:00
}
// Insert Rent end
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();
}
private void ShowRentListBox_SelectedIndexChanged(object sender, EventArgs e)
{
2017-08-30 20:10:55 +02:00
}
private void LoggedInUser_Click(object sender, EventArgs e)
{
}
//Add Location to ADDBox end
2017-07-26 18:18:37 +02:00
}
}