-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFeedbackTrainer.cs
More file actions
178 lines (158 loc) · 6.13 KB
/
FeedbackTrainer.cs
File metadata and controls
178 lines (158 loc) · 6.13 KB
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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
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;
using System.Data.SqlClient;
namespace project
{
public partial class FeedbackTrainer : Form
{
int memberID;
int userID;
string memberName;
string rating;
string help;
string response;
string dicipline;
string comment;
public FeedbackTrainer()
{
InitializeComponent();
userID = 1;
LoadComboBoxDataWithMember();
}
public FeedbackTrainer(int trainerID)
{
InitializeComponent();
userID = trainerID;
LoadComboBoxDataWithMember();
}
private void Form5_Load(object sender, EventArgs e)
{
}
private void label8_Click(object sender, EventArgs e)
{
}
private void label9_Click(object sender, EventArgs e)
{
}
private void label1_Click(object sender, EventArgs e)
{
}
private void LoadComboBoxDataWithMember()
{
using (SqlConnection conn = new SqlConnection("Data Source=10N5Q8AKAMRA\\SQLEXPRESS;Initial Catalog=project;Integrated Security=True"))
{
string query = "SELECT member.memberID,member.mName FROM FeedbackTrainer inner join Member on FeedbackTrainer.memberID=member.memberID where FeedbackTrainer.trainerID=" + userID;
SqlCommand cmd = new SqlCommand(query, conn);
try
{
conn.Open();
SqlDataReader reader = cmd.ExecuteReader();
// Clear existing items in the ComboBox
comboBox1.Items.Clear();
// Add items manually
while (reader.Read())
{
// Assuming mealID is in the first column (index 0), and mealName is in the second column (index 1)
int mID = reader.GetInt32(0);
string mName = reader.GetString(1);
// You can combine mealID and mealName into a single string or use them separately as per your requirement
string item = mID.ToString() + " " + mName;
comboBox1.Items.Add(item);
}
}
catch (Exception ex)
{
MessageBox.Show("Error: " + ex.Message);
}
finally
{
conn.Close();
}
}
}
private void button1_Click(object sender, EventArgs e)
{
this.Hide();
trainer form = new trainer(userID);
form.Show();
form.FormClosed += (s, argc) => this.Close();
}
private void Home_Click(object sender, EventArgs e)
{
this.Hide();
trainer form = new trainer(userID);
form.Show();
form.FormClosed += (s, argc) => this.Close();
}
private void createworkoutplan_Click(object sender, EventArgs e)
{
this.Hide();
Trainer_Workout_Plan form = new Trainer_Workout_Plan();
form.Show();
form.FormClosed += (s, argc) => this.Close();
}
private void createdietplan_Click(object sender, EventArgs e)
{
this.Hide();
dietplanTrainer form = new dietplanTrainer();
form.Show();
form.FormClosed += (s, argc) => this.Close();
}
private void booktrainingsession_Click(object sender, EventArgs e)
{
this.Hide();
TrainingSessionRequest form = new TrainingSessionRequest(userID);
form.Show();
form.FormClosed += (s, argc) => this.Close();
}
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
if (comboBox1.SelectedItem != null)
{
// Split the selected value by ':' and retrieve the first part (mealID)
string selectedValue = comboBox1.SelectedItem.ToString();
string temp = "";
for (int i = 0; selectedValue[i] != ' '; i++)
{
temp += selectedValue[i];
}
memberID = Convert.ToInt32(temp);
}
SqlConnection conn = new SqlConnection("Data Source=10N5Q8AKAMRA\\SQLEXPRESS;Initial Catalog=project;Integrated Security=True");//connection string
conn.Open();
string query = "SELECT member.memberID,member.mName,FeedbackTrainer.rating,FeedbackTrainer.help,FeedbackTrainer.discipline,FeedbackTrainer.comment FROM FeedbackTrainer inner join Member on FeedbackTrainer.memberID=member.memberID where FeedbackTrainer.trainerID=" + userID + " and Member.memberID=" + memberID;
SqlCommand cmd = new SqlCommand(query, conn);
using (SqlDataReader reader = cmd.ExecuteReader())
{
if (reader.Read())
{
// Extract data from the reader
memberName = reader.GetString(1); // Assuming mName is the second column
rating = reader.GetInt32(2).ToString(); // Assuming rating is the third column
help = reader.GetInt32(3).ToString();
///response= reader.GetString(4).ToString();
dicipline = reader.GetInt32(4).ToString();
comment = reader.GetString(5);
label3.Text = memberName;
label9.Text = rating;
label6.Text = help;
//label5.Text = response;
label7.Text = dicipline;
label4.Text = comment;
}
else
{
Console.WriteLine("No data found for the specified criteria.");
}
}
conn.Close();
}
}
}