public static bool sqlDelete(Atributo attr) { String sql = String.Format("DELETE FROM atributos WHERE idatributos = '{0}'" , attr.Id ); return BD.getInstance().sqlEjecuta(sql); }
// ============= custom ============ // public static bool existsName(Atributo attr) { String sql = String.Format("SELECT * FROM atributos WHERE atributo = '{0}'", attr.Attr); DataTable dt = BD.getInstance().sqlSelect(sql); if (dt.Rows.Count == 0) return false; return true; }
public static bool sqlUpdate(Atributo attr) { String sql = String.Format("UPDATE atributos SET atributo = '{0}', textarea = '{1}' WHERE idatributos = '{2}'" , attr.Attr , attr.Textarea , attr.Id ); return BD.getInstance().sqlEjecuta(sql); }
public static bool sqlLeer(Atributo attr) { String sql = String.Format("SELECT * FROM atributos WHERE idatributos = '{0}'" , attr.Id); DataTable dt = BD.getInstance().sqlSelect(sql); if (dt.Rows.Count == 0) return false; attr.Attr = dt.Rows[0]["atributo"].ToString(); attr.Textarea = int.Parse(dt.Rows[0]["textarea"].ToString()); return true; }
public static Boolean sqlInsert(Atributo attr) { if (!existsName(attr)) { String sql = String.Format("INSERT INTO atributos (atributo, textarea) VALUES ('{0}', '{1}')" , attr.Attr , attr.Textarea ); return BD.getInstance().sqlEjecuta(sql); } return false; }