private void btnAddBilet_Click(object sender, EventArgs e) { int nrLocuri; try { nrLocuri = int.Parse(txtNumarLocuri.Text); }catch (Exception ex) { MessageBox.Show("Numarul de locuri trebuie sa fie int zapacito!"); return; } string numeClient = txtNumeClient.Text; string adresa = txtAdresa.Text; string turisti = txtTuristi.Text; int idDestinatie = (int)dataGridViewZbor.Rows[dataGridViewZbor.SelectedCells[0].RowIndex].Cells[0].Value; if (!numeClient.Equals("") && !adresa.Equals("")) { if (servicesServer.findByIdZbor(idDestinatie).NrLocuriDisponibile >= nrLocuri) { servicesServer.addBilet(numeClient, turisti, adresa, idDestinatie); } else { MessageBox.Show("Not enough seats!"); } } else { MessageBox.Show("Invalid dates!"); } }
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); }