Example #1
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(TFXK.Model.OrderProLists model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into tb_OrderProLists(");
            strSql.Append("orderID,productID,orderNum,productPrice,totalMoney)");
            strSql.Append(" values (");
            strSql.Append("@orderID,@productID,@orderNum,@productPrice,@totalMoney)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@orderID",      SqlDbType.Int,     4),
                new SqlParameter("@productID",    SqlDbType.Int,     4),
                new SqlParameter("@orderNum",     SqlDbType.Int,     4),
                new SqlParameter("@productPrice", SqlDbType.Decimal, 9),
                new SqlParameter("@totalMoney",   SqlDbType.Decimal, 9)
            };
            parameters[0].Value = model.orderID;
            parameters[1].Value = model.productID;
            parameters[2].Value = model.orderNum;
            parameters[3].Value = model.productPrice;
            parameters[4].Value = model.totalMoney;

            object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);

            if (obj == null)
            {
                return(1);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Example #2
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public void Update(TFXK.Model.OrderProLists model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update tb_OrderProLists set ");
            strSql.Append("orderID=@orderID,");
            strSql.Append("productID=@productID,");
            strSql.Append("orderNum=@orderNum,");
            strSql.Append("productPrice=@productPrice,");
            strSql.Append("totalMoney=@totalMoney");
            strSql.Append(" where id=@id ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id",           SqlDbType.Int,     4),
                new SqlParameter("@orderID",      SqlDbType.Int,     4),
                new SqlParameter("@productID",    SqlDbType.Int,     4),
                new SqlParameter("@orderNum",     SqlDbType.Int,     4),
                new SqlParameter("@productPrice", SqlDbType.Decimal, 9),
                new SqlParameter("@totalMoney",   SqlDbType.Decimal, 9)
            };
            parameters[0].Value = model.id;
            parameters[1].Value = model.orderID;
            parameters[2].Value = model.productID;
            parameters[3].Value = model.orderNum;
            parameters[4].Value = model.productPrice;
            parameters[5].Value = model.totalMoney;

            DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
        }
Example #3
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public TFXK.Model.OrderProLists GetModel(int pid, int oid)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 id,orderID,productID,orderNum,productPrice,totalMoney from tb_OrderProLists ");
            strSql.Append(" where productID=@productID ");
            strSql.Append(" and orderID=@orderID ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@productID", SqlDbType.Int, 4),
                new SqlParameter("@orderID",   SqlDbType.Int, 4)
            };
            parameters[0].Value = pid;
            parameters[1].Value = oid;

            TFXK.Model.OrderProLists model = new TFXK.Model.OrderProLists();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["id"].ToString() != "")
                {
                    model.id = int.Parse(ds.Tables[0].Rows[0]["id"].ToString());
                }
                if (ds.Tables[0].Rows[0]["orderID"].ToString() != "")
                {
                    model.orderID = int.Parse(ds.Tables[0].Rows[0]["orderID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["productID"].ToString() != "")
                {
                    model.productID = int.Parse(ds.Tables[0].Rows[0]["productID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["orderNum"].ToString() != "")
                {
                    model.orderNum = int.Parse(ds.Tables[0].Rows[0]["orderNum"].ToString());
                }
                if (ds.Tables[0].Rows[0]["productPrice"].ToString() != "")
                {
                    model.productPrice = decimal.Parse(ds.Tables[0].Rows[0]["productPrice"].ToString());
                }
                if (ds.Tables[0].Rows[0]["totalMoney"].ToString() != "")
                {
                    model.totalMoney = decimal.Parse(ds.Tables[0].Rows[0]["totalMoney"].ToString());
                }
                return(model);
            }
            else
            {
                return(null);
            }
        }