mike Delvotti

mike Delvotti

  • NA
  • 262
  • 0

Loading Data From Database Rows

Jun 13 2009 7:42 AM

Hi,
I'm developing a calendar in C# Windows Form Application, the calendar inserts appointments fine manually with the below button click event. I have a database and a dataset with rows: DateBegin, DateEnd, Text (text will be the description) how can i change the below button click event to fill the appointments from my dataset instead of the datepickers on the form? Calendar1 is the calendar component on the form.
The button code that works is below:
private
void addItem_Click(object sender, EventArgs e)
{
try
{
DateTime startTime = new DateTime(datePicker.Value.Year, datePicker.Value.Month, datePicker.Value.Day, (int)this.startHour.Value, Int32.Parse(this.startMinute.Text), 0);
DateTime endTime = new DateTime(datePicker1.Value.Year, datePicker1.Value.Month, datePicker1.Value.Day, (int)this.endHour.Value, Int32.Parse(this.endMinute.Text), 0);
if (endTime.CompareTo(startTime) <= 0)
{
MessageBox.Show("End time is either same as or before the start time. Please check the times");
return;
}
if (this.descriptionTextBox.Text == null || this.descriptionTextBox.Text.Trim() == String.Empty)
{
MessageBox.Show("Please enter some description of this item");
return;
}
this.calendar1.CalendarItems.Add(new CalendarItem(startTime, endTime, this.descriptionTextBox.Text.Trim(), this.tentativeCheckBox.Checked));
this.calendar1.InitializeDisplay();
}
catch (Exception ex)
{
Trace.WriteLine(ex.ToString());
}
}