private void btnOK_Click(object sender, EventArgs e) { if (contact != null) { var name = txtName.Text; var phone = txtPhone.Text; var email = txtEmail.Text; ContactService.EditContactDB(contact.idContact, name, phone, email); } else { var name = txtName.Text; var phone = txtPhone.Text; var email = txtEmail.Text; ContactService.AddContactDB(name, phone, email, userName); } MessageBox.Show("Đã cập nhật dữ liệu thành công"); DialogResult = DialogResult.OK; }
private void btnDongY_Click(object sender, EventArgs e) { if (contact != null) { //cap nhat contact.Name = txtName.Text; contact.Email = txtEmail.Text; contact.Phone = txtPhone.Text; ContactService.EditContactDB(contact); } else { //them moi Contacts cont = new Contacts(); cont.IDContact = Guid.NewGuid().ToString(); cont.Name = txtName.Text; cont.Email = txtEmail.Text; cont.Phone = txtPhone.Text; cont.Username = user.Username; ContactService.AddContactDB(cont); } MessageBox.Show("Đã cập nhật thành công"); DialogResult = DialogResult.OK; // đóng form }