Esempio n. 1
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Hi.Model.BD_PromotionDetail2 model, SqlTransaction Tran)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into [BD_PromotionDetail2](");
            strSql.Append("[ProID],[CompID],[OrderPrice],[Discount],[modifyuser],[CreateUserID])");
            strSql.Append(" values (");
            strSql.Append("@ProID,@CompID,@OrderPrice,@Discount,@modifyuser,@CreateUserID)");
            strSql.Append(";select @@Identity");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ProID",        SqlDbType.Int),
                new SqlParameter("@CompID",       SqlDbType.Int),
                new SqlParameter("@OrderPrice",   SqlDbType.Decimal),
                new SqlParameter("@Discount",     SqlDbType.Decimal),
                new SqlParameter("@modifyuser",   SqlDbType.Int),
                new SqlParameter("@CreateUserID", SqlDbType.Int)
            };
            parameters[0].Value = model.ProID;
            parameters[1].Value = model.CompID;
            parameters[2].Value = model.OrderPrice;
            parameters[3].Value = model.Discount;
            parameters[4].Value = model.modifyuser;
            parameters[5].Value = model.CreateUserID;
            // return SqlHelper.GetInt(SqlHelper.GetSingle(SqlHelper.LocalSqlServer, strSql.ToString(), parameters));
            if (Tran != null)
            {
                return(SqlHelper.GetInt(SqlHelper.GetSingle(strSql.ToString(), Tran, parameters)));
            }
            return(SqlHelper.GetInt(SqlHelper.GetSingle(SqlHelper.LocalSqlServer, strSql.ToString(), parameters)));
        }
Esempio n. 2
0
 /// <summary>
 /// 由一行数据得到一个实体
 /// </summary>
 private Hi.Model.BD_PromotionDetail2 GetModel(DataRow r)
 {
     Hi.Model.BD_PromotionDetail2 model = new Hi.Model.BD_PromotionDetail2();
     model.ID           = SqlHelper.GetInt(r["ID"]);
     model.ProID        = SqlHelper.GetInt(r["ProID"]);
     model.CompID       = SqlHelper.GetInt(r["CompID"]);
     model.OrderPrice   = SqlHelper.GetDecimal(r["OrderPrice"]);
     model.Discount     = SqlHelper.GetDecimal(r["Discount"]);
     model.dr           = SqlHelper.GetInt(r["dr"]);
     model.modifyuser   = SqlHelper.GetInt(r["modifyuser"]);
     model.CreateDate   = SqlHelper.GetDateTime(r["CreateDate"]);
     model.CreateUserID = SqlHelper.GetInt(r["CreateUserID"]);
     model.ts           = SqlHelper.GetDateTime(r["ts"]);
     return(model);
 }
Esempio n. 3
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Hi.Model.BD_PromotionDetail2 model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update [BD_PromotionDetail2] set ");
            strSql.Append("[ProID]=@ProID,");
            strSql.Append("[CompID]=@CompID,");
            strSql.Append("[OrderPrice]=@OrderPrice,");
            strSql.Append("[Discount]=@Discount,");
            strSql.Append("[dr]=@dr,");
            strSql.Append("[modifyuser]=@modifyuser,");
            strSql.Append("[CreateDate]=@CreateDate,");
            strSql.Append("[CreateUserID]=@CreateUserID,");
            strSql.Append("[ts]=@ts");
            strSql.Append(" where [ID]=@ID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ID",           SqlDbType.Int),
                new SqlParameter("@ProID",        SqlDbType.Int),
                new SqlParameter("@CompID",       SqlDbType.Int),
                new SqlParameter("@OrderPrice",   SqlDbType.Decimal),
                new SqlParameter("@Discount",     SqlDbType.Decimal),
                new SqlParameter("@dr",           SqlDbType.SmallInt),
                new SqlParameter("@modifyuser",   SqlDbType.Int),
                new SqlParameter("@CreateDate",   SqlDbType.DateTime),
                new SqlParameter("@CreateUserID", SqlDbType.Int),
                new SqlParameter("@ts",           SqlDbType.DateTime)
            };
            parameters[0].Value = model.ID;
            parameters[1].Value = model.ProID;
            parameters[2].Value = model.CompID;
            parameters[3].Value = model.OrderPrice;
            parameters[4].Value = model.Discount;
            parameters[5].Value = model.dr;
            parameters[6].Value = model.modifyuser;
            parameters[7].Value = model.CreateDate;
            parameters[8].Value = model.CreateUserID;
            parameters[9].Value = model.ts;

            return(SqlHelper.ExecuteSql(SqlHelper.LocalSqlServer, strSql.ToString(), parameters) > 0);
        }
Esempio n. 4
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int Add(Hi.Model.BD_PromotionDetail2 model, SqlTransaction Tran)
 {
     return(dal.Add(model, Tran));
 }