Exemplo n.º 1
0
        private void btnReserve_Click(object sender, RoutedEventArgs e)
        {
            string message;
            bool   result = Functions.ValidateCustomer(txbCustomerFName, txbCustomerLName, rdbMale, rdbFemale, out message);

            lblMessage.Content = message;

            if (result)
            {
                Person person = new Person();
                person.First_Name = txbCustomerFName.Text;
                person.Last_Name  = txbCustomerLName.Text;
                if ((bool)rdbFemale.IsChecked)
                {
                    person.Gender = true;
                    femaleQueue.Enqueue(person);
                }
                else
                {
                    person.Gender = false;
                    maleQueue.Enqueue(person);
                }
                lblQueueCount.Content = "تعداد افراد منتظر در صف: " + (maleQueue.Lenght + femaleQueue.Lenght).ToString();
                MessageBox.Show("نوبت شما با موفقیت رزرو شد.");
                txbCustomerFName.Clear(); txbCustomerLName.Clear(); rdbFemale.IsChecked = false; rdbMale.IsChecked = false;
            }
        }
        public static void readCustomerFromFile(MyQueue femaleQ, MyQueue maleQ)
        {
            MyQueue      tempQueue = new MyQueue();
            StreamReader sr        = new StreamReader("customerFile.txt");

            for (int i = 0; !sr.EndOfStream; i++)
            {
                Person temp = new Person();
                temp.First_Name = sr.ReadLine();
                temp.Last_Name  = sr.ReadLine();
                temp.Gender     = Convert.ToBoolean(sr.ReadLine());
                int n = Convert.ToInt32(sr.ReadLine());
                for (int j = 0; j < n; j++)
                {
                    Book tempBook = new Book();
                    tempBook.BookName        = sr.ReadLine();
                    tempBook.WriterName      = sr.ReadLine();
                    tempBook.PublicationYear = Convert.ToInt32(sr.ReadLine());
                    tempBook.Price           = Convert.ToInt32(sr.ReadLine());
                    temp.ShoppingBag.pushBack(tempBook);
                }
                sr.ReadLine();
                tempQueue.Enqueue(temp);
            }
            for (int i = 0; i < tempQueue.Lenght; i++)
            {
                Person temp = (Person)tempQueue[i];
                if (temp.Gender)
                {
                    femaleQ.Enqueue(temp);
                }
                else
                {
                    maleQ.Enqueue(temp);
                }
            }
        }