protected void btn_Retrieve_Click(object sender, EventArgs e) { StdInfoBLL sib = new StdInfoBLL(); List <StdInfoModel> lSim = sib.GetAllInformation(); bool isStdExit = false; if (tb_StdNum.Text != "") //信息完整 { for (int i = 0; i < lSim.Count; i++) { if (tb_StdNum.Text == lSim[i].StdNum) { isStdExit = true; } } if (isStdExit) //学生存在 { StdInfoModel sim = sib.GetInfoByNum(tb_StdNum.Text); string result = $"{sim.StdNum}/{sim.Name}/{sim.Sex}/{sim.Nation}/{sim.E_Mail}/{sim.PhoneNumber}"; listBox_Result.Items.Add(result); tb_StdNum.Text = ""; } else //学生不存在 { Response.Write(@"<script>alert('查无此人');</script>"); } } else //信息不完整 { Response.Write(@"<script>alert('请输入学号');</script>"); } }
private void btn_Retrieve_Click(object sender, EventArgs e) { if (tb_StdNum.Text != "") { StdInfoBLL sib = new StdInfoBLL(); StdInfoModel sim = sib.GetInfoByNum(tb_StdNum.Text); string result = $"{sim.StdNum}/{sim.Name}/{sim.Sex}/{sim.Nation}/{sim.E_Mail}/{sim.PhoneNumber}"; listBox_Result.Items.Add(result); tb_StdNum.Text = ""; } else { MessageBox.Show("请输入学号"); } }