private int ChkPlane(ModelloAereo mod, string tabella) { SqlCommand sqlComm = new SqlCommand("Select * from " + tabella + " where Codice like '" + mod.code + "'", _sqlConn); SqlDataReader sqr = sqlComm.ExecuteReader(); if (sqr.HasRows) { sqr.Read(); int id = (int)sqr[0]; sqr.Close(); return(id); } sqr.Close(); return(-1); }
public int AddModAliante(ModelloAereo mod) { Connect(); int id = ChkPlane(mod, "ModelloAliante"); if (id != -1) { return(id); } SqlCommand sqlComm = new SqlCommand("insertModelloAliante", _sqlConn); sqlComm.CommandType = System.Data.CommandType.StoredProcedure; sqlComm.Parameters.Add("codice", mod.code); sqlComm.Parameters.Add("modello", mod.model); sqlComm.ExecuteNonQuery(); id = ChkPlane(mod, "ModelloAliante"); Close(); return(id); }