private void toolStripTextBox_timKiem_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { loadDanhSachLienLac(LienLac.timKiem(toolStripTextBox_timKiem.Text)); } }
//tim kiếm private void TextBox1_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { string tenGoi = txttimkiem.Text; List <LienLac> lstSearch = LienLac.timLienLac(path1, tenGoi); dtgvlienlac.DataSource = lstSearch; } }
private void dataGridView_nhom_CellClick(object sender, DataGridViewCellEventArgs e) { bindingSource_lienLac.DataSource = LienLac.getContactList(pathDataContact, (bindingSource_nhom.Current as Nhom).MaNhom); dataGridView_lienLac.DataSource = bindingSource_lienLac; if (dataGridView_lienLac.Rows.Count > 0) { dataGridView_lienLac.Rows[0].Selected = false; } }
private void toolStripButton_xoaLienLac_Click(object sender, EventArgs e) { LienLac lienLac = LienLac.ParseLienLac(bindingSource_lienLac.Current as DataRowView); if (MessageBox.Show("Bạn có muốn xóa liên lạc \"" + lienLac.TenLienLac + "\" không?", "Xóa liên lạc", MessageBoxButtons.YesNo) == DialogResult.Yes) { bindingSource_lienLac.RemoveCurrent(); Nhom.xoaLienHeDatabase(lienLac.MaLienLac); } }
private void dataGridView_nhom_SelectionChanged(object sender, EventArgs e) { DataRowView nhom = (bindingSource_nhom.Current as DataRowView); if (nhom == null) { return; } loadDanhSachLienLac(LienLac.layDanhSachLienHe((int)nhom["MaNhom"])); }
// Refresh dtgvLienLac public void refreshDtgvLienLac() { dtgvnhom.CurrentRow.Selected = true; string tenNhom = dtgvnhom.SelectedCells[0].Value.ToString(); string maNhom = Nhom.getMaTuTenNhom(tenNhom, path); dtgvlienlac.AutoGenerateColumns = false; dtgvlienlac.DataSource = LienLac.getLienLacTuMaNhom(maNhom, path1); dtgvlienlac.Refresh(); }
private void button_them_Click(object sender, EventArgs e) { List <int> danhSachNhom = new List <int>(); foreach (DataRowView row in checkedListBox_nhom.CheckedItems) { Nhom nhom = Nhom.ParseNhom(row); danhSachNhom.Add(nhom.MaNhom); } LienLac.themLienLac(textBox_tenLienLac.Text, textBox_email.Text, textBox_soDienThoai.Text, textBox_diaChi.Text, danhSachNhom.ToArray()); DialogResult = DialogResult.OK; }
string path1 = @"C:\Users\USER\source\repos\KiemTra\KiemTra\DATA\lienlac.txt"; //path liên lạc public Form1() { InitializeComponent(); List <Nhom> nhom = Nhom.getNhomfromfile(path); dtgvnhom.AutoGenerateColumns = false; dtgvnhom.DataSource = nhom; List <LienLac> lienlac = LienLac.getLienlacfromfile(path1); dtgvlienlac.AutoGenerateColumns = false; dtgvlienlac.DataSource = lienlac; }
//kích chuột vào tên nhóm và hiển thị thông tin ra dtgv liên lạc private void Dtgvnhom_CellClick(object sender, DataGridViewCellEventArgs e) { int index = e.RowIndex; if (index >= 0) { DataGridViewRow selectRow = dtgvnhom.Rows[index]; string tenNhom = selectRow.Cells["TenNhom"].Value.ToString(); string maNhom = Nhom.getMaTuTenNhom(tenNhom, path); dtgvlienlac.AutoGenerateColumns = false; dtgvlienlac.DataSource = LienLac.getLienLacTuMaNhom(maNhom, path1); } }
private void Btnupdate_Click(object sender, EventArgs e) { string ten = txtten.Text; string email = txtema.Text; string sdt = txtso.Text; if (ten != null) { LienLac.add(maNhom, ten, email, sdt, path1); MessageBox.Show("Thêm thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); } DialogResult = System.Windows.Forms.DialogResult.OK; this.Close(); }
private void dataGridView_lienLac_SelectionChanged(object sender, EventArgs e) { LienLac lienLac = LienLac.ParseLienLac(bindingSource_lienLac.Current as DataRowView); if (lienLac == null) { textBox_ten.Text = ""; textBox_email.Text = ""; textBox_soDienThoai.Text = ""; textBox_diaChi.Text = ""; } else { textBox_ten.Text = lienLac.TenLienLac; textBox_email.Text = lienLac.Email; textBox_soDienThoai.Text = lienLac.SoDienThoai; textBox_diaChi.Text = lienLac.DiaChi; } }
// xóa liên lạc private void Btnxoalienlac_Click(object sender, EventArgs e) { if (MessageBox.Show("Bạn có Muốn Xóa?", "Thông báo", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == System.Windows.Forms.DialogResult.OK) { bool flag = dtgvlienlac.CurrentRow.Selected; if (flag) { string tenGoi = dtgvlienlac.SelectedCells[0].Value.ToString(); string Email = LienLac.getEmailTuTenGoi(tenGoi, path1); //Console.WriteLine(maNhom); LienLac.xoalienlac(Email, path1); } MessageBox.Show("Da xoa thanh cong!", "Thong bao", MessageBoxButtons.OK, MessageBoxIcon.Information); } //refersh refreshDtgvLienLac(); }