-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSection3_consecutiveSessions.cs
207 lines (159 loc) · 7.79 KB
/
Section3_consecutiveSessions.cs
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
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
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 MySql.Data.MySqlClient;
using System.Collections;
namespace ABC_Institute___Timetable_Generator
{
public partial class Section3_consecutiveSessions : Form
{
string connectionString = @"SERVER=abcdatabase.mysql.database.azure.com;PORT=3306;DATABASE=mydb;UID=abcadmin@abcdatabase;PASSWORD=ABC@123abc";
public Section3_consecutiveSessions()
{
InitializeComponent();
fillTagGridsessions();
}
private void Button1_Click(object sender, EventArgs e)
{
this.Close();
}
private void button4_Click(object sender, EventArgs e)
{
var arlist = new ArrayList();
foreach (DataGridViewRow item in asdcs12.Rows)
{
if (bool.Parse(item.Cells[0].Value.ToString()))
{
arlist.Add(item.Cells[1].Value.ToString());
}
}
var session = arlist[0];
int count = arlist.Count;
for (int i = 0; i < count - 1; i++)
{
session = session + "," + arlist[i + 1];
}
using (MySqlConnection mySqlCon = new MySqlConnection(connectionString))
{
string Query = "insert into mydb.consecutivesessions(consecetive_sessions) values('" + session + "');";
MySqlCommand MyCommand2 = new MySqlCommand(Query, mySqlCon);
MySqlDataReader MyReader2;
mySqlCon.Open();
MyReader2 = MyCommand2.ExecuteReader(); // Here our query will be executed and data saved into the database.
MessageBox.Show("Consecutive Session Added" + Environment.NewLine + "Session IDs : " + session);
while (MyReader2.Read())
{
}
mySqlCon.Close();
}
}
private void button2_Click(object sender, EventArgs e)
{
// using (MySqlConnection mySqlCon = new MySqlConnection(connectionString))
// {
// mySqlCon.Open();
// MySqlDataAdapter sqlDa = new MySqlDataAdapter("sessiongetByGroupID", mySqlCon);
// sqlDa.SelectCommand.CommandType = CommandType.StoredProcedure;
// sqlDa.SelectCommand.Parameters.AddWithValue("_Group_ID", visalcmbconsegid.Text.Trim());
// DataTable datasessions = new DataTable();
// sqlDa.Fill(datasessions);
// visaldatagridconse.DataSource = datasessions;
// }
using (MySqlConnection mySqlCon = new MySqlConnection(connectionString))
{
mySqlCon.Open();
MySqlDataAdapter sqlDa = new MySqlDataAdapter("MasterTablefilterByGroupID", mySqlCon);
sqlDa.SelectCommand.CommandType = CommandType.StoredProcedure;
sqlDa.SelectCommand.Parameters.AddWithValue("_groupID", visalcmbconsegid.Text.Trim());
DataTable dataTags = new DataTable();
sqlDa.Fill(dataTags);
foreach (DataRow item in dataTags.Rows)
{
int aa = asdcs12.Rows.Add();
asdcs12.Rows[aa].Cells[0].Value = "false";
asdcs12.Rows[aa].Cells[1].Value = item["sessionID"].ToString();
asdcs12.Rows[aa].Cells[2].Value = item["LecID"].ToString();
asdcs12.Rows[aa].Cells[3].Value = item["lecturerName"].ToString();
asdcs12.Rows[aa].Cells[4].Value = item["GroupID"].ToString();
asdcs12.Rows[aa].Cells[5].Value = item["room"].ToString();
asdcs12.Rows[aa].Cells[6].Value = item["time"].ToString();
asdcs12.Rows[aa].Cells[7].Value = item["day"].ToString();
asdcs12.Rows[aa].Cells[8].Value = item["tag"].ToString();
asdcs12.Rows[aa].Cells[9].Value = item["subcode"].ToString();
}
{
int aa = asdcs12.Rows.Add();
asdcs12.Rows[aa].Cells[0].Value = "false";
asdcs12.Rows[aa].Cells[1].Value =null;
asdcs12.Rows[aa].Cells[2].Value = null;
asdcs12.Rows[aa].Cells[3].Value = null;
asdcs12.Rows[aa].Cells[4].Value = null;
asdcs12.Rows[aa].Cells[5].Value = null;
asdcs12.Rows[aa].Cells[6].Value = null;
asdcs12.Rows[aa].Cells[7].Value = null;
asdcs12.Rows[aa].Cells[8].Value = null;
asdcs12.Rows[aa].Cells[9].Value = null;
}
}
}
private void visaldatagridconse_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
}
public void fillTagGridsessions()
{
using (MySqlConnection mySqlCon = new MySqlConnection(connectionString))
{
// mySqlCon.Open();
// MySqlDataAdapter sqlDa = new MySqlDataAdapter("Select * from newsessions", mySqlCon);
//sqlDa.SelectCommand.CommandType = CommandType.StoredProcedure;
// DataTable dataTags = new DataTable();
// sqlDa.Fill(dataTags);
mySqlCon.Open();
MySqlDataAdapter sqlDa = new MySqlDataAdapter("getMasterTable", mySqlCon);
sqlDa.SelectCommand.CommandType = CommandType.StoredProcedure;
DataTable dataTags = new DataTable();
sqlDa.Fill(dataTags);
// vdataGridTags.DataSource = dataTags;
foreach (DataRow item in dataTags.Rows)
{
int aa = visaldatagridconse.Rows.Add();
visaldatagridconse.Rows[aa].Cells[0].Value = "false";
visaldatagridconse.Rows[aa].Cells[1].Value = item["sessionID"].ToString();
visaldatagridconse.Rows[aa].Cells[2].Value = item["LecID"].ToString();
visaldatagridconse.Rows[aa].Cells[3].Value = item["lecturerName"].ToString();
visaldatagridconse.Rows[aa].Cells[4].Value = item["GroupID"].ToString();
visaldatagridconse.Rows[aa].Cells[5].Value = item["room"].ToString();
visaldatagridconse.Rows[aa].Cells[6].Value = item["time"].ToString();
visaldatagridconse.Rows[aa].Cells[7].Value = item["day"].ToString();
visaldatagridconse.Rows[aa].Cells[8].Value = item["tag"].ToString();
visaldatagridconse.Rows[aa].Cells[9].Value = item["subcode"].ToString();
}
// visaldatagridconse.DataSource = dataTags;
}
}
private void visalcmbconsegid_SelectedIndexChanged(object sender, EventArgs e)
{
}
private void Section3_consecutiveSessions_Load(object sender, EventArgs e)
{
MySqlConnection cs = new MySqlConnection(connectionString);
MySqlDataAdapter grouplotdapter = new MySqlDataAdapter("SELECT * FROM groupinfo", cs);
DataTable groupDatatable = new DataTable();
grouplotdapter.Fill(groupDatatable);
visalcmbconsegid.Items.Clear();
for (int i = 0; i < groupDatatable.Rows.Count; i++)
{
visalcmbconsegid.Items.Add((groupDatatable.Rows[i]["GroupID"]));
}
}
private void tabPage3_Click(object sender, EventArgs e)
{
}
}
}