コード例 #1
0
        protected static bool UpdateDetail(OrderDetail orderDetail, DbTransaction pTransaction, string executedBy)
        {
            bool rslt = false;

            try
            {
                Database db = DatabaseFactory.CreateDatabase(Constants.DBConnection);
                DbCommand cmd = db.GetStoredProcCommand(Constants.SP_OrderDetails_Update);

                db.AddInParameter(cmd, "OrderDetailID", DbType.Int32, orderDetail.OrderDetailID);
                db.AddInParameter(cmd, "OrderID", DbType.Int32, orderDetail.OrderID);
                db.AddInParameter(cmd, "ItemID", DbType.Int32, orderDetail.ItemID);
                db.AddInParameter(cmd, "OrderQty", DbType.Int32, orderDetail.OrderQty);
                db.AddInParameter(cmd, "UpdatedBY", DbType.Int32, orderDetail.UpdatedBy);

                db.ExecuteNonQuery(cmd, pTransaction);
                rslt = true;
            }

            catch (Exception ex)
            {
                rslt = false;
                throw ex;
            }

            return rslt;
        }
コード例 #2
0
        protected static bool InsertDetail(OrderDetail orderDetail, DbTransaction pTransaction, string executedBy)
        {
            bool rslt = false;

            try
            {
                Database db = DatabaseFactory.CreateDatabase(Constants.DBConnection);
                DbCommand cmd = db.GetStoredProcCommand(Constants.SP_OrderDetails_Insert);

                db.AddInParameter(cmd, "OrderID", DbType.Int32, orderDetail.OrderID);
                db.AddInParameter(cmd, "ItemID", DbType.Int32, orderDetail.ItemID);
                db.AddInParameter(cmd, "OrderQty", DbType.Int32, orderDetail.OrderQty);

                db.AddInParameter(cmd, "CreatedBy", DbType.Int32, orderDetail.CreatedBy);

                db.AddOutParameter(cmd, "NewID", DbType.Int32, 4);

                db.ExecuteNonQuery(cmd, pTransaction);

                int newID = 0;
                int.TryParse(db.GetParameterValue(cmd, "NewID").ToString(), out newID);

                if (newID > 0)
                    rslt = true;
            }

            catch (Exception ex)
            {
                rslt = false;
                throw ex;
            }

            return rslt;
        }