public void insertComanda(int idClient, DateTime dataC) { SqlCommand command = new SqlCommand(); command.CommandText = "INSERT INTO Comenzi(id_client,data_comanda) VALUES(@id,@data)"; command.Connection = conn.getConnection(); command.Parameters.Add("id", SqlDbType.Int).Value = idClient; command.Parameters.Add("data", SqlDbType.DateTime).Value = dataC; conn.openConnection(); command.ExecuteNonQuery(); conn.closeConnection(); }
public void insertClient(string nume, string pre, string pass, string address, string email) { SqlCommand command = new SqlCommand(); command.CommandText = "INSERT INTO Clienti(nume,parola,prenume,adresa,email) VALUES(@nm,@par,@pre,@add,@em) "; command.Connection = conn.getConnection(); command.Parameters.Add("nm", SqlDbType.VarChar).Value = nume; command.Parameters.Add("par", SqlDbType.VarChar).Value = pass; command.Parameters.Add("pre", SqlDbType.VarChar).Value = pre; command.Parameters.Add("add", SqlDbType.VarChar).Value = address; command.Parameters.Add("em", SqlDbType.VarChar).Value = email; conn.openConnection(); command.ExecuteNonQuery(); conn.closeConnection(); }
public static void stergere() { CONNECT conn = new CONNECT(); conn.openConnection(); SqlCommand command = new SqlCommand("DELETE FROM Meniu", conn.getConnection()); command.ExecuteNonQuery(); conn.closeConnection(); }
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(); }