public List <DonVi> SelectAllDonViByRegionIDAndPhanLoai(int ID, int PhanLoai, int ParentID) { List <DonVi> donvi = new List <DonVi>(); DbDataReader reader = null; DbConnection conn = _DbHelper.CreateConnection(Common.ConnectionString); conn.Open(); try { List <DbParameter> para = new List <DbParameter>(); para.Add(_DbHelper.CreateParameter("ID", ID, false)); para.Add(_DbHelper.CreateParameter("PhanLoai", PhanLoai, false)); para.Add(_DbHelper.CreateParameter("ParentID", ParentID, false)); reader = _DbHelper.ExecuteReader(conn, Common.DatabaseSchema + "[DonVi_SelectByRegionIDAndPhanLoai]", para.ToArray()); if (reader.HasRows) { DonViDataAccess.SetListDonViInfo(ref reader, ref donvi); } return(donvi); } catch (Exception ex) { throw new Exception(String.Format(" DonViDataAccess.SelectAll: {0}", ex.Message)); } finally { if (reader != null) { reader.Close(); } conn.Close(); } }
public List <DonVi> SelectDonViChuQuanLogin() { List <DonVi> donvi = new List <DonVi>(); DbDataReader reader = null; DbConnection conn = _DbHelper.CreateConnection(Common.ConnectionString); conn.Open(); try { reader = _DbHelper.ExecuteReader(conn, Common.DatabaseSchema + "[SelectDonViChuQuanLogin]", null); if (reader.HasRows) { DonViDataAccess.SetListDonViInfo(ref reader, ref donvi); } return(donvi); } catch (Exception ex) { throw new Exception(String.Format(" DonVi_SelectAllDVbyPhanLoai.SelectAll: {0}", ex.Message)); } finally { if (reader != null) { reader.Close(); } conn.Close(); } }
public List <DonVi> SYS_Region_Organization_SelectByIDIDRegion(int IDIDRegion) { List <DonVi> donvi = new List <DonVi>(); DbDataReader reader = null; DbConnection conn = _DbHelper.CreateConnection(Common.ConnectionString); conn.Open(); try { List <DbParameter> para = new List <DbParameter>(); para.Add(_DbHelper.CreateParameter("IDRegion", IDIDRegion, false)); reader = _DbHelper.ExecuteReader(conn, Common.DatabaseSchema + "[SYS_Region_Organization_SelectByIDIDRegion]", para.ToArray()); if (reader.HasRows) { DonViDataAccess.SetListDonViInfo(ref reader, ref donvi); } return(donvi); } catch (Exception ex) { throw new Exception(String.Format(" SYS_Region_Organization_SelectByIDIDRegion.SelectAll: {0}", ex.Message)); } finally { if (reader != null) { reader.Close(); } conn.Close(); } }
public BindingList <DonVi> SelectBindingAllDonVi() { BindingList <DonVi> donvi = new BindingList <DonVi>(); DbDataReader reader = null; DbConnection conn = _DbHelper.CreateConnection(Common.ConnectionString); conn.Open(); try { reader = _DbHelper.ExecuteReader(conn, Common.DatabaseSchema + "[DonVi_SelectAll]", (DbParameter[])null); if (reader.HasRows) { DonViDataAccess.SetBindingListDonViInfo(ref reader, ref donvi); } return(donvi); } catch (Exception ex) { throw new Exception(String.Format(" DonViDataAccess.SelectAll: {0}", ex.Message)); } finally { if (reader != null) { reader.Close(); } conn.Close(); } }
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); } }