private void button1_Click(object sender, EventArgs e) { int date = new int(); date = 0; keeys ky = new keeys(); attendValues val = new attendValues(); foreach (var s in attend) { if (use.student_id == s.Key.s_id && use.course_id == s.Key.c_id) { if (date < s.Key.week) { date = s.Key.week; } } } date++; ky.c_id = use.course_id; ky.s_id = use.student_id; ky.week = date; if (comboBox1.selectedIndex == 0) { val.attendance = "Yes"; } else { val.attendance = "No"; } val.e_id = use.user_id; attend.Add(ky, val); insertdata(ky.s_id, ky.c_id, val.e_id, ky.week, val.attendance); }
//------------------------------------------------------------------------------------------------------------------------------------------------- public Dictionary <keeys, attendValues> dataattendance() { SqlConnection con = new SqlConnection("Data Source=.;Initial Catalog=DSProject;Integrated Security=True"); con.Open(); SqlDataAdapter reader3 = new SqlDataAdapter("select * from Attendance ", con); DataTable dt = new DataTable(); reader3.Fill(dt); foreach (DataRow dr in dt.Rows) { keeys key1 = new keeys(); attendValues value1 = new attendValues(); key1.c_id = (int)dr["C_ID"]; key1.s_id = (int)dr["S_ID"]; key1.week = (int)dr["week"]; value1.attendance = (string)dr["_status"]; value1.e_id = (int)dr["Emp_Id"]; attend.Add(key1, value1); } con.Close(); return(attend); }