コード例 #1
0
        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);
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        //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();
        }
コード例 #4
0
        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);
        }
コード例 #5
0
        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();
            }
        }
コード例 #6
0
        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);
        }
コード例 #7
0
ファイル: LogIn.cs プロジェクト: eduard2276/College-projects
        public LogIn()
        {
            InitializeComponent();
            Zbor zb = new Zbor();

            zb.updateZboruriDisponibile();
        }
コード例 #8
0
ファイル: PocetnaPage.xaml.cs プロジェクト: lukasopar/ZborApp
        async void MojZborTapped(object sender, SelectedItemChangedEventArgs e)
        {
            ListView btn  = (ListView)sender;
            Zbor     zbor = (Zbor)btn.SelectedItem;

            App.Zbor = zbor;
            await Navigation.PushAsync(new ZborMasterPage());
        }
コード例 #9
0
        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);
        }
コード例 #10
0
        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);
        }
コード例 #11
0
        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());
        }
コード例 #12
0
        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);
        }
コード例 #13
0
        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"));
        }
コード例 #14
0
        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);
            }
        }
コード例 #15
0
        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);
        }
コード例 #16
0
        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);
        }
コード例 #17
0
        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();
        }
コード例 #18
0
        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);
        }
コード例 #19
0
ファイル: PocetnaPage.xaml.cs プロジェクト: lukasopar/ZborApp
 async void NeMojZbor(object sender, SelectedItemChangedEventArgs e)
 {
     ListView btn  = (ListView)sender;
     Zbor     zbor = (Zbor)btn.SelectedItem;
     await Navigation.PushAsync(new JavniProfilPage(zbor.Id));
 }
コード例 #20
0
ファイル: ObjectResponseProtocol.cs プロジェクト: Huskyez/Uni
 public FindZborResponse(Zbor zbor)
 {
     this.zbor = zbor;
 }
コード例 #21
0
ファイル: DTOUtils.cs プロジェクト: Clusi/mpp-tema3-CSharp
 public static ZborDTO getDTO(Zbor zbor)
 {
     return(new ZborDTO(zbor.Id, zbor.Destinatie, zbor.DataOraPlecare, zbor.Aeroport, zbor.NrLocuriDisponibile));
 }
コード例 #22
0
        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);
        }