public int getNrComenzi() { SqlCommand command = new SqlCommand(); command.CommandText = "Select * From Comenzi "; command.Connection = conn.getConnection(); DataTable table = new DataTable(); SqlDataAdapter adapter = new SqlDataAdapter(); adapter.SelectCommand = command; adapter.Fill(table); return(Convert.ToInt32(table.Rows.Count)); }
public static void stergere() { CONNECT conn = new CONNECT(); conn.openConnection(); SqlCommand command = new SqlCommand("DELETE FROM Meniu", conn.getConnection()); command.ExecuteNonQuery(); conn.closeConnection(); }
public DataTable getMeniu() { SqlCommand command = new SqlCommand(); command.CommandText = "Select id_produs As Id, denumire_Produs As Name, descriere As Description, Pret As Price, kcal As Kcal, Felul As Type From Meniu "; command.Connection = conn.getConnection(); DataTable table = new DataTable(); SqlDataAdapter adapter = new SqlDataAdapter(); adapter.SelectCommand = command; adapter.Fill(table); return(table); }
public int getClientId(string email) { SqlCommand command = new SqlCommand(); command.CommandText = "Select id_client From Clienti Where email=@em "; command.Connection = conn.getConnection(); command.Parameters.Add("em", SqlDbType.VarChar).Value = email; DataTable table = new DataTable(); SqlDataAdapter adapter = new SqlDataAdapter(); adapter.SelectCommand = command; adapter.Fill(table); return(Convert.ToInt32(table.Rows[0][0].ToString())); }
public static void intializare() { CONNECT conn = new CONNECT(); SqlCommand command = new SqlCommand(); StreamReader sr = new StreamReader(Application.StartupPath + @"\Resurse_C#\meniu.txt"); char[] split = { ';' }; string sir; conn.openConnection(); sir = sr.ReadLine(); while ((sir = sr.ReadLine()) != null) { string[] siruri = sir.Split(split); string query = "INSERT INTO Meniu(id_produs,denumire_produs,descriere,pret,kcal,felul) VALUES (@id,@nume,@desc,@pret,@kcal,@felul)"; //@id,@nume,@desc,@pret,@kcal,@felul //command.CommandText = query; //command.Connection = conn.getConnection(); command = new SqlCommand(query, conn.getConnection()); if (siruri[0].Trim() != "") { command.Parameters.Add("id", SqlDbType.Int).Value = Convert.ToInt32(siruri[0].Trim()); command.Parameters.Add("nume", SqlDbType.VarChar).Value = siruri[1].ToString(); command.Parameters.Add("desc", SqlDbType.NText).Value = siruri[2].ToString(); command.Parameters.Add("pret", SqlDbType.Int).Value = Convert.ToInt32(siruri[3].ToString()); command.Parameters.Add("kcal", SqlDbType.Int).Value = Convert.ToInt32(siruri[4].ToString()); command.Parameters.Add("felul", SqlDbType.Int).Value = Convert.ToInt32(siruri[5].ToString()); command.ExecuteNonQuery(); } } conn.closeConnection(); }