public int sua(phong ph) { SqlConnection con = Config.getConnect(); DataTable dt = new DataTable(); if (con.State == ConnectionState.Closed) { con.Open();// mo ket noi sql } string sqlstr = "update Phong set TinhTrang = '" + ph.getTinhTrang() + "',GiaPhong = " + ph.getGiaPhong() + ",LoaiPhong = '" + ph.getLoaiPhong() + "' where MaPhong = '" + ph.getMaPhong() + "'"; SqlCommand cmd = new SqlCommand(sqlstr, con); try { int sa = cmd.ExecuteNonQuery(); con.Close(); return(sa); } catch { throw; } }
public int themPhong(phong ph) { SqlConnection con = Config.getConnect(); DataTable dt = new DataTable(); if (con.State == ConnectionState.Closed) { con.Open();// mo ket noi sql } string sqlstr = "INSERT INTO Phong values ('" + ph.getMaPhong() + "', '" + ph.getTinhTrang() + "', " + ph.getGiaPhong() + ",'" + ph.getLoaiPhong() + "')"; SqlCommand cmd = new SqlCommand(sqlstr, con); try { int add = cmd.ExecuteNonQuery(); con.Close(); return(add); } catch { throw; } }