public async Task <IActionResult> Edit(int id, [Bind("FutarId,Nev")] Futar futar) { if (id != futar.FutarId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(futar); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!FutarExists(futar.FutarId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(futar)); }
public async Task <IActionResult> Create([Bind("FutarId,Nev")] Futar futar) { if (ModelState.IsValid) { _context.Add(futar); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(futar)); }
public void addFutarToList(Futar ujFutar) { try { futarok.Add(ujFutar); } catch (Exception e) { throw new RepositoryExceptionCantAdd("A futár hozzáadása nem sikerült"); } }
private void fillFutarListFromDataTable(DataTable futardt) { foreach (DataRow row in futardt.Rows) { int id = Convert.ToInt32(row[0]); string name = row[1].ToString(); string tel = row[2].ToString(); Futar f = new Futar(id, name, tel); futarok.Add(f); } }
private void buttonFutarUjMentes_Click(object sender, EventArgs e) { torolHibauzenetet(); errorProviderFutarNeve.Clear(); errorProviderFutarTel.Clear(); try { Futar ujF = new Futar( Convert.ToInt32(textBoxFutarAzonosito.Text), textBoxFutarNev.Text, textBoxFutarTel.Text ); int azonosito = Convert.ToInt32(textBoxFutarAzonosito.Text); //1. Hozzáadni a listához try { fr.addFutarToList(ujF); } catch (Exception ex) { kiirHibauzenetet(ex.Message); return; } //2. Hozzáadni az adatbázishoz RepositoryFutarDatabaseTable rfdt = new RepositoryFutarDatabaseTable(); try { rfdt.insertFutarToDatabase(ujF); } catch (Exception ex) { kiirHibauzenetet(ex.Message); } //3. Frissíteni a DataGridView-t updateFutarDGV(); beallitGombokatUjMegrendeloMegsemEsMentes(); if (dataGridViewFutar.SelectedRows.Count == 1) { setFutarDGV(); } } catch (ModelFutarNotValidNameExeption fnv) { errorProviderFutarNeve.SetError(textBoxFutarNev, fnv.Message); } catch (ModelFutarNotValidTelExeption ftv) { errorProviderFutarTel.SetError(textBoxFutarTel, ftv.Message); } catch (Exception ex) { } }
private void buttonModositFutar_Click(object sender, EventArgs e) { torolHibauzenetet(); errorProviderFutarNeve.Clear(); errorProviderFutarTel.Clear(); try { Futar modosult = new Futar( Convert.ToInt32(textBoxFutarAzonosito.Text), textBoxFutarNev.Text, textBoxFutarTel.Text ); int azonosito = Convert.ToInt32(textBoxFutarAzonosito.Text); //1. módosítani a listába try { fr.updateFutarInList(azonosito, modosult); } catch (Exception ex) { kiirHibauzenetet(ex.Message); return; } //2. módosítani az adatbáziba RepositoryFutarDatabaseTable rfdt = new RepositoryFutarDatabaseTable(); try { rfdt.updateFutarInDatabase(azonosito, modosult); } catch (Exception ex) { kiirHibauzenetet(ex.Message); } //3. módosítani a DataGridView-ban updateFutarDGV(); } catch (ModelFutarNotValidNameExeption fnv) { errorProviderFutarNeve.SetError(textBoxFutarNev, "Hiba a névben!"); } catch (ModelFutarNotValidTelExeption ftv) { errorProviderFutarTel.SetError(textBoxFutarTel, "Hiba a Telefonszámban!"); } catch (RepositoryExceptionCantModified recm) { kiirHibauzenetet(recm.Message); Debug.WriteLine("Módosítás nem sikerült, a megrendelő nincs a listába!"); } catch (Exception ex) { } }
public void updateFutarInList(int id, Futar modified) { Futar f = futarok.Find(x => x.getId() == id); if (f != null) { f.update(modified); } else { throw new RepositoryExceptionCantModified("A futár módosítása nem sikerült"); } }
public void deleteFutarFromList(int id) { Futar f = futarok.Find(x => x.getId() == id); if (f != null) { futarok.Remove(f); } else { throw new RepositoryExceptionCantDelete("A futárt nem lehetett törölni."); } }
private void fillFutarListFromDataTable(DataTable futardt) { foreach (DataRow row in futardt.Rows) { int azon = Convert.ToInt32(row[0]); string nev = row[1].ToString(); string lakcim = row[2].ToString(); string telefonszam = row[3].ToString(); string email = row[4].ToString(); Futar f = new Futar(azon, nev, lakcim, telefonszam, email); futarok.Add(f); } }
private static void FutarnakBeoszt(Futar futar, LancoltLista <IKuldemeny> kuldemenyek) { Func <IKuldemeny, bool> expr = x => !x.Beosztva && x.Tomeg + futar.AktalisTeher < futar.Kapacitas; IKuldemeny kov = kuldemenyek .Kovetkezo(expr); while (kov != null) { futar.Kuldemenyek.Add(kov); futar.AktalisTeher += kov.Tomeg; kov.Beosztva = true; kov = kuldemenyek.Kovetkezo(expr); } futar.TeleVan = true; }
public void deleteDataFromFutarTable() { MySqlConnection connection = new MySqlConnection(connectionString); try { connection.Open(); string query = Futar.getSQLCommandFutarDeleteAllRecord(); MySqlCommand cmd = new MySqlCommand(query, connection); cmd.ExecuteNonQuery(); } catch (Exception e) { connection.Close(); Debug.WriteLine(e.Message); throw new RepositoryException("Tesztadatok törlése sikertelen."); } }
public void updateFutarInDatabase(int id, Futar modified) { MySqlConnection connection = new MySqlConnection(connectionString); try { connection.Open(); string query = modified.getUpdateFutar(id); MySqlCommand cmd = new MySqlCommand(query, connection); cmd.ExecuteNonQuery(); connection.Close(); } catch (Exception e) { connection.Close(); Debug.WriteLine(e.Message); Debug.WriteLine(id + " idéjű futár módosítása nem sikerült."); throw new RepositoryException("Sikertelen módosítás az adatbázisból."); } }
public void insertFutarToDatabase(Futar ujFutar) { MySqlConnection connection = new MySqlConnection(connectionString); try { connection.Open(); string query = ujFutar.getInsertFutar(); MySqlCommand cmd = new MySqlCommand(query, connection); cmd.ExecuteNonQuery(); connection.Close(); } catch (Exception e) { connection.Close(); Debug.WriteLine(e.Message); Debug.WriteLine(ujFutar + " futár beszúrása adatbázisba nem sikerült."); throw new RepositoryException("Sikertelen beszúrás az adatbázisból."); } }
public List <Futar> getFutarFromDatabaseTable() { List <Futar> futar = new List <Futar>(); MySqlConnection connection = new MySqlConnection(connectionString); try { connection.Open(); string query = Futar.getSQLCommandGetAllRecord(); MySqlCommand cmd = new MySqlCommand(query, connection); MySqlDataReader dr; dr = cmd.ExecuteReader(); while (dr.Read()) { string name = dr["fnev"].ToString(); bool goodResult = false; int id = -1; goodResult = int.TryParse(dr["fazon"].ToString(), out id); if (goodResult) { int ig = -1; goodResult = int.TryParse(dr["fig"].ToString(), out ig); if (goodResult) { Futar p = new Futar(id, name, ig); futar.Add(p); } } } connection.Close(); } catch (Exception e) { connection.Close(); Debug.WriteLine(e.Message); throw new RepositoryException("Futár beolvasása az adatbázisból nem sikerült!"); } return(futar); }
public List <Futar> getFutarokFromDatabaseTable() { List <Futar> futarok = new List <Futar>(); MySqlConnection connection = new MySqlConnection(connectionString); try { connection.Open(); string query = Futar.getSQLCommandGetAllRecord(); MySqlCommand cmd = new MySqlCommand(query, connection); MySqlDataReader dr; dr = cmd.ExecuteReader(); while (dr.Read()) { string name = dr["nev"].ToString(); string address = dr["lakcim"].ToString(); string phonenumber = dr["telefonszam"].ToString(); string email = dr["email"].ToString(); bool goodResult = false; int id = -1; goodResult = int.TryParse(dr["id"].ToString(), out id); if (goodResult) { Futar f = new Futar(id, name, address, phonenumber, email); futarok.Add(f); } } connection.Close(); } catch (Exception e) { connection.Close(); Debug.WriteLine(e.Message); throw new RepositoryException("Futár adatok beolvasása az adatbázisból nem sikerült!"); } return(futarok); }
private void buttonFutarModosit_Click(object sender, EventArgs e) { torolHibauzenetet(); errorProviderFutarNev.Clear(); errorProviderFutarLakcim.Clear(); errorProviderFutarTelszam.Clear(); errorProviderFutarEmail.Clear(); try { Futar modosult = new Futar( Convert.ToInt32(textBoxFutarAzonosito.Text), textBoxFutarNev.Text, textBoxFutarLakcim.Text, textBoxFutarTelszam.Text, textBoxFutarEmail.Text ); int azonosito = Convert.ToInt32(textBoxFutarAzonosito.Text); //1. módosítani a listába try { futarRepo.updateFutarInList(azonosito, modosult); } catch (Exception ex) { kiirHibauzenetet(ex.Message); return; } //2. módosítani az adatbáziba RepositoryDatabaseTablePizza rdtp = new RepositoryDatabaseTablePizza(); try { rdtp.updateFutarInDatabase(azonosito, modosult); } catch (Exception ex) { kiirHibauzenetet(ex.Message); } //3. módosítani a DataGridView-ban frissitFutarAdatokkalDataGriedViewt(); } catch (ModelFutarNotValidNameExeption nvn) { errorProviderFutarNev.SetError(textBoxFutarNev, nvn.Message); } catch (ModelFutarNotValidAddressExeption nvp) { errorProviderFutarLakcim.SetError(textBoxFutarLakcim, nvp.Message); } catch (ModelFutarNotValidPhonenumberExeption nvp) { errorProviderFutarTelszam.SetError(textBoxFutarTelszam, nvp.Message); } catch (ModelFutarNotValidEmailExeption nvp) { errorProviderFutarEmail.SetError(textBoxFutarEmail, nvp.Message); } catch (RepositoryExceptionCantModified recm) { kiirHibauzenetet(recm.Message); Debug.WriteLine("Módosítás nem sikerült, a futár nincs a listába!"); } catch (Exception ex) { } }
private void buttonUjFutarMentes_Click(object sender, EventArgs e) { torolHibauzenetet(); errorProviderFutarNev.Clear(); errorProviderFutarLakcim.Clear(); errorProviderFutarTelefonszam.Clear(); errorProviderFutarEmail.Clear(); try { Futar ujFutar = new Futar( Convert.ToInt32(textBoxFutarAzon.Text), textBoxFutarNAME.Text, textBoxFutarADDRESS.Text, textBoxFutarPHONENUM.Text, textBoxFutarEMAIL.Text ); int azonosito = Convert.ToInt32(textBoxFutarAzon.Text); //1. Hozzáadni a listához try { futarRepo.addFutarToList(ujFutar); } catch (Exception ex) { kiirHibauzenetet(ex.Message); return; } //2. Hozzáadni az adatbázishoz RepositoryDatabaseTablePizza rdtp = new RepositoryDatabaseTablePizza(); try { rdtp.insertFutarToDatabase(ujFutar); } catch (Exception ex) { kiirHibauzenetet(ex.Message); } //3. Frissíteni a DataGridView-t beallitGombokatUjFutarMegsemEsMentes(); frissitFutarAdatokkalDataGriedViewt(); if (dataGridViewFutars.SelectedRows.Count == 1) { bealliFutartPizzaDataGriViewt(); } } catch (ModelFutarNotValidNameExeption nvn) { errorProviderFutarNev.SetError(textBoxFutarNAME, nvn.Message); } catch (ModelFutarNotValidLakcimExeption nvl) { errorProviderFutarLakcim.SetError(textBoxFutarADDRESS, nvl.Message); } catch (ModelFutarNotValidTelefonszamExeption nvt) { errorProviderFutarTelefonszam.SetError(textBoxFutarPHONENUM, nvt.Message); } catch (ModelFutarNotValidEmailExeption nve) { errorProviderFutarEmail.SetError(textBoxFutarEMAIL, nve.Message); } catch (Exception ex) { Debug.WriteLine(ex.Message); } }
private void buttonFutarMentese_Click(object sender, EventArgs e) { torolHibauzenetet(); errorProviderFutarNev.Clear(); errorProviderFutarLakcim.Clear(); errorProviderFutarTelszam.Clear(); errorProviderFutarEmail.Clear(); try { Futar ujFutar = new Futar( Convert.ToInt32(textBoxFutarAzonosito.Text), textBoxFutarNev.Text, textBoxFutarLakcim.Text, textBoxFutarTelszam.Text, textBoxFutarEmail.Text ); int azonosito = Convert.ToInt32(textBoxFutarAzonosito.Text); //1. Hozzáadni a listához try { futarRepo.addFutarToList(ujFutar); } catch (Exception ex) { kiirHibauzenetet(ex.Message); return; } //2. Hozzáadni az adatbázishoz RepositoryDatabaseTablePizza rdtp = new RepositoryDatabaseTablePizza(); try { rdtp.insertFutarToDatabase(ujFutar); } catch (Exception ex) { kiirHibauzenetet(ex.Message); } //3. Frissíteni a DataGridView-t beallitGombokatUjFutarMegsemEsMentes(); frissitFutarAdatokkalDataGriedViewt(); if (dataGridViewFutar.SelectedRows.Count == 1) { beallitFutarDataGriViewt(); } } catch (ModelFutarNotValidNameExeption nvn) { errorProviderFutarNev.SetError(textBoxFutarNev, nvn.Message); } catch (ModelFutarNotValidAddressExeption nvp) { errorProviderFutarLakcim.SetError(textBoxFutarLakcim, nvp.Message); } catch (ModelFutarNotValidPhonenumberExeption nvp) { errorProviderFutarTelszam.SetError(textBoxFutarTelszam, nvp.Message); } catch (ModelFutarNotValidEmailExeption nvp) { errorProviderFutarEmail.SetError(textBoxFutarEmail, nvp.Message); } catch (Exception ex) { } }