コード例 #1
0
 private void btnLogIn_Click(object sender, EventArgs e)
 {
     if (txtPassword.Text != "" && txtUserName.Text != "")
     {
         if (servicesServer.logIn(txtUserName.Text, txtPassword.Text))
         {
             Form2 secondForm = new Form2(servicesServer);
             secondForm.Show();
             this.Hide();
         }
         else
         {
             MessageBox.Show("Invalid user or password!");
         }
     }
     else
     {
         MessageBox.Show("Empty fields!");
     }
 }
コード例 #2
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);
        }