/// <summary> /// Create new rosie event and navigate onto the screen to perform /// the next step in event organization /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnNext_Click(object sender, EventArgs e) { if (radNew.Checked) { if (validateAddEventFrm()) { RosieEvent ev = new RosieEvent(); ev.EventDate = dtpFormDate.Value; ev.LocationId = (cmbLocations.SelectedItem as EventLocation).Id; ev.Name = txtEventName.Text; ev.Type = ((KeyValuePair <string, EventType>)cmbTypes.SelectedItem).Value; //SqlTransaction transaction = RosieEntity.Connector.Connection.BeginTransaction(); ev.Create(); RosieEvent createdEvent = RosieEvent.Retrieve(ev.EventDate, ev.LocationId); goToNextStepForEvent(createdEvent); } } else { if (dgEvents.SelectedRows.Count > 0) { goToNextStepForEvent(dgEvents.SelectedRows[0].DataBoundItem as RosieEvent); } } }
private static DateTime GenEvent(int nRecords, EventLocation location, DateTime lastDate) { DateTime latestDate = lastDate; for (int i = 0; i < nRecords; i++) { try { RosieEvent rosieEvent = new RosieEvent(); rosieEvent.Name = ""; rosieEvent.EventDate = latestDate.AddDays(RandomNumber.Next(1, 5)); rosieEvent.LocationId = location.Id; rosieEvent.Type = SelectEventType(); rosieEvent.Create(); latestDate = rosieEvent.EventDate; } catch { } } return(latestDate); }