Beispiel #1
0
        /// <summary>
        /// 对象实体绑定数据
        /// </summary>
        public SuitProductModel ReaderBind(IDataReader dataReader)
        {
            SuitProductModel model = new SuitProductModel();
            object           ojb;

            ojb = dataReader["SuitProductId"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.SuitProductId = (int)ojb;
            }
            ojb = dataReader["ProductId"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.ProductId = (int)ojb;
            }
            model.SuitName = dataReader["SuitName"].ToString();
            ojb            = dataReader["MerchantPrice"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.MerchantPrice = (decimal)ojb;
            }
            ojb = dataReader["TradePrice"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.TradePrice = (decimal)ojb;
            }
            ojb = dataReader["Status"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.Status = (int)ojb;
            }
            return(model);
        }
Beispiel #2
0
        /// <summary>
        ///  更新一条数据
        /// </summary>
        public void Update(SuitProductModel model)
        {
            DbCommand dbCommand = dbw.GetStoredProcCommand("UP_pdSuitProduct_Update");

            dbw.AddInParameter(dbCommand, "SuitProductId", DbType.Int32, model.SuitProductId);
            dbw.AddInParameter(dbCommand, "ProductId", DbType.Int32, model.ProductId);
            dbw.AddInParameter(dbCommand, "SuitName", DbType.AnsiString, model.SuitName);
            dbw.AddInParameter(dbCommand, "MerchantPrice", DbType.Decimal, model.MerchantPrice);
            dbw.AddInParameter(dbCommand, "TradePrice", DbType.Decimal, model.TradePrice);
            dbw.AddInParameter(dbCommand, "Status", DbType.Byte, model.Status);
            dbw.ExecuteNonQuery(dbCommand);
        }
Beispiel #3
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public SuitProductModel GetModel(int SuitProductId)
        {
            DbCommand dbCommand = dbr.GetStoredProcCommand("UP_pdSuitProduct_GetModel");

            dbr.AddInParameter(dbCommand, "SuitProductId", DbType.Int32, SuitProductId);

            SuitProductModel model = null;

            using (IDataReader dataReader = dbr.ExecuteReader(dbCommand))
            {
                if (dataReader.Read())
                {
                    model = ReaderBind(dataReader);
                }
            }
            return(model);
        }
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List <SuitProductModel> GetModelList(string strWhere)
        {
            DataSet ds = dal.GetList(strWhere);
            List <SuitProductModel> modelList = new List <SuitProductModel>();
            int rowsCount = ds.Tables[0].Rows.Count;

            if (rowsCount > 0)
            {
                SuitProductModel model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new SuitProductModel();
                    if (ds.Tables[0].Rows[n]["SuitProductId"].ToString() != "")
                    {
                        model.SuitProductId = int.Parse(ds.Tables[0].Rows[n]["SuitProductId"].ToString());
                    }
                    if (ds.Tables[0].Rows[n]["ProductId"].ToString() != "")
                    {
                        model.ProductId = int.Parse(ds.Tables[0].Rows[n]["ProductId"].ToString());
                    }
                    model.SuitName = ds.Tables[0].Rows[n]["SuitName"].ToString();
                    if (ds.Tables[0].Rows[n]["MerchantPrice"].ToString() != "")
                    {
                        model.MerchantPrice = decimal.Parse(ds.Tables[0].Rows[n]["MerchantPrice"].ToString());
                    }
                    if (ds.Tables[0].Rows[n]["TradePrice"].ToString() != "")
                    {
                        model.TradePrice = decimal.Parse(ds.Tables[0].Rows[n]["TradePrice"].ToString());
                    }
                    if (ds.Tables[0].Rows[n]["Status"].ToString() != "")
                    {
                        model.Status = int.Parse(ds.Tables[0].Rows[n]["Status"].ToString());
                    }
                    modelList.Add(model);
                }
            }
            return(modelList);
        }
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public void Update(SuitProductModel model)
 {
     dal.Update(model);
 }
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public void Add(SuitProductModel model)
 {
     dal.Add(model);
 }