Exemple #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            int           k    = 0;
            List <DanhBa> DB   = DanhBa.GetNhom();
            string        path = Application.StartupPath + @"/TenNhom.txt";

            for (int i = 0; i < DB.Count; i++)
            {
                if (txtTenNhom.Text.Equals(DB[i].TenNhom))
                {
                    k = 1;
                }
            }
            if (k == 1)
            {
                MessageBox.Show("Tên Nhóm đã có trong cơ sở!");
            }
            else
            {
                String line = txtTenNhom.Text + System.Environment.NewLine;
                File.AppendAllText(path, line, Encoding.UTF8);
                MessageBox.Show("Thêm nhóm thành công!");
                this.Close();
            }
        }
        private void toolStripButton2_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("Bạn có thực sự muốn xóa", "Thông báo!", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == System.Windows.Forms.DialogResult.OK)
            {
                String   Tennhom = (string)sqdNhom.CurrentRow.Cells[0].Value;
                string   path    = Application.StartupPath + @"/TenNhom.txt";
                String[] lines   = File.ReadAllLines(path);
                File.WriteAllText(path, "");
                for (int i = 0; i < lines.Length; i++)
                {
                    string[] vd = lines[i].Split(new char[] { '#' });
                    if (vd[0].Equals(Tennhom) == false)
                    {
                        String line = vd[0] + Environment.NewLine;
                        File.AppendAllText(path, line, Encoding.UTF8);
                    }
                    else
                    {
                    }
                }
            }
            else
            {
            }
            List <DanhBa> Nhom = DanhBa.GetNhom();

            sqdNhom.DataSource = Nhom;
        }
        private void button1_Click(object sender, EventArgs e)
        {
            int           k       = 0;
            string        path    = Application.StartupPath + @"/lienlac.txt";
            List <DanhBa> tennhom = DanhBa.GetNhom();

            for (int i = 0; i < tennhom.Count; i++)
            {
                // MessageBox.Show(tennhom[i].TenNhom);
                if (txtNhom.Text.Equals(tennhom[i].TenNhom))
                {
                    k = 1;
                }
            }
            if (k == 0)
            {
                MessageBox.Show("Tên nhóm không có trong cơ sở!");
            }
            else
            {
                String line = txtNhom.Text + "#" + txtTenGoi.Text + "#" + txtEmail.Text + "#" + txtSdt.Text + System.Environment.NewLine;
                File.AppendAllText(path, line, Encoding.UTF8);
                MessageBox.Show("Đã thêm thành công!");
                this.Close();
            }
        }
        private void toolStripButton5_Click(object sender, EventArgs e)
        {
            List <DanhBa> Nhom = DanhBa.GetNhom();

            sqdNhom.AutoGenerateColumns    = false;
            sqdNhom.DataSource             = Nhom;
            sqdTenNhom.AutoGenerateColumns = false;
            List <DanhBa> DB = DanhBa.getDanhBa((string)sqdNhom.CurrentCell.Value);

            sqdTenNhom.DataSource = DB;
        }
        public Form1()
        {
            InitializeComponent();
            sqdNhom.AutoGenerateColumns = false;
            List <DanhBa> Nhom = DanhBa.GetNhom();

            sqdNhom.DataSource             = Nhom;
            sqdTenNhom.AutoGenerateColumns = false;
            List <DanhBa> DB = DanhBa.getDanhBa(Nhom[0].TenNhom);

            sqdTenNhom.DataSource = DB;
            label5.Text           = (string)DB[0].Email;
            label6.Text           = (string)DB[0].SoDt;
            label7.Text           = (string)DB[0].TenGoi;
        }