public static bool GetClubInfo(out string error, string PAN, string TerminalID, out ClubInfo Response) { bool result = false; error = ""; Response = new ClubInfo(); SqlDataReader reader = null; SqlCommand command = null; try { if (!CreateCommand(out error, out command, "GetClubByPAN", new SqlParameter("@PAN", PAN))) { throw new Exception(error); } if (!ExecuteReader(out error, out reader, command)) { throw new Exception(error); } if (reader.Read()) { Response.ID = Convert.ToInt16(reader["ID"].ToString()); Response.Name = reader["Name"].ToString(); Response.Description = reader["Description"].ToString(); Response.IsActive = Convert.ToBoolean(reader["IsActive"]); Response.CreationDate = reader["CreationDate"].ToString(); } if (Response.Name == "" || Response.CreationDate == "") { error = "can not find Club for PAN:" + PAN; result = false; } else result = true; } catch (Exception ex) { error = ex.Message; result = false; } finally { if (command.Connection.State == ConnectionState.Open) command.Connection.Close(); if (reader != null && !reader.IsClosed) reader.Close(); command.Dispose(); } return result; }
private void button2_Click(object sender, EventArgs e) { string error = ""; ClubInfo club = new ClubInfo(); if( DataLayer.GetClubInfoByTerminal(out error, textBox2.Text, out club)) MessageBox.Show(club.Name); else MessageBox.Show(error); }