private void button1_Click(object sender, EventArgs e) { if (numeCBox.Text != null && locuriCBox.Text != null && listaShow.SelectedItems.Count == 1) { try { int nrLocuri = int.Parse(locuriCBox.Text); int idShow = int.Parse(listaShow.SelectedItems[0].SubItems[0].Text); int locuriDisp = int.Parse(listaShow.SelectedItems[0].SubItems[4].Text); if (locuriDisp >= nrLocuri) { //Show s = new Show() { Id = idShow }; string numeC = numeCBox.Text; //Ticket t = new Ticket() { IdShow = idShow, NrSeatsWanted = nrLocuri, BuyerName = numeC }; ShowDTO showDTO = new ShowDTO(); showDTO.Id = idShow; TicketDTO ticketDTO = new TicketDTO(); ticketDTO.IdShow = idShow; ticketDTO.NrWantedSeats = nrLocuri; ticketDTO.BuyerName = numeC; TTransport transport = new TSocket("localhost", 9091); TProtocol protocol = new TBinaryProtocol(transport); transport.Open(); AppService.Client client = new AppService.Client(protocol); client.ticketsSold(showDTO, ticketDTO); transport.Close(); CallPopulateTable(); //this.ctrl.ticketsSold(s, t); } else { MessageBox.Show("Nu avem suficiente locuri libere!"); } numeCBox.Clear(); locuriCBox.Clear(); } catch (Exception ex) { MessageBox.Show("Ati introdus gresit datele in campul de locuri dorite!"); } } else { MessageBox.Show("Va rugam completati toate campurile si selectati un spectacol din lista"); } }
/*private void button1_Click(object sender, EventArgs e) * { * string username = usernameBox.Text; * string password = passwordBox.Text; * Employee es = new Employee() { Username = username, Password = password }; * if (username!=null && password!= null){ * try * { * ctrl.login(es); * //MessageBox.Show("Login succeded"); * mainPage chatWin = new mainPage(es,ctrl,this); * chatWin.Text = "Chat window for " + username; * chatWin.Show(); * this.Hide(); * } * catch (Exception ex) * { * MessageBox.Show("Nu exista cont cu aceste date de logare! Va rugam incercati din nou!"); * return; * } * } * }*/ private void button1_Click(object sender, EventArgs e) { string username = usernameBox.Text; string password = passwordBox.Text; try { TTransport transport = new TSocket("localhost", 9091); TProtocol protocol = new TBinaryProtocol(transport); transport.Open(); AppService.Client client = new AppService.Client(protocol); port = getFreePort(9092); String response = client.login(username, password, "localhost", port); transport.Close(); if (response.Equals("loggedIn")) { mainPage chatWin = new mainPage(port, this, username); chatWin.Text = "Window for " + username; chatWin.Show(); this.Hide(); } else if (response.Equals("alreadyLoggedIn")) { throw new Exception("Utilizator deja conectat!"); } else { throw new Exception("Nu exista cont cu aceste date de logare! Va rugam incercati din nou!"); } } catch (Exception ex) { MessageBox.Show(ex.Message); return; } }
private void PopulateShowTable(bool isUpdated) { if (isUpdated) { foreach (ShowDTO s in showData.ToList <ShowDTO>()) { var row = new string[] { s.Id.ToString(), s.ArtistName, s.Location, s.DataTimp.Split('T')[0], s.NrAvailableSeats.ToString(), s.NrSoldSeats.ToString() }; var lvi = new ListViewItem(row); if (s.NrAvailableSeats == 0) { lvi.BackColor = Color.Red; } listaShow.Items.Add(lvi); } } else { TTransport transport = new TSocket("localhost", 9091); TProtocol protocol = new TBinaryProtocol(transport); transport.Open(); AppService.Client client = new AppService.Client(protocol); showData = client.findAllShows(); transport.Close(); listaShow.Items.Clear(); foreach (ShowDTO s in showData.ToList <ShowDTO>()) { var row = new string[] { s.Id.ToString(), s.ArtistName, s.Location, s.DataTimp.Split('T')[0], s.NrAvailableSeats.ToString(), s.NrSoldSeats.ToString() }; var lvi = new ListViewItem(row); if (s.NrAvailableSeats == 0) { lvi.BackColor = Color.Red; } listaShow.Items.Add(lvi); } } }
public void logout() { //Console.WriteLine("Ctrl logout"); // ctrl.logout(CurrentUser); // CurrentUser = null; // ctrl.updateEvent -= userUpdate; TTransport transport = new TSocket("localhost", 9091); TProtocol protocol = new TBinaryProtocol(transport); transport.Open(); AppService.Client client = new AppService.Client(protocol); String response = client.logOut(this.currentClient, "localhost", port); transport.Close(); if (!response.Equals("loggedOut")) { throw new Exception("Eroare la logout!"); } loginWindow.Enabled = true; loginWindow.Show(); }