public static WOInformation GetWOInformationForm(string InfoCode) { var question = new WOInformation(); using (var con = new SqlConnection(ConnectionUtility.GetConnectionString())) { con.Open(); var cmd = new SqlCommand("SpGetWOInfoFormByGridCode", con) { CommandType = CommandType.StoredProcedure }; cmd.Parameters.AddWithValue("@InfoCode", InfoCode); var reader = cmd.ExecuteReader(); while (reader.Read()) question.FetchData(question, new SafeDataReader(reader)); reader.NextResult(); while (reader.Read()) { var item = new WOInformationForm(); question.FetchItems(item, new SafeDataReader(reader)); question.QItems.Add(item); } } return question; }
private void FetchData(WOInformation woForm, SafeDataReader reader) { woForm.Id = reader.GetInt32("Id"); woForm.Name = reader.GetString("Name"); woForm.InfoCode = reader.GetString("InfoCode"); woForm.WOCode = reader.GetString("WOCode"); }