예제 #1
0
        private void button2_Click(object sender, EventArgs e)
        {
            bool flag   = false;
            int  countp = 0;

            foreach (var num in numbers)
            {
                if (Int32.Parse(Numb.Text) == num.number)
                {
                    flag   = true;
                    countp = num.countPerDay;
                    break;
                }
            }
            if (!flag)
            {
                MessageBox.Show("Извините, но данные номер не найден в списке");
                Numb.Text = "";
            }
            else
            {
                string[] words = CurrentProfile.lastbooked.Split(':');
                GuestCommands.sendBook(Int32.Parse(Numb.Text), words[0], words[1], words[2], countp * Int32.Parse(words[1]));
            }
        }
예제 #2
0
 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);
         }
     }
 }
예제 #3
0
 public void clos()
 {
     MessageBox.Show("Номер успешно забронирован!");
     GuestCommands.sendUpdateBook(CurrentProfile.me.id);
     AllForms.menuGuest.Show();
     this.Close();
 }
예제 #4
0
 static public void checking()
 {
     while (true)
     {
         if ((AllForms.booked != null && !AllForms.booked.Visible || AllForms.booked == null) &&
             (AllForms.infoBooking != null && !AllForms.infoBooking.Visible || AllForms.infoBooking == null) &&
             (AllForms.infoNumbers != null && !AllForms.infoNumbers.Visible || AllForms.infoNumbers == null) &&
             (AllForms.menuGuest != null && !AllForms.menuGuest.Visible || AllForms.menuGuest == null) &&
             (AllForms.offers != null && !AllForms.offers.Visible || AllForms.offers == null) &&
             (AllForms.profile != null && !AllForms.profile.Visible || AllForms.profile == null) &&
             (AllForms.registration != null && !AllForms.registration.Visible || AllForms.registration == null) &&
             (AllForms.types != null && !AllForms.types.Visible || AllForms.types == null) &&
             (AllForms.cancBooking != null && !AllForms.cancBooking.Visible || AllForms.cancBooking == null) &&
             (AllForms.anketa != null && !AllForms.anketa.Visible || AllForms.anketa == null) &&
             (AllForms.changePass != null && !AllForms.changePass.Visible || AllForms.changePass == null) &&
             (AllForms.bookingSettle != null && !AllForms.bookingSettle.Visible || AllForms.bookingSettle == null) &&
             (AllForms.faceSettling != null && !AllForms.faceSettling.Visible || AllForms.faceSettling == null) &&
             (AllForms.infoGuests != null && !AllForms.infoGuests.Visible || AllForms.infoGuests == null) &&
             (AllForms.receptionistMenu != null && !AllForms.receptionistMenu.Visible || AllForms.receptionistMenu == null) &&
             (AllForms.unsettling != null && !AllForms.unsettling.Visible || AllForms.unsettling == null) &&
             (AllForms.CleanerMenu != null && !AllForms.CleanerMenu.Visible || AllForms.CleanerMenu == null) &&
             (Program.authorisation != null && !Program.authorisation.Visible || Program.authorisation == null))
         {
             GuestCommands.sendClose();
             System.Environment.Exit(0);
         }
     }
 }
예제 #5
0
 private void button1_Click(object sender, EventArgs e)
 {
     if (amountDays.Text != "" && guests.Text != "")
     {
         DateTime lastda = dateT.Value.AddDays(double.Parse(amountDays.Text));
         string   lday   = lastda.Day + "." + lastda.Month + "." + lastda.Year;
         if (minim.Text == "")
         {
             minim.Text = "0";
         }
         if (maxim.Text == "")
         {
             maxim.Text = "100000000";
         }
         GuestCommands.sendBooked(dateT.Text, amountDays.Text, guests.Text, minim.Text, maxim.Text, lday);
         if (minim.Text == "0")
         {
             minim.Text = "";
         }
         if (maxim.Text == "100000000")
         {
             maxim.Text = "";
         }
     }
     else
     {
         MessageBox.Show("Пустые необходимые поля для заполнения");
     }
 }
예제 #6
0
        private void button2_Click(object sender, EventArgs e)
        {
            bool flag = false;

            foreach (var book in CurrentProfile.bookings)
            {
                if (book.id == Int32.Parse(textBox1.Text))
                {
                    flag = true;
                    break;
                }
            }
            if (!flag)
            {
                MessageBox.Show("Не найден текущий Id");
            }
            else
            {
                GuestCommands.sendCancel(Int32.Parse(textBox1.Text));
                MessageBox.Show("Бронь успешно отменена!");
                GuestCommands.sendUpdateBook(CurrentProfile.me.id);
                AllForms.menuGuest.Show();
                this.Close();
            }
        }
예제 #7
0
 private void button1_Click_1(object sender, EventArgs e)
 {
     if (textBox1.Text != "" && textBox2.Text != "")
     {
         GuestCommands.sendLogin(textBox1.Text, textBox2.Text);
     }
     else
     {
         MessageBox.Show("Пустое поле");
     }
 }
예제 #8
0
 private void button1_Click(object sender, EventArgs e)
 {
     if (newPassword.Text != "" && oldPassword.Text != "")
     {
         GuestCommands.sendChangepass(CurrentProfile.me.login, oldPassword.Text, newPassword.Text);
     }
     else
     {
         MessageBox.Show("Пустое поле!");
     }
 }
예제 #9
0
 public static void addfilt(string message)
 {
     filtrs.Add(Int32.Parse(message));
     if (filtrs.Count < sizefil)
     {
         GuestCommands.sendFilt(filtrs.Count);
     }
     else
     {
         AllForms.booked.Invoke(AllForms.booked.closeDelegate);
     }
 }
예제 #10
0
 public static void Close()
 {
     GuestCommands.sendClose();
     if (client != null)
     {
         client.Close();
     }
     if (stream != null)
     {
         stream.Close();
     }
 }
예제 #11
0
 public static void addNumber(string message)
 {
     string[] words = message.Split(':');
     numbers.Add(new Number(Int32.Parse(words[0]), Int32.Parse(words[1]), words[2], words[3] == "True", Int32.Parse(words[4]), words[5] == "True"));
     GuestCommands.sendNumber(++stype);
     if (AllForms.infoNumbers != null && AllForms.infoNumbers.Visible)
     {
         AllForms.infoNumbers.Invoke(AllForms.infoNumbers.upd);
     }
     if (AllForms.CleanerMenu != null && AllForms.CleanerMenu.Visible)
     {
         AllForms.CleanerMenu.Invoke(AllForms.CleanerMenu.upd);
     }
 }
예제 #12
0
 private void button3_Click(object sender, EventArgs e)
 {
     if (!CurrentProfile.updBook)
     {
         CurrentProfile.updBook  = true;
         CurrentProfile.windOpen = 1;
         GuestCommands.sendUpdateBook(CurrentProfile.me.id);
     }
     else
     {
         AllForms.infoBooking = new InfoBooking();
         AllForms.infoBooking.Show();
         this.Hide();
     }
 }
예제 #13
0
 private void button3_Click(object sender, EventArgs e)
 {
     if (textBox8.ReadOnly)
     {
         textBox8.ReadOnly = !textBox8.ReadOnly;
     }
     else
     {
         if (textBox8.Text.Length != 11)
         {
             MessageBox.Show("Неверный формат телефона");
             return;
         }
         textBox8.ReadOnly = !textBox8.ReadOnly;
         GuestCommands.sendChangepho(CurrentProfile.me.id, textBox8.Text);
     }
 }
예제 #14
0
 private void button4_Click(object sender, EventArgs e)
 {
     if (textBox9.ReadOnly)
     {
         textBox9.ReadOnly = !textBox9.ReadOnly;
     }
     else
     {
         if (textBox9.Text.Split(new char[] { '@', '.' }).Length != 3)
         {
             MessageBox.Show("Неверный формат Email");
             return;
         }
         textBox9.ReadOnly = !textBox9.ReadOnly;
         GuestCommands.sendEmail(CurrentProfile.me.id, textBox9.Text);
     }
 }
예제 #15
0
 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();
         }
     }
 }
예제 #16
0
 public static void Connect()
 {
     client.Connect(address, port);
     stream = client.GetStream();
     GuestCommands.sendOpen();
 }
예제 #17
0
 public void toLogin(string message)
 {
     string[] words = message.Split(':');
     if (words[1] == "Guest")
     {
         CurrentProfile.Role     = Role.Guest;
         CurrentProfile.me       = new User(words[9], words[0], words[2], words[3], words[4], words[5], words[6], words[7], words[8]);
         CurrentProfile.numbers  = new List <Number>();
         CurrentProfile.snum     = 0;
         CurrentProfile.bookings = new List <Booking>();
         CurrentProfile.stype    = 0;
         CurrentProfile.types    = new List <Type>();
         GuestCommands.sendType(0);
         CurrentProfile.updBook = false;
         AllForms.profile.filling(CurrentProfile.me);
         if (CurrentProfile.me.name == "")
         {
             MessageBox.Show("Пожалуйста, заполните анкету");
             AllForms.anketa = new Anketa();
             AllForms.anketa.Show();
         }
         else
         {
             AllForms.menuGuest.Show();
         }
         textBox1.Text = "";
         textBox2.Text = "";
         this.Hide();
     }
     if (words[1] == "Reseptionist")
     {
         CurrentProfile.Role       = Role.Receptionis;
         CurrentProfile.me         = new User(words[9], words[0], words[2], words[3], words[4], words[5], words[6], words[7], words[8]);
         CurrentProfile.numbers    = new List <Number>();
         CurrentProfile.snum       = 0;
         CurrentProfile.bookings   = new List <Booking>();
         CurrentProfile.stype      = 0;
         CurrentProfile.updBook    = false;
         CurrentProfile.types      = new List <Type>();
         CurrentProfile.guests     = new List <User>();
         CurrentProfile.updgue     = false;
         CurrentProfile.sizegue    = 0;
         CurrentProfile.settles    = new List <Settling>();
         CurrentProfile.updSettle  = false;
         CurrentProfile.sizeSettle = 0;
         GuestCommands.sendType(0);
         AllForms.receptionistMenu.Show();
         textBox1.Text = "";
         textBox2.Text = "";
         this.Hide();
     }
     if (words[1] == "Cleaner")
     {
         CurrentProfile.Role    = Role.Cleaner;
         CurrentProfile.numbers = new List <Number>();
         CurrentProfile.stype   = 0;
         CurrentProfile.types   = new List <Type>();
         GuestCommands.sendType(0);
         AllForms.CleanerMenu.Show();
         textBox1.Text = "";
         textBox2.Text = "";
         this.Hide();
     }
 }
예제 #18
0
 public static void addType(string message)
 {
     string[] words = message.Split(':');
     types.Add(new Type(words[0], Int32.Parse(words[1]), Int32.Parse(words[2]), words[3] == "True"));
     GuestCommands.sendType(++stype);
 }