Esempio n. 1
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public void Add(SOSOshop.Model.Order.OrderProduct model, DbTransaction tran)
        {
            //重新计算订单原始明细
            //DELETE OrderProductDetails WHERE ProId IN (SELECT Product_ID FROM dbo.Product)
            //Insert into OrderProductDetails(OrderId,ProId,dbo.DrugsBase_Manufacturer,guige,jianzhuang) SELECT a.OrderId,a.ProId,b.DrugsBase_Manufacturer,c.shpgg,CONVERT(VARCHAR(11),b.Goods_Pcs)+b.Goods_Unit FROM  dbo.OrderProduct a INNER JOIN dbo.Product b ON a.ProId=b.Product_ID INNER JOIN dbo.spzl c ON b.Product_ID=c.product_id WHERE a.ProId IN (SELECT Product_ID FROM dbo.Product)
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into OrderProduct(");
            strSql.Append("OrderId,ProId,ProName,ProPrice,ProNum,AddTime,pro_pno,pro_pdate,Status,issplit,iden,jigid,IsExpirationProduct)");

            strSql.Append(" values (");
            strSql.Append("@OrderId,@ProId,@ProName,@ProPrice,@ProNum,@AddTime,@pro_pno,@pro_pdate,@Status,@issplit,@iden,@jigid,@IsExpirationProduct)");
            strSql.AppendFormat(";Insert into OrderProductDetails(OrderId,ProId,dbo.DrugsBase_Manufacturer,guige,jianzhuang) SELECT '{0}' OrderId,{1} ProId,b.DrugsBase_Manufacturer,null,CONVERT(VARCHAR(11),b.Goods_Pcs)+b.Goods_Unit FROM  dbo.Product b WHERE b.product_id={1}", model.OrderId, model.ProId);
            DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString());

            db.AddInParameter(dbCommand, "OrderId", DbType.AnsiString, model.OrderId);
            db.AddInParameter(dbCommand, "ProId", DbType.Int32, model.ProId);
            db.AddInParameter(dbCommand, "ProName", DbType.AnsiString, model.ProName);
            db.AddInParameter(dbCommand, "ProPrice", DbType.Double, model.ProPrice);
            db.AddInParameter(dbCommand, "ProNum", DbType.Double, model.ProNum);
            db.AddInParameter(dbCommand, "AddTime", DbType.DateTime, model.AddTime);
            db.AddInParameter(dbCommand, "pro_pno", DbType.AnsiString, model.pro_pno);
            db.AddInParameter(dbCommand, "pro_pdate", DbType.AnsiString, model.pro_pdate);
            db.AddInParameter(dbCommand, "Status", DbType.Int32, model.Status);
            db.AddInParameter(dbCommand, "issplit", DbType.Boolean, model.issplit);
            db.AddInParameter(dbCommand, "iden", DbType.Int32, model.iden);
            db.AddInParameter(dbCommand, "jigid", DbType.String, model.jigid);
            db.AddInParameter(dbCommand, "IsExpirationProduct", DbType.Byte, model.IsExpirationProduct);
            db.ExecuteScalar(dbCommand, tran);
        }
Esempio n. 2
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(SOSOshop.Model.Order.OrderProduct model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update OrderProduct set ");
            strSql.Append("OrderId=@OrderId,");
            strSql.Append("ProId=@ProId,");
            strSql.Append("ProName=@ProName,");
            strSql.Append("ProPrice=@ProPrice,");
            strSql.Append("ProNum=@ProNum,");
            strSql.Append("AddTime=@AddTime,");
            strSql.Append("pro_pno=@pro_pno,");
            strSql.Append("pro_pdate=@pro_pdate,");
            strSql.Append("Status=@Status");
            strSql.Append(" where Id=@Id ");

            DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString());

            db.AddInParameter(dbCommand, "Id", DbType.Int32, model.Id);
            db.AddInParameter(dbCommand, "OrderId", DbType.AnsiString, model.OrderId);
            db.AddInParameter(dbCommand, "ProId", DbType.Int32, model.ProId);
            db.AddInParameter(dbCommand, "ProName", DbType.AnsiString, model.ProName);
            db.AddInParameter(dbCommand, "ProPrice", DbType.Double, model.ProPrice);
            db.AddInParameter(dbCommand, "ProNum", DbType.Double, model.ProNum);
            db.AddInParameter(dbCommand, "AddTime", DbType.DateTime, model.AddTime);
            db.AddInParameter(dbCommand, "pro_pno", DbType.AnsiString, model.pro_pno);
            db.AddInParameter(dbCommand, "pro_pdate", DbType.AnsiString, model.pro_pdate);
            db.AddInParameter(dbCommand, "Status", DbType.Int32, model.Status);
            int rows = db.ExecuteNonQuery(dbCommand);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }