-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMyForm11.h
123 lines (114 loc) · 4.35 KB
/
MyForm11.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
#pragma once
namespace R {
using namespace::System::Data::SqlClient;
using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;
/// <summary>
/// Summary for MyForm11
/// </summary>
public ref class MyForm11 : public System::Windows::Forms::Form
{
public:
String^ N = "";
MyForm11(void)
{
InitializeComponent();
//
//TODO: Add the constructor code here
//
}
MyForm11(String^ name)
{
N = name;
}
protected:
/// <summary>
/// Clean up any resources being used.
/// </summary>
~MyForm11()
{
if (components)
{
delete components;
}
}
private: System::Windows::Forms::DataGridView^ dataGridView1;
protected:
private:
/// <summary>
/// Required designer variable.
/// </summary>
System::ComponentModel::Container ^components;
#pragma region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
void InitializeComponent(void)
{
System::ComponentModel::ComponentResourceManager^ resources = (gcnew System::ComponentModel::ComponentResourceManager(MyForm11::typeid));
this->dataGridView1 = (gcnew System::Windows::Forms::DataGridView());
(cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->dataGridView1))->BeginInit();
this->SuspendLayout();
//
// dataGridView1
//
this->dataGridView1->AllowUserToAddRows = false;
this->dataGridView1->AllowUserToDeleteRows = false;
this->dataGridView1->AllowUserToResizeColumns = false;
this->dataGridView1->AllowUserToResizeRows = false;
this->dataGridView1->BackgroundColor = System::Drawing::SystemColors::ActiveBorder;
this->dataGridView1->ColumnHeadersHeightSizeMode = System::Windows::Forms::DataGridViewColumnHeadersHeightSizeMode::AutoSize;
this->dataGridView1->GridColor = System::Drawing::SystemColors::Control;
this->dataGridView1->Location = System::Drawing::Point(-1, -2);
this->dataGridView1->Margin = System::Windows::Forms::Padding(2, 2, 2, 2);
this->dataGridView1->Name = L"dataGridView1";
this->dataGridView1->ReadOnly = true;
this->dataGridView1->RowHeadersWidth = 51;
this->dataGridView1->RowTemplate->Height = 24;
this->dataGridView1->Size = System::Drawing::Size(411, 334);
this->dataGridView1->TabIndex = 8;
this->dataGridView1->CellContentClick += gcnew System::Windows::Forms::DataGridViewCellEventHandler(this, &MyForm11::dataGridView1_CellContentClick);
//
// MyForm11
//
this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
this->BackgroundImage = (cli::safe_cast<System::Drawing::Image^>(resources->GetObject(L"$this.BackgroundImage")));
this->ClientSize = System::Drawing::Size(412, 333);
this->Controls->Add(this->dataGridView1);
this->Icon = (cli::safe_cast<System::Drawing::Icon^>(resources->GetObject(L"$this.Icon")));
this->Margin = System::Windows::Forms::Padding(2, 2, 2, 2);
this->Name = L"MyForm11";
this->Text = L"Booked Tickets";
this->Load += gcnew System::EventHandler(this, &MyForm11::MyForm11_Load);
(cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->dataGridView1))->EndInit();
this->ResumeLayout(false);
}
#pragma endregion
private: System::Void MyForm11_Load(System::Object^ sender, System::EventArgs^ e) {
try {
String^ sqlconnection = "Data Source=localhost\\sqlexpress;Initial Catalog=ADMIN;Integrated Security=True";
SqlConnection sqlconn(sqlconnection);
sqlconn.Open();
String^ SqlQuery = "SELECT * FROM Booked WHERE BookedBy=@B";
SqlCommand^ cmd = gcnew SqlCommand(SqlQuery, % sqlconn);
cmd->Parameters->AddWithValue("@B", N);
SqlDataAdapter^ adapter = gcnew SqlDataAdapter(cmd);
DataSet^ dataset = gcnew DataSet();
adapter->Fill(dataset, SqlQuery);
dataGridView1->DataSource = dataset->Tables[SqlQuery];
}
catch (SqlException^ ex)
{
MessageBox::Show(ex->Message);
}
}
private: System::Void dataGridView1_CellContentClick(System::Object^ sender, System::Windows::Forms::DataGridViewCellEventArgs^ e) {
}
};
}