/// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(KPS.Model.ProductInfo model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update PSI_ProductInfo set ");
            strSql.Append("productname=@productname ,");
            strSql.Append("promoney=@promoney ");
            strSql.Append(" where productid=@productid");
            OleDbParameter[] parameters =
            {
                new OleDbParameter("@productname", OleDbType.VarChar, 255),
                new OleDbParameter("@promoney",    OleDbType.Double, 2)
            };
            parameters[0].Value = model.productname;
            parameters[1].Value = model.promoney;

            int rows = DbHelperOleDb.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(KPS.Model.ProductInfo model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into PSI_ProductInfo(");
            strSql.Append("productname,promoney)");
            strSql.Append(" values (");
            strSql.Append("@productname,@promoney)");
            OleDbParameter[] parameters =
            {
                new OleDbParameter("@productname", OleDbType.VarChar, 255),
                new OleDbParameter("@promoney",    OleDbType.Double, 2)
            };
            parameters[0].Value = model.productname;
            parameters[1].Value = model.promoney;

            int rows = DbHelperOleDb.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public KPS.Model.ProductInfo DataRowToModel(DataRow row)
 {
     KPS.Model.ProductInfo model = new KPS.Model.ProductInfo();
     if (row != null)
     {
         if (row["productid"] != null && row["productid"].ToString() != "")
         {
             model.productid = int.Parse(row["productid"].ToString());
         }
         if (row["productname"] != null)
         {
             model.productname = row["productname"].ToString();
         }
         if (row["promoney"] != null)
         {
             model.promoney = Convert.ToDouble(row["promoney"]);
         }
     }
     return(model);
 }
Пример #4
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public KPS.Model.ProductInfo DataRowToModel(DataRow row)
 {
     KPS.Model.ProductInfo model = new KPS.Model.ProductInfo();
     if (row != null)
     {
         if(row["productid"]!=null && row["productid"].ToString()!="")
         {
             model.productid=int.Parse(row["productid"].ToString());
         }
         if(row["productname"]!=null)
         {
             model.productname=row["productname"].ToString();
         }
         if (row["promoney"] != null)
         {
             model.promoney =Convert.ToDouble(row["promoney"]);
         }
     }
     return model;
 }
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public KPS.Model.ProductInfo GetModel(int productid)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select productid,productname,promoney ");
            strSql.Append(" where productid=@productid");
            OleDbParameter[] parameters =
            {
                new OleDbParameter("@productid", OleDbType.Integer, 4)
            };
            parameters[0].Value = productid;

            KPS.Model.ProductInfo model = new KPS.Model.ProductInfo();
            DataSet ds = DbHelperOleDb.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
Пример #6
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public KPS.Model.ProductInfo GetModel(int productid)
        {
            StringBuilder strSql=new StringBuilder();
            strSql.Append("select productid,productname,promoney ");
            strSql.Append(" where productid=@productid");
            OleDbParameter[] parameters = {
                    new OleDbParameter("@productid", OleDbType.Integer,4)
            };
            parameters[0].Value = productid;

            KPS.Model.ProductInfo model = new KPS.Model.ProductInfo();
            DataSet ds=DbHelperOleDb.Query(strSql.ToString(),parameters);
            if(ds.Tables[0].Rows.Count>0)
            {
                return DataRowToModel(ds.Tables[0].Rows[0]);
            }
            else
            {
                return null;
            }
        }