private void button9_Click(object sender, EventArgs e) { try { DialogResult dg = new DialogResult(); dg = MessageBox.Show("Bạn có muốn xóa không", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dg == DialogResult.Yes) { NgCPobject ng = new NgCPobject(); ng.Tenngcp = textBox6.Text; ng.Cmt = textBox7.Text; ng.Makh = textBox8.Text; if (radNAM.Checked == true) { ng.Gt = radNAM.Text; } else { ng.Gt = radNU.Text; } NgCPcontrol.deleteNCP(ng); dataNCP.DataSource = NgCPcontrol.getdataNCP(); } } catch { } }
public void updateNCP(NgCPobject nguoi) { kn.connect(); SqlCommand cmd = new SqlCommand("UPDATENCP", kn.con); cmd.CommandType = CommandType.StoredProcedure; SqlParameter p = new SqlParameter("@TENNCP", nguoi.Tenngcp); cmd.Parameters.Add(p); p = new SqlParameter("@CMT", nguoi.Cmt); cmd.Parameters.Add(p); p = new SqlParameter("@MAKH", nguoi.Makh); cmd.Parameters.Add(p); p = new SqlParameter("@GT", nguoi.Gt); cmd.Parameters.Add(p); int count = cmd.ExecuteNonQuery(); if (count > 0) { MessageBox.Show("Sửa thành công"); } else { MessageBox.Show("Không thể sửa @@@"); } kn.disconnect(); }
private void button8_Click(object sender, EventArgs e) { try { NgCPobject ng = new NgCPobject(); ng.Tenngcp = textBox6.Text; ng.Cmt = textBox7.Text; ng.Makh = textBox8.Text; if (this.radNAM.Checked == true) { ng.Gt = radNAM.Text; } if (this.radNU.Checked == true) { ng.Gt = radNU.Text; } NgCPcontrol.updateNCP(ng); dataNCP.DataSource = NgCPcontrol.getdataNCP(); } catch { } }
public void deleteNCP(NgCPobject nguoi) { kn.connect(); SqlCommand cmd = new SqlCommand("DELETENCP", kn.con); cmd.CommandType = CommandType.StoredProcedure; SqlParameter p = new SqlParameter("@CMT", nguoi.Cmt); cmd.Parameters.Add(p); int count = cmd.ExecuteNonQuery(); if (count > 0) { MessageBox.Show("Xóa thành công"); } else { MessageBox.Show("Không thể Xóa!!!"); } kn.disconnect(); }
public static void deleteNCP(NgCPobject nguoi) { NgCPmodel ng = new NgCPmodel(); ng.deleteNCP(nguoi); }
public static void addNCP(NgCPobject nguoi) { NgCPmodel ng = new NgCPmodel(); ng.addNCP(nguoi); }