private void AGE_CALC_TextChanged(object sender, EventArgs e) { try { if (AGE_FINAL.Text.Length >= 1) { if (Convert.ToDateTime(DATEBIRTH.Text).Year == 1908) { double age_days = (System.DateTime.Now - Convert.ToDateTime(DATEBIRTH.Text)).TotalDays; //(EndDate - StartDate).TotalDays //MessageBox.Show(age_days.ToString()); if (age_days > 183 && age_days <= 1825) { CHILDAGE.Text = "1"; CHILDAGE.Enabled = false; } else { CHILDAGE.Text = "2"; CHILDAGE.Enabled = false; } } else if (Convert.ToDateTime(DATEBIRTH.Text).Year != 1908) { double age_days = (System.DateTime.Now - Convert.ToDateTime(DATEBIRTH.Text)).TotalDays; //(EndDate - StartDate).TotalDays //MessageBox.Show(age_days.ToString()); if (age_days > 183 && age_days <= 1825) { // MessageBox.Show(age_days.ToString()); CHILDAGE.Text = "1"; CHILDAGE.Enabled = false; SEX.Focus(); } else //else if (age_days <= 183 && age_days > 1825) { // MessageBox.Show(age_days.ToString()); CHILDAGE.Text = "2"; CHILDAGE.Enabled = false; SEX.Focus(); } } } } catch { MessageBox.Show("Please put in a date of birth if known", "ZTDT"); } }
else
if
Convert.ToDateTime
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)