Beispiel #1
0
        private void Doc_Click(object sender, EventArgs e)
        {
            try
            {
                myList.clear(myList);                                          //Xóa hết dữ liệu đã tồn tại trong danh sách liên kết
                StreamReader rd = new StreamReader("Sach.txt", Encoding.UTF8); //Đọc file text
                if (rd == null)
                {
                    MessageBox.Show("Đọc file không thành công.", "THÔNG BÁO:");
                }
                string x = rd.ReadLine();           /// doc so cuon sach
                sosach = Convert.ToInt32(x);        ///
                for (int i = 0; i < sosach; i++)
                {
                    string x1 = rd.ReadLine();
                    dsChuoi.Add(x1);
                }
                for (int j = 0; j < sosach; j++)
                {
                    SACH     x2       = new SACH();
                    string[] thongtin = dsChuoi[j].Split('/');
                    x2.Nhap(thongtin[1], thongtin[2], thongtin[3], int.Parse(thongtin[4]));
                    myList.addHead(x2);
                }

                if (rd != null)
                {
                    MessageBox.Show("Lấy dữ liệu thành công.", "THÔNG BÁO:");
                }
                rd.Close();
            }
            catch (Exception ee) { MessageBox.Show(ee.Message); }
        }
Beispiel #2
0
        private void Button1_Click(object sender, EventArgs e)
        {
            masach   = textBox1.Text;
            tensach  = textBox2.Text;
            loaisach = textBox3.Text;
            dongia   = Convert.ToInt32(textBox4.Text);

            Std.Nhap(masach, tensach, loaisach, dongia);
            this.Close();
        }
Beispiel #3
0
 private void Button1_Click(object sender, EventArgs e)
 {
     if (tMaSach.Text.CompareTo("") == 0)
     {
         ktThem = 1;
     }
     else
     {
         temp.Nhap(tMaSach.Text, tTenSach.Text, tLoaiSach.Text, Convert.ToInt32(tDonGia.Text));
     }
     this.Close();
 }
Beispiel #4
0
        public void SearchNode(LinkedList myList, string x)
        {
            Node p = myList.Head;

            while (p != null)
            {
                SACH temp = new SACH(); //Biến nhớ kiểu sinh viên để đưa vào list
                if ((x == p.info.MaSach) || (x == p.info.TenSach) || (x == p.info.LoaiSach) || (x == p.info.DonGia.ToString()))
                {
                    temp.Nhap(p.info.MaSach, p.info.TenSach, p.info.LoaiSach, p.info.DonGia);
                    found.Add(temp);
                }
                p = p.Next;
            }
        }