//ListWhere_sp
        public List <Ob_POS_DM_PTTT> _ListWhere_sp(string StoredName, SqlParameter[] ArrayParameter, SqlConnection conn)
        {
            if (conn.ConnectionString == "")
            {
                return(null);
            }
            conn.Open();
            List <Ob_POS_DM_PTTT> list    = new List <Ob_POS_DM_PTTT>();
            SqlCommand            command = new SqlCommand
            {
                Connection  = conn,
                CommandType = CommandType.Text,
                CommandText = StoredName
            };

            command.Parameters.AddRange(ArrayParameter);
            SqlDataReader reader = command.ExecuteReader();

            while (reader.Read())
            {
                Ob_POS_DM_PTTT ob = new Ob_POS_DM_PTTT();
                if (reader[0] != DBNull.Value)
                {
                    ob.ID_PTTT = Convert.ToInt32(reader[0]);
                }
                if (reader[1] != DBNull.Value)
                {
                    ob.TENPTTT = Convert.ToString(reader[1]);
                }
                list.Add(ob);
            }
            command.Dispose();
            command = null;
            reader.Dispose();
            reader = null;
            conn.Close();
            return(list);
        }
        //ListAll
        public List <Ob_POS_DM_PTTT> _ListAll(SqlConnection conn)
        {
            if (conn.ConnectionString == "")
            {
                return(null);
            }
            conn.Open();
            List <Ob_POS_DM_PTTT> list    = new List <Ob_POS_DM_PTTT>();
            SqlCommand            command = new SqlCommand
            {
                Connection  = conn,
                CommandType = CommandType.Text,
                CommandText = @"Select ID_PTTT, TenPTTT From POS_DM_PTTT"
            };
            SqlDataReader reader = command.ExecuteReader();

            while (reader.Read())
            {
                Ob_POS_DM_PTTT ob = new Ob_POS_DM_PTTT();
                if (reader[0] != DBNull.Value)
                {
                    ob.ID_PTTT = Convert.ToInt32(reader[0]);
                }
                if (reader[1] != DBNull.Value)
                {
                    ob.TENPTTT = Convert.ToString(reader[1]);
                }
                list.Add(ob);
            }
            command.Dispose();
            command = null;
            reader.Dispose();
            reader = null;
            conn.Close();
            return(list);
        }
Esempio n. 3
0
 public Ob_POS_DM_PTTT(Ob_POS_DM_PTTT newOb)
 {
     id_pttt = newOb.ID_PTTT;
     tenpttt = newOb.TENPTTT;
 }