public first() { InitializeComponent(); sqlConnection = new SqlConnection(connectionString); MaterialSkinManager materialSkinManager = MaterialSkinManager.Instance; materialSkinManager.AddFormToManage(this); materialSkinManager.Theme = MaterialSkinManager.Themes.LIGHT; // Configure color schema materialSkinManager.ColorScheme = new ColorScheme( Primary.Indigo500, Primary.Indigo800, Primary.Indigo400, Accent.Red700, TextShade.WHITE); SqlConnection con = new SqlConnection(DBHelper.connectionString); string query = "select e.e_date,m.m_req,eve.eve_req,e.e_id from ExamTT as e,MorningExam as m,EveningExam as eve where e.e_id = m.e_id and e.e_id = eve.e_id and m.e_id = eve.e_id"; con.Open(); SqlCommand cmd = new SqlCommand(query, con); SqlDataReader dr = cmd.ExecuteReader(); DataTable dt = new DataTable(); dt.Load(dr); Dictionary <int, string> exam = new Dictionary <int, string>(); foreach (DataRow r in dt.Rows) { exam.Add(Int32.Parse(r[3].ToString()), r[0].ToString()); } dt.Columns.RemoveAt(3); gdvexam.DataSource = dt; gdvexam.Columns[0].HeaderText = "Date"; gdvexam.Columns[1].HeaderText = "Morning Requirments"; gdvexam.Columns[2].HeaderText = "Evening Requirments"; gdvexam.Columns[0].Width = 300; gdvexam.Columns[1].Width = 300; gdvexam.Columns[2].Width = 300; gdvexam.Columns[0].ReadOnly = true; gdvexam.ForeColor = System.Drawing.Color.Black; btndateselect.Iconimage = System.Drawing.Bitmap.FromFile("D:\\Supervision Allotment\\Login\\Icons\\Date To_96px.png"); btndel.Iconimage = System.Drawing.Bitmap.FromFile("D:\\Supervision Allotment\\Login\\Icons\\Trash_96px.png"); btnadd.Iconimage = System.Drawing.Bitmap.FromFile("D:\\Supervision Allotment\\Login\\Icons\\Classroom_96px.png"); bunifuFlatButton3.Iconimage = System.Drawing.Bitmap.FromFile("D:\\Supervision Allotment\\Login\\Icons\\Trash_96px.png"); btnallot.Iconimage = System.Drawing.Bitmap.FromFile("D:\\Supervision Allotment\\Login\\Icons\\Run Command_100px.png"); btnswap.Iconimage = System.Drawing.Bitmap.FromFile("D:\\Supervision Allotment\\Login\\Icons\\Replace_100px.png"); btndateselect.IconVisible = true; btndel.IconVisible = true; btnadd.IconVisible = true; bunifuFlatButton3.IconVisible = true; btnswap.IconVisible = true; btnallot.IconVisible = true; btnexport.IconVisible = true; string faculty_query = "select f_id,f_name,f_dept from Faculty"; DataTable dt_faculties = new DataTable(); SqlDataReader dtr = (new SqlCommand(faculty_query, con)).ExecuteReader(); dt_faculties.Load(dtr); Dictionary <int, Faculty> fac = new Dictionary <int, Faculty>(); foreach (DataRow r in dt_faculties.Rows) { fac.Add(Int32.Parse(r[0].ToString()), new Faculty(r[1].ToString(), Int32.Parse(r[2].ToString()))); } string allotment_query = "select * from Allotments"; DataTable dt_allotment_db = new DataTable(); dt_allotment_db.Load(new SqlCommand(allotment_query, con).ExecuteReader()); DataTable dt_allotments = new DataTable(); dt_allotments.Columns.Add("Date"); dt_allotments.Columns.Add("Faculty Name"); dt_allotments.Columns.Add("Shift"); dt_allotments.Columns.Add("Department"); DataRow datarow; foreach (DataRow drow in dt_allotment_db.Rows) { datarow = dt_allotments.NewRow(); int fid = Int32.Parse(drow[2].ToString()); datarow["Faculty Name"] = fac[fid].name; datarow["Department"] = Faculty.getDept(fac[fid].dept); if (Int32.Parse(drow[3].ToString()) == 1) { datarow["Shift"] = "Morning"; } else if (Int32.Parse(drow[3].ToString()) == 2) { datarow["Shift"] = "Evening"; } datarow["Date"] = exam[Int32.Parse(drow[1].ToString())]; dt_allotments.Rows.Add(datarow); } gdvallotment.DataSource = dt_allotments; gdvallotment.Columns[0].Width = 300; gdvallotment.Columns[1].Width = 300; gdvallotment.Columns[2].Width = 200; gdvallotment.Columns[3].Width = 250; gdvallotment.Columns[0].ReadOnly = true; gdvallotment.ForeColor = System.Drawing.Color.Black; dt_excel = dt_allotments; con.Close(); }