public static bool UpdateQuyDinh(QuyDinh qd)
        {
            var cm = CreateCommand();

            cm.CommandText = @"Exec update_row_QuyDinh @ID, @MT, @GT, @DV";
            cm.Parameters.Add(new SqlParameter("@ID", qd.ID));
            cm.Parameters.Add(new SqlParameter("@MT", qd.MoTa));
            cm.Parameters.Add(new SqlParameter("@GT", qd.GiaTri));
            cm.Parameters.Add(new SqlParameter("@DV", qd.DonVi));
            int rs = cm.ExecuteNonQuery();

            cn.Close();
            return(rs > 0);
        }
Exemplo n.º 2
0
        public static QuyDinh Read(SqlDataReader reader)
        {
            var qd = new QuyDinh()
            {
                ID     = reader.GetString(iID),
                MoTa   = reader.GetString(iMoTa),
                GiaTri = reader.GetFloat(iGiaTri),
                DonVi  = reader.GetString(iDonVi)
            };

            byte[] bytes = Encoding.Default.GetBytes(qd.MoTa);
            qd.MoTa = Encoding.UTF8.GetString(bytes);
            return(qd);
        }
        public static List <QuyDinh> DSQuyDinh()
        {
            var lqd = new List <QuyDinh>();
            var cm  = CreateCommand();

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

            while (reader.Read())
            {
                lqd.Add(QuyDinh.Read(reader));
            }
            cn.Close();
            return(lqd);
        }