using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;

namespace lab6
{
    public partial class Form3 : Form
    {
        public Form3()
        {
            InitializeComponent();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            String kieutimkiem = comboBox1.SelectedItem.ToString();
            if (kieutimkiem == "ten")
            {
                String ten = "ten : " + textBox1.Text;
                String[] line = File.ReadAllLines(@"D:\\nghiadaica1.txt");
                for (int i = 0; i < line.Length; i++)
                {
                    if (ten.Trim() == line[i].Substring(0, line[i].IndexOf("\t")).Trim())
                    {
                        listBox1.Items.Add(line[i]);
                    }
                }
            }
            else
            {
                String sodienthoai = "so dien thoai "+textBox1.Text;
                String[] line = File.ReadAllLines(@"D:\\nghiadaica1.txt");
                for (int i = 0; i < line.Length; i++)
                {
                    String a = line[i];
                    int len = a.Length;
                    int batdau = line[i].LastIndexOf("\t");
                    String b = a.Substring(batdau, len);
                    if (sodienthoai.CompareTo(b)==0)
                    {
                        listBox1.Items.Add(line[i]);
                    }
                }
            }
        }
    }
}
