public Zbor findOne(int id) { log.InfoFormat("Entering findOne with value {0}", id); IDbConnection con = DBUtils.getConnection(props); using (var comm = con.CreateCommand()) { comm.CommandText = "select * from Zboruri where ID=@id"; IDbDataParameter paramId = comm.CreateParameter(); paramId.ParameterName = "@id"; paramId.Value = id; comm.Parameters.Add(paramId); using (var dataR = comm.ExecuteReader()) { if (dataR.Read()) { int IdZ = dataR.GetInt32(0); String Destinatie = dataR.GetString(1); String PlecareS = dataR.GetString(2); DateTime Plecare = DateTime.Parse(PlecareS); String Aeroport = dataR.GetString(3); int Locuri = dataR.GetInt32(4); Zbor z = new Zbor(IdZ, Destinatie, Plecare, Aeroport, Locuri); log.InfoFormat("Exiting findOne with value {0}", z); return(z); } } } log.InfoFormat("Exiting findOne with value {0}", null); return(null); }
public IEnumerable <Zbor> FindByDestinatieAndPlecare(string destinatie, string plecare) { IDbConnection con = DBUtils.getConnection(props); IList <Zbor> zborR = new List <Zbor>(); using (var comm = con.CreateCommand()) { comm.CommandText = "select * from Zboruri where Destinatia=@dest and DATE(Plecare) = @plecare"; IDbDataParameter paramDestinatie = comm.CreateParameter(); paramDestinatie.ParameterName = "@dest"; paramDestinatie.Value = destinatie; comm.Parameters.Add(paramDestinatie); IDbDataParameter paramPlecare = comm.CreateParameter(); paramPlecare.ParameterName = "@plecare"; paramPlecare.Value = plecare; comm.Parameters.Add(paramPlecare); using (var dataR = comm.ExecuteReader()) { while (dataR.Read()) { int IdZ = dataR.GetInt32(0); String Destinatie = dataR.GetString(1); String PlecareS = dataR.GetString(2); DateTime Plecare = DateTime.Parse(PlecareS); String Aeroport = dataR.GetString(3); int Locuri = dataR.GetInt32(4); Zbor zbor = new Zbor(IdZ, Destinatie, Plecare, Aeroport, Locuri); zborR.Add(zbor); } } } return(zborR); }
//Functie de adaugare zbor private void adaugaZbor() { Zbor nouZbor = new Zbor(this.companie, cod.Text, tipAvion.Text, int.Parse(nrLocuriBus.Text), float.Parse(pretBus.Text), int.Parse(nrLocEc.Text), float.Parse(pretEc.Text), Plecare.Text, dataPlecare.Text, oraPlecare.Text, sosire.Text, dataSosire.Text, oraSosire.Text); nouZbor.add(); clc(); }
public IEnumerable <Zbor> findAll() { IDbConnection con = DBUtils.getConnection(props); IList <Zbor> zborR = new List <Zbor>(); using (var comm = con.CreateCommand()) { comm.CommandText = "select * from Zboruri"; using (var dataR = comm.ExecuteReader()) { while (dataR.Read()) { int IdZ = dataR.GetInt32(0); String Destinatie = dataR.GetString(1); String PlecareS = dataR.GetString(2); DateTime Plecare = DateTime.Parse(PlecareS); String Aeroport = dataR.GetString(3); int Locuri = dataR.GetInt32(4); Zbor zbor = new Zbor(IdZ, Destinatie, Plecare, Aeroport, Locuri); zborR.Add(zbor); } } } return(zborR); }
public void save(Zbor entity) { var con = DBUtils.getConnection(props); using (var comm = con.CreateCommand()) { comm.CommandText = "insert into Zboruri values (@idZ, @destinatie, @plecare, @aeroport, @locuri)"; var paramId = comm.CreateParameter(); paramId.ParameterName = "@idZ"; paramId.Value = entity.Id; comm.Parameters.Add(paramId); var paramDestinatie = comm.CreateParameter(); paramDestinatie.ParameterName = "@destinatie"; paramDestinatie.Value = entity.Destinatie; comm.Parameters.Add(paramDestinatie); var paramPlecare = comm.CreateParameter(); paramPlecare.ParameterName = "@plecare"; paramPlecare.Value = entity.Plecare; comm.Parameters.Add(paramPlecare); var paramAeroport = comm.CreateParameter(); paramAeroport.ParameterName = "@aeroport"; paramAeroport.Value = entity.Aeroport; comm.Parameters.Add(paramAeroport); var paramLocuri = comm.CreateParameter(); paramLocuri.ParameterName = "@locuri"; paramLocuri.Value = entity.Locuri; comm.Parameters.Add(paramLocuri); var result = comm.ExecuteNonQuery(); } }
public async Task OdbijPoziv(Zbor zbor) { var poziv = model.MojiPozivi.Where(p => p.IdZbor == zbor.Id).SingleOrDefault(); await _apiServices.OdbijPoziv(poziv.Id); PoziviZborovi.Remove(zbor); }
public LogIn() { InitializeComponent(); Zbor zb = new Zbor(); zb.updateZboruriDisponibile(); }
async void MojZborTapped(object sender, SelectedItemChangedEventArgs e) { ListView btn = (ListView)sender; Zbor zbor = (Zbor)btn.SelectedItem; App.Zbor = zbor; await Navigation.PushAsync(new ZborMasterPage()); }
public void add(string client, string adresa, int idDestinatie) { Zbor zbor = repositoryZbor.findById(idDestinatie); repositoryBilet.add(new Bilet(1, client, adresa, idDestinatie)); zbor.NrLocuriDisponibile = zbor.NrLocuriDisponibile - 1; repositoryZbor.update(zbor, idDestinatie); }
public Zbor findByIdZbor(int id) { Zbor z = null; sendRequest(new FindByIdZborRequest(id)); IResponse response = readResponse(); if (response is FindByIdResponse) { FindByIdResponse r = (FindByIdResponse)response; z = DTOUtils.getFromDTO(r.Zbor); } return(z); }
public async Task <IActionResult> OnGetAsync(int?id) { if (id == null) { return(NotFound()); } Zbor = await _context.Zbor.FirstOrDefaultAsync(m => m.ID == id); if (Zbor == null) { return(NotFound()); } return(Page()); }
public Zbor FindZbor(String destinatie, String data, String ora) { sendRequest(new FindZborRequest(new ZborDTO3(destinatie, data, ora))); Response response = readResponse(); if (response is ErrorResponse) { closeConnection(); throw new FlightException("Error finding clinet"); } FindZborResponse responseR = (FindZborResponse)response; Zbor zbor = responseR.Zbor; return(zbor); }
public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } Zbor = await _context.Zbor.FindAsync(id); if (Zbor != null) { _context.Zbor.Remove(Zbor); await _context.SaveChangesAsync(); } return(RedirectToPage("./Index")); }
internal void AddBilet(string destinatie, string data, string ora, string nume, string adresa, string locuri, string turisti) { Client c = repoC.findClientByNameAndAdresa(nume, adresa); string data2 = data + " " + ora; Zbor z = repoZ.findByDestinatieAndTime(destinatie, data2); int locuri2 = int.Parse(locuri); int id = getCorrectId(); Bilet b = new Bilet(id, z.Id, c.Id, turisti, locuri2); repoB.save(b); MessageBox.Show("Bilet rezervat"); int locuriRamase = z.Locuri - locuri2; if (locuriRamase == 0) { repoZ.delete(z.Id); } else { repoZ.updateLocuri(z.Id, locuriRamase); } }
public Zbor findByDestinatieAndTime(string destinatie, string time) { IDbConnection con = DBUtils.getConnection(props); IList <Zbor> zboruri = new List <Zbor>(); using (var comm = con.CreateCommand()) { comm.CommandText = "select * from Zboruri where Destinatie=@destinatie and Plecare=@time"; IDbDataParameter paramDestinatie = comm.CreateParameter(); paramDestinatie.ParameterName = "@destinatie"; paramDestinatie.Value = destinatie; comm.Parameters.Add(paramDestinatie); IDbDataParameter paramData = comm.CreateParameter(); paramData.ParameterName = "@time"; paramData.Value = time; comm.Parameters.Add(paramData); using (var dataR = comm.ExecuteReader()) { if (dataR.Read()) { int IdZ = dataR.GetInt32(0); String destinatie2 = dataR.GetString(1); DateTime plecare = DateTime.Parse(dataR.GetString(2)); String aeroport = dataR.GetString(3); int locuri = dataR.GetInt32(4); Zbor z = new Zbor(IdZ, destinatie2, plecare, aeroport, locuri); //log.InfoFormat("Exiting findOne with value {0}", c); return(z); } } } //log.InfoFormat("Exiting findOne with value {0}", null); return(null); }
public Zbor FindOneByDestinatieAndDateTime(String destinatie, String DataTimp) { IDbConnection con = DBUtils.getConnection(props); using (var comm = con.CreateCommand()) { comm.CommandText = "select * from Zboruri where Destinatia=@destinatia and Plecare=@plecare"; IDbDataParameter paramDestinatie = comm.CreateParameter(); paramDestinatie.ParameterName = "@destinatia"; paramDestinatie.Value = destinatie; comm.Parameters.Add(paramDestinatie); IDbDataParameter paramPlecare = comm.CreateParameter(); paramPlecare.ParameterName = "@plecare"; paramPlecare.Value = DataTimp; comm.Parameters.Add(paramPlecare); using (var dataR = comm.ExecuteReader()) { if (dataR.Read()) { int IdZ = dataR.GetInt32(0); String Destinatie = dataR.GetString(1); String PlecareS = dataR.GetString(2); DateTime Plecare = DateTime.Parse(PlecareS); String Aeroport = dataR.GetString(3); int Locuri = dataR.GetInt32(4); Zbor z = new Zbor(IdZ, Destinatie, Plecare, Aeroport, Locuri); log.InfoFormat("Exiting findOne with value {0}", z); return(z); } } } log.InfoFormat("Exiting findOne with value {0}", null); return(null); }
private void buttonCumpara_Click(object sender, EventArgs e) { String numeClient = textBoxNumeClient.Text; String adresaClient = textBoxAdresa.Text; String turisti = textBoxTuristi.Text; int locuri = Int32.Parse(textBoxLocuri.Text); String destinatie = textBoxDestinatie.Text; String data = textBoxData.Text; String data1 = data.Remove(10); String[] data2 = data1.Split('.'); String dataCorecta = data2[2] + "-" + data2[1] + "-" + data2[0]; String ora = textBoxOra.Text; ora = ora.Remove(5, 3); Client client = clientController.FindClient(numeClient, adresaClient); Zbor zbor = clientController.FindZbor(destinatie, dataCorecta, ora); int index = clientController.FindIndex(); Bilet bilet = new Bilet(++index, zbor.Id, client.Id, turisti, locuri); clientController.CumparaBilet(bilet, zbor.Id, zbor.Locuri - locuri); clientController.notifyServer(); }
private IResponse handleRequest(IRequest request) { IResponse response = null; if (request is LogInRequest) { Console.WriteLine("Login request ..."); LogInRequest logReq = (LogInRequest)request; AngajatDTO udto = logReq.User; Angajat user = DTOUtils.getFromDTO(udto); try { lock (server) { bool ok = server.logIn(user.User, user.Parola); if (ok == true) { response = new OkResponse(); } else { response = new ErrorResponse("log in error"); } } } catch (Exception e) { connected = false; return(new ErrorResponse(e.Message)); } } else if (request is GetFlightsRequest) { List <Zbor> flights = new List <Zbor>(); flights = server.getAllFlight(); response = new GetFlightsResponse(DTOUtils.getDTO(flights)); } else if (request is SearchFlightsRequest) { SearchFlightsRequest r = (SearchFlightsRequest)request; List <Zbor> flights = new List <Zbor>(); flights = server.findByDestinatieDataplecareFlight(r.Destinatie, r.DataPlecare); response = new SearchFlightsResponse(DTOUtils.getDTO(flights)); } else if (request is AddBiletRequest) { AddBiletRequest r = (AddBiletRequest)request; server.addBilet(r.Client, r.Turisti, r.Adresa, r.IdDestinatie); response = new AddBiletResponse(); } else { if (request is FindByIdZborRequest) { FindByIdZborRequest r = (FindByIdZborRequest)request; Zbor z = server.findByIdZbor(r.IdZbor); response = new FindByIdResponse(DTOUtils.getDTO(z)); } } return(response); }
async void NeMojZbor(object sender, SelectedItemChangedEventArgs e) { ListView btn = (ListView)sender; Zbor zbor = (Zbor)btn.SelectedItem; await Navigation.PushAsync(new JavniProfilPage(zbor.Id)); }
public FindZborResponse(Zbor zbor) { this.zbor = zbor; }
public static ZborDTO getDTO(Zbor zbor) { return(new ZborDTO(zbor.Id, zbor.Destinatie, zbor.DataOraPlecare, zbor.Aeroport, zbor.NrLocuriDisponibile)); }
public async Task PovuciPrijavu(Zbor zbor) { await _apiServices.ObrisiPrijavuZborAsync(zbor.PrijavaZaZbor.Where(p => p.IdKorisnik == App.Korisnik.Id && p.IdZbor == zbor.Id).Single()); PrijaveZborovi.Remove(zbor); }