public bool suaDichvu(DTO_dichvu dv) { try { conn.Open(); string SQL = string.Format( "UPDATE dbo.DICHVU SET TEN_DV='{0}',GIA='{1}' where MA_DV='{2}'", dv.TEN_DV, dv.GIA, dv.MA_DV); SqlCommand cmd = new SqlCommand(SQL, conn); int kq = cmd.ExecuteNonQuery(); if (kq > 0) { return(true); } } catch (Exception ex) { throw ex; } finally { conn.Close(); } return(false); }
public bool themDichvu(DTO_dichvu dv) { try { conn.Open(); string SQL = string.Format( "INSERT INTO dbo.DICHVU VALUES ('{0}',N'{1}','{2}')" , dv.MA_DV, dv.TEN_DV, dv.GIA); SqlCommand cmd = new SqlCommand(SQL, conn); int kq = (int)cmd.ExecuteNonQuery(); if (kq > 0) { return(true); } } catch (Exception ex) { throw ex; } finally { conn.Close(); } return(false); }
private void btnXoa_dv_Click(object sender, EventArgs e) { DTO_dichvu dichvu = new DTO_dichvu(txtMa_dv.Text, txtTendv.Text, txtGia.Text); if (bus_dichvu.xoaDichvu(dichvu)) { MessageBox.Show("xóa thành công"); dvgDichvu.DataSource = bus_dichvu.getDichvu(); } else { MessageBox.Show("xóa không thành công"); } }
private void btnThem_dv_Click(object sender, EventArgs e) { if (txtMa_dv.Text != "" && txtTendv.Text != "" && txtGia.Text != "") { DTO_dichvu dichvu = new DTO_dichvu(txtMa_dv.Text, txtTendv.Text, txtGia.Text); // thêm if (bus_dichvu.themDichvu(dichvu)) { MessageBox.Show("thêm thành công"); dvgDichvu.DataSource = bus_dichvu.getDichvu(); } else { MessageBox.Show("thêm không thành công"); } } else { MessageBox.Show("xin vui lòng nhập đủ thông tin"); } }
public bool xoaDichvu(DTO_dichvu dv) { try { conn.Open(); string SQL = string.Format("DELETE dbo.DICHVU WHERE MA_DV=N'{0}'", dv.MA_DV); SqlCommand cmd = new SqlCommand(SQL, conn); int kq = cmd.ExecuteNonQuery(); if (kq > 0) { return(true); } } catch (Exception ex) { throw ex; } finally { conn.Close(); } return(false); }
public bool xoaDichvu(DTO_dichvu dv) { return(dichvu.xoaDichvu(dv)); }
public bool suaDichvu(DTO_dichvu dv) { return(dichvu.suaDichvu(dv)); }
public bool themDichvu(DTO_dichvu dv) { return(dichvu.themDichvu(dv)); }