public static void addBook(string message) { string[] words = message.Split(':'); bookings.Add(new Booking(Int32.Parse(words[0]), Int32.Parse(words[1]), Int32.Parse(words[2]), words[3], Int32.Parse(words[4]), Int32.Parse(words[5]))); if (sizebooking > bookings.Count()) { GuestCommands.sendNextBook(bookings.Count); } else if (windOpen == 1) { AllForms.menuGuest.Invoke(AllForms.menuGuest.hideDelegate); windOpen = 0; } else if (windOpen == 2) { AllForms.menuGuest.Invoke(AllForms.menuGuest.hideCancDelegate); windOpen = 0; } else if (windOpen == 3) { AllForms.receptionistMenu.Invoke(AllForms.receptionistMenu.hideDelegate); windOpen = 0; } if (windOpen == 0) { if (AllForms.bookingSettle.Visible) { AllForms.bookingSettle.Invoke(AllForms.bookingSettle.updDeleg); } } }
public static void GetMessage() { while (true) { try { byte[] data = new byte[255]; StringBuilder builder = new StringBuilder(); int bytes = 0; do { bytes = stream.Read(data, 0, data.Length); builder.Append(Encoding.Unicode.GetString(data, 0, bytes)); } while (stream.DataAvailable); string message = builder.ToString(); if (message == "") { continue; } string[] words = message.Split('#'); if (words.Length == 0) { continue; } if (words[0] == "ESTABLISHED") { continue; } if (words[0] == "CLOSE") { continue; } if (words[0] == "GOODLOGIN") { Program.authorisation.Invoke(Program.authorisation.loginDelegate, words[1]); } if (words[0] == "BADLOGIN") { Program.authorisation.badLogin(); } if (words[0] == "GOODANKETA") { AllForms.anketa.Invoke(AllForms.anketa.anketDelegate, words[1]); } if (words[0] == "BADREGISTRATION") { MessageBox.Show("Данный логин уже занят"); } if (words[0] == "GOODREGISTRATION") { AllForms.registration.Invoke(AllForms.registration.regDelegate); } if (words[0] == "NEWTYPE") { if (Int32.Parse(words[1].Split(':')[4]) == 0) { CurrentProfile.stype = 0; CurrentProfile.types = new List <Type>(); CurrentProfile.numbers = new List <Number>(); } CurrentProfile.addType(words[1]); } if (words[0] == "NEWNUMBER") { CurrentProfile.addNumber(words[1]); } if (words[0] == "FOUNDBOOKED") { CurrentProfile.sizefil = Int32.Parse(words[1]); if (CurrentProfile.filtrs == null) { CurrentProfile.filtrs = new List <int>(); } CurrentProfile.filtrs.Clear(); if (CurrentProfile.sizefil == 0) { AllForms.booked.Invoke(AllForms.booked.closeDelegate); } else { GuestCommands.sendFilt(0); } } if (words[0] == "NEWFILTER") { CurrentProfile.addfilt(words[1]); } if (words[0] == "BADBOOK") { MessageBox.Show("Номер уже занят, извините"); } if (words[0] == "GOODBOOK") { AllForms.offers.Invoke(AllForms.offers.closing); } if (words[0] == "NEWBOOKING") { CurrentProfile.addBook(words[1]); } if (words[0] == "FOUNDBOOKINGS") { CurrentProfile.sizebooking = Int32.Parse(words[1]); CurrentProfile.bookings = new List <Booking>(); if (CurrentProfile.sizebooking > 0) { GuestCommands.sendNextBook(0); } } if (words[0] == "GOODEMAIL") { MessageBox.Show("Email успешно изменен!"); } if (words[0] == "GOODPASS") { MessageBox.Show("Пароль успешно изменен!"); AllForms.changePass.Invoke(AllForms.changePass.closDelegate); } if (words[0] == "BADPASS") { MessageBox.Show("Неправильно введен старый пароль!"); } if (words[0] == "GOODPHONE") { MessageBox.Show("Телефон успешно изменен!"); } if (words[0] == "UPDATEBOOKINGS") { ReseptionistCommands.sendUpdateBook(); } if (words[0] == "UPDATEGUESTINGS") { CurrentProfile.sizegue = Int32.Parse(words[1]); CurrentProfile.guests = new List <User>(); if (CurrentProfile.sizegue > 0) { ReseptionistCommands.sendGuest(0); } } if (words[0] == "NEWGUEST") { CurrentProfile.addfgue(words[1]); } if (words[0] == "UPDATESETTLING") { CurrentProfile.sizeSettle = Int32.Parse(words[1]); CurrentProfile.settles = new List <Settling>(); if (CurrentProfile.sizeSettle > 0) { ReseptionistCommands.sendSettle(0); } } if (words[0] == "NEWSETTLE") { CurrentProfile.addSettle(words[1]); } } catch (Exception ex) { Close(); } } }