public bool IsExist(int masv) { for (int i = 0; i < listSV.Count;i++ ) { Sinh_Vien sv = new Sinh_Vien(); sv = (Sinh_Vien)listSV[i]; if(sv.getMaSV()==masv) { return true;///ma sinh vien da ton tai } } return false;//ma sinh vien chua ton tai }
public void ShowSearch(ArrayList list) { listView1.Items.Clear(); ArrayList dulieu = list; for (int i = 0; i < dulieu.Count; i++) { sv = (Sinh_Vien)dulieu[i]; ListViewItem item = new ListViewItem(sv.getMaSV().ToString()); item.SubItems.Add(sv.getHoten()); item.SubItems.Add(sv.getDiem().ToString()); listView1.Items.Add(item); listView1.View = View.Details; } }
//public void hienThiList() //{ // for (int i = 0; i < listSV.Count; i++) // { // Sinh_Vien sv = new Sinh_Vien(); // sv = (Sinh_Vien)listSV[i]; // } //} //public void readFile() //{ // Stream s = File.OpenRead("node.txt"); // StreamReader st = new StreamReader(s); // string str = st.ReadLine(); //} public void luuDL() { StreamWriter sw = new StreamWriter("Du lieu.txt"); int i; for (i = 0; i < listSV.Count; i++) { Sinh_Vien sv = new Sinh_Vien(); sv = (Sinh_Vien)listSV[i];//ép mỗi phần tử của arraylist về kiểu sinh viên sw.WriteLine(sv.getMaSV() + " " + sv.getHoten() + " " + sv.getDiem()); } sw.Flush(); sw.Close(); sw.Dispose(); }
public void loadData() { listView1.Items.Clear(); //string mang = sv.getMaSV() + " " + sv.getHoten() + " " + sv.getDiem(); ArrayList dulieu = DL.getDSSinhVienFromFile(); for (int i = 0; i < dulieu.Count;i++ ) { sv = (Sinh_Vien)dulieu[i]; // string[] arrayStr = mang.Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries); ListViewItem item = new ListViewItem(sv.getMaSV().ToString()); //item.SubItems.Add(sv.getMaSV().ToString()); item.SubItems.Add(sv.getHoten()); item.SubItems.Add(sv.getDiem().ToString()); listView1.Items.Add(item); listView1.View = View.Details; } }
public ArrayList searchDL(Sinh_Vien sv_,int index) { // for (int i=0; i < listSV.Count;i++ ) // { // Sinh_Vien sv = new Sinh_Vien(); // sv = (Sinh_Vien)listSV[i]; switch(index) { case 0: SearchSV(sv_.getMaSV());//masv break; case 1: SearchSV(sv_.getHoten());//ho ten break; case 2: SearchSV(sv_.getMaSV(),sv_.getHoten());//ho ten va maSV break; default: SearchSV(sv_.getMaSV());//masv break; } // if (sv.getMaSV() == sv_.getMaSV()&&sv.getHoten()==sv_.getHoten()) // { // // } return listSearch; }
public void hienthiSV(Sinh_Vien sv) { StreamWriter sw = new StreamWriter("Du lieu.txt"); sw.WriteLine(sv.getMaSV() + " " + sv.getHoten() + " " + sv.getDiem()); }
public void xoaDL(int masv) { for (int i= 0; i < listSV.Count; i++) { Sinh_Vien sv = new Sinh_Vien(); sv = (Sinh_Vien)listSV[i]; if (sv.getMaSV().ToString() == masv.ToString()) { listSV.RemoveAt(i); } //listSV.RemoveAt(i); } }
// int i; // ArrayList Items=new ArrayList(); public void timDL(int masv) { for (int i = 0; i < listSV.Count; i++) { Sinh_Vien sv = new Sinh_Vien(); sv = (Sinh_Vien)listSV[i]; if (sv.getMaSV() == masv) { hienthiSV(sv); break; } } }
public void suaDL(Sinh_Vien sv_) { for (int i=0; i < listSV.Count;i++ ) { Sinh_Vien sv = new Sinh_Vien(); sv = (Sinh_Vien)listSV[i]; if (sv.getMaSV() == sv_.getMaSV()) { listSV[i] = sv_; } } }
public ArrayList SearchSV(int masv,string strHoten) { listSearch.Clear(); for (int i = 0; i < listSV.Count; i++) { Sinh_Vien sv = new Sinh_Vien(); sv = (Sinh_Vien)listSV[i]; if (sv.getMaSV() == masv&&sv.getHoten()==strHoten) { listSearch.Add(sv); } } return listSearch; }