public void Update(Carros c) { Database db = Database.GetInstance(); string qry = String.Format("UPDATE MotoresVenda SET M10 = {0}, P10 = {1}, M10T = {2}, P10T = {3}, M13 = {4}, P13 = {5}, M16 = {6}, P16 = {7}, M20 = {8}, P20 = {9}, M20T = {10}, P20T = {11} WHERE id = {12}", c.Motor.M10, c.Motor.P10, c.Motor.M10t, c.Motor.P10t, c.Motor.M13, c.Motor.P13, c.Motor.M16, c.Motor.P16, c.Motor.M20, c.Motor.P20, c.Motor.M20t, c.Motor.P20t, c.Motor.Id); db.ExecuteNonQuery(qry); }
public List <Carros> ListByName(string nome) { Database db = Database.GetInstance(); string qry = "SELECT * FROM carrosVenda nome LIKE '%" + nome + "%'"; DataSet ds = db.ExecuteQuery(qry); List <Carros> lc = new List <Carros>(); foreach (DataRow dr in ds.Tables[0].Rows) { Carros c = new Carros(); c.Cod = int.Parse(dr["Cod"].ToString()); c.Nome = dr["nome"].ToString(); c.Modelo = dr["modelo"].ToString(); c.MotorTexto = dr["motor"].ToString(); c.Motor.Id = int.Parse(dr["idMotores"].ToString()); c.TetoSolar = bool.Parse(dr["TetoSolar"].ToString()); c.Multimidia = bool.Parse(dr["Multimidia"].ToString()); c.LigaLeve = bool.Parse(dr["LigaLeve"].ToString()); c.PAdicional = double.Parse(dr["PAdicional"].ToString()); c.PrecoTotal = double.Parse(dr["PTotal"].ToString()); c.Codoriginal = int.Parse(dr["idCarro"].ToString()); lc.Add(c); } return(lc); }
public Carros Read(int key) { Database db = Database.GetInstance(); string qry = String.Format("SELECT * FROM MotoresVenda WHERE id = {0}", key); DataSet ds = db.ExecuteQuery(qry); Carros c = new Carros(); DataRow dr = ds.Tables[0].Rows[0]; c.Motor.Id = int.Parse(dr["id"].ToString()); c.Motor.M10 = bool.Parse(dr["M10"].ToString()); c.Motor.P10 = double.Parse(dr["P10"].ToString()); c.Motor.M10t = bool.Parse(dr["M10T"].ToString()); c.Motor.P10t = double.Parse(dr["P10T"].ToString()); c.Motor.M13 = bool.Parse(dr["M13"].ToString()); c.Motor.P13 = double.Parse(dr["P13"].ToString()); c.Motor.M16 = bool.Parse(dr["M16"].ToString()); c.Motor.P16 = double.Parse(dr["P16"].ToString()); c.Motor.M20 = bool.Parse(dr["M20"].ToString()); c.Motor.P20 = double.Parse(dr["P20"].ToString()); c.Motor.M20t = bool.Parse(dr["M20T"].ToString()); c.Motor.P20t = double.Parse(dr["P20T"].ToString()); return(c); }
public Carros Read(int key) { Database db = Database.GetInstance(); string qry = "SELECT * FROM carros c JOIN Motores m ON c.idMotores = m.id WHERE c.Cod =" + key; DataSet ds = db.ExecuteQuery(qry); Carros c = new Carros(); DataRow dr = ds.Tables[0].Rows[0]; c.Cod = int.Parse(dr["Cod"].ToString()); c.Nome = dr["nome"].ToString(); c.Modelo = dr["modelo"].ToString(); //c.Motor.Id = int.Parse(dr["idMotores"].ToString()); c.TetoSolar = bool.Parse(dr["TetoSolar"].ToString()); c.Multimidia = bool.Parse(dr["Multimidia"].ToString()); c.LigaLeve = bool.Parse(dr["LigaLeve"].ToString()); c.PAdicional = double.Parse(dr["PAdicional"].ToString()); c.Motor.Id = int.Parse(dr["id"].ToString()); c.Motor.M10 = bool.Parse(dr["M10"].ToString()); c.Motor.P10 = double.Parse(dr["P10"].ToString()); c.Motor.M10t = bool.Parse(dr["M10T"].ToString()); c.Motor.P10t = double.Parse(dr["P10T"].ToString()); c.Motor.M13 = bool.Parse(dr["M13"].ToString()); c.Motor.P13 = double.Parse(dr["P13"].ToString()); c.Motor.M16 = bool.Parse(dr["M16"].ToString()); c.Motor.P16 = double.Parse(dr["P16"].ToString()); c.Motor.M20 = bool.Parse(dr["M20"].ToString()); c.Motor.P20 = double.Parse(dr["P20"].ToString()); c.Motor.M20t = bool.Parse(dr["M20T"].ToString()); c.Motor.P20t = double.Parse(dr["P20T"].ToString()); return(c); }
public void Update(Carros c) { Database db = Database.GetInstance(); string qry = String.Format("UPDATE carrosVenda SET TetoSolar = '{0}', Multimidia = '{1}', LigaLeve = '{2}', nome = '{3}', modelo = '{4}', PAdicional = '{5}', PTotal = '{6}', motor = '{7}' WHERE id = {8};", c.TetoSolar, c.Multimidia, c.LigaLeve, c.Nome, c.Modelo, c.PAdicional, c.PrecoTotal, c.MotorTexto, c.Cod); db.ExecuteNonQuery(qry); }
public Vendas(Carros carro, Cliente cliente, double precoFinal, double juros, int nParcelas, int id, DateTime data) { this.carro = carro; this.cliente = cliente; this.precoFinal = precoFinal; this.juros = juros; this.nParcelas = nParcelas; this.id = id; this.data = data; }
public void Update(Carros c) { Database db = Database.GetInstance(); string qry = String.Format("UPDATE carros SET nome = '{0}', modelo = '{1}', TetoSolar = {2}, Multimidia = {3}, LigaLeve = {4}, PAdicional = {5} WHERE Cod = {6}", c.Nome, c.Modelo, c.TetoSolar, c.Multimidia, c.LigaLeve, c.PAdicional, c.Cod); db.ExecuteNonQuery(qry); // Motor.Update(c); //qry = String.Format("UPDATE carros SET M10 = {0}, P10 = {1}, M10T = {2}, P10T = {3}, M13 = {4}, P13 = {5}, M16 = {6}, P16 = {7}, M20 = {8}, P20 = {9}, M20T = {10}, P20T = {11}, WHERE idMotores = {12}", c.Motor.M10, c.Motor.P10, c.Motor.M10t, c.Motor.P10t, c.Motor.M13, c.Motor.P13, c.Motor.M16, c.Motor.P16, c.Motor.M20, c.Motor.P20, c.Motor.M20t, c.Motor.P20t, c.Motor.Id); }
public void Create(Carros c) { int key; Database dbConcessionaria = Database.GetInstance(); Motor.Create(c); key = Motor.Keymotores; string qry = String.Format("INSERT INTO carros(nome, modelo, idMotores, TetoSolar, Multimidia, Ligaleve, PAdicional) VALUES('{0}', '{1}', '{2}', {3}, {4}, {5}, '{6}');", c.Nome, c.Modelo, key, c.TetoSolar, c.Multimidia, c.LigaLeve, c.PAdicional); dbConcessionaria.ExecuteNonQuery(qry); }
public void Create(Carros c) { Database dbConcessionaria = Database.GetInstance(); string qry = String.Format("INSERT INTO MotoresVenda(M10, P10, M10T, P10T, M13, P13, M16, P16, M20, P20, M20T, P20T) VALUES({0}, {1}, {2}, {3}, {4}, {5}, {6}, {7}, {8}, {9}, {10}, {11});", c.Motor.M10, c.Motor.P10, c.Motor.M10t, c.Motor.P10t, c.Motor.M13, c.Motor.P13, c.Motor.M16, c.Motor.P16, c.Motor.M20, c.Motor.P20, c.Motor.M20t, c.Motor.P20t); dbConcessionaria.ExecuteNonQuery(qry); qry = String.Format("SELECT LAST_INSERT_ID();"); DataSet ds = dbConcessionaria.ExecuteQuery(qry); DataRow dr = ds.Tables[0].Rows[0]; Keymotores = int.Parse(dr["LAST_INSERT_ID()"].ToString()); }
public void Create(Carros c) { int key; Database dbConcessionaria = Database.GetInstance(); string qry = String.Format("INSERT INTO carrosVenda(nome, modelo, TetoSolar, Multimidia, Ligaleve, PAdicional, PTotal, idCarro, motor) VALUES('{0}', '{1}', '{2}', '{3}', '{4}', '{5}', '{6}', '{7}', '{8}');", c.Nome, c.Modelo, c.TetoSolar, c.Multimidia, c.LigaLeve, c.PAdicional, c.PrecoTotal, c.Cod, c.MotorTexto); dbConcessionaria.ExecuteNonQuery(qry); qry = String.Format("SELECT LAST_INSERT_ID();"); DataSet ds = dbConcessionaria.ExecuteQuery(qry); DataRow dr = ds.Tables[0].Rows[0]; KeyCarro = int.Parse(dr["LAST_INSERT_ID()"].ToString()); }
public Carros Read(int key) { Database db = Database.GetInstance(); string qry = "SELECT * FROM carrosVenda WHERE id =" + key; DataSet ds = db.ExecuteQuery(qry); Carros c = new Carros(); DataRow dr = ds.Tables[0].Rows[0]; c.Cod = int.Parse(dr["Id"].ToString()); c.Nome = dr["nome"].ToString(); c.Modelo = dr["modelo"].ToString(); c.MotorTexto = dr["motor"].ToString(); c.TetoSolar = bool.Parse(dr["TetoSolar"].ToString()); c.Multimidia = bool.Parse(dr["Multimidia"].ToString()); c.LigaLeve = bool.Parse(dr["LigaLeve"].ToString()); c.PAdicional = double.Parse(dr["PAdicional"].ToString()); c.PrecoTotal = double.Parse(dr["PTotal"].ToString()); c.Codoriginal = int.Parse(dr["idCarro"].ToString()); return(c); }
public List <Carros> ListAll() { Database db = Database.GetInstance(); string qry = "SELECT * FROM carros c JOIN Motores m ON c.idMotores = m.id"; DataSet ds = db.ExecuteQuery(qry); List <Carros> lc = new List <Carros>(); foreach (DataRow dr in ds.Tables[0].Rows) { Carros c = new Carros(); c.Cod = int.Parse(dr["Cod"].ToString()); c.Nome = dr["nome"].ToString(); c.Modelo = dr["modelo"].ToString(); c.Motor.Id = int.Parse(dr["idMotores"].ToString()); c.TetoSolar = bool.Parse(dr["TetoSolar"].ToString()); c.Multimidia = bool.Parse(dr["Multimidia"].ToString()); c.LigaLeve = bool.Parse(dr["LigaLeve"].ToString()); c.Motor.Id = int.Parse(dr["id"].ToString()); c.Motor.M10 = bool.Parse(dr["M10"].ToString()); c.Motor.P10 = double.Parse(dr["P10"].ToString()); c.Motor.M10t = bool.Parse(dr["M10T"].ToString()); c.Motor.P10t = double.Parse(dr["P10T"].ToString()); c.Motor.M13 = bool.Parse(dr["M13"].ToString()); c.Motor.P13 = double.Parse(dr["P13"].ToString()); c.Motor.M16 = bool.Parse(dr["M16"].ToString()); c.Motor.P16 = double.Parse(dr["P16"].ToString()); c.Motor.M20 = bool.Parse(dr["M20"].ToString()); c.Motor.P20 = double.Parse(dr["P20"].ToString()); c.Motor.M20t = bool.Parse(dr["M20T"].ToString()); c.Motor.P20t = double.Parse(dr["P20T"].ToString()); c.PAdicional = double.Parse(dr["PAdicional"].ToString()); lc.Add(c); } return(lc); }