private void AddButton_Click(object sender, RoutedEventArgs e) { TCClass tmp = new TCClass(AddBox.Text); tmp.code = MainWindow.Class.Count; MainWindow.Class.Add(tmp); MainWindow.Class.Sort(delegate(TCClass x, TCClass y) { return(x.Name.CompareTo(y.Name)); }); for (int i = 0; i < MainWindow.Class.Count; ++i) { MainWindow.Class[i].code = i; } updatelistclass(); MessageBox.Show("Thêm lớp thành công!"); MainWindow.needupdateclass = true; }
public void InitalizeStudent() { // Student using (StreamReader str = new StreamReader("Data/StudentInfo.tcfile")) { string txt; while ((txt = str.ReadLine()) != null) { TCStudent tmpstu = new TCStudent(); tmpstu.FName = txt; tmpstu.LName = str.ReadLine(); tmpstu.Gender = str.ReadLine(); tmpstu.Class = int.Parse(str.ReadLine()); tmpstu.Code = int.Parse(str.ReadLine()); tmpstu.AbsentNum = int.Parse(str.ReadLine()); tmpstu.WrongSeatNum = int.Parse(str.ReadLine()); tmpstu.chkexist = bool.Parse(str.ReadLine()); tmpstu.ImgDir = str.ReadLine(); Student.Add(tmpstu); tfstudent.Add(false); tfseat.Add(false); } } // Class using (StreamReader str = new StreamReader("Data/ClassInfo.tcfile")) { string txt; while ((txt = str.ReadLine()) != null) { TCClass tmpstu = new TCClass(); tmpstu.Name = txt; tmpstu.chkexist = bool.Parse(str.ReadLine()); tmpstu.code = int.Parse(str.ReadLine()); int tmpnum = int.Parse(str.ReadLine()); for (int i = 0; i < tmpnum; ++i) { int tmpnum2 = int.Parse(str.ReadLine()); tmpstu.member.Add(tmpnum2); } tmpnum = int.Parse(str.ReadLine()); for (int i = 0; i < tmpnum; ++i) { int tmpnum2 = int.Parse(str.ReadLine()); tmpstu.seatdefine.Add(tmpnum2); } tmpnum = int.Parse(str.ReadLine()); for (int i = 0; i < tmpnum; ++i) { int tmpnum2 = int.Parse(str.ReadLine()); tmpstu.numseatperrow.Add(tmpnum2); } tmpstu.attnum = 0; Class.Add(tmpstu); } } // Add region AddBox4.Items.Add("Nam"); AddBox4.Items.Add("Nữ"); // Graph region foreach (TCClass x in Class) { Labels[x.code] = x.Name; SeriesCollection[0].Values.Add(0); SeriesCollection[1].Values.Add(x.member.Count); } }