public Student ShowNameEmail(Student aStudent) { if (HasThisRegNo(aStudent.RegNo)) { return aStudentGateway.ShowNameEmail(aStudent.RegNo); } return null; }
public Student ShowNameEmail(string regNo) { connection.Open(); string queryString = string.Format("Select * from StudentsTable Where RegNo='{0}'", regNo); SqlCommand command = new SqlCommand(queryString, connection); SqlDataReader aReader = command.ExecuteReader(); Student aStudent = new Student(); while (aReader.Read()) { aStudent.Name = aReader[1].ToString(); aStudent.RegNo = aReader[0].ToString(); aStudent.Email = aReader[2].ToString(); } connection.Close(); return aStudent; }
private void findButton_Click(object sender, EventArgs e) { aStudent = new Student(); tempStudent = new Student(); aStudent.Name = nameTextBox.Text; aStudent.RegNo = regNoTextBox.Text; aStudent.Email = emailTextBox.Text; tempStudent = aStudentBll.ShowNameEmail(aStudent); if (tempStudent==null) { MessageBox.Show(@"Not Registered"); } else { nameTextBox.Text=tempStudent.Name; emailTextBox.Text = tempStudent.Email; } }
private void findButton_Click(object sender, EventArgs e) { aStudent = new Student(regNoTextBox.Text, nameTextBox.Text, emailTextBox.Text); }