Пример #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                foreach (ListItem li in allTeeTimes//.Where(tt => tt.TimeOfDay )
                         .Select(tt => new ListItem(tt.TimeOfDay.ToString(), tt.ToShortTimeString())))
                {
                    DropDownList2.Items.Add(li);
                }
            }

            if (IsPostBack)
            {
                customer newCustomer = new customer();
                newCustomer.firstName = Request.Form["first_name"];
                newCustomer.lastName  = Request.Form["last_name"];
                newCustomer.email     = Request.Form["user_email"];
                if (!allCustomers.Contains(newCustomer))
                {
                    allCustomers.Add(newCustomer);
                }

                DateTime date = Convert.ToDateTime(Request.Form["date"]);
                DateTime time = Convert.ToDateTime(DropDownList2.SelectedItem.Value);

                teetime booking = new teetime();
                booking.booker = newCustomer;
                booking.time   = new DateTime(date.Year, date.Month, date.Day, time.Hour, time.Minute, time.Second);

                booking.numGuests = int.Parse(NoGuests.SelectedItem.Value);

                WebApplication1.File.SaveBooking(booking);
            }
        }
Пример #2
0
        public static void SaveBooking(teetime tt)
        {
            string filePath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "//bookings.txt";
            using (System.IO.FileStream bookingStream = new System.IO.FileStream(filePath, System.IO.FileMode.Append, FileAccess.Write))
            {
                StreamWriter writer = new StreamWriter(bookingStream);
                string linen = string.Format("{0}\t{1}\t{2}\t{3}\t{4}", tt.time, tt.booker.firstName, tt.booker.lastName, tt.booker.email, tt.numGuests);
                writer.WriteLine(linen);

                writer.Close();
            }
        }
Пример #3
0
        public static void SaveBooking(teetime tt)
        {
            string filePath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "//bookings.txt";

            using (System.IO.FileStream bookingStream = new System.IO.FileStream(filePath, System.IO.FileMode.Append, FileAccess.Write))
            {
                StreamWriter writer = new StreamWriter(bookingStream);
                string       linen  = string.Format("{0}\t{1}\t{2}\t{3}\t{4}", tt.time, tt.booker.firstName, tt.booker.lastName, tt.booker.email, tt.numGuests);
                writer.WriteLine(linen);

                writer.Close();
            }
        }
Пример #4
0
        public static void ReadBooking(List<teetime> booked, DateTime date)
        {
            string filePath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "//bookings.txt";
            using (System.IO.FileStream bookingStream = new System.IO.FileStream(filePath, FileMode.Open, FileAccess.Read))
            {
                using (StreamReader reader = new StreamReader(bookingStream))
                {

                    String line;
                    while ((line = reader.ReadLine()) != null)
                    {
                        string[] read = line.Split('\t');
                        teetime booking = new teetime() { time = Convert.ToDateTime(read[0]), booker = new customer() { firstName = (read[1]), lastName = (read[2]), email = (read[3]) }, numGuests = int.Parse(read[4]) };
                        booked.Add(booking);
                    }
                }
            }
        }
Пример #5
0
        public static void ReadBooking(List <teetime> booked, DateTime date)
        {
            string filePath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "//bookings.txt";

            using (System.IO.FileStream bookingStream = new System.IO.FileStream(filePath, FileMode.Open, FileAccess.Read))
            {
                using (StreamReader reader = new StreamReader(bookingStream))
                {
                    String line;
                    while ((line = reader.ReadLine()) != null)
                    {
                        string[] read    = line.Split('\t');
                        teetime  booking = new teetime()
                        {
                            time = Convert.ToDateTime(read[0]), booker = new customer()
                            {
                                firstName = (read[1]), lastName = (read[2]), email = (read[3])
                            }, numGuests = int.Parse(read[4])
                        };
                        booked.Add(booking);
                    }
                }
            }
        }
Пример #6
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                foreach (ListItem li in allTeeTimes//.Where(tt => tt.TimeOfDay )
                    .Select(tt => new ListItem(tt.TimeOfDay.ToString(), tt.ToShortTimeString())))
                    DropDownList2.Items.Add(li);

            }

            if (IsPostBack)
            {
                customer newCustomer = new customer();
                newCustomer.firstName = Request.Form["first_name"];
                newCustomer.lastName = Request.Form["last_name"];
                newCustomer.email = Request.Form["user_email"];
                if (!allCustomers.Contains(newCustomer))
                    allCustomers.Add(newCustomer);

                DateTime date = Convert.ToDateTime(Request.Form["date"]);
                DateTime time = Convert.ToDateTime(DropDownList2.SelectedItem.Value);

                teetime booking = new teetime();
                booking.booker = newCustomer;
                booking.time = new DateTime(date.Year, date.Month, date.Day, time.Hour, time.Minute, time.Second);

                booking.numGuests = int.Parse(NoGuests.SelectedItem.Value);

                WebApplication1.File.SaveBooking(booking);

            }
        }