public Marke getMarke(int id) { Marke marke = new Marke(); string conn = ConfigurationManager.ConnectionStrings["MysqlConnection"].ConnectionString; MySqlConnection mySqlConnection = new MySqlConnection(conn); string sqlquery = @"SELECT m.kinostudijosid, m.kspavadinimas FROM " + Globals.dbPrefix + "kinostudjia m WHERE m.kinostudijosid=" + id; MySqlCommand mySqlCommand = new MySqlCommand(sqlquery, mySqlConnection); mySqlConnection.Open(); MySqlDataAdapter mda = new MySqlDataAdapter(mySqlCommand); DataTable dt = new DataTable(); mda.Fill(dt); mySqlConnection.Close(); foreach (DataRow item in dt.Rows) { marke.id = Convert.ToInt32(item["kinostudijosid"]); marke.pavadinimas = Convert.ToString(item["kspavadinimas"]); } return(marke); }
public Marke getMarke(int kodas) { Marke marke = new Marke(); string conn = ConfigurationManager.ConnectionStrings["MysqlConnection"].ConnectionString; MySqlConnection mySqlConnection = new MySqlConnection(conn); string sqlquery = @"SELECT m.kodas, m.pavadinimas FROM marke m WHERE m.kodas=" + kodas; MySqlCommand mySqlCommand = new MySqlCommand(sqlquery, mySqlConnection); mySqlConnection.Open(); MySqlDataAdapter mda = new MySqlDataAdapter(mySqlCommand); DataTable dt = new DataTable(); mda.Fill(dt); mySqlConnection.Close(); foreach (DataRow item in dt.Rows) { marke.kodas = Convert.ToInt32(item["kodas"]); marke.pavadinimas = Convert.ToString(item["pavadinimas"]); } return(marke); }
public async Task <IActionResult> Edit(int id, [Bind("MarkeId,MarkeName")] Marke marke) { if (id != marke.MarkeId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(marke); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!MarkeExists(marke.MarkeId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(marke)); }
public async Task <IActionResult> Create([Bind("MarkeId,MarkeName")] Marke marke) { if (ModelState.IsValid) { _context.Add(marke); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(marke)); }
public bool addMarke(Marke marke) { string conn = ConfigurationManager.ConnectionStrings["MysqlConnection"].ConnectionString; MySqlConnection mySqlConnection = new MySqlConnection(conn); string sqlquery = @"INSERT INTO " + Globals.dbPrefix + "pareigos(pareigospavadinimas,pareigosid)VALUES(?pv,?pid)"; MySqlCommand mySqlCommand = new MySqlCommand(sqlquery, mySqlConnection); mySqlCommand.Parameters.Add("?pv", MySqlDbType.VarChar).Value = marke.pavadinimas; mySqlCommand.Parameters.Add("?pid", MySqlDbType.VarChar).Value = marke.id; mySqlCommand.ExecuteNonQuery(); mySqlConnection.Close(); return(true); }
public bool updateMarke(Marke marke) { string conn = ConfigurationManager.ConnectionStrings["MysqlConnection"].ConnectionString; MySqlConnection mySqlConnection = new MySqlConnection(conn); string sqlquery = @"UPDATE " + Globals.dbPrefix + "kinostudija a SET a.kspavadinimas=?kspavadinimas WHERE a.kinostudijosid=?kinostudijosid"; MySqlCommand mySqlCommand = new MySqlCommand(sqlquery, mySqlConnection); mySqlCommand.Parameters.Add("?kinostudijosid", MySqlDbType.VarChar).Value = marke.id; mySqlCommand.Parameters.Add("?kspavadinimas", MySqlDbType.VarChar).Value = marke.pavadinimas; mySqlConnection.Open(); mySqlCommand.ExecuteNonQuery(); mySqlConnection.Close(); return(true); }
public bool updateMarke(Marke marke) { string conn = ConfigurationManager.ConnectionStrings["MysqlConnection"].ConnectionString; MySqlConnection mySqlConnection = new MySqlConnection(conn); string sqlquery = @"UPDATE marke a SET a.pavadinimas=?pavadinimas WHERE a.kodas=?kodas"; MySqlCommand mySqlCommand = new MySqlCommand(sqlquery, mySqlConnection); mySqlCommand.Parameters.Add("?kodas", MySqlDbType.VarChar).Value = marke.kodas; mySqlCommand.Parameters.Add("?pavadinimas", MySqlDbType.VarChar).Value = marke.pavadinimas; mySqlConnection.Open(); mySqlCommand.ExecuteNonQuery(); mySqlConnection.Close(); return(true); }
public bool addMarke(Marke marke) { int kodas = getNewId(); string conn = ConfigurationManager.ConnectionStrings["MysqlConnection"].ConnectionString; MySqlConnection mySqlConnection = new MySqlConnection(conn); string sqlquery = @"INSERT INTO marke(kodas,pavadinimas)VALUES(?kodas,?pavadinimas)"; MySqlCommand mySqlCommand = new MySqlCommand(sqlquery, mySqlConnection); mySqlCommand.Parameters.Add("?pavadinimas", MySqlDbType.VarChar).Value = marke.pavadinimas; mySqlCommand.Parameters.Add("?kodas", MySqlDbType.VarChar).Value = kodas; marke.kodas = kodas; mySqlConnection.Open(); mySqlCommand.ExecuteNonQuery(); mySqlConnection.Close(); return(true); }
public ActionResult Edit(int id, Marke collection) { try { // atnajina markes informacija if (ModelState.IsValid) { markeRepository.updateMarke(collection); } return(RedirectToAction("Index")); } catch { return(View(collection)); } }
public ActionResult Create(Marke collection) { try { // išsaugo nauja markę duomenų bazėje if (ModelState.IsValid) { markeRepository.addMarke(collection); } return(RedirectToAction("Index")); } catch { return(View(collection)); } }
public Hatchback(Marke marke) : base(marke) { }
public Sedan(Marke marke) : base(marke) { }
protected Car(Marke marke) { this.marke = marke; }
public async Task PopuniVozila() { if (Marke.Count == 0) { var marke = await _marke.Get <IEnumerable <Marke> >(null); foreach (var item in marke) { Marke.Add(item); } } if (Tipovi.Count == 0) { var tipovi = await _tipVozila.Get <IEnumerable <TipoviVozila> >(null); foreach (var item in tipovi) { Tipovi.Add(item); } } if (Transmisija.Count == 0) { var transmisija = await _transmisija.Get <IEnumerable <Transmisija> >(null); foreach (var item in transmisija) { Transmisija.Add(item); } } if (MarkaSearch != null || TipSearch != null || TransSearch != null) { VozilaSearchRequest search = new VozilaSearchRequest(); if (MarkaSearch != null) { search.MarkaId = MarkaSearch.MarkaId; MarkaSearch = null; } if (TransSearch != null) { search.TransmisijaId = TransSearch.TransmisijaId; TransSearch = null; } if (TipSearch != null) { search.TipVozilaId = TipSearch.TipVozilaId; TipSearch = null; } var listM = await _vozila.Get <IEnumerable <VozilaM> >(search); VozilaList.Clear(); foreach (var item in listM) { VozilaList.Add(item); } return; } if (MarkaSearch == null && TipSearch == null && TransSearch == null) { var list = await _vozila.Get <IEnumerable <VozilaM> >(null); VozilaList.Clear(); foreach (var item in list) { VozilaList.Add(item); } } }
// GET: Marke/Create public ActionResult Create() { Marke marke = new Marke(); return(View(marke)); }
internal static void Initialize(CarDbContext context) { context.Database.EnsureCreated(); if (!context.Markes.Any()) { var Markes = new Marke[] { new Marke { Name = "Tesla" }, new Marke { Name = "BMW" }, new Marke { Name = "Ferrari" }, new Marke { Name = "Mini" }, new Marke { Name = "Jaguar" }, new Marke { Name = "Land Rover" }, new Marke { Name = "Mercedes-Benz" }, new Marke { Name = "Porsche" }, new Marke { Name = "Hyundai" }, new Marke { Name = "Volkswagen" }, new Marke { Name = "Ford" }, new Marke { Name = "Toyota" }, }; context.Markes.AddRange(Markes); context.SaveChanges(); if (!context.Cars.Any()) { var cars = new Car[] { new Car { ModelName = "MINI Cooper 5 DOOR", Marke = Markes[6].Name, Color = "blue", ProductionYear = 2013 }, new Car { ModelName = "Ferrari Pininfarina Sergio Concept", Marke = Markes[6].Name, Color = "green", ProductionYear = 2013 }, new Car { ModelName = "BMW M5 E39", Marke = Markes[6].Name, Color = "Black", ProductionYear = 2018 }, new Car { ModelName = "Tesla S", Marke = Markes[0].Name, Color = "white", ProductionYear = 2019 }, new Car { ModelName = "Mercedes 300 SLR", Marke = Markes[10].Name, Color = "golden", ProductionYear = 2017 }, new Car { ModelName = "Porsche Cayman GT4", Marke = Markes[1].Name, Color = "silver", ProductionYear = 2016 } }; context.Cars.AddRange(cars); context.SaveChanges(); } } }