private void buttonCheckCardID_Click(object sender, EventArgs e) { textBoxCheckCardIDArea.Text = ""; textBoxCheckCardIDGender.Text = ""; textBoxCheckCardIDAge.Text = ""; string cardID = textBoxCheckCardID.Text.Trim(); int gender = -1; DateTime brithday = default(DateTime); string area = ""; string errMsg = ""; bool result = RegexUtils.CheckCardID(cardID.ToUpper(), out gender, out brithday, out area, out errMsg); if (result) { string genderStr = gender == 1 ? "男" : "女"; int age = RegexUtils.CalculateAgeCorrect(brithday, DateTime.Now); textBoxLog.AppendText($"身份证号:{cardID}, 性别:{genderStr}, 年龄:{age}, 地区:{area}\r\n"); textBoxCheckCardIDArea.Text = area; textBoxCheckCardIDGender.Text = genderStr; textBoxCheckCardIDAge.Text = age.ToString(); } else { MessageBox.Show($"{errMsg}\r\n", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); textBoxLog.AppendText($""); } }
public void MysqlModifyUserInfoFormInit(Student student) { this.m_currentDatabaseStudent = student; m_chinaList = DatabaseManager.Instance.chinaList; for (int i = 0; i < m_chinaList.Count; i++) { string merName = m_chinaList[i].mername; string[] name = merName.Split(','); if (name.Length == 2) { Dictionary <string, List <string> > dataDic = new Dictionary <string, List <string> >(); cityDic.Add(name[1], dataDic); } else if (name.Length == 3) { List <string> dataList = new List <string>(); cityDic[name[1]].Add(name[2], dataList); } else if (name.Length == 4) { cityDic[name[1]][name[2]].Add(name[3]); } } foreach (var item in cityDic.Keys) { if (!comboBox1.Items.Contains(item)) { comboBox1.Items.Add(item); } } List <int> gradeIDlist = GetComboBoxItems("select distinct gradeid from class;"); this.comboBoxGrade.Items.Clear(); for (int i = 0; i < gradeIDlist.Count; i++) { this.comboBoxGrade.Items.Add(gradeIDlist[i]); } this.comboBoxGrade.SelectedItem = student.GradeID; List <int> classIDlist = GetComboBoxItems($"select classid from class where gradeid={student.GradeID};"); this.comboBoxClass.Items.Clear(); for (int i = 0; i < classIDlist.Count; i++) { this.comboBoxClass.Items.Add(classIDlist[i]); } this.comboBoxClass.SelectedItem = student.ClassID; this.textBoxStuNum.Text = student.StuNum; this.textBoxName.Text = student.Name; this.textBoxAge.Text = string.Format("{0}", student.Age); string[] address = student.GetAddressFromDatabase().Split('$'); if (address.Length <= 3) { this.textBoxAddress.Text = student.Address; } else { this.comboBox1.SelectedItem = address[0]; this.comboBox2.SelectedItem = address[1]; this.comboBox3.SelectedItem = address[2]; this.textBoxAddress.Text = address[3]; } this.textBoxEmai.Text = student.Email; this.textBoxPhone.Text = student.PhoneNum; this.comboBoxGender.SelectedItem = student.Gender; this.textBoxCardID.Text = student.CardID; this.textBoxCardID.ReadOnly = true; int gender = 0; m_curBrithday = default(DateTime); string area = ""; string errMsg = ""; RegexUtils.CheckCardID(student.CardID, out gender, out m_curBrithday, out area, out errMsg); Console.WriteLine($"{errMsg}"); DateTime now = DateTime.Now; for (int i = 0; i < 100; i++) { int offsetYear = i * -1; int curYear = now.AddYears(offsetYear).Year; if (curYear < 1974) { break; } this.comboBoxYear.Items.Add(curYear); } this.comboBoxYear.SelectedItem = m_curBrithday.Year; }