private void buttonGenerateDongle_Click(object sender, System.EventArgs e) { if (!this.textBoxComputerName.Text.Trim().Equals("")) { DateTime startDateTime = DateTime.Now; DateTime endDateTime = DateTime.Now; if (this.radioButtonYears.Checked) { int years = System.Convert.ToInt32(this.textBoxLeaseDuration.Text); endDateTime = endDateTime.AddYears(years); } else if (this.radioButtonMonths.Checked) { int months = System.Convert.ToInt32(this.textBoxLeaseDuration.Text); endDateTime = endDateTime.AddMonths(months); } else if (this.radioButtonDays.Checked) { int days = System.Convert.ToInt32(this.textBoxLeaseDuration.Text); endDateTime = endDateTime.AddDays(days); } Lease lease = new Lease(startDateTime, endDateTime, this.textBoxComputerName.Text); DongleGenerator dg = new DongleGenerator(); if (dg.GenerateDongle(lease)) { StringBuilder sb = new StringBuilder(); sb.Append("Lease Start: "); sb.Append(lease.LeaseStart.ToString()); sb.Append(" ("); sb.Append(lease.GetStringFromDateTime(lease.LeaseStart)); sb.Append(")"); sb.Append("\r\n"); sb.Append("Lease End: "); sb.Append(lease.LeaseEnd.ToString()); sb.Append(" ("); sb.Append(lease.GetStringFromDateTime(lease.LeaseEnd)); sb.Append(")"); sb.Append("\r\n"); sb.Append("Serial #: "); sb.Append(lease.GetStringFromDateTime(lease.LeaseStart)); sb.Append("\r\n"); sb.Append("Computer Name: "); sb.Append(lease.ComputerName); this.textBoxLease.Text = sb.ToString(); } else { MessageBox.Show("The file already exists!"); } } else { MessageBox.Show("Please specify a computer name!"); } }