//身份证号失去焦点事件 private void textstuNub_LostFocus(object sender, RoutedEventArgs e) { if (string.IsNullOrEmpty(textstuNub.Text.Trim())) { System.Windows.MessageBox.Show("身份证号不能为空!"); textstuNub.Focus(); } else if (DataValidate.IsIDcard(textstuNub.Text.Trim())) { System.Windows.MessageBox.Show("请输入正确身份证格式!"); textstuNub.Focus(); return; } else //在失去焦点后将生日信息和年龄存入相应框 { dateBirthday.Content = Commmon.GetValueBystuIDcard.GetBirthday(textstuNub.Text.Trim()).ToString("yyyy-MM-dd"); //存储生日 textAge.Content = GetValueBystuIDcard.GetAge( Commmon.GetValueBystuIDcard.GetBirthday(textstuNub.Text.Trim())); } }
//身份证失去焦点事件 private void textStuNubIDcard_LostFocus(object sender, RoutedEventArgs e) { if (string.IsNullOrEmpty(textStuNubIDcard.Text.Trim())) { System.Windows.MessageBox.Show("身份证号不能为空!"); textStuNubIDcard.Focus(); return; } /* else if (DataValidate.IsIDcard(textStuNubIDcard.Text.Trim())==false) * { * System.Windows.Forms.MessageBox.Show("请输入正确身份证格式!", "友情提示", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Information); * return; * }*/ else //在失去焦点后将生日信息和年龄存入相应框 { labBirthday.Content = Commmon.GetValueBystuIDcard.GetBirthday(textStuNubIDcard.Text.Trim()).ToString("yyyy-MM-dd"); //存储生日 labAge.Content = GetValueBystuIDcard.GetAge( Commmon.GetValueBystuIDcard.GetBirthday(textStuNubIDcard.Text.Trim())); } }