private void btnUpdate_Click(object sender, EventArgs e) { NCCPTien exited = NCCPTien.Single(Code); NCCPTien newAdd = controls_Load(); if (exited.TenNCC != newAdd.TenNCC) { if (NCCPTien.FindByTenNCC(newAdd.TenNCC) != null) { MessageBox.Show("This supplier had been exited!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); btnAdd.Enabled = false; return; } } int affected = NCCPTien.Update(newAdd); if (affected > 0) { MessageBox.Show("Updating is successfull!", "Kim Nguyễn say:", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); this.DialogResult = System.Windows.Forms.DialogResult.OK; this.Close(); } else { MessageBox.Show("Updating had been failse!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void btnAdd_Click(object sender, EventArgs e) { NCCPTien nc = NCCPTien.FindByTenNCC(txtName.Text); if (nc != null) { MessageBox.Show("This supplier had been exited!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); btnAdd.Enabled = false; return; } int affected = NCCPTien.Add(controls_Load()); if (affected > 0) { MessageBox.Show("Adding is successful!", "Kim Nguyễn say:", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); this.DialogResult = System.Windows.Forms.DialogResult.OK; this.Close(); } else { MessageBox.Show("Adding had been failse!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }