// DELETE
        public static bool DeletePhong(Phong p)
        {
            var cm = CreateCommand();

            cm.CommandText = @"Exec delete_row_Phong @ID, @LP, @GC";
            cm.Parameters.Add(new SqlParameter("@ID", p.ID));
            cm.Parameters.Add(new SqlParameter("@LP", p.LoaiPhong));
            cm.Parameters.Add(new SqlParameter("@GC", p.GhiChu));
            int rs = cm.ExecuteNonQuery();

            cn.Close();
            return(rs > 0);
        }
Пример #2
0
        public static Phong Read(SqlDataReader reader)
        {
            var p = new Phong()
            {
                ID        = reader.GetString(iID),
                LoaiPhong = reader.GetString(iLoaiPhong),
                GhiChu    = reader.GetString(iGhiChu)
            };

            //byte[] bytes = Encoding.Default.GetBytes(p.GhiChu);
            //p.GhiChu = Encoding.UTF8.GetString(bytes);
            return(p);
        }
        public static List <Phong> DSPhong()
        {
            var lp = new List <Phong>();
            var cm = CreateCommand();

            cm.CommandText = @"SELECT * FROM PHONG";
            var reader = cm.ExecuteReader();

            while (reader.Read())
            {
                lp.Add(Phong.Read(reader));
            }
            cn.Close();
            return(lp);
        }