public void Input(string str) { StreamReader rd = new StreamReader(str); while (!rd.EndOfStream) { SinhVien sv = new SinhVien(); sv.maSV = rd.ReadLine(); sv.hoten = rd.ReadLine(); sv.gioitinh = rd.ReadLine(); sv.ngaysinh = DateTime.Parse(rd.ReadLine()); sv.quequan = rd.ReadLine(); sv.donvi = rd.ReadLine(); //int x; //if (int.TryParse(rd.ReadLine(), out x)) //{ // sv.cmnd.setSoCMND(x); //} sv.cmnd = rd.ReadLine(); sv.diem = Convert.ToDouble(rd.ReadLine()); rd.ReadLine(); lstSv.Add(sv); } rd.Close(); }
public bool Insert(SinhVien sv) { try { lstSv.Insert(lstSv.Count, sv); return true; } catch { return false; } }
public bool Insert(SinhVien sv, int i) { try { lstSv.Insert(i, sv); return true; } catch { return false; } }
public void LayGT() { sv = new SinhVien(); try { string Masv = ""; if (them == true) Masv = dsSV.SinhMaSV(); else Masv = txtMaSV.Text; sv = new SinhVien(Masv, txtHoTen.Text, txtGT.Text, dateTimePickerSV.Text, txtQueQuan.Text, txtDV.Text, txtCMND.Text, txtDiem.Text); } catch { } }
public bool Insert(SinhVien sv, bool dk) { try { if (dk == true) lstSv.Insert(0, sv); else { if (Insert(sv) == false) return false; } return true; } catch { return false; } }
public void SXTheoTen() { SinhVien[] arr = new SinhVien[lstSv.Count]; for (int i = 0; i < lstSv.Count; i++) arr[i] = lstSv[i]; Array.Sort(arr, new SXTenSV()); for (int i = 0; i < lstSv.Count; i++) lstSv[i] = arr[i]; }
public bool Edit(SinhVien sv, int i) { lstSv[i] = sv; return true; }
public List<SinhVien> Search(string strMa, string strTen, string diem) { List<SinhVien> list = new List<SinhVien>(); SinhVien sv = new SinhVien(); strMa = strMa.ToUpper(); strTen = strTen.ToUpper(); foreach(SinhVien s in lstSv) { string s1 = s.maSV.ToUpper(); string s2 = s.hoten.ToUpper(); string s3 = s.diem.ToString().ToUpper(); if (s1.Contains(strMa) == true && s2.Contains(strTen) && s3.Contains(diem) ) { list.Add(s); } } return list; }