private void btnXoa_Click(object sender, EventArgs e) { if (MessageBox.Show("Bạn có chắc muốn xóa ?", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Hand) == DialogResult.Yes) { KHO k = new KHO(); k.MAKHO = txtMAKHO.Text; if (bllK.DeleteKho(k)) { ShowAllKho(); } else { MessageBox.Show("Lỗi", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
private void btnSua_Click(object sender, EventArgs e) { KHO k = new KHO(); k.MAKHO = txtMAKHO.Text; k.TENKHO = txtTENKHO.Text; k.DIACHIKHO = txtDIACHIKHO.Text; k.MATK = txtMATK.Text; if (bllK.UpdateKho(k)) { ShowAllKho(); } else { MessageBox.Show("Lỗi", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public bool DeleteKho(KHO k) { string sql = "DELETE KHO WHERE MAKHO = @MAKHO"; SqlConnection con = dc.getConnect(); try { cmd = new SqlCommand(sql, con); con.Open(); cmd.Parameters.Add("MAKHO", SqlDbType.NChar).Value = k.MAKHO; cmd.ExecuteNonQuery(); con.Close(); } catch (Exception e) { return(false); } return(true); }
public bool UpdateKho(KHO k) { string sql = "UPDATE KHO SET MAKHO = @MAKHO, TENKHO = @TENKHO, DIACHIKHO = @DIACHIKHO, MATK = @MATK WHERE MAKHO = @MAKHO"; SqlConnection con = dc.getConnect(); try { cmd = new SqlCommand(sql, con); con.Open(); cmd.Parameters.Add("@MAKHO", SqlDbType.NChar).Value = k.MAKHO; cmd.Parameters.Add("@TENKHO", SqlDbType.NVarChar).Value = k.TENKHO; cmd.Parameters.Add("@DIACHIKHO", SqlDbType.NVarChar).Value = k.DIACHIKHO; cmd.Parameters.Add("@MATK", SqlDbType.NChar).Value = k.MATK; cmd.ExecuteNonQuery(); con.Close(); } catch (Exception e) { return(false); } return(true); }
public bool InsertKho(KHO k) { string sql = "INSERT INTO KHO(MAKHO, TENKHO, DIACHIKHO, MATK) VALUES(@MAKHO, @TENKHO, @DIACHIKHO, @MATK)"; SqlConnection con = dc.getConnect(); try { cmd = new SqlCommand(sql, con); con.Open(); cmd.Parameters.Add("@MAKHO", SqlDbType.NChar).Value = k.MAKHO; cmd.Parameters.Add("@TENKHO", SqlDbType.NVarChar).Value = k.TENKHO; cmd.Parameters.Add("@DIACHIKHO", SqlDbType.NVarChar).Value = k.DIACHIKHO; cmd.Parameters.Add("@MATK", SqlDbType.NChar).Value = k.MATK; cmd.ExecuteNonQuery(); con.Close(); } catch (Exception e) { return(false); } return(true); }
public bool DeleteKho(KHO k) { return(dalK.DeleteKho(k)); }
public bool UpdateKho(KHO k) { return(dalK.UpdateKho(k)); }
public bool InsertKho(KHO k) { return(dalK.InsertKho(k)); }