Hello,
I did not find what I was needing with a search, so here goes. I am having problems getting my calendar to work, passing a start and end date for a rental car and displaying on the form the number of days chosen and the amount for the total. This is the first form problem I have done. I cannot see what I am doing wrong. It does not figure number of days and the amount just stays zero. Thank you.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class CarRental : Form
{
double pricePerDay = 0;
int numDays = 0;
public CarRental()
{
InitializeComponent();
}
private void monthCalendar1_DateSelected(object sender, System.Windows.Forms.DateRangeEventArgs e)
{
// Show the start and end dates in the labels.
this.SelectionStart.Text = "Date Selected: Start = " +
e.Start.ToShortDateString();
this.SelectionEnd.Text = "Date Selected: End = " + e.End.ToShortDateString();
}
private void monthCalendar1_DateChanged(object sender, DateRangeEventArgs e)
{
DateTime selectedDates = monthCalendar1.SelectionStart;
TimeSpan diffDays = selectedDates.Subtract(e.Start);
numDays = diffDays.Days;
}
private void selectionBox_Enter(object sender, EventArgs e)
{
}
private void radioBtnCompact_CheckedChanged(object sender, EventArgs e)
{
pricePerDay = 19.95;
}
private void radioBtnStandard_CheckedChanged(object sender, EventArgs e)
{
pricePerDay = 24.95;
}
private void radioBtnLuxury_CheckedChanged(object sender, EventArgs e)
{
pricePerDay = 39.00;
}
private void btnSelection_Click(object sender, EventArgs e)
{
numbOfDaysLbl.Text = "Number of Rental Days is: " + numDays;
totalLbl.Text = "Total is: " + (numDays * pricePerDay).ToString("C");
}
private void btnExit_Click(object sender, EventArgs e)
{
Application.Exit();
}
}
}
Thanks a bunch!