public DonVi SelectDonVi(int ID) { DonVi donvi = new DonVi(); DbDataReader reader = null; DbConnection conn = _DbHelper.CreateConnection(Common.ConnectionString); conn.Open(); try { List <DbParameter> para = new List <DbParameter>(); para.Add(_DbHelper.CreateParameter(FIELD_ID, ID, false)); reader = _DbHelper.ExecuteReader(conn, Common.DatabaseSchema + "[DonVi_SelectById]", para.ToArray()); if (reader.HasRows && reader.Read()) { DonViDataAccess.SetDonViInfo(reader, ref donvi); } return(donvi); } catch (Exception ex) { throw new Exception(String.Format("DonViDataAccess.SelectById: {0}", ex.Message)); } finally { if (reader != null) { reader.Close(); } conn.Close(); } }
private static void SetBindingListDonViInfo(ref DbDataReader reader, ref BindingList <DonVi> donvis) { DonVi donvi = null; while (reader.Read()) { donvi = new DonVi(); DonViDataAccess.SetDonViInfo(reader, ref donvi); donvis.Add(donvi); } }