Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- namespace Reservations
- {
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- }
- //public bool IsValidData()
- //{
- //}
- public bool IsPresent(TextBox textBox, string name)
- {
- if (textBox.Text == "")
- {
- MessageBox.Show(name + " is a required field.", "Entry Error");
- textBox.Focus();
- return false;
- }
- return true;
- }
- //public bool IsDateTime(TextBox textBox, string name)
- //{
- //}
- //public bool IsWithinRange(TextBox textBox, string name,
- // DateTime min, DateTime max)
- //{
- //}
- private void btnExit_Click(object sender, EventArgs e)
- {
- this.Close();
- }
- private void btnCalculate_Click(object sender, EventArgs e)
- {
- double weekendprice_perNight=0, price_perNight=0;
- double total=0;
- double average;
- DateTime arrivalDate = DateTime.Today;
- DateTime.TryParse(txtArrivalDate.Text, out arrivalDate);
- DateTime departureDate = DateTime.Today;
- DateTime.TryParse(txtDepartureDate.Text, out departureDate);
- TimeSpan totalTime = departureDate.Subtract(arrivalDate);
- int totalNights = totalTime.Days;
- txtNights.Text += totalNights;
- DayOfWeek dayOfWeek = arrivalDate.DayOfWeek ;
- int counter = 0;
- for(counter=1; counter <= 7; counter++)
- {
- if (dayOfWeek == DayOfWeek.Friday || dayOfWeek == DayOfWeek.Saturday)
- {
- weekendprice_perNight = 150;
- }
- else
- {
- price_perNight = 120;
- }
- total = (price_perNight * totalNights) + weekendprice_perNight;
- txtTotalPrice.Text = total.ToString("c");
- average = total / totalNights;
- txtAvgPrice.Text = average.ToString("c");
- }
- }
- private void Form1_Load(object sender, EventArgs e)
- {
- DateTime currentDate = DateTime.Today;
- DateTime depDate = currentDate.AddDays(3);
- txtArrivalDate.Text = currentDate.ToShortDateString();
- txtDepartureDate.Text = depDate.ToShortDateString();
- //DateTime dateTime = new DateTime(2016, 1, 29);
- //DateTime departureTime = dateTime.AddDays(3);
- //string shortDate = dateTime.ToShortDateString();
- //shortDate = shortDate.Replace("-", "/");
- //string shortDepDate = departureTime.ToShortDateString();
- //shortDepDate = shortDepDate.Replace("-", "/");
- //txtArrivalDate.Text = shortDate;
- //txtDepartureDate.Text = shortDepDate;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement